IntaRNA 3.4.1
RNA-RNA interaction prediction | C++ API
Loading...
Searching...
No Matches
InteractionEnergyBasePair.h
Go to the documentation of this file.
1
2#ifndef INTARNA_INTERACTIONENERGYBASEPAIR_H_
3#define INTARNA_INTERACTIONENERGYBASEPAIR_H_
4
5#include "IntaRNA/general.h"
10
11
12namespace IntaRNA {
13
14
21
22public:
23
53 , const size_t maxInternalLoopSize1 = 16
54 , const size_t maxInternalLoopSize2 = 16
55 , const bool initES = false
56 , const Z_type RT = Z_type(1.0)
57 , const E_type bpEnergy = Ekcal_2_E(-1.0)
58 , const size_t minLoopLength = 3
59 , const E_type energyAdd = Ekcal_2_E(0.0)
60 , const bool energyWithDangles = true
61 , const bool internalLoopGU = true
62 );
63
65
66
80 virtual
81 E_type
82 getES1( const size_t i1, const size_t j1 ) const;
83
97 virtual
98 E_type
99 getES2( const size_t i2, const size_t j2 ) const;
100
110 virtual
111 E_type
112 getE_multiUnpaired( const size_t numUnpaired ) const;
113
114
126 virtual
127 E_type
128 getE_multiHelix( const size_t j1, const size_t j2 ) const;
129
136 virtual
137 E_type
138 getE_multiClosing() const;
139
140
146 virtual
147 E_type
148 getE_init() const;
149
150
166 virtual
167 E_type
168 getE_interLeft( const size_t i1, const size_t j1, const size_t i2, const size_t j2 ) const;
169
182 virtual
183 E_type
184 getE_danglingLeft( const size_t i1, const size_t i2 ) const;
185
186
197 virtual
198 E_type
199 getE_danglingRight( const size_t j1, const size_t j2 ) const;
200
210 virtual
211 E_type
212 getE_endLeft( const size_t i1, const size_t i2 ) const;
213
223 virtual
224 E_type
225 getE_endRight( const size_t j1, const size_t j2 ) const;
226
232 virtual
233 Z_type
234 getRT() const;
235
242 E_type
243 getE_basePair() const;
244
250 virtual
251 E_type
252 getEall1() const;
253
259 virtual
260 E_type
261 getEall2() const;
262
263
264private:
265
267 const E_type basePairEnergy;
269 const Z_type RT;
271 const Z_type basePairWeight;
273 const size_t minLoopLength;
275 mutable E_type Eall1;
277 mutable E_type Eall2;
278
283
284 /***
285 * Compute the ES for a given sequence and store it in the given lookup table.
286 * @param seq RNASequence
287 * @param logQ The resulting lookuptable
288 */
289 void computeES(const RnaSequence &seq, NussinovHandler::E2dMatrix &logQ);
290
297 E_type
298 computeIntraEall( const Accessibility & acc ) const;
299
300};
301
302
303
307
308inline
310 const Accessibility & accS1
311 , const ReverseAccessibility & accS2
312 , const size_t maxInternalLoopSize1
313 , const size_t maxInternalLoopSize2
314 , const bool initES
315 , const Z_type _RT
316 , const E_type bpEnergy
317 , const size_t minLoopLen
318 , const E_type energyAdd
319 , const bool energyWithDangles
320 , const bool internalLoopGU
321 )
322 :
323 InteractionEnergy(accS1, accS2
324 , maxInternalLoopSize1, maxInternalLoopSize2
325 , energyAdd, energyWithDangles,internalLoopGU ),
326 RT(_RT),
327 basePairEnergy(bpEnergy),
328 minLoopLength(minLoopLen),
329 basePairWeight(Z_exp(E_2_Z(-bpEnergy) / _RT)),
330 Eall1(E_INF),
331 Eall2(E_INF),
332 logQ1(),
333 logQ2()
334{
335 if (initES) {
336 computeES(accS1.getSequence(), logQ1);
337 computeES(accS2.getSequence(), logQ2);
338 }
339}
340
342
343inline
347
349
350inline
351E_type
353getES1( const size_t i1, const size_t j1 ) const
354{
355#if INTARNA_IN_DEBUG_MODE
356 // sanity check
357 if (i1>j1) throw std::runtime_error("InteractionEnergy::getES1(i1="+toString(i1)+" > j1="+toString(j1));
358 if (j1>=size1()) throw std::runtime_error("InteractionEnergy::getES1() : j1="+toString(j1)+" >= size1()="+toString(size1()));
359 if (logQ1.size1() != size1()) throw std::runtime_error("InteractionEnergy::getES1() : ES wasn't computed yet.");
360#endif
361 return logQ1(i1, j1);
362}
363
365
366inline
367E_type
369getES2( const size_t i2, const size_t j2 ) const
370{
371#if INTARNA_IN_DEBUG_MODE
372 // sanity check
373 if (i2>j2) throw std::runtime_error("InteractionEnergy::getES2(i2="+toString(i2)+" > j2="+toString(j2));
374 if (j2>=size2()) throw std::runtime_error("InteractionEnergy::getES2() : j2="+toString(j2)+" >= size2()="+toString(size2()));
375 if (logQ2.size1() != size2()) throw std::runtime_error("InteractionEnergy::getES2() : ES wasn't computed yet.");
376#endif
377 return logQ2(i2, j2);
378}
379
381
382inline
383E_type
385getE_multiUnpaired( const size_t numUnpaired ) const
386{
387 return E_type(0);
388}
389
391
392inline
393E_type
395getE_multiHelix( const size_t j1, const size_t j2 ) const
396{
397 return E_type(0);
398}
399
401
402inline
403E_type
405getE_multiClosing() const
406{
407 return E_type(0);
408}
409
411
412inline
413E_type
415getE_init() const
416{
417 return basePairEnergy;
418}
419
421
422inline
423E_type
425getE_interLeft( const size_t i1, const size_t j1, const size_t i2, const size_t j2 ) const
426{
427 // if valid internal loop
428 if ( isValidInternalLoop(i1,j1,i2,j2) ) {
429 // return negated number of gained base pairs by closing this loop = -1
430 return basePairEnergy;
431 } else {
432 return E_INF;
433 }
434}
435
437
438inline
439E_type
441getE_danglingLeft( const size_t i1, const size_t i2 ) const
442{
443 // no dangling end contribution
444 return E_type(0);
445}
446
448
449inline
450E_type
452getE_danglingRight( const size_t j1, const size_t j2 ) const
453{
454 // no dangling end contribution
455 return E_type(0);
456}
457
459
460inline
461E_type
463getE_endLeft( const size_t i1, const size_t i2 ) const {
464 return E_type(0);
465}
466
468
469inline
470E_type
472getE_endRight( const size_t j1, const size_t j2 ) const {
473 return E_type(0);
474}
475
477
478inline
479E_type
481getE_basePair() const {
482 return basePairEnergy;
483}
484
486
487inline
488Z_type
490getRT() const {
491 return this->RT;
492}
493
495
496} // namespace IntaRNA
497
498#endif /* INTERACTIONENERGYBASEPAIR_H_ */
Definition Accessibility.h:25
virtual const RnaSequence & getSequence() const
Definition Accessibility.h:259
Definition InteractionEnergyBasePair.h:20
virtual E_type getES2(const size_t i2, const size_t j2) const
Definition InteractionEnergyBasePair.h:369
virtual E_type getEall2() const
virtual E_type getE_init() const
Definition InteractionEnergyBasePair.h:415
virtual E_type getE_danglingLeft(const size_t i1, const size_t i2) const
Definition InteractionEnergyBasePair.h:441
InteractionEnergyBasePair(const Accessibility &accS1, const ReverseAccessibility &accS2, const size_t maxInternalLoopSize1=16, const size_t maxInternalLoopSize2=16, const bool initES=false, const Z_type RT=Z_type(1.0), const E_type bpEnergy=Ekcal_2_E(-1.0), const size_t minLoopLength=3, const E_type energyAdd=Ekcal_2_E(0.0), const bool energyWithDangles=true, const bool internalLoopGU=true)
Definition InteractionEnergyBasePair.h:309
virtual E_type getES1(const size_t i1, const size_t j1) const
Definition InteractionEnergyBasePair.h:353
virtual E_type getEall1() const
virtual E_type getE_multiClosing() const
Definition InteractionEnergyBasePair.h:405
virtual E_type getE_multiUnpaired(const size_t numUnpaired) const
Definition InteractionEnergyBasePair.h:385
virtual E_type getE_multiHelix(const size_t j1, const size_t j2) const
Definition InteractionEnergyBasePair.h:395
virtual E_type getE_endLeft(const size_t i1, const size_t i2) const
Definition InteractionEnergyBasePair.h:463
virtual Z_type getRT() const
Definition InteractionEnergyBasePair.h:490
virtual E_type getE_interLeft(const size_t i1, const size_t j1, const size_t i2, const size_t j2) const
Definition InteractionEnergyBasePair.h:425
virtual E_type getE_danglingRight(const size_t j1, const size_t j2) const
Definition InteractionEnergyBasePair.h:452
virtual ~InteractionEnergyBasePair()
Definition InteractionEnergyBasePair.h:344
virtual E_type getE_endRight(const size_t j1, const size_t j2) const
Definition InteractionEnergyBasePair.h:472
E_type getE_basePair() const
Definition InteractionEnergyBasePair.h:481
Definition InteractionEnergy.h:20
const ReverseAccessibility & accS2
accessibility values for sequence S2 (reversed index order)
Definition InteractionEnergy.h:591
const E_type energyAdd
user defined shift of the energy spectrum
Definition InteractionEnergy.h:602
const size_t maxInternalLoopSize1
Definition InteractionEnergy.h:595
const Accessibility & accS1
accessibility values for sequence S1
Definition InteractionEnergy.h:588
const bool energyWithDangles
whether or not dangling end energy contributions are to be added
Definition InteractionEnergy.h:605
const bool internalLoopGU
whether or not GU base pairs allowed in internal loops
Definition InteractionEnergy.h:608
virtual bool isValidInternalLoop(const size_t i1, const size_t j1, const size_t i2, const size_t j2) const
Definition InteractionEnergy.h:729
virtual size_t size1() const
Definition InteractionEnergy.h:709
const size_t maxInternalLoopSize2
Definition InteractionEnergy.h:599
virtual size_t size2() const
Definition InteractionEnergy.h:719
Definition ReverseAccessibility.h:13
virtual const RnaSequence & getSequence() const
Definition ReverseAccessibility.h:147
Definition RnaSequence.h:29
std::size_t size1() const noexcept
Definition Matrix.h:365
#define E_2_Z(e)
convert E_type to Z_type
Definition general.h:119
#define toString(x)
Definition general.h:60
#define Ekcal_2_E(e)
convert energy in kcal/mol units to internal energy type
Definition general.h:113
#define Z_exp
Definition general.h:90
Definition Accessibility.h:13
int E_type
type for energy values (energy + accessibility [ED]) (internally)
Definition general.h:78
double Z_type
type for probabilities, RT and Boltzmann values
Definition general.h:88
const E_type E_INF
Definition general.h:79