22 namespace seqan3::detail
36 template <
typename structure_alph_type,
typename bpp_type, std::ranges::range structure_type>
38 void bpp_from_rna_structure(bpp_type & bpp, structure_type
const & structure,
double weight = 1.)
41 throw parse_error{
"Cannot create base pair probabilities from a structure that is not RNA structure."};
44 if constexpr (std::ranges::sized_range<structure_type>)
45 bpp.reserve(
size(structure));
49 for (structure_alph_type symbol : structure)
54 if (symbol.is_pair_open())
56 brackets[id].
push(pos);
58 else if (symbol.is_pair_close())
60 if (!brackets[
id].
empty())
62 bpp[pos].emplace(weight, brackets[
id].top());
63 bpp[brackets[id].
top()].emplace(weight, pos);
68 throw parse_error{
std::string{
"Invalid bracket notation: Unpaired closing bracket at position "}
75 for (uint8_t
id = 0u; id < max_pseudoknot_depth<structure_alph_type>; ++id)
77 if (!brackets[
id].
empty())
79 throw parse_error{
std::string{
"Invalid bracket notation: Unpaired opening bracket at position "}