The alignment base format. More...
#include <seqan3/io/sam_file/detail/format_sam_base.hpp>
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 . More... | |
template<typename stream_view_t , arithmetic arithmetic_target_type> | |
void | read_arithmetic_field (stream_view_t &&stream_view, arithmetic_target_type &arithmetic_target) |
Reads arithmetic fields using std::from_chars. More... | |
template<typename stream_view_t > | |
void | read_byte_field (stream_view_t &&stream_view, std::byte &byte_target) |
Reads std::byte fields using std::from_chars. More... | |
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. More... | |
template<typename stream_view_type , typename ref_ids_type , typename ref_seqs_type > | |
void | read_header (stream_view_type &&stream_view, sam_file_header< ref_ids_type > &hdr, ref_seqs_type &) |
Reads the SAM header. More... | |
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. More... | |
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. More... | |
Constructors, destructor and assignment | |
format_sam_base ()=default | |
Defaulted. | |
format_sam_base (format_sam_base const &)=default | |
Defaulted. | |
format_sam_base & | operator= (format_sam_base const &)=default |
Defaulted. | |
format_sam_base (format_sam_base &&)=default | |
Defaulted. | |
format_sam_base & | operator= (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. | |
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.
|
inlineprotected |
Checks for known reference ids or adds a new reference is and assigns a reference id to ref_id
.
ref_id_type | The type of the reference id (usually a views::type_reduce over ref_id_tmp_type). |
ref_id_tmp_type | The type of the temporary parsed id (same_as type as reference ids in header). |
header_type | The type of the alignment header. |
ref_seqs_type | A tag whether the reference information were given or not (std::ignore or not). |
[out] | ref_id | The reference id to be filled. |
[in] | ref_id_tmp | The temporary of the parsed reference id. |
[in,out] | header | The header object that stores the reference id information. |
|
inlineprotected |
Reads arithmetic fields using std::from_chars.
stream_view_t | The type of the stream as a view. |
arithmetic_target_type | The type of value to parse from input; must model seqan3::arithmetic. |
[in,out] | stream_view | The stream view to iterate over. |
[out] | arithmetic_target | The arithmetic value object to store the parsed value. |
seqan3::format_error | if the character sequence in stream_view cannot be successfully converted to a value of type arithmetic_target_type. |
|
inlineprotected |
Reads std::byte fields using std::from_chars.
stream_view_t | The type of the stream as a view. |
[in,out] | stream_view | The stream view to iterate over. |
[out] | byte_target | The std::byte object to store the parsed value. |
seqan3::format_error | if the character sequence in stream_view cannot be successfully converted to a value of type std::byte. |
|
inlineprotected |
Reads a range by copying from stream_view to target, converting values with seqan3::views::char_to.
stream_view_type | The type of the stream as a view. |
target_range_type | The type of range to parse from input; must model std::ranges::forward_range. |
[in,out] | stream_view | The stream view to iterate over. |
[out] | target | The range to store the parsed sequence. |
|
inlineprotected |
Reads the SAM header.
stream_view_type | The type of the stream as a view. |
[in,out] | stream_view | The stream view to iterate over. |
[in,out] | hdr | The header (as a pointer) to store the parsed values. |
seqan3::format_error | if 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 any unknown tag was encountered. It will also fail 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.
|
inlineprotected |
Returns the soft clipping value at the front of the cigar_vector
or 0 if none present.
[in] | cigar_vector | The cigar information to parse for soft-clipping. |
|
inlineprotected |
Writes the SAM header.
stream_t | The stream type. |
[in,out] | stream | The stream to print to. |
[in] | options | The options to alter printing. |
[in] | header | The header to print. |
seqan3::format_error | if 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.