IntaRNA 3.4.1
RNA-RNA interaction prediction | C++ API
Loading...
Searching...
No Matches
InteractionRange.h
Go to the documentation of this file.
1
2#ifndef INTARNA_INTERACTIONRANGE_H_
3#define INTARNA_INTERACTIONRANGE_H_
4
5#include "IntaRNA/general.h"
8
9namespace IntaRNA {
10
11// dummy declaration to avoid inclusion loop
12class Interaction;
13
18public:
19
21 const RnaSequence * s1;
22
24 const RnaSequence * s2;
25
28
31
34
35public:
36
46 const RnaSequence & rna1
47 , const RnaSequence & rna2
50 , const E_type energy = E_INF )
51 : s1(&rna1)
52 , s2(&rna2)
53 , r1(r1.from, (r1.to > rna1.size()?rna1.size()-1:r1.to))
54 , r2((r2.from > rna2.size()?rna2.size()-1:r2.from), r2.to)
55 , energy(energy)
56 {
57#if INTARNA_IN_DEBUG_MODE
58 if (!isSane())
59 throw std::runtime_error("InteractionRange("+toString(*this)+") not sane!");
60#endif
61 }
62
66 InteractionRange( const Interaction& interaction )
67 : s1(NULL), s2(NULL), r1(), r2(), energy(E_INF)
68 {
69 // copy data
70 this->operator =(interaction);
71 }
72
77 {}
78
79
84 bool isSane() const
85 {
86 // range of first sequence ascending
87 // range of second sequence descending
88 return r1.isAscending() && r2.isDescending();
89 }
90
97 friend std::ostream& operator<<(std::ostream& out, const InteractionRange& r)
98 {
99 return (out <<"("<<r.r1<<"#"<<r.r2<<")");
100 }
101
107 const bool operator < ( const InteractionRange &r ) const
108 {
109 return ( r1 < r.r1 || (!(r.r1<r1) && r2<r.r2) );
110 }
111
117 InteractionRange & operator= ( const Interaction & interaction );
118
119};
120
121} // namespace
122
123#endif /* INTERACTIONRANGE_H_ */
Definition IndexRange.h:20
bool isAscending() const
Definition IndexRange.h:80
bool isDescending() const
Definition IndexRange.h:89
Definition InteractionRange.h:17
const RnaSequence * s1
the first interaction partner
Definition InteractionRange.h:21
InteractionRange(const RnaSequence &rna1, const RnaSequence &rna2, const IndexRange &r1=IndexRange(0, RnaSequence::lastPos), const IndexRange &r2=IndexRange(RnaSequence::lastPos, 0), const E_type energy=E_INF)
Definition InteractionRange.h:45
virtual ~InteractionRange()
Definition InteractionRange.h:76
E_type energy
the energy value associated with this interaction range
Definition InteractionRange.h:33
IndexRange r1
the index range of s1 interacting with r2
Definition InteractionRange.h:27
IndexRange r2
the index range of s2 interacting with r1
Definition InteractionRange.h:30
InteractionRange & operator=(const Interaction &interaction)
InteractionRange(const Interaction &interaction)
Definition InteractionRange.h:66
const RnaSequence * s2
the second interaction partner
Definition InteractionRange.h:24
friend std::ostream & operator<<(std::ostream &out, const InteractionRange &r)
Definition InteractionRange.h:97
bool isSane() const
Definition InteractionRange.h:84
const bool operator<(const InteractionRange &r) const
Definition InteractionRange.h:107
Definition Interaction.h:28
Definition RnaSequence.h:29
static const size_t lastPos
Definition RnaSequence.h:57
#define toString(x)
Definition general.h:60
Definition Accessibility.h:13
int E_type
type for energy values (energy + accessibility [ED]) (internally)
Definition general.h:78
const E_type E_INF
Definition general.h:79