SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
seqan3::cigar Class Reference

The cigar semialphabet pairs a counter with a seqan3::cigar_op letter. More...

#include <seqan3/alphabet/cigar/cigar.hpp>

+ Inheritance diagram for seqan3::cigar:

Public Member Functions

Constructors, destructor and assignment
constexpr cigar () noexcept=default
 Defaulted.
 
constexpr cigar (cigar const &) noexcept=default
 Defaulted.
 
constexpr cigar (cigar &&) noexcept=default
 Defaulted.
 
constexpr cigaroperator= (cigar const &) noexcept=default
 Defaulted.
 
constexpr cigaroperator= (cigar &&) noexcept=default
 Defaulted.
 
 ~cigar () noexcept=default
 Defaulted.
 
constexpr cigar (component_type const alph) noexcept
 Construction via a value of one of the components. More...
 
constexpr cigaroperator= (component_type const alph) noexcept
 Assignment via a value of one of the components. More...
 
Read functions
small_string< 11 > to_string () const noexcept
 Return the string representation.
 
Write functions
cigarassign_string (small_string< 11 > const s) noexcept
 Assign from the string representation.
 
Get functions
template<size_t index>
constexpr auto get (cigar &l) noexcept
 Tuple-like access to the contained components. More...
 
template<typename type >
constexpr auto get (cigar &l) noexcept
 Tuple-like access to the contained components. More...
 
Read functions

All read operations are constant complexity.

constexpr operator type () const noexcept
 Implicit cast to a single letter. Works only if the type is unique in the type list.
 
Read 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...
 
Write functions
constexpr derived_type & assign_char (char_type const c) noexcept
 Assign from a character, implicitly converts invalid characters. More...
 
constexpr derived_type & assign_rank (rank_type const c) noexcept
 Assign from a numeric value. More...
 

Static Public Attributes

static detail::min_viable_uint_t< size > constexpr alphabet_size = size
 The size of the alphabet, i.e. the number of different values it can take.
 

Protected Types

Member 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.
 

Related Functions

(Note that these are not member functions.)

Requirements for std::totally_ordered

You can expect these functions on all types that implement std::totally_ordered.

bool operator< (type const &lhs, type const &rhs)
 Less-than, greater-than and -or-equal comparisons. More...
 
bool operator<= (type const &lhs, type const &rhs)
 Less-than, greater-than and -or-equal comparisons. More...
 
bool operator> (type const &lhs, type const &rhs)
 Less-than, greater-than and -or-equal comparisons. More...
 
bool operator>= (type const &lhs, type const &rhs)
 Less-than, greater-than and -or-equal comparisons. More...
 
Requirements for std::equality_comparable

You can expect these functions on all types that implement std::Equality_comparable.

bool operator== (type const &lhs, type const &rhs)
 (In-)Equality comparison. More...
 
bool operator!= (type const &lhs, type const &rhs)
 (In-)Equality comparison. More...
 
Requirements for std::swappable

You can expect these functions on all types that implement std::swappable.

void swap (t &lhs, t &rhs)
 Swaps the contents of two objects. More...
 

Detailed Description

The cigar semialphabet pairs a counter with a seqan3::cigar_op letter.

This semialphabet represents a unit in a CIGAR string, typically found in the SAM and BAM formats. It consists of a number and a seqan3::cigar_op symbol.

It has a "visual representation", but since this is a string and not a char, the type only models seqan3::writable_semialphabet and not seqan3::writable_alphabet. Members for reading/writing the string are provided.

To avoid confusion between string and char literal, this alphabet has no user defined literal operators. Always assign from a pair of uint32_t and seqan3::cigar_op.

Example

using seqan3::operator""_cigar_op;
int main()
{
seqan3::cigar c{13, 'M'_cigar_op};
seqan3::debug_stream << c << '\n'; // "13M"
c.assign_string("14X");
seqan3::debug_stream << c << '\n'; // "14X"
}

Constructor & Destructor Documentation

◆ cigar()

constexpr seqan3::cigar::cigar ( component_type const  alph)
inlinenoexcept

Construction via a value of one of the components.

Template Parameters
component_typeOne of the component types; must be uniquely contained in the type list of the composite.
Parameters
[in]alphThe value of a component that should be assigned.
int main()
{
using seqan3::operator""_cigar_op;
seqan3::cigar letter1{0};
// creates 0M, as the cigar_op field is not provided.
seqan3::cigar letter2{'M'_cigar_op};
// creates 0M, as the integer field is not provided.
if (letter1 == letter2)
seqan3::debug_stream << "yeah\n"; // yeah
seqan3::cigar letter3{10, 'I'_cigar_op};
// creates 10I, as both fields are explicitly given.
}

Member Function Documentation

◆ assign_char()

template<typename derived_type, size_t size, typename char_t = char>
constexpr derived_type& seqan3::alphabet_base< derived_type, size, char_t >::assign_char ( char_type const  c)
inlinenoexceptinherited

Assign from a character, implicitly converts invalid characters.

Parameters
cThe character to be assigned.

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

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ assign_rank()

template<typename derived_type, size_t size, typename char_t = char>
constexpr derived_type& seqan3::alphabet_base< derived_type, size, char_t >::assign_rank ( rank_type const  c)
inlinenoexceptinherited

Assign from a numeric value.

Parameters
cThe rank to be assigned.

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

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ get() [1/2]

template<size_t index>
constexpr auto seqan3::cigar::get ( cigar l)
inlinenoexcept

Tuple-like access to the contained components.

Template Parameters
indexReturn the i-th element.
Returns
A proxy to the contained element that models the same alphabets concepts and supports assignment.
int main()
{
using seqan3::get;
using seqan3::operator""_cigar_op;
seqan3::cigar letter{10, 'M'_cigar_op};
uint32_t size{get<0>(letter)}; // Note this is equivalent to get<uint32_t>(letter)
seqan3::cigar_op cigar_char{get<1>(letter)}; // Note this is equivalent to get<seqan3::cigar_op>(letter)
seqan3::debug_stream << "Size is " << size << '\n';
seqan3::debug_stream << "Cigar char is " << cigar_char << '\n'; // seqan3::debug_stream converts to char on the fly.
}

◆ get() [2/2]

template<typename type >
constexpr auto seqan3::cigar::get ( cigar l)
inlinenoexcept

Tuple-like access to the contained components.

Template Parameters
typeReturn the element of specified type; only available if the type is unique in the set of components.
Returns
A proxy to the contained element that models the same alphabet concepts and supports assignment.
int main()
{
using seqan3::get;
using seqan3::operator""_cigar_op;
seqan3::cigar letter{10, 'M'_cigar_op};
uint32_t size{get<uint32_t>(letter)}; // Note this is equivalent to get<0>(letter)
seqan3::cigar_op cigar_char{get<seqan3::cigar_op>(letter)}; // Note this is equivalent to get<1>(letter)
seqan3::debug_stream << "Size is " << size << '\n';
seqan3::debug_stream << "Cigar char is " << cigar_char << '\n'; // seqan3::debug_stream converts to char on the fly.
}

◆ operator=()

constexpr cigar& seqan3::cigar::operator= ( component_type const  alph)
inlinenoexcept

Assignment via a value of one of the components.

Template Parameters
component_typeOne of the component types; must be uniquely contained in the type list of the composite.
Parameters
[in]alphThe value of a component that should be assigned.
int main()
{
using seqan3::operator""_cigar_op;
seqan3::cigar letter{10, 'I'_cigar_op};
letter = 'D'_cigar_op; // yields 10D
letter = 20; // yields 20D
if (letter == seqan3::cigar{20, 'D'_cigar_op})
seqan3::debug_stream << "yeah\n";
}

◆ to_char()

template<typename derived_type, size_t size, typename char_t = char>
constexpr char_type seqan3::alphabet_base< derived_type, size, char_t >::to_char ( ) const
inlinenoexceptinherited

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.

◆ to_rank()

template<typename derived_type, size_t size, typename char_t = char>
constexpr rank_type seqan3::alphabet_base< derived_type, size, char_t >::to_rank ( ) const
inlinenoexceptinherited

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.


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