IntaRNA 3.4.1
RNA-RNA interaction prediction | C++ API
Loading...
Searching...
No Matches
PredictionTrackerProfileSpotProb.h
Go to the documentation of this file.
1
2#ifndef INTARNA_PREDICTIONTRACKERPROFILESPOTPROB_H_
3#define INTARNA_PREDICTIONTRACKERPROFILESPOTPROB_H_
4
7
8#include <iostream>
9
10#include <boost/algorithm/string.hpp>
11
12namespace IntaRNA {
13
23{
24
25public:
26
47 , const std::string & seq1streamName
48 , const std::string & seq2streamName
49 , const std::string & NA_string = "NA"
50 , const std::string & sep = ";"
51 );
52
69 , std::ostream * seq1stream
70 , std::ostream * seq2stream
71 , const std::string & NA_string = "NA"
72 , const std::string & sep = ";"
73 );
74
79
80
90 virtual
91 void
92 updateOptimumCalled( const size_t i1, const size_t j1
93 , const size_t i2, const size_t j2
94 , const E_type energy
95 );
96
97
98protected:
99
102
105
107 std::ostream * seq1stream;
108
110 std::ostream * seq2stream;
111
113 const std::string NA_string;
114
116 const std::string sep;
117
119 typedef std::vector<Z_type> ZProfile;
120
123
126
129
138 static
139 void
141 , const size_t i
142 , const size_t j
143 , const Z_type boltzmannWeight);
144
157 template < typename ZProfileIterator >
158 static
159 void
160 writeProfile( std::ostream &out
161 , const ZProfileIterator & begin
162 , const ZProfileIterator & end
163 , const Z_type overallZ
164 , const RnaSequence & rna
165 , const std::string & NA_string
166 , const std::string & sep
167 );
168
169
170};
171
173
174template < typename ZProfileIterator >
175inline
176void
178writeProfile( std::ostream &out
179 , const ZProfileIterator & begin
180 , const ZProfileIterator & end
181 , const Z_type overallZ
182 , const RnaSequence & rna
183 , const std::string & NA_string
184 , const std::string & sep
185 )
186{
187 // write in CSV-like format (column data)
188
189 const bool noZ = (overallZ==0.0);
190
191 // print header : seq.ID ; spotProb
192 out <<"idx"<<sep<<boost::replace_all_copy(rna.getId(), sep, "_")<<sep<<"spotProb" <<'\n';
193 // print spot probability data
194 size_t i=0;
195 for (ZProfileIterator curZ = begin; curZ!=end; curZ++) {
196 out
197 // out index
198 <<rna.getInOutIndex(i)<<sep
199 // out nucleotide (index starts with 0)
200 <<rna.asString().at(i)<<sep
201 ;
202 // out infinity replacement if needed
203 if ( noZ || Z_isINF( *curZ ) ) {
204 out<<NA_string <<'\n';
205 } else {
206 out <<((*curZ)/overallZ) <<'\n';
207 }
208 // increase position counter
209 i++;
210 }
211}
212
214
215} // namespace
216
217#endif /* PREDICTIONTRACKERPROFILESPOTPROB_H_ */
Definition InteractionEnergy.h:20
Definition PredictionTrackerProfileSpotProb.h:23
PredictionTrackerProfileSpotProb(const InteractionEnergy &energy, const std::string &seq1streamName, const std::string &seq2streamName, const std::string &NA_string="NA", const std::string &sep=";")
std::ostream * seq1stream
if non-NULL, the stream to write the spotProb-profile for seq1 to
Definition PredictionTrackerProfileSpotProb.h:107
Z_type overallZ
the overall partition function to be used for normalization
Definition PredictionTrackerProfileSpotProb.h:128
static void writeProfile(std::ostream &out, const ZProfileIterator &begin, const ZProfileIterator &end, const Z_type overallZ, const RnaSequence &rna, const std::string &NA_string, const std::string &sep)
Definition PredictionTrackerProfileSpotProb.h:178
std::vector< Z_type > ZProfile
container definition for partition function profile data
Definition PredictionTrackerProfileSpotProb.h:119
std::ostream * seq2stream
if non-NULL, the stream to write the spotProb-profile for seq2 to
Definition PredictionTrackerProfileSpotProb.h:110
PredictionTrackerProfileSpotProb(const InteractionEnergy &energy, std::ostream *seq1stream, std::ostream *seq2stream, const std::string &NA_string="NA", const std::string &sep=";")
const bool deleteStreamsOnDestruction
whether or not the streams are to be deleted on destruction
Definition PredictionTrackerProfileSpotProb.h:104
const std::string NA_string
the output string representation if a value is not available for profile output
Definition PredictionTrackerProfileSpotProb.h:113
ZProfile seq2Z
the position-wise partition function values for seq2
Definition PredictionTrackerProfileSpotProb.h:125
const std::string sep
the output string representation of a column separator
Definition PredictionTrackerProfileSpotProb.h:116
virtual void updateOptimumCalled(const size_t i1, const size_t j1, const size_t i2, const size_t j2, const E_type energy)
ZProfile seq1Z
the position-wise partition function values for seq1
Definition PredictionTrackerProfileSpotProb.h:122
static void updateProfile(ZProfile &profile, const size_t i, const size_t j, const Z_type boltzmannWeight)
const InteractionEnergy & energy
energy handler used for predictions
Definition PredictionTrackerProfileSpotProb.h:101
Definition PredictionTracker.h:15
Definition RnaSequence.h:29
long getInOutIndex(const size_t i) const
Definition RnaSequence.h:376
const std::string & getId() const
Definition RnaSequence.h:346
const String_type & asString() const
Definition RnaSequence.h:442
#define Z_isINF(e)
check if a given energy is set to Z_INF
Definition general.h:176
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