SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
header.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <deque>
13#include <ranges>
14#include <unordered_map>
15#include <vector>
16
20
21namespace seqan3
22{
23
38
44template <std::ranges::forward_range ref_ids_type = std::deque<std::string>>
46{
47public:
51 sam_file_header() = default;
52 sam_file_header(sam_file_header const &) = delete;
56 ~sam_file_header() = default;
57
61 sam_file_header(ref_ids_type & ref_ids) : ref_ids_ptr{&ref_ids, ref_ids_deleter_noop}
62 {}
63
67 sam_file_header(ref_ids_type && ref_ids) :
68 ref_ids_ptr{new ref_ids_type{std::move(ref_ids)}, ref_ids_deleter_default}
69 {}
71
79
81
83
84private:
86 using ref_ids_ptr_t = std::unique_ptr<ref_ids_type, std::function<void(ref_ids_type *)>>;
88 static void ref_ids_deleter_noop(ref_ids_type *)
89 {}
91 static void ref_ids_deleter_default(ref_ids_type * ptr)
92 {
93 delete ptr;
94 }
98 type_reduce_t<std::ranges::range_reference_t<ref_ids_type>>>;
100 ref_ids_ptr_t ref_ids_ptr{new ref_ids_type{}, ref_ids_deleter_default};
101
103 struct key_hasher
104 {
106 template <typename key_t>
107 size_t operator()(key_t && key) const noexcept
108 {
109 using char_t = std::ranges::range_value_t<key_t>;
110 size_t result{0};
112 for (char_t character : key)
113 {
114 result *= 0x8F'3F'73'B5'CF'1C'9A'DE;
115 result += h(character);
116 }
117 return result;
118 }
119 };
120
121public:
140 ref_ids_type & ref_ids()
141 {
142 return *ref_ids_ptr;
143 }
144
177
180
216};
217
218} // namespace seqan3
Core alphabet concept and free function/type trait wrappers.
Stores the header information of SAM/BAM files.
Definition header.hpp:46
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:61
std::vector< std::pair< std::string, std::string > > read_groups
The Read Group Dictionary (used by the SAM/BAM format).
Definition header.hpp:215
std::string sorting
The sorting of the file. SAM: [unknown, unsorted, queryname, coordinate].
Definition header.hpp:75
ref_ids_type & ref_ids()
The range of reference ids.
Definition header.hpp:140
sam_file_header(sam_file_header &&)=default
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:179
sam_file_header & operator=(sam_file_header const &)=delete
Deleted. Holds a unique_ptr.
std::vector< std::tuple< int32_t, std::string > > ref_id_info
The reference information. (used by the SAM/BAM format)
Definition header.hpp:176
std::string format_version
The file format version. Note: this is overwritten by our formats on output.
Definition header.hpp:74
~sam_file_header()=default
Defaulted.
sam_file_header(sam_file_header const &)=delete
Deleted. Holds a unique_ptr.
std::vector< std::string > comments
The list of comments.
Definition header.hpp:82
sam_file_header()=default
Defaulted.
std::string grouping
The grouping of the file. SAM: [none, query, reference].
Definition header.hpp:78
std::string subsorting
The sub-sorting of the file. SAM: [unknown, unsorted, queryname, coordinate](:[A-Za-z0-9_-]+)+.
Definition header.hpp:77
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:67
sam_file_header & operator=(sam_file_header &&)=default
Defaulted.
std::vector< program_info_t > program_infos
The list of program information.
Definition header.hpp:80
Auxiliary functions for the SAM IO.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
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:30
std::string description
A description of the program and/or program call.
Definition header.hpp:35
std::string command_line_call
The command line call that produces the file.
Definition header.hpp:33
std::string previous
The id of the previous program if program calls were chained.
Definition header.hpp:34
std::string name
The official name.
Definition header.hpp:32
std::string id
A unique (file scope) id.
Definition header.hpp:31
std::string version
The program/tool version.
Definition header.hpp:36
Provides seqan3::views::type_reduce.
Hide me