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 cigarassign_char (char_type const c) noexcept
 Assign from a character, implicitly converts invalid characters. More...
 
constexpr cigarassign_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.
 

Protected Types

Member types
using char_type = std::conditional_t< std::same_as< void, void >, char, void >
 The char representation; conditional needed to make semi alphabet definitions legal.
 
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()).
 

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)
inlineconstexprnoexcept

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()

constexpr cigar & seqan3::alphabet_base< cigar , size, void >::assign_char ( char_type const  c)
inlineconstexprnoexceptinherited

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()

constexpr cigar & seqan3::alphabet_base< cigar , size, void >::assign_rank ( rank_type const  c)
inlineconstexprnoexceptinherited

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)
inlineconstexprnoexcept

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)
inlineconstexprnoexcept

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)
inlineconstexprnoexcept

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()

constexpr char_type seqan3::alphabet_base< cigar , size, void >::to_char
inlineconstexprnoexceptinherited

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()

constexpr rank_type seqan3::alphabet_base< cigar , size, void >::to_rank
inlineconstexprnoexceptinherited

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:
debug_stream.hpp
Provides seqan3::debug_stream and related types.
seqan3::get
constexpr auto const & get(configuration< configs_t... > const &config) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: configuration.hpp:627
cigar_op.hpp
Introduces the cigar_op alphabet.
seqan3::cigar
The cigar semialphabet pairs a counter with a seqan3::cigar_op letter.
Definition: cigar.hpp:55
seqan3::pack_traits::size
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:116
cigar.hpp
Provides the seqan3::cigar alphabet.
seqan3::debug_stream
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:42
seqan3::cigar_op
The (extended) cigar operation alphabet of M,D,I,H,N,P,S,X,=.
Definition: cigar_op.hpp:53