SeqAn3 3.3.0-rc.1
The Modern C++ library for sequence analysis.
 
Loading...
Searching...
No Matches
header.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, 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 <deque>
16#include <ranges>
17#include <unordered_map>
18#include <vector>
19
23
24namespace seqan3
25{
26
33{
40};
41
47template <std::ranges::forward_range ref_ids_type = std::deque<std::string>>
49{
50public:
55 sam_file_header() = default;
57 sam_file_header(sam_file_header const &) = default;
65 ~sam_file_header() = default;
66
70 sam_file_header(ref_ids_type & ref_ids) : ref_ids_ptr{&ref_ids, ref_ids_deleter_noop}
71 {}
72
76 sam_file_header(ref_ids_type && ref_ids) :
77 ref_ids_ptr{new ref_ids_type{std::move(ref_ids)}, ref_ids_deleter_default}
78 {}
80
88
90
92
93private:
95 using ref_ids_ptr_t = std::unique_ptr<ref_ids_type, std::function<void(ref_ids_type *)>>;
97 static void ref_ids_deleter_noop(ref_ids_type *)
98 {}
100 static void ref_ids_deleter_default(ref_ids_type * ptr)
101 {
102 delete ptr;
103 }
107 type_reduce_t<std::ranges::range_reference_t<ref_ids_type>>>;
109 ref_ids_ptr_t ref_ids_ptr{new ref_ids_type{}, ref_ids_deleter_default};
110
112 struct key_hasher
113 {
115 template <typename key_t>
116 size_t operator()(key_t && key) const noexcept
117 {
118 using char_t = std::ranges::range_value_t<key_t>;
119 size_t result{0};
121 for (char_t character : key)
122 {
123 result *= 0x8F3F73B5CF1C9ADE;
124 result += h(character);
125 }
126 return result;
127 }
128 };
129
130public:
149 ref_ids_type & ref_ids()
150 {
151 return *ref_ids_ptr;
152 }
153
186
189
225};
226
227} // namespace seqan3
Core alphabet concept and free function/type trait wrappers.
Stores the header information of SAM/BAM files.
Definition: header.hpp:49
sam_file_header(sam_file_header const &)=default
Copy construction is defaulted.
sam_file_header(ref_ids_type &ref_ids)
Construct from a range of reference ids which redirects the ref_ids_ptr member (non-owning).
Definition: header.hpp:70
std::vector< std::pair< std::string, std::string > > read_groups
The Read Group Dictionary (used by the SAM/BAM format).
Definition: header.hpp:224
std::string sorting
The sorting of the file. SAM: [unknown, unsorted, queryname, coordinate].
Definition: header.hpp:84
sam_file_header & operator=(sam_file_header const &)=default
Copy assignment is defaulted.
ref_ids_type & ref_ids()
The range of reference ids.
Definition: header.hpp:149
sam_file_header(sam_file_header &&)=default
Move construction is defaulted.
std::unordered_map< key_type, int32_t, key_hasher, detail::view_equality_fn > ref_dict
The mapping of reference id to position in the ref_ids() range and the ref_id_info range.
Definition: header.hpp:188
std::vector< std::tuple< int32_t, std::string > > ref_id_info
The reference information. (used by the SAM/BAM format)
Definition: header.hpp:185
std::string format_version
The file format version. Note: this is overwritten by our formats on output.
Definition: header.hpp:83
~sam_file_header()=default
Destructor is defaulted.
std::vector< std::string > comments
The list of comments.
Definition: header.hpp:91
sam_file_header()=default
Default constructor is defaulted.
std::string grouping
The grouping of the file. SAM: [none, query, reference].
Definition: header.hpp:87
std::string subsorting
The sub-sorting of the file. SAM: [unknown, unsorted, queryname, coordinate](:[A-Za-z0-9_-]+)+.
Definition: header.hpp:86
sam_file_header(ref_ids_type &&ref_ids)
Construct from a rvalue range of reference ids which is moved into the ref_ids_ptr (owning).
Definition: header.hpp:76
sam_file_header & operator=(sam_file_header &&)=default
Move assignment is defaulted.
std::vector< program_info_t > program_infos
The list of program information.
Definition: header.hpp:89
Auxiliary functions for the SAM IO.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
SeqAn specific customisations in the standard namespace.
Stores information of the program/tool that was used to create a SAM/BAM file.
Definition: header.hpp:33
std::string description
A description of the program and/or program call.
Definition: header.hpp:38
std::string command_line_call
The command line call that produces the file.
Definition: header.hpp:36
std::string previous
The id of the previous program if program calls were chained.
Definition: header.hpp:37
std::string name
The official name.
Definition: header.hpp:35
std::string id
A unique (file scope) id.
Definition: header.hpp:34
std::string version
The program/tool version.
Definition: header.hpp:39
Provides seqan3::views::type_reduce.