157 typename ref_id_type,
158 typename ref_offset_type,
187 typename header_type,
191 typename ref_id_type,
199 header_type && header,
234 template <
typename t>
237 return std::forward<t>(
v);
240 template <arithmetic value_type>
247 template <
typename stream_it_t, std::ranges::forward_range field_type>
250 template <
typename stream_it_t>
253 template <
typename stream_it_t>
294 if constexpr (!detail::decays_to_ignore_v<seq_type>)
295 if (std::ranges::distance(
sequence) == 0)
296 throw parse_error{
"The sequence information must not be empty."};
297 if constexpr (!detail::decays_to_ignore_v<id_type>)
299 if (std::ranges::distance(
id) == 0)
300 throw parse_error{
"The id information must not be empty."};
348 typename ref_id_type,
349 typename ref_offset_type,
378 static_assert(detail::decays_to_ignore_v<ref_offset_type>
379 || detail::is_type_specialisation_of_v<ref_offset_type, std::optional>,
380 "The ref_offset must be a specialisation of std::optional.");
400 position_buffer = stream.tellg();
409 if constexpr (!detail::decays_to_ignore_v<id_type>)
427 throw format_error{
"No negative values are allowed for field::ref_offset."};
429 if constexpr (!detail::decays_to_ignore_v<mapq_type>)
434 if constexpr (!detail::decays_to_ignore_v<cigar_type>)
439 if constexpr (!detail::decays_to_ignore_v<mate_type>)
446 if constexpr (!detail::decays_to_ignore_v<ref_id_type>)
462 throw format_error{
"No negative values are allowed at the mate mapping position."};
470 if constexpr (!detail::decays_to_ignore_v<seq_type>)
483 + detail::type_name_as_string<seq_legal_alph_type>
501 if constexpr (!detail::decays_to_ignore_v<qual_type>)
504 if constexpr (!detail::decays_to_ignore_v<seq_type> && !detail::decays_to_ignore_v<qual_type>)
506 if (std::ranges::distance(
seq) != 0 && std::ranges::distance(
qual) != 0
507 && std::ranges::distance(
seq) != std::ranges::distance(
qual))
510 std::ranges::distance(
seq),
511 ") and quality length (",
512 std::ranges::distance(
qual),
513 ") must be the same.")};
519 if constexpr (!detail::decays_to_ignore_v<tag_dict_type>)
542 typename header_type,
546 typename ref_id_type,
554 header_type && header,
586 "The seq object must be a std::ranges::forward_range over "
587 "letters that model seqan3::alphabet.");
590 "The id object must be a std::ranges::forward_range over "
591 "letters that model seqan3::alphabet.");
593 if constexpr (!detail::decays_to_ignore_v<ref_id_type>)
595 static_assert((std::ranges::forward_range<ref_id_type> || std::integral<std::remove_reference_t<ref_id_type>>
596 || detail::is_type_specialisation_of_v<std::remove_cvref_t<ref_id_type>,
std::optional>),
597 "The ref_id object must be a std::ranges::forward_range "
598 "over letters that model seqan3::alphabet.");
600 if constexpr (std::integral<std::remove_cvref_t<ref_id_type>>
601 || detail::is_type_specialisation_of_v<std::remove_cvref_t<ref_id_type>,
std::optional>)
602 static_assert(!detail::decays_to_ignore_v<header_type>,
603 "If you give indices as reference id information the header must also be present.");
607 "The qual object must be a std::ranges::forward_range "
608 "over letters that model seqan3::alphabet.");
611 "The mate object must be a std::tuple of size 3 with "
612 "1) a std::ranges::forward_range with a value_type modelling seqan3::alphabet, "
613 "2) a std::integral or std::optional<std::integral>, and "
614 "3) a std::integral.");
617 ((std::ranges::forward_range<decltype(std::get<0>(
mate))>
620 && (std::integral<std::remove_cvref_t<decltype(std::get<1>(
mate))>>
622 && std::integral<std::remove_cvref_t<decltype(std::get<2>(
mate))>>),
623 "The mate object must be a std::tuple of size 3 with "
624 "1) a std::ranges::forward_range with a value_type modelling seqan3::alphabet, "
625 "2) a std::integral or std::optional<std::integral>, and "
626 "3) a std::integral.");
628 if constexpr (std::integral<std::remove_cvref_t<decltype(std::get<0>(
mate))>>
631 static_assert(!detail::decays_to_ignore_v<header_type>,
632 "If you give indices as mate reference id information the header must also be present.");
635 "The tag_dict object must be of type seqan3::sam_tag_dictionary.");
640 if constexpr (!detail::decays_to_ignore_v<header_type> && !detail::decays_to_ignore_v<ref_id_type>
641 && !std::integral<std::remove_reference_t<ref_id_type>>
642 && !detail::is_type_specialisation_of_v<std::remove_reference_t<ref_id_type>,
std::optional>)
649 if constexpr (std::ranges::contiguous_range<
decltype(
ref_id)> && std::ranges::sized_range<
decltype(
ref_id)>
650 && std::ranges::borrowed_range<
decltype(
ref_id)>)
659 "The ref_id type is not convertible to the reference id information stored in the "
660 "reference dictionary of the header object.");
668 "' was not in the list of references:",
674 throw format_error{
"The ref_offset object must be a std::integral >= 0."};
679 if constexpr (!detail::decays_to_ignore_v<header_type>)
701 if constexpr (!detail::decays_to_ignore_v<ref_id_type>)
703 if constexpr (std::integral<std::remove_reference_t<ref_id_type>>)
707 else if constexpr (detail::is_type_specialisation_of_v<std::remove_reference_t<ref_id_type>,
std::optional>)
745 if constexpr (std::integral<std::remove_reference_t<decltype(get<0>(
mate))>>)
749 else if constexpr (detail::is_type_specialisation_of_v<std::remove_reference_t<decltype(get<0>(
mate))>,
764 if constexpr (detail::is_type_specialisation_of_v<std::remove_cvref_t<decltype(get<1>(
mate))>,
std::optional>)
805template <arithmetic value_type>
814 while (
start_pos != std::string_view::npos)
843 if (str.
size() % 2 != 0)
844 throw format_error{
"[CORRUPTED SAM FILE] Hexadecimal tag must have even number of digits."};
852 if (
res.ec == std::errc::invalid_argument)
854 +
"' could not be cast into type uint8_t."};
856 if (
res.ec == std::errc::result_out_of_range)
858 +
"' into type uint8_t would cause an overflow."};
890 uint16_t
tag =
static_cast<uint16_t
>(
tag_str[0]) << 8;
964 "SAM tag ([TAG]:[TYPE_ID]:[VALUE]) must be one of [A,i,Z,H,B,f] but '")
976template <
typename stream_it_t, std::ranges::forward_range field_type>
985 if constexpr (std::same_as<std::remove_cvref_t<std::ranges::range_reference_t<field_type>>,
char>)
998template <
typename stream_it_t>
1011template <
typename stream_it_t>
1019 if constexpr (std::ranges::input_range<T>)
1021 if constexpr (std::same_as<std::remove_cvref_t<std::ranges::range_reference_t<T>>,
char>)
1025 else if constexpr (std::same_as<std::remove_cvref_t<std::ranges::range_reference_t<T>>,
std::byte>)
1027 if (!std::ranges::empty(
arg))
1031 for (
auto &&
elem :
arg | std::views::drop(1))
1040 if (!std::ranges::empty(
arg))
1044 for (
auto &&
elem :
arg | std::views::drop(1))
1052 else if constexpr (std::same_as<std::remove_cvref_t<T>,
char>)
Core alphabet concept and free function/type trait wrappers.
Functionally the same as std::istreambuf_iterator, but faster.
Definition fast_istreambuf_iterator.hpp:37
Functionally the same as std::ostreambuf_iterator, but offers writing a range more efficiently.
Definition fast_ostreambuf_iterator.hpp:38
The SAM tag dictionary class that stores all optional SAM fields.
Definition sam_tag_dictionary.hpp:327
Provides seqan3::detail::fast_ostreambuf_iterator.
auto const to_char
A view that calls seqan3::to_char() on each element in the input range.
Definition to_char.hpp:60
constexpr auto assign_char_to
Assign a character to an alphabet object.
Definition alphabet/concept.hpp:517
sam_flag
An enum flag that describes the properties of an aligned read (given as a SAM record).
Definition sam_flag.hpp:73
constexpr char sam_tag_type_char_extra[12]
Each types SAM tag type extra char id. Index corresponds to the seqan3::detail::sam_tag_variant types...
Definition sam_tag_dictionary.hpp:42
constexpr char sam_tag_type_char[12]
Each SAM tag type char identifier. Index corresponds to the seqan3::detail::sam_tag_variant types.
Definition sam_tag_dictionary.hpp:39
constexpr std::vector< cigar > parse_cigar(std::string_view const cigar_str)
Parses a cigar string into a vector of operation-count pairs (e.g. (M, 3)).
Definition io/sam_file/detail/cigar.hpp:87
@ none
None of the flags below are set.
constexpr auto take_until_and_consume
A view adaptor that returns elements from the underlying range until the functor evaluates to true (o...
Definition take_until_view.hpp:589
constexpr auto istreambuf
A view factory that returns a view over the stream buffer of an input stream.
Definition istreambuf_view.hpp:104
@ flag
The alignment flag (bit information), uint16_t value.
@ ref_offset
Sequence (seqan3::field::ref_seq) relative start position (0-based), unsigned value.
@ ref_seq
The (reference) "sequence" information, usually a range of nucleotides or amino acids.
@ mapq
The mapping quality of the seqan3::field::seq alignment, usually a Phred-scaled score.
@ bit_score
The bit score (statistical significance indicator), unsigned value.
@ mate
The mate pair information given as a std::tuple of reference name, offset and template length.
@ ref_id
The identifier of the (reference) sequence that seqan3::field::seq was aligned to.
@ seq
The "sequence", usually a range of nucleotides or amino acids.
@ qual
The qualities, usually in Phred score notation.
std::string make_printable(char const c)
Returns a printable value for the given character c.
Definition pretty_print.hpp:45
constexpr auto is_char
Checks whether a given letter is the same as the template non-type argument.
Definition predicate.hpp:60
constexpr auto is_space
Checks whether c is a space character.
Definition predicate.hpp:122
seqan::stl::ranges::to to
Converts a range to a container. <dl class="no-api">This entity is not part of the SeqAn API....
Definition to.hpp:23
The generic alphabet concept that covers most data types used in ranges.
Checks whether from can be implicityly converted to to.
The generic concept for a (biological) sequence.
Whether a type behaves like a tuple.
Auxiliary functions for the SAM IO.
Provides seqan3::detail::istreambuf.
std::string to_string(value_type &&... values)
Streams all parameters via the seqan3::debug_stream and returns a concatenated string.
Definition to_string.hpp:26
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
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:412
Provides seqan3::sam_file_output_options.
Provides helper data structures for the seqan3::sam_file_output.
Provides the seqan3::sam_tag_dictionary class and auxiliaries.
Provides seqan3::sequence_file_output_options.
Provides seqan3::views::slice.
Thrown if there is a parse error, such as reading an unexpected character from an input stream.
Definition io/exception.hpp:45
The options type defines various option members that influence the behavior of all or some formats.
Definition sam_file/output_options.hpp:23
bool add_carriage_return
The default plain text line-ending is "\n", but on Windows an additional carriage return is recommend...
Definition sam_file/output_options.hpp:27
bool sam_require_header
Whether to require a header for SAM files.
Definition sam_file/output_options.hpp:41
The options type defines various option members that influence the behaviour of all or some formats.
Definition sequence_file/output_options.hpp:23
Provides seqan3::views::take_until and seqan3::views::take_until_or_throw.
Provides seqan3::ranges::to.
Provides seqan3::views::to_char.
Provides traits to inspect some information of a type, for example its name.
Provides seqan3::tuple_like.