1 #ifndef SPARSIFICATION_MAPPER_HH 2 #define SPARSIFICATION_MAPPER_HH 12 #include "basepairs.hh" 13 #include "ext_rna_data.hh" 22 template <
class T1,
class T2>
23 std::ostream& operator << (std::ostream& out, const std::pair<T1,T2>& pair) {
24 return out <<
"(" << pair.first <<
"," << pair.second <<
") ";
60 this->valid_arcs.clear();
71 const double prob_unpaired_in_loop_threshold;
72 const double prob_basepair_in_loop_threshold;
74 std::vector<InfoForPosVec> info_valid_seq_pos_vecs;
80 std::vector<std::vector<matidx_t> > valid_mat_pos_vecs_before_eq;
84 std::vector<std::vector<ArcIdxVec > > left_adj_vec;
87 void compute_mapping_idx_arcs();
90 void compute_mapping_idx_left_ends();
94 void iterate_left_adj_list(
pos_type cur_left_end,
116 double prob_unpaired_in_loop_threshold_,
117 double prob_basepair_in_loop_threshold_,
118 bool index_left_ends):
121 prob_unpaired_in_loop_threshold(prob_unpaired_in_loop_threshold_),
122 prob_basepair_in_loop_threshold(prob_basepair_in_loop_threshold_),
126 compute_mapping_idx_left_ends();
129 compute_mapping_idx_arcs();
138 return max_info_vec_size;
146 const InfoForPosVec &
148 return info_valid_seq_pos_vecs.at(idx);
159 return info_valid_seq_pos_vecs.at(idx).at(pos).valid_arcs;
174 std::numeric_limits<index_t>::max())
const {
175 if (left_end == std::numeric_limits<index_t>::max())
177 assert (pos >= left_end);
178 return valid_mat_pos_vecs_before_eq.at(index).at(pos-left_end);
193 std::numeric_limits<index_t>::max())
const {
207 return (info_valid_seq_pos_vecs.at(idx).at(pos).seq_pos);
216 return info_valid_seq_pos_vecs.at(idx).size();
227 return info_valid_seq_pos_vecs.at(idx).at(pos).unpaired;
254 return left_adj_vec.at(arc.
idx()).at(pos-arc.
left());
268 matidx_t
idx_geq(index_t index, seq_pos_t min_col, index_t left_end = std::numeric_limits<index_t>::max())
const{
270 if (left_end == std::numeric_limits<index_t>::max())
277 if(min_col<=left_end)
return 0;
281 if(min_col>last_mapped_seq_pos)
return num_pos;
299 matidx_t
idx_after_leq(index_t index, seq_pos_t max_col, index_t left_end = std::numeric_limits<index_t>::max())
const{
301 if (left_end == std::numeric_limits<index_t>::max())
308 if(max_col<left_end)
return 0;
312 if(max_col>=last_mapped_seq_pos)
return num_pos;
333 bool is_valid_arc(
const Arc &inner_arc,
const Arc &arc)
const{
345 bool is_valid_arc_external(
const Arc &inner_arc)
const{
359 assert(arc.
left()<pos && pos<arc.
right());
380 std::ostream& operator<<(std::ostream& out, const std::vector<T>& vec){
381 for(
typename std::vector<T>::const_iterator it = vec.begin();it!=vec.end();it++){
393 std::ostream &operator << (std::ostream &out, const std::vector<SparsificationMapper::InfoForPosVec> &pos_vecs_);
405 #endif // SPARSIFICATION_MAPPER_HH ArcIdxVec valid_arcs
a vector of arcs with common right end from the sequence position
Definition: sparsification_mapper.hh:55
virtual ~SparsificationMapper()
class destructor
Definition: sparsification_mapper.hh:258
matidx_t idx_after_leq(index_t index, seq_pos_t max_col, index_t left_end=std::numeric_limits< index_t >::max()) const
Definition: sparsification_mapper.hh:299
size_t left() const
Definition: basepairs.hh:72
size_t right() const
Definition: basepairs.hh:80
double arc_external_prob(pos_type i, pos_type j) const
Get base pair in loop probability.
Definition: rna_data.cc:807
std::ostream & operator<<(std::ostream &out, AlignerRestriction r)
Definition: aligner_restriction.hh:113
SparsificationMapper(const BasePairs &bps_, const ExtRnaData &rnadata_, double prob_unpaired_in_loop_threshold_, double prob_basepair_in_loop_threshold_, bool index_left_ends)
Definition: sparsification_mapper.hh:114
size_type pos_type
type of a sequence position
Definition: aux.hh:97
pos_type seq_pos_t
type for a sequence position
Definition: sparsification_mapper.hh:41
represent sparsified data of RNA ensemble extended by in loop probabilities
Definition: ext_rna_data.hh:34
size_t size_type
general size type
Definition: aux.hh:94
size_type get_max_info_vec_size() const
Definition: sparsification_mapper.hh:136
const InfoForPosVec & valid_seq_positions(index_t idx) const
Definition: sparsification_mapper.hh:147
double arc_in_loop_prob(pos_type i, pos_type j, pos_type p, pos_type q) const
Get base pair in loop probability.
Definition: rna_data.cc:801
bool matching_without_gap_possible(const Arc &arc, seq_pos_t pos) const
Definition: sparsification_mapper.hh:241
std::vector< ArcIdx > ArcIdxVec
vector of arc indices
Definition: sparsification_mapper.hh:39
Definition: aligner.cc:17
bool unpaired
if true, the sequence position can occur unpaired
Definition: sparsification_mapper.hh:54
size_t index_t
type for an index
Definition: sparsification_mapper.hh:49
const ArcIdxVec & valid_arcs_right_adj(index_t idx, matidx_t pos) const
Definition: sparsification_mapper.hh:158
matidx_t first_valid_mat_pos_before_eq(index_t index, seq_pos_t pos, index_t left_end=std::numeric_limits< index_t >::max()) const
Definition: sparsification_mapper.hh:172
BasePairs__Arc Arc
type of arc
Definition: sparsification_mapper.hh:37
double unpaired_external_prob(pos_type k) const
Get base pair in loop probability.
Definition: rna_data.cc:824
bool pos_unpaired(index_t idx, matidx_t pos) const
Definition: sparsification_mapper.hh:226
Represents the mapping for sparsification.
Definition: sparsification_mapper.hh:34
seq_pos_t get_pos_in_seq_new(index_t idx, matidx_t pos) const
Definition: sparsification_mapper.hh:205
size_type number_of_valid_mat_pos(index_t idx) const
Definition: sparsification_mapper.hh:215
pos_type matidx_t
type for a matrix position
Definition: sparsification_mapper.hh:40
const ArcIdxVec & valid_arcs_left_adj(const Arc &arc, seq_pos_t pos) const
Definition: sparsification_mapper.hh:253
void reset()
resets the content of the struct
Definition: sparsification_mapper.hh:58
a struct to represent all necessary information for all valid sequence positions
Definition: sparsification_mapper.hh:52
Represents a base pair.
Definition: basepairs.hh:40
std::vector< info_for_pos > InfoForPosVec
vector of struct info_for_pos that is assigned to the index (either common left end or arc index) ...
Definition: sparsification_mapper.hh:65
size_t idx() const
Definition: basepairs.hh:88
bool is_valid_pos_external(seq_pos_t pos) const
Definition: sparsification_mapper.hh:368
size_t ArcIdx
type of arc index
Definition: sparsification_mapper.hh:38
Describes sequence and structure ensemble of an RNA.
Definition: basepairs.hh:107
bool is_valid_pos(const Arc &arc, seq_pos_t pos) const
Definition: sparsification_mapper.hh:358
seq_pos_t seq_pos
the sequence position
Definition: sparsification_mapper.hh:53
matidx_t first_valid_mat_pos_before(index_t index, seq_pos_t pos, index_t left_end=std::numeric_limits< index_t >::max()) const
Definition: sparsification_mapper.hh:191
matidx_t idx_geq(index_t index, seq_pos_t min_col, index_t left_end=std::numeric_limits< index_t >::max()) const
Definition: sparsification_mapper.hh:268
double unpaired_in_loop_prob(pos_type k, pos_type p, pos_type q) const
Get base pair in loop probability.
Definition: rna_data.cc:818