SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::detail::format_sam_base Class Reference

The alignment base format. More...

#include <seqan3/io/sam_file/detail/format_sam_base.hpp>

+ Inheritance diagram for seqan3::detail::format_sam_base:

Protected Member Functions

template<typename ref_id_type , typename ref_id_tmp_type , typename header_type , typename ref_seqs_type >
void check_and_assign_ref_id (ref_id_type &ref_id, ref_id_tmp_type &ref_id_tmp, header_type &header, ref_seqs_type &)
 Checks for known reference ids or adds a new reference is and assigns a reference id to ref_id.
 
template<arithmetic arithmetic_target_type>
void read_arithmetic_field (std::string_view const &str, arithmetic_target_type &arithmetic_target)
 Reads arithmetic fields using std::from_chars.
 
template<std::ranges::forward_range target_range_type>
void read_forward_range_field (std::string_view const str, target_range_type &target)
 Reads from str to target, converting values with seqan3::views::char_to.
 
template<typename stream_view_type , std::ranges::forward_range target_range_type>
void read_forward_range_field (stream_view_type &&stream_view, target_range_type &target)
 Reads a range by copying from stream_view to target, converting values with seqan3::views::char_to.
 
template<typename stream_view_type , typename ref_ids_type , typename ref_seqs_type , typename seq_legal_alph_type >
void read_header (stream_view_type &&stream_view, sam_file_header< ref_ids_type > &hdr, ref_seqs_type &, sam_file_input_options< seq_legal_alph_type > const &options)
 Reads the SAM header.
 
int32_t soft_clipping_at_front (std::vector< cigar > const &cigar_vector) const
 Returns the soft clipping value at the front of the cigar_vector or 0 if none present.
 
template<typename stream_t , typename header_type >
void write_header (stream_t &stream, sam_file_output_options const &options, header_type &header)
 Writes the SAM header.
 
Constructors, destructor and assignment
 format_sam_base ()=default
 Defaulted.
 
 format_sam_base (format_sam_base const &)=default
 Defaulted.
 
format_sam_baseoperator= (format_sam_base const &)=default
 Defaulted.
 
 format_sam_base (format_sam_base &&)=default
 Defaulted.
 
format_sam_baseoperator= (format_sam_base &&)=default
 Defaulted.
 
 ~format_sam_base ()=default
 Defaulted.
 

Protected Attributes

std::array< char, 316 > arithmetic_buffer {}
 A buffer used when parsing arithmetic values with std::from_chars.
 
bool header_was_written {false}
 A variable that tracks whether the content of header has been written or not.
 
bool ref_info_present_in_header {false}
 Tracks whether reference information (@SQ tag) were found in the SAM header.
 

Static Protected Attributes

static constexpr std::array format_version {'1', '.', '6'}
 The format version string.
 

Detailed Description

The alignment base format.

Since the SAM and BAM format share a lot of functionality, this abstract base class defines common member variables and functions that are used in both formats.

Member Function Documentation

◆ check_and_assign_ref_id()

template<typename ref_id_type , typename ref_id_tmp_type , typename header_type , typename ref_seqs_type >
void seqan3::detail::format_sam_base::check_and_assign_ref_id ( ref_id_type &  ref_id,
ref_id_tmp_type &  ref_id_tmp,
header_type &  header,
ref_seqs_type &   
)
inlineprotected

Checks for known reference ids or adds a new reference is and assigns a reference id to ref_id.

Template Parameters
ref_id_typeThe type of the reference id (usually a views::type_reduce over ref_id_tmp_type).
ref_id_tmp_typeThe type of the temporary parsed id (same_as type as reference ids in header).
header_typeThe type of the alignment header.
ref_seqs_typeA tag whether the reference information were given or not (std::ignore or not).
Parameters
[out]ref_idThe reference id to be filled.
[in]ref_id_tmpThe temporary of the parsed reference id.
[in,out]headerThe header object that stores the reference id information.

◆ read_arithmetic_field()

template<arithmetic arithmetic_target_type>
void seqan3::detail::format_sam_base::read_arithmetic_field ( std::string_view const &  str,
arithmetic_target_type &  arithmetic_target 
)
inlineprotected

Reads arithmetic fields using std::from_chars.

Template Parameters
arithmetic_target_typeThe type of value to parse from input; must model seqan3::arithmetic.
Parameters
[in,out]strThe string_view to parse.
[out]arithmetic_targetThe arithmetic value object to store the parsed value.
Exceptions
seqan3::format_errorif the character sequence in str cannot be successfully converted to a value of type arithmetic_target_type.

◆ read_forward_range_field() [1/2]

template<std::ranges::forward_range target_range_type>
void seqan3::detail::format_sam_base::read_forward_range_field ( std::string_view const  str,
target_range_type &  target 
)
inlineprotected

Reads from str to target, converting values with seqan3::views::char_to.

Template Parameters
target_range_typeThe type of range to parse from input; must model std::ranges::forward_range.
Parameters
[in,out]strThe string_view to parse.
[out]targetThe range to store the parsed sequence.

◆ read_forward_range_field() [2/2]

template<typename stream_view_type , std::ranges::forward_range target_range_type>
void seqan3::detail::format_sam_base::read_forward_range_field ( stream_view_type &&  stream_view,
target_range_type &  target 
)
inlineprotected

Reads a range by copying from stream_view to target, converting values with seqan3::views::char_to.

Template Parameters
stream_view_typeThe type of the stream as a view.
target_range_typeThe type of range to parse from input; must model std::ranges::forward_range.
Parameters
[in,out]stream_viewThe stream view to iterate over.
[out]targetThe range to store the parsed sequence.

◆ read_header()

template<typename stream_view_type , typename ref_ids_type , typename ref_seqs_type , typename seq_legal_alph_type >
void seqan3::detail::format_sam_base::read_header ( stream_view_type &&  stream_view,
sam_file_header< ref_ids_type > &  hdr,
ref_seqs_type &  ,
sam_file_input_options< seq_legal_alph_type > const &  options 
)
inlineprotected

Reads the SAM header.

Template Parameters
stream_view_typeThe type of the stream as a view.
Parameters
[in,out]stream_viewThe stream view to iterate over.
[in,out]hdrThe header (as a pointer) to store the parsed values.
[in]optionsThe options to alter the parsing process.
Exceptions
seqan3::format_errorif any unexpected character or format is encountered.

Reading the header format is done according to the official SAM format specifications.

The function throws a seqan3::format_error if the format is not in a correct state (e.g. required fields are not given), but throwing might occur downstream of the actual error.

If any unknown tag was encountered, a warning will be emitted to std::cerr. This can be configured with seqan3::sam_file_input_options::stream_warnings_to.

◆ soft_clipping_at_front()

int32_t seqan3::detail::format_sam_base::soft_clipping_at_front ( std::vector< cigar > const &  cigar_vector) const
inlineprotected

Returns the soft clipping value at the front of the cigar_vector or 0 if none present.

Parameters
[in]cigar_vectorThe cigar information to parse for soft-clipping.

◆ write_header()

template<typename stream_t , typename header_type >
void seqan3::detail::format_sam_base::write_header ( stream_t &  stream,
sam_file_output_options const &  options,
header_type &  header 
)
inlineprotected

Writes the SAM header.

Template Parameters
stream_tThe stream type.
Parameters
[in,out]streamThe stream to print to.
[in]optionsThe options to alter printing.
[in]headerThe header to print.
Exceptions
seqan3::format_errorif the header object contains the wrong information or the contents are ill-formed.

Before writing the header, the contents are checked for correctness according to the rules of the official SAM format specifications.


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