Loading...
Searching...
No Matches
header.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <deque>
#include <ranges>
#include <unordered_map>
#include <vector>
#include <seqan3/alphabet/concept.hpp>
#include <seqan3/io/sam_file/detail/cigar.hpp>
#include <seqan3/utility/views/type_reduce.hpp>
namespace seqan3
{
struct sam_file_program_info_t
{
std::string id;
std::string name;
std::string command_line_call;
std::string previous;
std::string description;
std::string version;
std::string user_tags;
};
template <std::ranges::forward_range ref_ids_type = std::deque<std::string>>
class sam_file_header
{
public:
sam_file_header() = default;
sam_file_header(sam_file_header const &) = default;
sam_file_header & operator=(sam_file_header const &) = default;
sam_file_header(sam_file_header &&) = default;
sam_file_header & operator=(sam_file_header &&) = default;
~sam_file_header() = default;
sam_file_header(ref_ids_type ref_ids) : reference_ids{std::move(ref_ids)}
{}
using program_info_t =
sam_file_program_info_t;
std::string format_version;
std::string sorting;
std::string
subsorting;
std::string grouping;
std::vector<program_info_t> program_infos;
std::vector<std::string> comments;
private:
using key_type = std::conditional_t<std::ranges::contiguous_range<std::ranges::range_reference_t<ref_ids_type>>,
std::span<range_innermost_value_t<ref_ids_type> const>,
type_reduce_t<std::ranges::range_reference_t<ref_ids_type>>>;
ref_ids_type reference_ids{};
struct key_hasher
{
template <typename key_t>
size_t operator()(key_t && key) const noexcept
{
using char_t = std::ranges::range_value_t<key_t>;
size_t result{0};
std::hash<char_t> h{};
for (char_t character : key)
{
result *= 0x8F'3F'73'B5'CF'1C'9A'DE;
result += h(character);
}
return result;
}
};
public:
ref_ids_type & ref_ids()
{
return reference_ids;
}
std::vector<std::tuple<int32_t, std::string>> ref_id_info{};
std::unordered_map<key_type, int32_t, key_hasher, detail::view_equality_fn> ref_dict{};
std::vector<std::pair<std::string, std::string>> read_groups;
std::string user_tags;
};
} // namespace seqan3
concept.hpp
Core alphabet concept and free function/type trait wrappers.
std::string
seqan3::sam_file_header::sam_file_header
sam_file_header(sam_file_header const &)=default
Defaulted.
seqan3::sam_file_header::program_info_t
sam_file_program_info_t program_info_t
Stores information of the program/tool that was used to create the file.
Definition header.hpp:66
seqan3::sam_file_header< typename traits_type::ref_ids >::read_groups
std::vector< std::pair< std::string, std::string > > read_groups
Definition header.hpp:199
seqan3::sam_file_header< typename traits_type::ref_ids >::sorting
std::string sorting
Definition header.hpp:69
seqan3::sam_file_header::operator=
sam_file_header & operator=(sam_file_header const &)=default
Defaulted.
seqan3::sam_file_header< typename traits_type::ref_ids >::ref_ids
ref_ids_type & ref_ids()
Definition header.hpp:124
seqan3::sam_file_header::sam_file_header
sam_file_header(sam_file_header &&)=default
Defaulted.
seqan3::sam_file_header< typename traits_type::ref_ids >::user_tags
std::string user_tags
Definition header.hpp:201
seqan3::sam_file_header< typename traits_type::ref_ids >::ref_dict
std::unordered_map< key_type, int32_t, key_hasher, detail::view_equality_fn > ref_dict
Definition header.hpp:163
seqan3::sam_file_header< typename traits_type::ref_ids >::ref_id_info
std::vector< std::tuple< int32_t, std::string > > ref_id_info
Definition header.hpp:160
seqan3::sam_file_header< typename traits_type::ref_ids >::format_version
std::string format_version
Definition header.hpp:68
seqan3::sam_file_header::~sam_file_header
~sam_file_header()=default
Defaulted.
seqan3::sam_file_header< typename traits_type::ref_ids >::comments
std::vector< std::string > comments
Definition header.hpp:76
seqan3::sam_file_header::sam_file_header
sam_file_header(ref_ids_type ref_ids)
Construct from a range of reference ids.
Definition header.hpp:62
seqan3::sam_file_header::sam_file_header
sam_file_header()=default
Defaulted.
seqan3::sam_file_header< typename traits_type::ref_ids >::grouping
std::string grouping
Definition header.hpp:72
seqan3::sam_file_header< typename traits_type::ref_ids >::subsorting
std::string subsorting
Definition header.hpp:71
seqan3::sam_file_header::operator=
sam_file_header & operator=(sam_file_header &&)=default
Defaulted.
seqan3::sam_file_header< typename traits_type::ref_ids >::program_infos
std::vector< program_info_t > program_infos
Definition header.hpp:74
std::conditional_t
deque
std::hash
cigar.hpp
Auxiliary functions for the SAM IO.
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
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:159
std
SeqAn specific customisations in the standard namespace.
seqan3::sam_file_program_info_t
Stores information of the program/tool that was used to create a SAM/BAM file.
Definition header.hpp:30
seqan3::sam_file_program_info_t::description
std::string description
A description of the program and/or program call.
Definition header.hpp:35
seqan3::sam_file_program_info_t::command_line_call
std::string command_line_call
The command line call that produces the file.
Definition header.hpp:33
seqan3::sam_file_program_info_t::previous
std::string previous
The id of the previous program if program calls were chained.
Definition header.hpp:34
seqan3::sam_file_program_info_t::name
std::string name
The official name.
Definition header.hpp:32
seqan3::sam_file_program_info_t::user_tags
std::string user_tags
Additional user-defined tags.
Definition header.hpp:37
seqan3::sam_file_program_info_t::id
std::string id
A unique (file scope) id.
Definition header.hpp:31
seqan3::sam_file_program_info_t::version
std::string version
The program/tool version.
Definition header.hpp:36
type_reduce.hpp
Provides seqan3::views::type_reduce.
unordered_map
vector
Hide me