2121#include < seqan3/io/detail/misc.hpp>
2222#include < seqan3/io/sam_file/detail/cigar.hpp>
2323#include < seqan3/io/sam_file/header.hpp>
24+ #include < seqan3/io/sam_file/input_options.hpp>
2425#include < seqan3/io/sam_file/output_format_concept.hpp>
2526#include < seqan3/utility/detail/type_name_as_string.hpp>
2627#include < seqan3/utility/views/repeat_n.hpp>
@@ -82,10 +83,11 @@ class format_sam_base
8283 template <arithmetic arithmetic_target_type>
8384 void read_arithmetic_field (std::string_view const & str, arithmetic_target_type & arithmetic_target);
8485
85- template <typename stream_view_type, typename ref_ids_type, typename ref_seqs_type>
86+ template <typename stream_view_type, typename ref_ids_type, typename ref_seqs_type, typename seq_legal_alph_type >
8687 void read_header (stream_view_type && stream_view,
8788 sam_file_header<ref_ids_type> & hdr,
88- ref_seqs_type & /* ref_id_to_pos_map*/ );
89+ ref_seqs_type & /* ref_id_to_pos_map*/ ,
90+ sam_file_input_options<seq_legal_alph_type> const & options);
8991
9092 template <typename stream_t , typename header_type>
9193 void write_header (stream_t & stream, sam_file_output_options const & options, header_type & header);
@@ -258,6 +260,7 @@ inline void format_sam_base::read_arithmetic_field(std::string_view const & str,
258260 * \tparam stream_view_type The type of the stream as a view.
259261 * \param[in, out] stream_view The stream view to iterate over.
260262 * \param[in, out] hdr The header (as a pointer) to store the parsed values.
263+ * \param[in] options The options to alter the parsing process.
261264 *
262265 * \throws seqan3::format_error if any unexpected character or format is encountered.
263266 *
@@ -270,10 +273,11 @@ inline void format_sam_base::read_arithmetic_field(std::string_view const & str,
270273 * not in a correct state (e.g. required fields are not given), but throwing might occur downstream of the actual
271274 * error.
272275 */
273- template <typename stream_view_type, typename ref_ids_type, typename ref_seqs_type>
276+ template <typename stream_view_type, typename ref_ids_type, typename ref_seqs_type, typename seq_legal_alph_type >
274277inline void format_sam_base::read_header (stream_view_type && stream_view,
275278 sam_file_header<ref_ids_type> & hdr,
276- ref_seqs_type & /* ref_id_to_pos_map*/ )
279+ ref_seqs_type & /* ref_id_to_pos_map*/ ,
280+ sam_file_input_options<seq_legal_alph_type> const & options)
277281{
278282 auto it = std::ranges::begin (stream_view);
279283 auto end = std::ranges::end (stream_view);
@@ -335,9 +339,13 @@ inline void format_sam_base::read_header(stream_view_type && stream_view,
335339 read_forward_range_field (string_buffer, value);
336340 };
337341
338- auto print_cerr_of_unspported_tag = [](char const * const header_tag, std::array<char , 2 > raw_tag)
342+ auto print_cerr_of_unspported_tag = [&options ](char const * const header_tag, std::array<char , 2 > raw_tag)
339343 {
340- std::cerr << " Unsupported SAM header tag in @" << header_tag << " : " << raw_tag[0 ] << raw_tag[1 ] << ' \n ' ;
344+ if (options.stream_warnings_to == nullptr )
345+ return ;
346+
347+ *options.stream_warnings_to << " Unsupported SAM header tag in @" << header_tag << " : " << raw_tag[0 ]
348+ << raw_tag[1 ] << ' \n ' ;
341349 };
342350
343351 while (it != end && is_char<' @' >(*it))
0 commit comments