34 template <
typename structure_alph_type,
typename bpp_type, std::ranges::Range structure_type>
36 void bpp_from_rna_structure(bpp_type & bpp, structure_type
const & structure,
double weight = 1.)
38 if constexpr (!RnaStructureAlphabet<structure_alph_type>)
39 throw parse_error{
"Cannot create base pair probabilities from a structure that is not RNA structure."};
43 bpp.reserve(
size(structure));
47 for (structure_alph_type symbol : structure)
52 if (symbol.is_pair_open())
54 brackets[id].
push(pos);
56 else if (symbol.is_pair_close())
58 if (!brackets[
id].
empty())
60 bpp[pos].emplace(weight, brackets[
id].top());
61 bpp[brackets[id].
top()].emplace(weight, pos);
66 throw parse_error{
std::string{
"Invalid bracket notation: Unpaired closing bracket at position "}
73 for (uint8_t
id = 0u; id < max_pseudoknot_depth<structure_alph_type>; ++id)
75 if (!brackets[
id].
empty())
77 throw parse_error{
std::string{
"Invalid bracket notation: Unpaired opening bracket at position "}
::ranges::size size
Alias for ranges::size. Obtains the size of a range whose size can be calculated in constant time...
Definition: ranges:189
Provides seqan3::RnaStructureAlphabet.
constexpr auto pseudoknot_id
Retrieve an id for the level of a pseudoknotted interaction (also known as 'page number').
Definition: concept.hpp:448
Definition: aligned_sequence_concept.hpp:35
::ranges::empty empty
Alias for ranges::empty. Checks whether a range is empty.
Definition: ranges:194
Specifies the requirements of a Range type that knows its size in constant time with the size functio...