SeqAn3
3.3.0-rc.1
The Modern C++ library for sequence analysis.
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
20
#include <
seqan3/alphabet/concept.hpp
>
21
#include <
seqan3/io/sam_file/detail/cigar.hpp
>
22
#include <
seqan3/utility/views/type_reduce.hpp
>
23
24
namespace
seqan3
25
{
26
32
template
<std::ranges::forward_range ref_
id
s_type = std::deque<std::
string
>>
33
class
sam_file_header
34
{
35
public
:
40
sam_file_header
() =
default
;
42
sam_file_header
(
sam_file_header
const
&) =
default
;
44
sam_file_header
&
operator=
(
sam_file_header
const
&) =
default
;
46
sam_file_header
(
sam_file_header
&&) =
default
;
48
sam_file_header
&
operator=
(
sam_file_header
&&) =
default
;
50
~sam_file_header
() =
default
;
51
55
sam_file_header
(ref_ids_type &
ref_ids
) :
ref_ids_ptr
{&
ref_ids
,
ref_ids_deleter_noop
}
56
{}
57
61
sam_file_header
(ref_ids_type &&
ref_ids
) :
62
ref_ids_ptr
{new ref_ids_type{
std
::move(
ref_ids
)},
ref_ids_deleter_default
}
63
{}
65
67
struct
program_info_t
68
{
69
std::string
id
;
70
std::string
name
;
71
std::string
command_line_call
;
72
std::string
previous
;
73
std::string
description
;
74
std::string
version
;
75
};
76
77
std::string
format_version
;
78
std::string
sorting
;
79
std::string
80
subsorting
;
81
std::string
grouping
;
82
83
std::vector<program_info_t>
program_infos
;
84
85
std::vector<std::string>
comments
;
86
87
private
:
89
using
ref_ids_ptr_t
=
std::unique_ptr
<ref_ids_type,
std::function
<void(ref_ids_type *)>>;
91
static
void
ref_ids_deleter_noop
(ref_ids_type *)
92
{}
94
static
void
ref_ids_deleter_default
(ref_ids_type * ptr)
95
{
96
delete
ptr;
97
}
99
using
key_type
=
std::conditional_t<std::ranges::contiguous_range<std::ranges::range_reference_t<ref_ids_type>
>,
100
std::span<range_innermost_value_t<ref_ids_type>
const
>,
101
type_reduce_t<std::ranges::range_reference_t<ref_ids_type>
>>;
103
ref_ids_ptr_t
ref_ids_ptr
{
new
ref_ids_type{},
ref_ids_deleter_default
};
104
106
struct
key_hasher
107
{
109
template
<
typename
key_t>
110
size_t
operator()
(key_t && key)
const
noexcept
111
{
112
using
char_t = std::ranges::range_value_t<key_t>;
113
size_t
result{0};
114
std::hash<char_t>
h{};
115
for
(char_t character : key)
116
{
117
result *= 0x8F3F73B5CF1C9ADE;
118
result += h(character);
119
}
120
return
result;
121
}
122
};
123
124
public
:
143
ref_ids_type &
ref_ids
()
144
{
145
return
*
ref_ids_ptr
;
146
}
147
179
std::vector<std::tuple<int32_t, std::string>
>
ref_id_info
{};
180
182
std::unordered_map<key_type, int32_t, key_hasher, detail::view_equality_fn>
ref_dict
{};
183
218
std::vector<std::pair<std::string, std::string>
>
read_groups
;
219
};
220
221
}
// namespace seqan3
concept.hpp
Core alphabet concept and free function/type trait wrappers.
std::string
seqan3::sam_file_header
Stores the header information of alignment files.
Definition:
header.hpp:34
seqan3::sam_file_header::sam_file_header
sam_file_header(sam_file_header const &)=default
Copy construction is defaulted.
seqan3::sam_file_header::sam_file_header
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:55
seqan3::sam_file_header::read_groups
std::vector< std::pair< std::string, std::string > > read_groups
The Read Group Dictionary (used by the SAM/BAM format).
Definition:
header.hpp:218
seqan3::sam_file_header::sorting
std::string sorting
The sorting of the file. SAM: [unknown, unsorted, queryname, coordinate].
Definition:
header.hpp:78
seqan3::sam_file_header::ref_ids_ptr
ref_ids_ptr_t ref_ids_ptr
The pointer to reference ids information (non-owning if reference information is given).
Definition:
header.hpp:103
seqan3::sam_file_header::operator=
sam_file_header & operator=(sam_file_header const &)=default
Copy assignment is defaulted.
seqan3::sam_file_header::ref_ids
ref_ids_type & ref_ids()
The range of reference ids.
Definition:
header.hpp:143
seqan3::sam_file_header::ref_ids_deleter_noop
static void ref_ids_deleter_noop(ref_ids_type *)
Stream deleter that does nothing (no ownership assumed).
Definition:
header.hpp:91
seqan3::sam_file_header::sam_file_header
sam_file_header(sam_file_header &&)=default
Move construction is defaulted.
seqan3::sam_file_header::ref_dict
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:182
seqan3::sam_file_header::ref_id_info
std::vector< std::tuple< int32_t, std::string > > ref_id_info
The reference information. (used by the SAM/BAM format)
Definition:
header.hpp:179
seqan3::sam_file_header::format_version
std::string format_version
The file format version. Note: this is overwritten by our formats on output.
Definition:
header.hpp:77
seqan3::sam_file_header::~sam_file_header
~sam_file_header()=default
Destructor is defaulted.
seqan3::sam_file_header::comments
std::vector< std::string > comments
The list of comments.
Definition:
header.hpp:85
seqan3::sam_file_header::ref_ids_deleter_default
static void ref_ids_deleter_default(ref_ids_type *ptr)
Stream deleter with default behaviour (ownership assumed).
Definition:
header.hpp:94
seqan3::sam_file_header::sam_file_header
sam_file_header()=default
Default constructor is defaulted.
seqan3::sam_file_header::grouping
std::string grouping
The grouping of the file. SAM: [none, query, reference].
Definition:
header.hpp:81
seqan3::sam_file_header::subsorting
std::string subsorting
The sub-sorting of the file. SAM: [unknown, unsorted, queryname, coordinate](:[A-Za-z0-9_-]+)+.
Definition:
header.hpp:80
seqan3::sam_file_header::sam_file_header
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:61
seqan3::sam_file_header::operator=
sam_file_header & operator=(sam_file_header &&)=default
Move assignment is defaulted.
seqan3::sam_file_header::program_infos
std::vector< program_info_t > program_infos
The list of program information.
Definition:
header.hpp:83
std::conditional_t
deque
std::function
std::hash
cigar.hpp
Auxiliary functions for the alignment IO.
seqan3
The main SeqAn3 namespace.
Definition:
aligned_sequence_concept.hpp:29
seqan3::type_reduce_t
decltype(views::type_reduce(std::declval< t >())) type_reduce_t
Deduces the return value of seqan3::views::type_reduce.
Definition:
type_reduce.hpp:162
std
SeqAn specific customisations in the standard namespace.
ranges
std::span
seqan3::sam_file_header::key_hasher
Custom hash function since std::hash is not defined for all range types (e.g. std::span<char>).
Definition:
header.hpp:107
seqan3::sam_file_header::key_hasher::operator()
size_t operator()(key_t &&key) const noexcept
Hash a key.
Definition:
header.hpp:110
seqan3::sam_file_header::program_info_t
Stores information of the program/tool that was used to create the file.
Definition:
header.hpp:68
seqan3::sam_file_header::program_info_t::name
std::string name
The official name.
Definition:
header.hpp:70
seqan3::sam_file_header::program_info_t::version
std::string version
The program/tool version.
Definition:
header.hpp:74
seqan3::sam_file_header::program_info_t::previous
std::string previous
The id of the previous program if program calls were chained.
Definition:
header.hpp:72
seqan3::sam_file_header::program_info_t::command_line_call
std::string command_line_call
The command line call that produces the file.
Definition:
header.hpp:71
seqan3::sam_file_header::program_info_t::description
std::string description
A description of the program and/or program call.
Definition:
header.hpp:73
seqan3::sam_file_header::program_info_t::id
std::string id
A unique (file scope) id.
Definition:
header.hpp:69
type_reduce.hpp
Provides seqan3::views::type_reduce.
std::unique_ptr
unordered_map
vector
seqan3
io
sam_file
header.hpp
Generated on Tue Oct 18 2022 12:40:59 for SeqAn3 by
1.9.4