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

#include <IndexRangeList.h>

Collaboration diagram for IntaRNA::IndexRangeList:
Collaboration graph
[legend]

Public Types

typedef List::iterator iterator
 
typedef List::const_iterator const_iterator
 
typedef List::reverse_iterator reverse_iterator
 
typedef List::const_reverse_iterator const_reverse_iterator
 

Public Member Functions

 IndexRangeList (const bool allowOverlap=false)
 
 IndexRangeList (const std::string &stringEncoding, const bool allowOverlap=false, const RnaSequence *seq=NULL, const bool isComplete=false)
 
 IndexRangeList (const IndexRangeList &toCopy)
 
virtual ~IndexRangeList ()
 
bool covers (const size_t index) const
 
bool covers (const size_t from, const size_t to) const
 
bool covers (const IndexRange &range) const
 
bool overlaps (const IndexRange &range) const
 
void push_back (const IndexRange &range)
 
iterator insert (const IndexRange &range)
 
IndexRange & get (const size_t idx)
 
const IndexRange & get (const size_t idx) const
 
iterator erase (iterator i)
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
bool empty () const
 
size_t size () const
 
void clear ()
 
bool isAllowingOverlap () const
 
void fromString (const std::string &stringEncoding, const RnaSequence *seq=NULL)
 
IndexRangeList shift (const int indexShift, const size_t indexMax) const
 
IndexRangeList & reverseInplace (const size_t seqLength)
 
IndexRangeList reverse (const size_t seqLength) const
 
const bool operator== (const IndexRangeList &r) const
 
const bool operator!= (const IndexRangeList &r) const
 
void setComplete (const bool isComplete)
 
bool isComplete () const
 

Static Public Attributes

static const std::string regexString
 regular expression string (without start/end matching)
 
static const boost::regex regex
 regular expression that matches valid IndexRangeList string encodings
 

Protected Types

typedef std::list< IndexRange > List
 List of ranges.
 

Protected Attributes

bool allowOverlap
 whether or not overlapping ranges are allowed
 
List list
 the list of indices
 
bool listIsComplete
 whether or not the list is complete, i.e. cannot be extended
 

Friends

std::ostream & operator<< (std::ostream &out, const IndexRangeList &l)
 

Detailed Description

Sorted list of ascending ranges that can be constrained to be non-overlapping

Author
Martin Mann

Member Typedef Documentation

◆ const_iterator

typedef List::const_iterator IntaRNA::IndexRangeList::const_iterator

◆ const_reverse_iterator

typedef List::const_reverse_iterator IntaRNA::IndexRangeList::const_reverse_iterator

◆ iterator

typedef List::iterator IntaRNA::IndexRangeList::iterator

◆ List

typedef std::list< IndexRange > IntaRNA::IndexRangeList::List
protected

List of ranges.

◆ reverse_iterator

typedef List::reverse_iterator IntaRNA::IndexRangeList::reverse_iterator

Constructor & Destructor Documentation

◆ IndexRangeList() [1/3]

IntaRNA::IndexRangeList::IndexRangeList ( const bool  allowOverlap = false)
inline

empty construction

Parameters
allowOverlapwhether or not overlapping ranges are allowed

◆ IndexRangeList() [2/3]

IntaRNA::IndexRangeList::IndexRangeList ( const std::string &  stringEncoding,
const bool  allowOverlap = false,
const RnaSequence *  seq = NULL,
const bool  isComplete = false 
)
inline

String encoding based construction

Parameters
stringEncodingthe string encoding to be parsed
allowOverlapwhether or not overlapping ranges are allowed
seqif not NULL, the RnaSequence to be used to shift in/output indices to 0-based internal index positions
isCompletewhether or not the list is complete (no further ranges can be added)
Exceptions
std::runtime_errorif stringEncoding does not match regex

◆ IndexRangeList() [3/3]

IntaRNA::IndexRangeList::IndexRangeList ( const IndexRangeList &  toCopy)
inline

copy construction

Parameters
toCopythe list to make this a copy of

◆ ~IndexRangeList()

IntaRNA::IndexRangeList::~IndexRangeList ( )
inlinevirtual

destruction

Member Function Documentation

◆ begin() [1/2]

IndexRangeList::iterator IntaRNA::IndexRangeList::begin ( )
inline

Access to the first index range within the list

Returns
the begin of the list

◆ begin() [2/2]

IndexRangeList::const_iterator IntaRNA::IndexRangeList::begin ( ) const
inline

Constant access to the first index range within the list

Returns
the begin of the list

◆ clear()

void IntaRNA::IndexRangeList::clear ( )
inline

Removes all stored elements

◆ covers() [1/3]

bool IntaRNA::IndexRangeList::covers ( const IndexRange &  range) const

checks whether or not a given index range is completely covered by one of the stored index ranges

Parameters
rangethe index range of interest
Returns
true if range is within one of the index ranges (including boundaries); false otherwise

◆ covers() [2/3]

bool IntaRNA::IndexRangeList::covers ( const size_t  from,
const size_t  to 
) const
inline

checks whether or not a given index range is completely covered by one of the stored index ranges

Parameters
fromthe start index of the range of interest
tothe end index of the range of interest
Returns
true if [from,to] is within one of the index ranges (including boundaries); false otherwise

◆ covers() [3/3]

bool IntaRNA::IndexRangeList::covers ( const size_t  index) const

checks whether or not a given index is covered by one of the stored index ranges

Parameters
indexthe index to check
Returns
true if index is within one of the index ranges (including boundaries); false otherwise

◆ empty()

bool IntaRNA::IndexRangeList::empty ( ) const
inline

Whether or not an index range is present

Returns
true if no index range is stored; false otherwise

◆ end() [1/2]

IndexRangeList::iterator IntaRNA::IndexRangeList::end ( )
inline

Access to the end of the index range iteration

Returns
the end of the list

◆ end() [2/2]

IndexRangeList::const_iterator IntaRNA::IndexRangeList::end ( ) const
inline

Constant access to the end of the index range iteration

Returns
the end of the list

◆ erase()

IndexRangeList::iterator IntaRNA::IndexRangeList::erase ( IndexRangeList::iterator  i)
inline

removes an element from the list

Parameters
ithe iterator pointing to the element to delete

◆ fromString()

void IntaRNA::IndexRangeList::fromString ( const std::string &  stringEncoding,
const RnaSequence *  seq = NULL 
)

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

Parameters
stringEncodingthe interval list string encoding
seqif not NULL, the RnaSequence to be used to shift in/output indices to 0-based internal index positions
Exceptions
std::runtime_errorif stringEncoding does not match regex

◆ get() [1/2]

IndexRange & IntaRNA::IndexRangeList::get ( const size_t  idx)

access to the stored range with the given index

Parameters
idxthe index of the range within the list to access
Returns
the range for index idx
Exceptions
std::runtime_errorif idx >= this.size()

◆ get() [2/2]

const IndexRange & IntaRNA::IndexRangeList::get ( const size_t  idx) const

Constant access to the stored range with the given index

Parameters
idxthe index of the range within the list to access
Returns
the range for index idx (const access)
Exceptions
std::runtime_errorif idx >= this.size()

◆ insert()

iterator IntaRNA::IndexRangeList::insert ( const IndexRange &  range)

adds an ascending range to the according position of the sorted list. Insertion of duplicates is avoided.

Parameters
rangethe ascending index range to add
Returns
iterator to the inserted (or already present) element

◆ isAllowingOverlap()

bool IntaRNA::IndexRangeList::isAllowingOverlap ( ) const
inline

Whether or not index ranges are allowed to overlap

Returns
true if ranges are allowed to overlap; false otherwise

◆ isComplete()

bool IntaRNA::IndexRangeList::isComplete ( ) const
inline

Whether or not the list is complete, i.e. cannot be extended

Returns
true if the list is complete; false otherwise

◆ operator!=()

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

Checks whether or not two range lists are inequivalent

Parameters
rthe range list to compare to
Returns
list != r.list

◆ operator==()

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

Checks whether or not two range lists are equivalent

Parameters
rthe range list to compare to
Returns
list == r.list

◆ overlaps()

bool IntaRNA::IndexRangeList::overlaps ( const IndexRange &  range) const

checks whether or not a given ascending index range is overlapping with at least one of the stored index ranges

Parameters
rangethe range to check
Returns
true if range is within one of the index ranges (including boundaries); false otherwise

◆ push_back()

void IntaRNA::IndexRangeList::push_back ( const IndexRange &  range)

adds an ascending range to the end of the list. NOTE: if the insertion would violate range sorting, an exception is raised

Parameters
rangethe ascending index range to add (from should be > rbegin()->to)

◆ rbegin() [1/2]

IndexRangeList::reverse_iterator IntaRNA::IndexRangeList::rbegin ( )
inline

Access to the last index range within the list

Returns
the begin of the list

◆ rbegin() [2/2]

IndexRangeList::const_reverse_iterator IntaRNA::IndexRangeList::rbegin ( ) const
inline

Constant access to the last index range within the list

Returns
the begin of the list

◆ rend() [1/2]

IndexRangeList::reverse_iterator IntaRNA::IndexRangeList::rend ( )
inline

Access to the end of the reversed index range iteration

Returns
the end of the list

◆ rend() [2/2]

IndexRangeList::const_reverse_iterator IntaRNA::IndexRangeList::rend ( ) const
inline

Constant access to the end of the reversed index range iteration

Returns
the end of the list

◆ reverse()

IndexRangeList IntaRNA::IndexRangeList::reverse ( const size_t  seqLength) const
inline

Reverses all indices for the given sequence length, i.e. (newIdx = seqLength-1-oldIdx)

◆ reverseInplace()

IndexRangeList & IntaRNA::IndexRangeList::reverseInplace ( const size_t  seqLength)

Reverses all indices for the given sequence length, i.e. (newIdx = seqLength-1-oldIdx)

◆ setComplete()

void IntaRNA::IndexRangeList::setComplete ( const bool  isComplete)
inline

Sets whether or not the list is complete, i.e. cannot be extended

Parameters
isCompletetrue if the list is complete; false otherwise

◆ shift()

IndexRangeList IntaRNA::IndexRangeList::shift ( const int  indexShift,
const size_t  indexMax 
) const

shifts all indices by the given value and returns all intervals within the boundaries [0,indexMax] including indexMax

Parameters
indexShiftthe shift to be applied to all index range boundaries
indexMaxthe maximal value any index in the returned list can have
Returns
a new range list with shifted ranges where all ranges shifted to indices below 0 are (I) removed if range'.to < 0 or (II) cut to range'.from = 0; the same holds respectively for upper bound violations exceeding indexMax.

◆ size()

size_t IntaRNA::IndexRangeList::size ( ) const
inline

The number of index ranges stored

Returns
the number of stored index ranges

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const IndexRangeList &  l 
)
friend

Prints the boundaries of the list's ranges to stream

Parameters
outthe ostream to write to
lthe IndexRangeList object to add
Returns
the altered stream out

Member Data Documentation

◆ allowOverlap

bool IntaRNA::IndexRangeList::allowOverlap
protected

whether or not overlapping ranges are allowed

◆ list

List IntaRNA::IndexRangeList::list
protected

the list of indices

◆ listIsComplete

bool IntaRNA::IndexRangeList::listIsComplete
protected

whether or not the list is complete, i.e. cannot be extended

◆ regex

const boost::regex IntaRNA::IndexRangeList::regex
static

regular expression that matches valid IndexRangeList string encodings

◆ regexString

const std::string IntaRNA::IndexRangeList::regexString
static

regular expression string (without start/end matching)


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