SeqAn3  3.1.0-rc.1
The Modern C++ library for sequence analysis.
output.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
15 #include <cassert>
16 #include <seqan3/std/filesystem>
17 #include <fstream>
18 #include <seqan3/std/ranges>
19 #include <string>
20 #include <string_view>
21 #include <variant>
22 #include <vector>
23 
28 #include <seqan3/io/exception.hpp>
29 #include <seqan3/io/record.hpp>
39 
40 namespace seqan3
41 {
42 
43 // ----------------------------------------------------------------------------
44 // sam_file_output
45 // ----------------------------------------------------------------------------
46 
144 template <detail::fields_specialisation selected_field_ids_ =
145  fields<field::seq,
146  field::id,
151  field::cigar,
152  field::mapq,
153  field::qual,
154  field::flag,
155  field::mate,
156  field::tags,
158  detail::type_list_of_sam_file_output_formats valid_formats_ = type_list<format_sam, format_bam>,
159  typename ref_ids_type = ref_info_not_given>
161 {
162 public:
168  using selected_field_ids = selected_field_ids_;
170  using valid_formats = valid_formats_;
172  using stream_char_type = char;
174 
177  field::id,
182  field::cigar,
183  field::mapq,
184  field::flag,
185  field::qual,
186  field::mate,
187  field::tags,
189 
190  static_assert([] () constexpr
191  {
192  for (field f : selected_field_ids::as_array)
193  if (!field_ids::contains(f))
194  return false;
195  return true;
196  }(),
197  "You selected a field that is not valid for alignment files, "
198  "please refer to the documentation of "
199  "seqan3::sam_file_output::field_ids for the accepted values.");
200 
207  using value_type = void;
209  using reference = void;
211  using const_reference = void;
213  using size_type = void;
219  using const_iterator = void;
221  using sentinel = std::default_sentinel_t;
223 
228  sam_file_output() = delete;
230  sam_file_output(sam_file_output const &) = delete;
238  ~sam_file_output() = default;
239 
266  selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
268  {
269  primary_stream->rdbuf()->pubsetbuf(stream_buffer.data(), stream_buffer.size());
270  static_cast<std::basic_ofstream<char> *>(primary_stream.get())->open(filename,
271  std::ios_base::out | std::ios::binary);
272 
273  // open stream
274  if (!primary_stream->good())
275  throw file_open_error{"Could not open file " + filename.string() + " for writing."};
276 
277  // possibly add intermediate compression stream
279 
280  // initialise format handler or throw if format is not found
281  detail::set_format(format, filename);
282  }
283 
300  template <output_stream stream_type, sam_file_output_format file_format>
302  requires std::same_as<typename std::remove_reference_t<stream_type>::char_type, stream_char_type>
304  sam_file_output(stream_type & stream,
305  file_format const & SEQAN3_DOXYGEN_ONLY(format_tag),
306  selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
309  format{detail::sam_file_output_format_exposer<file_format>{}}
310  {
311  static_assert(list_traits::contains<file_format, valid_formats>,
312  "You selected a format that is not in the valid_formats of this file.");
313  }
314 
316  template <output_stream stream_type, sam_file_output_format file_format>
318  requires std::same_as<typename std::remove_reference_t<stream_type>::char_type, stream_char_type>
320  sam_file_output(stream_type && stream,
321  file_format const & SEQAN3_DOXYGEN_ONLY(format_tag),
322  selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
323  primary_stream{new stream_type{std::move(stream)}, stream_deleter_default},
325  format{detail::sam_file_output_format_exposer<file_format>{}}
326  {
327  static_assert(list_traits::contains<file_format, valid_formats>,
328  "You selected a format that is not in the valid_formats of this file.");
329  }
330 
361  template <typename ref_ids_type_, std::ranges::forward_range ref_lengths_type>
363  requires std::same_as<std::remove_reference_t<ref_ids_type_>, ref_ids_type>
366  ref_ids_type_ && ref_ids,
367  ref_lengths_type && ref_lengths,
368  selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
370 
371  {
372  initialise_header_information(ref_ids, ref_lengths);
373  }
374 
396  template <output_stream stream_type,
397  sam_file_output_format file_format,
398  typename ref_ids_type_, // generic type to capture lvalue references
399  std::ranges::forward_range ref_lengths_type>
401  requires std::same_as<std::remove_reference_t<ref_ids_type_>, ref_ids_type>
403  sam_file_output(stream_type && stream,
404  ref_ids_type_ && ref_ids,
405  ref_lengths_type && ref_lengths,
406  file_format const & SEQAN3_DOXYGEN_ONLY(format_tag),
407  selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
408  sam_file_output{std::forward<stream_type>(stream), file_format{}, selected_field_ids{}}
409  {
410  initialise_header_information(ref_ids, ref_lengths);
411  }
413 
435  iterator begin() noexcept
436  {
437  return {*this};
438  }
439 
454  sentinel end() noexcept
455  {
456  return {};
457  }
458 
477  template <typename record_t>
478  void push_back(record_t && r)
480  requires detail::record_like<record_t>
482  {
483  using default_align_t = std::pair<std::span<gapped<char>>, std::span<gapped<char>>>;
484  using default_mate_t = std::tuple<std::string_view, std::optional<int32_t>, int32_t>;
485 
486  write_record(detail::get_or<field::header_ptr>(r, nullptr),
487  detail::get_or<field::seq>(r, std::string_view{}),
488  detail::get_or<field::qual>(r, std::string_view{}),
489  detail::get_or<field::id>(r, std::string_view{}),
490  detail::get_or<field::offset>(r, 0u),
491  detail::get_or<field::ref_seq>(r, std::string_view{}),
492  detail::get_or<field::ref_id>(r, std::ignore),
493  detail::get_or<field::ref_offset>(r, std::optional<int32_t>{}),
494  detail::get_or<field::alignment>(r, default_align_t{}),
495  detail::get_or<field::cigar>(r, std::vector<cigar>{}),
496  detail::get_or<field::flag>(r, sam_flag::none),
497  detail::get_or<field::mapq>(r, 0u),
498  detail::get_or<field::mate>(r, default_mate_t{}),
499  detail::get_or<field::tags>(r, sam_tag_dictionary{}),
500  detail::get_or<field::evalue>(r, 0u),
501  detail::get_or<field::bit_score>(r, 0u));
502  }
503 
525  template <typename tuple_t>
526  void push_back(tuple_t && t)
528  requires tuple_like<tuple_t> && (!detail::record_like<tuple_t>)
530  {
531  using default_align_t = std::pair<std::span<gapped<char>>, std::span<gapped<char>>>;
532  using default_mate_t = std::tuple<std::string_view, std::optional<int32_t>, int32_t>;
533 
534  // index_of might return npos, but this will be handled well by get_or_ignore (and just return ignore)
535  write_record(detail::get_or<selected_field_ids::index_of(field::header_ptr)>(t, nullptr),
536  detail::get_or<selected_field_ids::index_of(field::seq)>(t, std::string_view{}),
537  detail::get_or<selected_field_ids::index_of(field::qual)>(t, std::string_view{}),
538  detail::get_or<selected_field_ids::index_of(field::id)>(t, std::string_view{}),
539  detail::get_or<selected_field_ids::index_of(field::offset)>(t, 0u),
540  detail::get_or<selected_field_ids::index_of(field::ref_seq)>(t, std::string_view{}),
541  detail::get_or<selected_field_ids::index_of(field::ref_id)>(t, std::ignore),
542  detail::get_or<selected_field_ids::index_of(field::ref_offset)>(t, std::optional<int32_t>{}),
543  detail::get_or<selected_field_ids::index_of(field::alignment)>(t, default_align_t{}),
544  detail::get_or<selected_field_ids::index_of(field::cigar)>(t, std::vector<cigar>{}),
545  detail::get_or<selected_field_ids::index_of(field::flag)>(t, sam_flag::none),
546  detail::get_or<selected_field_ids::index_of(field::mapq)>(t, 0u),
547  detail::get_or<selected_field_ids::index_of(field::mate)>(t, default_mate_t{}),
548  detail::get_or<selected_field_ids::index_of(field::tags)>(t, sam_tag_dictionary{}),
549  detail::get_or<selected_field_ids::index_of(field::evalue)>(t, 0u),
550  detail::get_or<selected_field_ids::index_of(field::bit_score)>(t, 0u));
551  }
552 
576  template <typename arg_t, typename ...arg_types>
578  requires (sizeof...(arg_types) + 1 <= selected_field_ids::size)
580  void emplace_back(arg_t && arg, arg_types && ... args)
581  {
582  push_back(std::tie(arg, args...));
583  }
584 
606  template <typename rng_t>
607  sam_file_output & operator=(rng_t && range)
609  requires std::ranges::input_range<rng_t> && tuple_like<std::ranges::range_reference_t<rng_t>>
611  {
612  for (auto && record : range)
613  push_back(std::forward<decltype(record)>(record));
614  return *this;
615  }
616 
645  template <typename rng_t>
646  friend sam_file_output & operator|(rng_t && range, sam_file_output & f)
648  requires std::ranges::input_range<rng_t> && tuple_like<std::ranges::range_reference_t<rng_t>>
650  {
651  f = range;
652  return f;
653  }
654 
656  template <typename rng_t>
657  friend sam_file_output operator|(rng_t && range, sam_file_output && f)
659  requires std::ranges::input_range<rng_t> && tuple_like<std::ranges::range_reference_t<rng_t>>
661  {
662  f = range;
663  return std::move(f);
664  }
666 
669 
674  {
675  return *secondary_stream;
676  }
678 
689  auto & header()
690  {
691  if constexpr (std::same_as<ref_ids_type, ref_info_not_given>)
692  throw std::logic_error{"Please construct your file with reference id and length information in order "
693  "to properly initialise the header before accessing it."};
694 
695  return *header_ptr;
696  }
697 
698 protected:
702 
713 
718 
722 
726 
730  ref_ids_type>>;
731 
734 
736  template <typename ref_ids_type_, typename ref_lengths_type>
737  void initialise_header_information(ref_ids_type_ && ref_ids, ref_lengths_type && ref_lengths)
738  {
739  assert(std::ranges::size(ref_ids) == std::ranges::size(ref_lengths));
740 
741  header_ptr = std::make_unique<sam_file_header<ref_ids_type>>(std::forward<ref_ids_type_>(ref_ids));
742 
743  for (int32_t idx = 0; idx < std::ranges::distance(ref_ids); ++idx)
744  {
745  header_ptr->ref_id_info.emplace_back(ref_lengths[idx], "");
746 
747  if constexpr (std::ranges::contiguous_range<std::ranges::range_reference_t<ref_ids_type_>> &&
748  std::ranges::sized_range<std::ranges::range_reference_t<ref_ids_type_>> &&
749  std::ranges::borrowed_range<std::ranges::range_reference_t<ref_ids_type_>>)
750  {
751  auto && id = header_ptr->ref_ids()[idx];
752  header_ptr->ref_dict[std::span{std::ranges::data(id), std::ranges::size(id)}] = idx;
753  }
754  else
755  {
756  header_ptr->ref_dict[header_ptr->ref_ids()[idx]] = idx;
757  }
758  }
759  }
760 
762  template <typename record_header_ptr_t, typename ...pack_type>
763  void write_record(record_header_ptr_t && record_header_ptr, pack_type && ...remainder)
764  {
765  static_assert((sizeof...(pack_type) == 15), "Wrong parameter list passed to write_record.");
766 
767  assert(!format.valueless_by_exception());
768 
769  std::visit([&] (auto & f)
770  {
771  // use header from record if explicitly given, e.g. file_output = file_input
772  if constexpr (!std::same_as<record_header_ptr_t, std::nullptr_t>)
773  {
774  f.write_alignment_record(*secondary_stream,
775  options,
776  *record_header_ptr,
777  std::forward<pack_type>(remainder)...);
778  }
779  else if constexpr (std::same_as<ref_ids_type, ref_info_not_given>)
780  {
781  f.write_alignment_record(*secondary_stream,
782  options,
783  std::ignore,
784  std::forward<pack_type>(remainder)...);
785  }
786  else
787  {
788  f.write_alignment_record(*secondary_stream,
789  options,
790  *header_ptr,
791  std::forward<pack_type>(remainder)...);
792  }
793  }, format);
794  }
795 
797  friend iterator;
798 };
799 
808 template <detail::fields_specialisation selected_field_ids>
811 
815 template <output_stream stream_type,
816  sam_file_output_format file_format,
818 sam_file_output(stream_type &&, file_format const &, selected_field_ids const &)
820 
824 template <output_stream stream_type,
825  sam_file_output_format file_format,
827 sam_file_output(stream_type &, file_format const &, selected_field_ids const &)
829 
833 template <output_stream stream_type,
834  sam_file_output_format file_format>
835 sam_file_output(stream_type &&, file_format const &)
837 
841 template <output_stream stream_type,
842  sam_file_output_format file_format>
843 sam_file_output(stream_type &, file_format const &)
845 
848  std::ranges::forward_range ref_ids_type,
849  std::ranges::forward_range ref_lengths_type>
850 sam_file_output(std::filesystem::path const &, ref_ids_type &&, ref_lengths_type &&, selected_field_ids const &)
854 
856 template <std::ranges::forward_range ref_ids_type,
857  std::ranges::forward_range ref_lengths_type>
858 sam_file_output(std::filesystem::path const &, ref_ids_type &&, ref_lengths_type &&)
862 
864 template <output_stream stream_type,
865  std::ranges::forward_range ref_ids_type,
866  std::ranges::forward_range ref_lengths_type,
867  sam_file_output_format file_format,
869 sam_file_output(stream_type &&, ref_ids_type &&, ref_lengths_type &&, file_format const &, selected_field_ids const &)
871 
873 template <output_stream stream_type,
874  std::ranges::forward_range ref_ids_type,
875  std::ranges::forward_range ref_lengths_type,
876  sam_file_output_format file_format,
878 sam_file_output(stream_type &, ref_ids_type &&, ref_lengths_type &&, file_format const &, selected_field_ids const &)
880 
882 template <output_stream stream_type,
883  std::ranges::forward_range ref_ids_type,
884  std::ranges::forward_range ref_lengths_type,
885  sam_file_output_format file_format>
886 sam_file_output(stream_type &&, ref_ids_type &&, ref_lengths_type &&, file_format const &)
890 
892 template <output_stream stream_type,
893  std::ranges::forward_range ref_ids_type,
894  std::ranges::forward_range ref_lengths_type,
895  sam_file_output_format file_format>
896 sam_file_output(stream_type &, ref_ids_type &&, ref_lengths_type &&, file_format const &)
901 
902 } // namespace seqan3
Output iterator necessary for providing a range-like interface in output file.
Definition: out_file_iterator.hpp:47
Stores the header information of alignment files.
Definition: header.hpp:32
A class for writing alignment files, e.g. SAM, BAL, BLAST, ...
Definition: output.hpp:161
void const_reference
The const reference type (void).
Definition: output.hpp:211
void initialise_header_information(ref_ids_type_ &&ref_ids, ref_lengths_type &&ref_lengths)
Fill the header reference dictionary, with the given info.
Definition: output.hpp:737
sam_file_output(stream_type &&stream, ref_ids_type_ &&ref_ids, ref_lengths_type &&ref_lengths, file_format const &format_tag, selected_field_ids const &fields_tag=selected_field_ids{})
Construct from an existing stream and with specified format.
Definition: output.hpp:403
sam_file_output(stream_type &, ref_ids_type &&, ref_lengths_type &&, file_format const &, selected_field_ids const &) -> sam_file_output< selected_field_ids, type_list< file_format >, std::remove_reference_t< ref_ids_type >>
Deduces selected_field_ids, the valid format, and the ref_ids_type from input.
void size_type
The size type (void).
Definition: output.hpp:213
std::vector< char > stream_buffer
A larger (compared to stl default) stream buffer to use when reading from a file.
Definition: output.hpp:701
friend iterator
Befriend iterator so it can access the buffers.
Definition: output.hpp:797
sam_file_output(stream_type &&stream, file_format const &format_tag, selected_field_ids const &fields_tag=selected_field_ids{})
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: output.hpp:320
sam_file_output(sam_file_output const &)=delete
Copy construction is explicitly deleted, because you can't have multiple access to the same file.
friend sam_file_output & operator|(rng_t &&range, sam_file_output &f)
Write a range of records (or tuples) to the file.
Definition: output.hpp:646
sam_file_output()=delete
Default constructor is explicitly deleted, you need to give a stream or file name.
static void stream_deleter_noop(std::basic_ostream< stream_char_type > *)
Stream deleter that does nothing (no ownership assumed).
Definition: output.hpp:710
sam_file_output & operator=(rng_t &&range)
Write a range of records (or tuples) to the file.
Definition: output.hpp:607
sam_file_output & operator=(sam_file_output const &)=delete
Copy assignment is explicitly deleted, because you can't have multiple access to the same file.
std::basic_ostream< stream_char_type > & get_stream()
Expose a reference to the secondary stream. [public, but not documented as part of the API].
Definition: output.hpp:673
sam_file_output(std::filesystem::path const &, ref_ids_type &&, ref_lengths_type &&) -> sam_file_output< typename sam_file_output<>::selected_field_ids, typename sam_file_output<>::valid_formats, std::remove_reference_t< ref_ids_type >>
Deduces ref_ids_type from input. Valid formats, and selected_field_ids are set to the default.
format_type format
The actual std::variant holding a pointer to the detected/selected format.
Definition: output.hpp:724
auto & header()
Access the file's header.
Definition: output.hpp:689
std::default_sentinel_t sentinel
The type returned by end().
Definition: output.hpp:221
char stream_char_type
Character type of the stream(s).
Definition: output.hpp:172
sam_file_output(stream_type &stream, file_format const &format_tag, selected_field_ids const &fields_tag=selected_field_ids{})
Construct from an existing stream and with specified format.
Definition: output.hpp:304
iterator begin() noexcept
Returns an iterator to current position in the file.
Definition: output.hpp:435
sam_file_output(std::filesystem::path const &, ref_ids_type &&, ref_lengths_type &&, selected_field_ids const &) -> sam_file_output< selected_field_ids, typename sam_file_output<>::valid_formats, std::remove_reference_t< ref_ids_type >>
Deduces selected_field_ids and ref_ids_type from input. valid_formats is set to the default.
sentinel end() noexcept
Returns a sentinel for comparison with iterator.
Definition: output.hpp:454
void write_record(record_header_ptr_t &&record_header_ptr, pack_type &&...remainder)
Write record to format.
Definition: output.hpp:763
sam_file_output(std::filesystem::path, selected_field_ids const &) -> sam_file_output< selected_field_ids, typename sam_file_output<>::valid_formats, ref_info_not_given >
Deduces selected_field_ids from input and sets sam_file_output::ref_ids_type to seqan3::detail::ref_i...
void emplace_back(arg_t &&arg, arg_types &&... args)
Write a record to the file by passing individual fields.
Definition: output.hpp:580
void push_back(record_t &&r)
Write a seqan3::record to the file.
Definition: output.hpp:478
std::unique_ptr< header_type > header_ptr
The file header object (will be set on construction).
Definition: output.hpp:733
selected_field_ids_ selected_field_ids
A seqan3::fields list with the fields selected for the record.
Definition: output.hpp:168
sam_file_output & operator=(sam_file_output &&)=default
Move assignment is defaulted.
valid_formats_ valid_formats
A seqan3::type_list with the possible formats.
Definition: output.hpp:170
void reference
The reference type (void).
Definition: output.hpp:209
sam_file_output(stream_type &, ref_ids_type &&, ref_lengths_type &&, file_format const &) -> sam_file_output< typename sam_file_output<>::selected_field_ids, type_list< file_format >, std::remove_reference_t< ref_ids_type >>
Deduces the valid format, and the ref_ids_type from input. selected_field_ids set to the default.
sam_file_output(stream_type &&, file_format const &) -> sam_file_output< typename sam_file_output<>::selected_field_ids, type_list< file_format >, ref_info_not_given >
Deduces the valid format from input and sets sam_file_output::ref_ids_type to seqan3::detail::ref_inf...
sam_file_output(std::filesystem::path filename, selected_field_ids const &fields_tag=selected_field_ids{})
Construct from filename.
Definition: output.hpp:265
sam_file_output(stream_type &&, ref_ids_type &&, ref_lengths_type &&, file_format const &) -> sam_file_output< typename sam_file_output<>::selected_field_ids, type_list< file_format >, std::remove_reference_t< ref_ids_type >>
Deduces the valid format, and the ref_ids_type from input. selected_field_ids set to the default.
static void stream_deleter_default(std::basic_ostream< stream_char_type > *ptr)
Stream deleter with default behaviour (ownership assumed).
Definition: output.hpp:712
stream_ptr_t secondary_stream
The secondary stream is a compression layer on the primary or just points to the primary (no compress...
Definition: output.hpp:717
void push_back(tuple_t &&t)
Write a record in form of a std::tuple to the file.
Definition: output.hpp:526
void value_type
The value type (void).
Definition: output.hpp:207
~sam_file_output()=default
Destructor is defaulted.
sam_file_output_options options
The options are public and its members can be set directly.
Definition: output.hpp:668
sam_file_output(stream_type &&, ref_ids_type &&, ref_lengths_type &&, file_format const &, selected_field_ids const &) -> sam_file_output< selected_field_ids, type_list< file_format >, std::remove_reference_t< ref_ids_type >>
Deduces selected_field_ids, the valid format, and the ref_ids_type from input.
sam_file_output(sam_file_output &&)=default
Move construction is defaulted.
sam_file_output(stream_type &, file_format const &, selected_field_ids const &) -> sam_file_output< selected_field_ids, type_list< file_format >, ref_info_not_given >
Deduces selected_field_ids, and the valid format from input and sets sam_file_output::ref_ids_type to...
sam_file_output(stream_type &&, file_format const &, selected_field_ids const &) -> sam_file_output< selected_field_ids, type_list< file_format >, ref_info_not_given >
Deduces selected_field_ids, and the valid format from input and sets sam_file_output::ref_ids_type to...
sam_file_output(std::filesystem::path const &filename, ref_ids_type_ &&ref_ids, ref_lengths_type &&ref_lengths, selected_field_ids const &fields_tag=selected_field_ids{})
Construct from filename.
Definition: output.hpp:365
stream_ptr_t primary_stream
The primary stream is the user provided stream or the file stream if constructed from filename.
Definition: output.hpp:715
friend sam_file_output operator|(rng_t &&range, sam_file_output &&f)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: output.hpp:657
typename detail::variant_from_tags< valid_formats, detail::sam_file_output_format_exposer >::type format_type
Type of the format, an std::variant over the valid_formats.
Definition: output.hpp:721
void const_iterator
The const iterator type is void, because files are not const-iterable.
Definition: output.hpp:219
sam_file_output(stream_type &, file_format const &) -> sam_file_output< typename sam_file_output<>::selected_field_ids, type_list< file_format >, ref_info_not_given >
Deduces the valid format from input and sets sam_file_output::ref_ids_type to seqan3::detail::ref_inf...
The SAM tag dictionary class that stores all optional SAM fields.
Definition: sam_tag_dictionary.hpp:334
T data(T... args)
Provides auxiliary data structures and functions for seqan3::record and seqan3::fields.
This header includes C++17 filesystem support and imports it into namespace std::filesystem (independ...
Provides the seqan3::format_bam.
Provides the seqan3::format_sam.
T forward(T... args)
T get(T... args)
SEQAN3_CONCEPT type_list_of_sam_file_output_formats
Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::sam_fi...
Definition: output_format_concept.hpp:214
@ none
None of the flags below are set.
field
An enumerator for the fields used in file formats.
Definition: record.hpp:63
void set_format(format_variant_type &format, std::filesystem::path const &file_name)
Sets the file format according to the file name extension.
Definition: misc.hpp:67
decltype(auto) get_or(record< field_types, field_ids > &r, or_type &&or_value)
Access an element in a std::tuple or seqan3::record; return or_value if not contained.
Definition: record.hpp:162
SEQAN3_CONCEPT fields_specialisation
Auxiliary concept that checks whether a type is a specialisation of seqan3::fields.
Definition: record.hpp:35
auto make_secondary_ostream(std::basic_ostream< char_t > &primary_stream, std::filesystem::path &filename) -> std::unique_ptr< std::basic_ostream< char_t >, std::function< void(std::basic_ostream< char_t > *)>>
Depending on the given filename/extension, create a compression stream or just forward the primary st...
Definition: misc_output.hpp:42
@ 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.
@ alignment
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
@ cigar
The cigar vector (std::vector<seqan3::cigar>) representing the alignment in SAM/BAM format.
@ 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.
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
@ mate
The mate pair information given as a std::tuple of reference name, offset and template length.
@ header_ptr
A pointer to the seqan3::sam_file_header object storing header information.
@ ref_id
The identifier of the (reference) sequence that seqan3::field::seq was aligned to.
@ evalue
The e-value (length normalized bit score), double value.
@ id
The identifier, usually a string.
@ tags
The optional tags in the SAM format, stored in a dictionary.
@ seq
The "sequence", usually a range of nucleotides or amino acids.
@ qual
The qualities, usually in Phred score notation.
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:151
Provides the seqan3::sam_file_header class.
The generic concept for alignment file out formats.
Whether a type behaves like a tuple.
Provides exceptions used in the I/O module.
Stream concepts.
Provides various utility functions required only for output.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides the seqan3::detail::out_file_iterator class template.
Adaptations of concepts from the Ranges TS.
Provides the seqan3::record template and the seqan3::field enum.
Provides seqan3::detail::record_like.
Provides seqan3::sam_file_output_format and auxiliary classes.
Provides seqan3::sam_file_output_options.
Provides helper data structures for the seqan3::sam_file_output.
T size(T... args)
Internal class used to expose the actual format interface to write alignment records into the file.
Definition: output_format_concept.hpp:45
Base class to deduce the std::variant type from format tags.
Definition: misc.hpp:30
A class template that holds a choice of seqan3::field.
Definition: record.hpp:128
static constexpr bool contains(field f)
Whether a field is contained in the parameter pack.
Definition: record.hpp:149
The class template that file records are based on; behaves like an std::tuple.
Definition: record.hpp:191
Type tag which indicates that no reference information has been passed to the alignment file on const...
Definition: sam_flag.hpp:24
The options type defines various option members that influence the behavior of all or some formats.
Definition: output_options.hpp:23
Type that contains multiple types.
Definition: type_list.hpp:29
T tie(T... args)
Provides traits for seqan3::type_list.
Provides seqan3::tuple_like.
T visit(T... args)