SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
seqan3::wuss< SIZE > Class Template Reference

The WUSS structure alphabet of the characters .<>:,-_~;()[]{}AaBbCcDd... More...

#include <seqan3/alphabet/structure/wuss.hpp>

+ Inheritance diagram for seqan3::wuss< SIZE >:

Public Types

using char_type = std::conditional_t< std::same_as< char_t, void >, char, char_t >
 The char representation; conditional needed to make semi alphabet definitions legal. More...
 
using rank_type = detail::min_viable_uint_t< size - 1 >
 The type of the alphabet when represented as a number (e.g. via to_rank()). More...
 

Public Member Functions

constexpr char_type to_char () const noexcept
 Return the letter as a character of char_type. More...
 
constexpr rank_type to_rank () const noexcept
 Return the letter's numeric value (rank in the alphabet). More...
 
Constructors, destructor and assignment
constexpr wuss () noexcept=default
 Defaulted.
 
constexpr wuss (wuss const &) noexcept=default
 Defaulted.
 
constexpr wuss (wuss &&) noexcept=default
 Defaulted.
 
constexpr wussoperator= (wuss const &) noexcept=default
 Defaulted.
 
constexpr wussoperator= (wuss &&) noexcept=default
 Defaulted.
 
 ~wuss () noexcept=default
 Defaulted.
 
- Public Member Functions inherited from seqan3::alphabet_base< wuss< 51 >, 51 >
constexpr alphabet_base () noexcept=default
 Defaulted.
 
constexpr alphabet_base (alphabet_base const &) noexcept=default
 Defaulted.
 
constexpr alphabet_base (alphabet_base &&) noexcept=default
 Defaulted.
 
constexpr alphabet_baseoperator= (alphabet_base const &) noexcept=default
 Defaulted.
 
constexpr alphabet_baseoperator= (alphabet_base &&) noexcept=default
 Defaulted.
 
 ~alphabet_base () noexcept=default
 Defaulted.
 
constexpr char_type to_char () const noexcept
 Return the letter as a character of char_type. More...
 
constexpr rank_type to_rank () const noexcept
 Return the letter's numeric value (rank in the alphabet). More...
 
constexpr wuss< 51 > & assign_char (char_type const c) noexcept
 Assign from a character, implicitly converts invalid characters. More...
 
constexpr wuss< 51 > & assign_rank (rank_type const c) noexcept
 Assign from a numeric value. More...
 

Static Public Attributes

static constexpr detail::min_viable_uint_t< size > alphabet_size
 The size of the alphabet, i.e. the number of different values it can take. More...
 
- Static Public Attributes inherited from seqan3::alphabet_base< wuss< 51 >, 51 >
static constexpr detail::min_viable_uint_t< size > alphabet_size
 The size of the alphabet, i.e. the number of different values it can take. More...
 

Private Types

using base_t = alphabet_base< wuss< SIZE >, SIZE >
 The base class.
 

Private Attributes

friend base_t
 Befriend seqan3::alphabet_base.
 

Static Private Attributes

static constexpr std::array< rank_type, 256 > char_to_rank
 Char-to-value conversion table. More...
 
static std::array< int8_t, SIZE > const interaction_tab
 Lookup table for interactions: unpaired (0), pair-open (< 0), pair-close (> 0). Paired brackets have the same absolute value. More...
 
static constexpr std::array< char_type, alphabet_sizerank_to_char
 Value-to-char conversion table. More...
 

Related Functions

(Note that these are not member functions.)

using wuss51 = wuss< 51 >
 Alias for the default type wuss51.
 
Literals
std::vector< wuss51operator""_wuss51 (const char *str, std::size_t len)
 The seqan3::wuss51 string literal. More...
 
constexpr wuss51 operator""_wuss51 (char const ch) noexcept
 The seqan3::wuss51 char literal. More...
 

RNA structure properties

static constexpr uint8_t max_pseudoknot_depth {static_cast<uint8_t>((alphabet_size - 7) / 2)}
 The ability of this alphabet to represent pseudoknots, i.e. crossing interactions, up to a certain depth. It is the number of distinct pairs of interaction symbols the format supports: 4..30 (depends on size)
 
constexpr bool is_pair_open () const noexcept
 Check whether the character represents a rightward interaction in an RNA structure. More...
 
constexpr bool is_pair_close () const noexcept
 Check whether the character represents a leftward interaction in an RNA structure. More...
 
constexpr bool is_unpaired () const noexcept
 Check whether the character represents an unpaired position in an RNA structure. More...
 
constexpr std::optional< uint8_t > pseudoknot_id () const noexcept
 Get an identifier for a pseudoknotted interaction, where opening and closing brackets of the same type have the same id. More...
 

Additional Inherited Members

- Protected Types inherited from seqan3::alphabet_base< wuss< 51 >, 51 >
using char_type = std::conditional_t< std::same_as< char, void >, char, char >
 The char representation; conditional needed to make semi alphabet definitions legal. More...
 
using rank_type = detail::min_viable_uint_t< size - 1 >
 The type of the alphabet when represented as a number (e.g. via to_rank()). More...
 

Detailed Description

template<uint8_t SIZE = 51>
class seqan3::wuss< SIZE >

The WUSS structure alphabet of the characters .<>:,-_~;()[]{}AaBbCcDd...

Template Parameters
SIZEThe alphabet size defaults to 51 and must be an odd number in range 15..67. It determines the allowed pseudoknot depth by adding characters AaBb..Zz to the alphabet.

The symbols .:,-_~; denote unpaired characters, brackets <>()[]{} represent base pair interactions and AaBbCcDd... form pseudoknots in the structure. The default alphabet has size 51 (letters until Rr). The size can be varied with the optional template parameter between 15 (no letters for pseudoknots) and 67 (all Aa-Zz for pseudoknots).

<<<___>>>,,<<<__>>>
<<<<_AAAA____>>>>aaaa

Usage

The following code example creates a wuss vector, modifies it, and prints the result to stderr.

int main()
{
using seqan3::operator""_wuss51;
// create vector
std::vector<seqan3::wuss51> vec{'.'_wuss51, '>'_wuss51, '>'_wuss51};
// modify and print
vec[1] = '<'_wuss51;
for (seqan3::wuss51 chr : vec)
}
Provides seqan3::debug_stream and related types.
constexpr auto to_char
Return the char representation of an alphabet object.
Definition: concept.hpp:334
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:42
Provides the WUSS format for RNA structure.

Member Typedef Documentation

◆ char_type

template<uint8_t SIZE = 51>
using seqan3::alphabet_base< derived_type, size, char_t >::char_type = std::conditional_t<std::same_as<char_t, void>, char, char_t>

The char representation; conditional needed to make semi alphabet definitions legal.

We need a return type for seqan3::alphabet_base::to_char and seqan3::alphabet_base::assign_char other than void to make these in-class definitions valid when char_t is void.

This entity is stable. Since version 3.1.

◆ rank_type

template<uint8_t SIZE = 51>
using seqan3::alphabet_base< derived_type, size, char_t >::rank_type = detail::min_viable_uint_t<size - 1>

The type of the alphabet when represented as a number (e.g. via to_rank()).

This entity is stable. Since version 3.1.

Member Function Documentation

◆ is_pair_close()

template<uint8_t SIZE = 51>
constexpr bool seqan3::wuss< SIZE >::is_pair_close ( ) const
inlineconstexprnoexcept

Check whether the character represents a leftward interaction in an RNA structure.

Returns
True if the letter represents a leftward interaction, False otherwise.

◆ is_pair_open()

template<uint8_t SIZE = 51>
constexpr bool seqan3::wuss< SIZE >::is_pair_open ( ) const
inlineconstexprnoexcept

Check whether the character represents a rightward interaction in an RNA structure.

Returns
True if the letter represents a rightward interaction, False otherwise.

◆ is_unpaired()

template<uint8_t SIZE = 51>
constexpr bool seqan3::wuss< SIZE >::is_unpaired ( ) const
inlineconstexprnoexcept

Check whether the character represents an unpaired position in an RNA structure.

Returns
True if the letter represents an unpaired site, False otherwise.

◆ pseudoknot_id()

template<uint8_t SIZE = 51>
constexpr std::optional<uint8_t> seqan3::wuss< SIZE >::pseudoknot_id ( ) const
inlineconstexprnoexcept

Get an identifier for a pseudoknotted interaction, where opening and closing brackets of the same type have the same id.

Returns
The pseudoknot id, if alph denotes an interaction, and no value otherwise. It is guaranteed to be smaller than seqan3::max_pseudoknot_depth.

◆ to_char()

template<uint8_t SIZE = 51>
constexpr char_type seqan3::alphabet_base< derived_type, size, char_t >::to_char
inlineconstexprnoexcept

Return the letter as a character of char_type.

Provides an implementation for seqan3::to_char, required to model seqan3::alphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

This entity is stable. Since version 3.1.

◆ to_rank()

template<uint8_t SIZE = 51>
constexpr rank_type seqan3::alphabet_base< derived_type, size, char_t >::to_rank
inlineconstexprnoexcept

Return the letter's numeric value (rank in the alphabet).

Provides an implementation for seqan3::to_rank, required to model seqan3::semialphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

This entity is stable. Since version 3.1.

Friends And Related Function Documentation

◆ operator""_wuss51() [1/2]

template<uint8_t SIZE = 51>
constexpr wuss51 operator""_wuss51 ( char const  ch)
related

The seqan3::wuss51 char literal.

Parameters
[in]chThe character to represent as wuss.
Returns
seqan3::wuss51

You can use this string literal to assign a seqan3::wuss51 character. For different wuss alphabet sizes the assign_char function must be used.

int main()
{
using seqan3::operator""_wuss51;
// Using the char literal to assign a single WUSS character:
seqan3::wuss51 my_letter{'~'_wuss51};
my_letter.assign_char('<'); // <- assigns the char explicitly
}

◆ operator""_wuss51() [2/2]

template<uint8_t SIZE = 51>
std::vector< wuss51 > operator""_wuss51 ( const char *  str,
std::size_t  len 
)
related

The seqan3::wuss51 string literal.

Parameters
[in]strA pointer to the character string to assign.
[in]lenThe size of the character string to assign.
Returns
std::vector<seqan3::wuss51>

You can use this string literal to easily assign to a vector of seqan3::wuss51 characters:

int main()
{
using seqan3::operator""_wuss51;
// Using the string literal to assign a vector of WUSS characters:
std::vector<seqan3::wuss<>> foo{".<..>."_wuss51};
std::vector<seqan3::wuss<>> bar = ".<..>."_wuss51;
auto bax = ".<..>."_wuss51;
}

Member Data Documentation

◆ alphabet_size

template<uint8_t SIZE = 51>
constexpr detail::min_viable_uint_t<size> seqan3::alphabet_base< derived_type, size, char_t >::alphabet_size
staticconstexpr

The size of the alphabet, i.e. the number of different values it can take.

This entity is stable. Since version 3.1.

◆ char_to_rank

template<uint8_t SIZE = 51>
constexpr std::array<rank_type, 256> seqan3::wuss< SIZE >::char_to_rank
staticconstexprprivate
Initial value:
{
[] () constexpr
{
for (rank_type & rnk : rank_table)
rnk = 6u;
for (rank_type rnk = 0u; rnk < alphabet_size; ++rnk)
rank_table[rank_to_char[rnk]] = rnk;
return rank_table;
} ()
}
static constexpr std::array< char_type, alphabet_size > rank_to_char
Value-to-char conversion table.
Definition: wuss.hpp:139
detail::min_viable_uint_t< size - 1 > rank_type
The type of the alphabet when represented as a number (e.g. via to_rank()).
Definition: alphabet_base.hpp:74
static constexpr detail::min_viable_uint_t< size > alphabet_size
The size of the alphabet, i.e. the number of different values it can take.
Definition: alphabet_base.hpp:198

Char-to-value conversion table.

◆ interaction_tab

template<uint8_t SIZE>
constexpr std::array< int8_t, SIZE > seqan3::wuss< SIZE >::interaction_tab
staticconstexprprivate
Initial value:
= [] () constexpr
{
std::array<int8_t, alphabet_size> interaction_table{};
int cnt_open = 0;
int cnt_close = 0;
for (rank_type rnk = 0u; rnk <= 6u; ++rnk)
{
interaction_table[rnk] = 0;
}
for (rank_type rnk = 7u; rnk <= 10u; ++rnk)
{
interaction_table[rnk] = --cnt_open;
}
for (rank_type rnk = 11u; rnk <= 14u; ++rnk)
{
interaction_table[rnk] = ++cnt_close;
}
for (rank_type rnk = 15u; rnk + 1u < alphabet_size; rnk += 2u)
{
interaction_table[rnk] = --cnt_open;
interaction_table[rnk + 1u] = ++cnt_close;
}
return interaction_table;
} ()

Lookup table for interactions: unpaired (0), pair-open (< 0), pair-close (> 0). Paired brackets have the same absolute value.

◆ rank_to_char

template<uint8_t SIZE = 51>
constexpr std::array<char_type, alphabet_size> seqan3::wuss< SIZE >::rank_to_char
staticconstexprprivate
Initial value:
{
[] () constexpr
{
{
'.', ':', ',', '-', '_', '~', ';', '<', '(', '[', '{', '>', ')', ']', '}'
};
for (rank_type rnk = 15u; rnk + 1u < alphabet_size; rnk += 2u)
{
char_type const off = static_cast<char_type>((rnk - 15u) / 2u);
chars[rnk] = 'A' + off;
chars[rnk + 1u] = 'a' + off;
}
return chars;
} ()
}
std::conditional_t< std::same_as< char_t, void >, char, char_t > char_type
The char representation; conditional needed to make semi alphabet definitions legal.
Definition: alphabet_base.hpp:68
@ off
Automatic update notifications should be disabled.

Value-to-char conversion table.


The documentation for this class was generated from the following file: