IntaRNA 3.4.1
RNA-RNA interaction prediction | C++ API
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
IntaRNA::IndexRange Class Reference

#include <IndexRange.h>

Public Member Functions

 IndexRange (const size_t from=0, const size_t to=NA_INDEX)
 
 IndexRange (const std::string &stringEncoding, const RnaSequence *seq)
 
virtual ~IndexRange ()
 
bool isAscending () const
 
bool isDescending () const
 
IndexRange operator+ (const int shift) const
 
IndexRange operator- (const int shift) const
 
const bool operator< (const IndexRange &r) const
 
const bool operator== (const IndexRange &r) const
 
const bool operator!= (const IndexRange &r) const
 
void fromString (const std::string &stringEncoding, const RnaSequence *seq)
 
std::vector< IndexRange > overlappingWindows (const size_t windowWidth, const size_t windowOverlap) const
 

Public Attributes

size_t from
 the start of the index range
 
size_t to
 the end of the index range
 

Static Public Attributes

static const size_t LAST_INDEX
 
static const size_t NA_INDEX
 placeholder for not-defined values
 
static constexpr const char * regexString = R"((0|-?[123456789]\d*)-(0|-?[123456789]\d*))"
 regular expression that matches valid IndexRange string encodings
 
static const boost::regex regex
 regular expression that matches valid IndexRange string encodings
 

Friends

std::ostream & operator<< (std::ostream &out, const IndexRange &range)
 

Detailed Description

Defines an index region with functionality similar to pair

Author
Martin Mann

Constructor & Destructor Documentation

◆ IndexRange() [1/2]

IntaRNA::IndexRange::IndexRange ( const size_t  from = 0,
const size_t  to = NA_INDEX 
)
inline

Creates a range

Parameters
fromthe start index (default 0)
tothe end index (default NA_INDEX)

◆ IndexRange() [2/2]

IntaRNA::IndexRange::IndexRange ( const std::string &  stringEncoding,
const RnaSequence *  seq 
)
inline

Creates a range from a string encoding

Parameters
stringEncodingstring encoding of the range as produced by the ostream operator
seqif not NULL, the RnaSequence to be used to shift the indices of the input string from in/output positions to internal indices

◆ ~IndexRange()

virtual IntaRNA::IndexRange::~IndexRange ( )
inlinevirtual

destruction

Member Function Documentation

◆ fromString()

void IntaRNA::IndexRange::fromString ( const std::string &  stringEncoding,
const RnaSequence *  seq 
)
inline

updates the range data from a valid string encoding (matching regex)

Parameters
stringEncodingthe interval string encoding
Exceptions
std::runtime_errorif stringEncoding does not match regex

◆ isAscending()

bool IntaRNA::IndexRange::isAscending ( ) const
inline

Checks whether or not the range encoding is ascending.

Returns
from <= to

◆ isDescending()

bool IntaRNA::IndexRange::isDescending ( ) const
inline

Checks whether or not the range encoding is descending.

Returns
from >= to

◆ operator!=()

const bool IntaRNA::IndexRange::operator!= ( const IndexRange &  r) const
inline

Checks whether or not two ranges are different

Parameters
rthe range to compare to
Returns
!( this == r)

◆ operator+()

IndexRange IntaRNA::IndexRange::operator+ ( const int  shift) const
inline

Adds the given shift to the index range but ensure that the minimal value is 0.

Parameters
rthe range to be added to
shiftthe shift to be added to r
Returns
an altered range or (NA_INDEX,NA_INDEX) if the range falls completely below zero or changing from to the lower bound of 0.

◆ operator-()

IndexRange IntaRNA::IndexRange::operator- ( const int  shift) const
inline

Substracts the given shift to the index range but ensure that the minimal value is 0.

Parameters
rthe range to be altered
shiftthe shift to be substracted from r
Returns
an altered range or (NA_INDEX,NA_INDEX) if the range falls completely below zero or changing from to the lower bound of 0.

◆ operator<()

const bool IntaRNA::IndexRange::operator< ( const IndexRange &  r) const
inline

Checks whether or not the start of this range preceeds the given range.

Parameters
rthe range to compare to
Returns
(from<r.from) || (from==r.from && to<r.to)

◆ operator==()

const bool IntaRNA::IndexRange::operator== ( const IndexRange &  r) const
inline

Checks whether or not two ranges are equivalent

Parameters
rthe range to compare to
Returns
( from == r.from && to == r.to )

◆ overlappingWindows()

std::vector< IndexRange > IntaRNA::IndexRange::overlappingWindows ( const size_t  windowWidth,
const size_t  windowOverlap 
) const

Computes an overlapping window decomposition of this IndexRange

Parameters
windowWidththe width of a window
windowOverlapthe amount of overlap between two windows
Returns
a vector of overlapping IndexRanges covering this IndexRange

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const IndexRange &  range 
)
friend

Prints the range's boundaries to stream

Parameters
outthe ostream to write to
rangethe IndexRange object to add
Returns
the altered stream out

Member Data Documentation

◆ from

size_t IntaRNA::IndexRange::from

the start of the index range

◆ LAST_INDEX

const size_t IntaRNA::IndexRange::LAST_INDEX
static

placeholder to define the whole range (without explicit naming the last index) is defined

◆ NA_INDEX

const size_t IntaRNA::IndexRange::NA_INDEX
static

placeholder for not-defined values

◆ regex

const boost::regex IntaRNA::IndexRange::regex
static

regular expression that matches valid IndexRange string encodings

◆ regexString

constexpr const char* IntaRNA::IndexRange::regexString = R"((0|-?[123456789]\d*)-(0|-?[123456789]\d*))"
staticconstexpr

regular expression that matches valid IndexRange string encodings

◆ to

size_t IntaRNA::IndexRange::to

the end of the index range


The documentation for this class was generated from the following file: