1 #ifndef SPARSIFICATION_MAPPER_HH
2 #define SPARSIFICATION_MAPPER_HH
12 #include "basepairs.hh"
13 #include "ext_rna_data.hh"
18 template <
class T1,
class T2>
20 operator<<(std::ostream &out,
const std::pair<T1, T2> &pair) {
21 return out <<
"(" << pair.first <<
"," << pair.second <<
") ";
53 this->valid_arcs.clear();
68 const double prob_unpaired_in_loop_threshold;
71 const double prob_basepair_in_loop_threshold;
77 std::vector<InfoForPosVec> info_valid_seq_pos_vecs;
82 std::vector<std::vector<matidx_t> > valid_mat_pos_vecs_before_eq;
87 std::vector<std::vector<ArcIdxVec> > left_adj_vec;
92 compute_mapping_idx_arcs();
97 compute_mapping_idx_left_ends();
104 iterate_left_adj_list(
pos_type cur_left_end,
106 const Arc *inner_arc,
110 valid_pos_external(
pos_type cur_pos,
111 const Arc *inner_arc,
131 double prob_unpaired_in_loop_threshold_,
132 double prob_basepair_in_loop_threshold_,
133 bool index_left_ends)
136 prob_unpaired_in_loop_threshold(prob_unpaired_in_loop_threshold_),
137 prob_basepair_in_loop_threshold(prob_basepair_in_loop_threshold_),
138 max_info_vec_size(0) {
139 if (index_left_ends) {
140 compute_mapping_idx_left_ends();
142 compute_mapping_idx_arcs();
151 return max_info_vec_size;
162 return info_valid_seq_pos_vecs.at(idx);
173 return info_valid_seq_pos_vecs.at(idx).at(pos).valid_arcs;
191 index_t left_end = std::numeric_limits<index_t>::max())
const {
192 if (left_end == std::numeric_limits<index_t>::max())
194 assert(pos >= left_end);
195 return valid_mat_pos_vecs_before_eq.at(index).at(pos - left_end);
211 index_t left_end = std::numeric_limits<index_t>::max())
const {
228 info_valid_seq_pos_vecs.at(idx).at(pos).seq_pos);
238 return info_valid_seq_pos_vecs.at(idx).size();
250 return info_valid_seq_pos_vecs.at(idx).at(pos).unpaired;
281 return left_adj_vec.at(arc.
idx()).at(pos - arc.
left());
301 index_t left_end = std::numeric_limits<index_t>::max())
const {
302 if (left_end == std::numeric_limits<index_t>::max())
311 if (min_col <= left_end)
317 if (min_col > last_mapped_seq_pos)
347 index_t left_end = std::numeric_limits<index_t>::max())
const {
348 if (left_end == std::numeric_limits<index_t>::max())
357 if (max_col < left_end)
363 if (max_col >= last_mapped_seq_pos)
391 is_valid_arc(
const Arc &inner_arc,
const Arc &arc)
const {
392 assert(inner_arc.left() > arc.left() &&
393 inner_arc.right() < arc.right());
395 arc.left(), arc.right()) >=
396 prob_basepair_in_loop_threshold;
408 is_valid_arc_external(
const Arc &inner_arc)
const {
410 inner_arc.right()) >=
411 prob_basepair_in_loop_threshold;
427 assert(arc.
left() < pos && pos < arc.
right());
430 prob_unpaired_in_loop_threshold;
443 prob_unpaired_in_loop_threshold;
456 operator<<(std::ostream &out,
const std::vector<T> &vec) {
457 for (
typename std::vector<T>::const_iterator it = vec.begin();
458 it != vec.end(); ++it) {
474 const std::vector<SparsificationMapper::InfoForPosVec> &pos_vecs_);
Represents a base pair.
Definition: basepairs.hh:39
size_t right() const
Definition: basepairs.hh:77
size_t idx() const
Definition: basepairs.hh:87
size_t left() const
Definition: basepairs.hh:67
Describes sequence and structure ensemble of an RNA.
Definition: basepairs.hh:108
represent sparsified data of RNA ensemble extended by in loop probabilities
Definition: ext_rna_data.hh:37
double arc_external_prob(pos_type i, pos_type j) const
Get base pair in loop probability.
Definition: rna_data.cc:755
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:767
double unpaired_external_prob(pos_type k) const
Get base pair in loop probability.
Definition: rna_data.cc:776
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:745
Represents the mapping for sparsification.
Definition: sparsification_mapper.hh:30
seq_pos_t get_pos_in_seq_new(index_t idx, matidx_t pos) const
Definition: sparsification_mapper.hh:225
size_type number_of_valid_mat_pos(index_t idx) const
Definition: sparsification_mapper.hh:237
std::vector< ArcIdx > ArcIdxVec
vector of arc indices
Definition: sparsification_mapper.hh:34
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:129
const ArcIdxVec & valid_arcs_left_adj(const Arc &arc, seq_pos_t pos) const
Definition: sparsification_mapper.hh:280
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:208
bool matching_without_gap_possible(const Arc &arc, seq_pos_t pos) const
Definition: sparsification_mapper.hh:266
virtual ~SparsificationMapper()
class destructor
Definition: sparsification_mapper.hh:285
size_t ArcIdx
type of arc index
Definition: sparsification_mapper.hh:33
pos_type seq_pos_t
type for a sequence position
Definition: sparsification_mapper.hh:36
pos_type matidx_t
type for a matrix position
Definition: sparsification_mapper.hh:35
bool is_valid_pos_external(seq_pos_t pos) const
Definition: sparsification_mapper.hh:441
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:344
const ArcIdxVec & valid_arcs_right_adj(index_t idx, matidx_t pos) const
Definition: sparsification_mapper.hh:172
bool is_valid_pos(const Arc &arc, seq_pos_t pos) const
Definition: sparsification_mapper.hh:426
const InfoForPosVec & valid_seq_positions(index_t idx) const
Definition: sparsification_mapper.hh:161
size_t index_t
type for an index
Definition: sparsification_mapper.hh:38
std::vector< info_for_pos > InfoForPosVec
Definition: sparsification_mapper.hh:58
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:299
BasePairs__Arc Arc
type of arc
Definition: sparsification_mapper.hh:32
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:188
bool pos_unpaired(index_t idx, matidx_t pos) const
Definition: sparsification_mapper.hh:249
size_type get_max_info_vec_size() const
Definition: sparsification_mapper.hh:150
Definition: aligner.cc:15
size_type pos_type
type of a sequence position
Definition: aux.hh:126
std::ostream & operator<<(std::ostream &out, const AlignerRestriction &r)
Definition: aligner_restriction.hh:135
size_t size_type
general size type
Definition: aux.hh:120
Definition: sparsification_mapper.hh:42
bool unpaired
if true, the sequence position can occur unpaired
Definition: sparsification_mapper.hh:45
ArcIdxVec valid_arcs
Definition: sparsification_mapper.hh:46
seq_pos_t seq_pos
the sequence position
Definition: sparsification_mapper.hh:43
void reset()
resets the content of the struct
Definition: sparsification_mapper.hh:51