IntaRNA 3.4.1
RNA-RNA interaction prediction | C++ API
Loading...
Searching...
No Matches
InteractionEnergyVrna.h
Go to the documentation of this file.
1
2#ifndef INTARNA_INTERACTIONENERGYVIENNA_H_
3#define INTARNA_INTERACTIONENERGYVIENNA_H_
4
7
8extern "C" {
9 #include <ViennaRNA/utils.h>
10 #include <ViennaRNA/fold_vars.h>
11 #include <ViennaRNA/model.h>
12 #include <ViennaRNA/params.h>
13 #include <ViennaRNA/loop_energies.h>
14}
15#ifndef VIENNA_RNA_PAIR_MAT_H
16#define VIENNA_RNA_PAIR_MAT_H
17extern "C" {
18 #include <ViennaRNA/pair_mat.h>
19}
20#endif
21
22#include "IntaRNA/Matrix.h"
23
24#define Evrna_2_E( e ) ( static_cast<E_type>(e) )
25
26namespace IntaRNA {
27
28// http://www.tbi.univie.ac.at/RNA/ViennaRNA/doc/RNAlib-2.3.0.pdf
29
37
38public:
39
40
41
69 , VrnaHandler &vrnaHandler
70 , const size_t maxInternalLoopSize1 = 16
71 , const size_t maxInternalLoopSize2 = 16
72 , const bool initES = false
73 , const E_type energyAdd = Ekcal_2_E(0.0)
74 , const bool energyWithDangles = true
75 , const bool internalLoopGU = true
76 );
77
79
80
94 virtual
95 E_type
96 getES1( const size_t i1, const size_t j1 ) const;
97
111 virtual
112 E_type
113 getES2( const size_t i2, const size_t j2 ) const;
114
124 virtual
125 E_type
126 getE_multiUnpaired( const size_t numUnpaired ) const;
127
140 virtual
141 E_type
142 getE_multiHelix( const size_t j1, const size_t j2 ) const;
143
151 virtual
152 E_type
153 getE_multiClosing() const;
154
160 virtual
161 E_type
162 getE_init() const;
163
181 virtual
182 E_type
183 getE_interLeft( const size_t i1, const size_t j1, const size_t i2, const size_t j2 ) const;
184
185
196 virtual
197 E_type
198 getE_danglingLeft( const size_t i1, const size_t i2 ) const;
199
200
211 virtual
212 E_type
213 getE_danglingRight( const size_t j1, const size_t j2 ) const;
214
215
225 virtual
226 E_type
227 getE_endLeft( const size_t i1, const size_t i2 ) const;
228
238 virtual
239 E_type
240 getE_endRight( const size_t j1, const size_t j2 ) const;
241
247 virtual
248 E_type
249 getEall1() const;
250
256 virtual
257 E_type
258 getEall2() const;
259
265 virtual
266 Z_type
267 getRT() const;
268
269protected:
270
271
273 vrna_md_t foldModel;
274
277 vrna_param_t * foldParams;
278
281
283 const int bpCG;
284
286 const int bpGC;
287
290
293
296
298 mutable E_type Eall1;
299
301 mutable E_type Eall2;
302
309 bool
310 isGC( const size_t i1, const size_t i2 ) const;
311
317 void
318 computeES( const Accessibility & acc, EsMatrix & esToFill );
319
326 E_type
327 computeIntraEall( const Accessibility & acc ) const;
328};
329
330
334
335inline
336E_type
338getE_init() const
339{
340 // init term is sequence independent
341 return Evrna_2_E(foldParams->DuplexInit);
342}
343
345
346inline
347E_type
349getE_endLeft( const size_t i1, const size_t i2 ) const
350{
351 // VRNA non-GC penalty
352 return Evrna_2_E( isGC(i1,i2) ? 0.0 : foldParams->TerminalAU );
353}
354
356
357inline
358E_type
360getE_endRight( const size_t j1, const size_t j2 ) const
361{
362 // VRNA non-GC penalty
363 return Evrna_2_E( isGC(j1,j2) ? 0.0 : foldParams->TerminalAU );
364}
365
367
368inline
369Z_type
371getRT() const
372{
373 return RT;
374}
375
377
378inline
379E_type
381getE_interLeft( const size_t i1, const size_t j1, const size_t i2, const size_t j2 ) const
382{
383 // if valid internal loop
384 if ( isValidInternalLoop(i1,j1,i2,j2) ) {
385 assert( i1!=j1 && i2!=j2 );
386 // Vienna RNA : compute internal loop / stacking energy for base pair [i1,i2]
387 return Evrna_2_E(E_IntLoop( (int)j1-i1-1 // unpaired region 1
388 , (int)j2-i2-1 // unpaired region 2
389 , BP_pair[accS1.getSequence().asCodes().at(i1)][accS2.getSequence().asCodes().at(i2)] // type BP (i1,i2)
390 , BP_pair[accS2.getSequence().asCodes().at(j2)][accS1.getSequence().asCodes().at(j1)] // type BP (j2,j1)
391 , accS1.getSequence().asCodes().at(i1+1)
392 , accS2.getSequence().asCodes().at(i2+1)
393 , accS1.getSequence().asCodes().at(j1-1)
394 , accS2.getSequence().asCodes().at(j2-1)
395 , foldParams))
396 ;
397 } else {
398 return E_INF;
399 }
400}
401
403
404inline
405E_type
407getE_danglingLeft( const size_t i1, const size_t i2 ) const
408{
409 // Vienna RNA : dangling end contribution
410 return Evrna_2_E(vrna_E_ext_stem( BP_pair[accS1.getSequence().asCodes().at(i1)][accS2.getSequence().asCodes().at(i2)]
411 , ( i1==0 ? -1 : accS1.getSequence().asCodes().at(i1-1) )
412 , ( i2==0 ? -1 : accS2.getSequence().asCodes().at(i2-1) )
413 , foldParams
414 ))
415 // substract closing penalty
416 - getE_endLeft(i1,i2);
417}
418
420
421inline
422E_type
424getE_danglingRight( const size_t j1, const size_t j2 ) const
425{
426 // Vienna RNA : dangling end contribution (reverse base pair to be sequence end conform)
427 return Evrna_2_E(vrna_E_ext_stem( BP_pair[accS2.getSequence().asCodes().at(j2)][accS1.getSequence().asCodes().at(j1)]
428 , ( j2+1>=accS2.getSequence().size() ? -1 : accS2.getSequence().asCodes().at(j2+1) )
429 , ( j1+1>=accS1.getSequence().size() ? -1 : accS1.getSequence().asCodes().at(j1+1) )
430 , foldParams
431 ))
432 // substract closing penalty
433 - getE_endRight(j1,j2);
434}
435
437
438inline
439E_type
441getES1( const size_t i1, const size_t j1 ) const
442{
443#if INTARNA_IN_DEBUG_MODE
444 // sanity check
445 if (i1>j1) throw std::runtime_error("InteractionEnergy::getES1(i1="+toString(i1)+" > j1="+toString(j1));
446 if (j1>=size1()) throw std::runtime_error("InteractionEnergy::getES1() : j1="+toString(j1)+" >= size1()="+toString(size1()));
447 if (esValues1 == NULL) throw std::runtime_error("InteractionEnergy::getES1() : ES values not initialized");
448#endif
449
450 // return computed value
451 return (*esValues1)(i1,j1);
452}
453
455
456inline
457E_type
459getES2( const size_t i2, const size_t j2 ) const
460{
461#if INTARNA_IN_DEBUG_MODE
462 // sanity check
463 if (i2>j2) throw std::runtime_error("InteractionEnergy::getES2(i2="+toString(i2)+" > j2="+toString(j2));
464 if (j2>=size2()) throw std::runtime_error("InteractionEnergy::getES2() : j2="+toString(j2)+" >= size2()="+toString(size2()));
465 if (esValues2 == NULL) throw std::runtime_error("InteractionEnergy::getES2() : ES values not initialized");
466#endif
467
468 // return computed value
469 return (*esValues2)(i2,j2);
470}
471
473
474inline
475bool
477isGC( const size_t i1, const size_t i2 ) const
478{
479 const int bpType = BP_pair[accS1.getSequence().asCodes().at(i1)][accS2.getSequence().asCodes().at(i2)];
480 return (bpType==bpCG || bpType==bpGC);
481}
482
484
485inline
486E_type
488getE_multiUnpaired( const size_t numUnpaired ) const
489{
490 return E_type(numUnpaired) * (Evrna_2_E(foldParams->MLbase));
491}
492
494
495inline
496E_type
498getE_multiHelix( const size_t j1, const size_t j2 ) const
499{
500 return (Evrna_2_E(foldParams->MLintern[
501 BP_pair[accS2.getSequence().asCodes().at(j2)]
502 [accS1.getSequence().asCodes().at(j1)]
503 ]));
504}
505
507
508inline
509E_type
511getE_multiClosing() const
512{
513 return (Evrna_2_E(foldParams->MLclosing));
514}
515
517
518inline
519E_type
521getEall1() const
522{
523 // compute Z if needed
524 if (E_isINF(Eall1)) {
526 }
527 return Eall1;
528}
529
531
532inline
533E_type
535getEall2() const
536{
537 // compute Z if needed
538 if (E_isINF(Eall2)) {
540 }
541 return Eall2;
542}
543
545
546
547} // namespace
548
549#endif /* INTERACTIONENERGYVIENNA_H_ */
#define Evrna_2_E(e)
Definition InteractionEnergyVrna.h:24
Definition Accessibility.h:25
virtual const RnaSequence & getSequence() const
Definition Accessibility.h:259
Definition InteractionEnergyVrna.h:36
virtual E_type getEall2() const
Definition InteractionEnergyVrna.h:535
vrna_md_t foldModel
Vienna RNA package : folding model to be used for the energy computation.
Definition InteractionEnergyVrna.h:273
virtual E_type getE_multiHelix(const size_t j1, const size_t j2) const
Definition InteractionEnergyVrna.h:498
E_type Eall1
ensemble energy of intra-molecular structures of seq1
Definition InteractionEnergyVrna.h:298
void computeES(const Accessibility &acc, EsMatrix &esToFill)
virtual E_type getE_endRight(const size_t j1, const size_t j2) const
Definition InteractionEnergyVrna.h:360
E_type Eall2
ensemble energy of intra-molecular structures of seq2
Definition InteractionEnergyVrna.h:301
UpperTriangularMatrix< E_type > EsMatrix
matrix to store ES values (upper triangular matrix)
Definition InteractionEnergyVrna.h:289
const int bpCG
base pair code for (C,G)
Definition InteractionEnergyVrna.h:283
virtual E_type getES2(const size_t i2, const size_t j2) const
Definition InteractionEnergyVrna.h:459
EsMatrix * esValues2
the ES values for seq2 if computed (otherwise NULL)
Definition InteractionEnergyVrna.h:295
virtual E_type getE_danglingRight(const size_t j1, const size_t j2) const
Definition InteractionEnergyVrna.h:424
virtual E_type getE_danglingLeft(const size_t i1, const size_t i2) const
Definition InteractionEnergyVrna.h:407
virtual E_type getE_multiUnpaired(const size_t numUnpaired) const
Definition InteractionEnergyVrna.h:488
virtual Z_type getRT() const
Definition InteractionEnergyVrna.h:371
const int bpGC
base pair code for (G,C)
Definition InteractionEnergyVrna.h:286
virtual E_type getE_multiClosing() const
Definition InteractionEnergyVrna.h:511
virtual E_type getES1(const size_t i1, const size_t j1) const
Definition InteractionEnergyVrna.h:441
virtual E_type getE_endLeft(const size_t i1, const size_t i2) const
Definition InteractionEnergyVrna.h:349
Z_type RT
the RT constant to be used for Boltzmann weight computations
Definition InteractionEnergyVrna.h:280
virtual E_type getE_interLeft(const size_t i1, const size_t j1, const size_t i2, const size_t j2) const
Definition InteractionEnergyVrna.h:381
E_type computeIntraEall(const Accessibility &acc) const
virtual E_type getE_init() const
Definition InteractionEnergyVrna.h:338
virtual E_type getEall1() const
Definition InteractionEnergyVrna.h:521
bool isGC(const size_t i1, const size_t i2) const
Definition InteractionEnergyVrna.h:477
EsMatrix * esValues1
the ES values for seq1 if computed (otherwise NULL)
Definition InteractionEnergyVrna.h:292
vrna_param_t * foldParams
Definition InteractionEnergyVrna.h:277
InteractionEnergyVrna(const Accessibility &accS1, const ReverseAccessibility &accS2, VrnaHandler &vrnaHandler, const size_t maxInternalLoopSize1=16, const size_t maxInternalLoopSize2=16, const bool initES=false, const E_type energyAdd=Ekcal_2_E(0.0), const bool energyWithDangles=true, const bool internalLoopGU=true)
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
virtual const Accessibility & getAccessibilityOrigin() const
Definition ReverseAccessibility.h:185
const CodeSeq_type & asCodes() const
Definition RnaSequence.h:454
size_t size() const
Definition RnaSequence.h:366
Definition Matrix.h:227
Definition VrnaHandler.h:20
#define toString(x)
Definition general.h:60
#define E_isINF(e)
check if a given energy is set to E_INF
Definition general.h:143
#define Ekcal_2_E(e)
convert energy in kcal/mol units to internal energy type
Definition general.h:113
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