Loading...
Searching...
No Matches
sam_file/input_format_concept.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 <fstream>
#include <optional>
#include <string>
#include <vector>
#include <seqan3/alphabet/cigar/cigar.hpp>
#include <seqan3/alphabet/gap/gapped.hpp>
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/alphabet/nucleotide/dna5.hpp>
#include <seqan3/alphabet/quality/aliases.hpp>
#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/io/sam_file/header.hpp>
#include <seqan3/io/sam_file/input_options.hpp>
#include <seqan3/io/sam_file/sam_flag.hpp>
#include <seqan3/io/sam_file/sam_tag_dictionary.hpp>
#include <seqan3/utility/type_list/type_list.hpp>
namespace seqan3::detail
{
template <typename format_type>
struct sam_file_input_format_exposer : public format_type
{
public:
// Can't use `using format_type::read_alignment_record` as it produces a hard failure in the format concept check
// for types that do not model the format concept, i.e. don't offer the proper read_alignment_record interface.
template <typename... ts>
void read_alignment_record(ts &&... args)
{
format_type::read_alignment_record(std::forward<ts>(args)...);
}
};
} // namespace seqan3::detail
namespace seqan3
{
template <typename t>
concept sam_file_input_format = requires (detail::sam_file_input_format_exposer<t> & v,
std::ifstream & stream,
sam_file_input_options<dna5> & options,
std::vector<dna5_vector> & ref_sequences,
sam_file_header<> & header,
std::streampos & position_buffer,
dna5_vector & seq,
std::vector<phred42> & qual,
std::string & id,
dna5_vector & ref_seq,
std::optional<int32_t> & ref_id,
std::optional<int32_t> & ref_offset,
std::vector<cigar> & cigar,
sam_flag & flag,
uint8_t & mapq,
std::tuple<std::optional<int32_t>, std::optional<int32_t>, int32_t> & mate,
sam_tag_dictionary & tag_dict,
double & e_value,
double & bit_score) {
t::file_extensions;
// std::same_as<decltype(t::file_extensions), std::vector<std::string>>;
{
v.read_alignment_record(stream,
options,
ref_sequences,
header,
position_buffer,
seq,
qual,
id,
ref_seq,
ref_id,
ref_offset,
cigar,
flag,
mapq,
mate,
tag_dict,
e_value,
bit_score)
};
{
v.read_alignment_record(stream,
options,
std::ignore,
header,
position_buffer,
std::ignore,
std::ignore,
std::ignore,
std::ignore,
std::ignore,
std::ignore,
std::ignore,
std::ignore,
std::ignore,
std::ignore,
std::ignore,
std::ignore,
std::ignore,
std::ignore)
};
};
// Workaround for https://github.com/doxygen/doxygen/issues/9379
#if SEQAN3_DOXYGEN_ONLY(1) 0
template <typename t>
class sam_file_input_format
{};
#endif
} // namespace seqan3
namespace seqan3::detail
{
template <typename t>
constexpr bool is_type_list_of_sam_file_input_formats_v = false;
template <typename... ts>
constexpr bool is_type_list_of_sam_file_input_formats_v<type_list<ts...>> = (sam_file_input_format<ts> && ...);
template <typename t>
concept type_list_of_sam_file_input_formats = is_type_list_of_sam_file_input_formats_v<t>;
} // namespace seqan3::detail
aliases.hpp
Provides aliases for qualified.
cigar.hpp
Provides the seqan3::cigar alphabet.
seqan3::cigar
The seqan3::cigar semialphabet pairs a counter with a seqan3::cigar::operation letter.
Definition alphabet/cigar/cigar.hpp:57
seqan3::sam_file_header
Stores the header information of SAM/BAM files.
Definition header.hpp:47
seqan3::sam_file_input_format
The generic concept for alignment file input formats.
Definition sam_file/input_format_concept.hpp:146
seqan3::sam_tag_dictionary
The SAM tag dictionary class that stores all optional SAM fields.
Definition sam_tag_dictionary.hpp:327
dna4.hpp
Provides seqan3::dna4, container aliases and string literals.
dna5.hpp
Provides seqan3::dna5, container aliases and string literals.
std::forward
T forward(T... args)
fstream
gapped.hpp
Provides seqan3::gapped.
seqan3::sam_flag
sam_flag
An enum flag that describes the properties of an aligned read (given as a SAM record).
Definition sam_flag.hpp:73
seqan3::field::flag
@ flag
The alignment flag (bit information), uint16_t value.
Definition record.hpp:84
seqan3::field::ref_offset
@ ref_offset
Sequence (seqan3::field::ref_seq) relative start position (0-based), unsigned value.
Definition record.hpp:81
seqan3::field::ref_seq
@ ref_seq
The (reference) "sequence" information, usually a range of nucleotides or amino acids.
Definition record.hpp:80
seqan3::field::mapq
@ mapq
The mapping quality of the seqan3::field::seq alignment, usually a Phred-scaled score.
Definition record.hpp:86
seqan3::field::bit_score
@ bit_score
The bit score (statistical significance indicator), unsigned value.
Definition record.hpp:90
seqan3::field::mate
@ mate
The mate pair information given as a std::tuple of reference name, offset and template length.
Definition record.hpp:85
seqan3::field::ref_id
@ ref_id
The identifier of the (reference) sequence that seqan3::field::seq was aligned to.
Definition record.hpp:79
seqan3::field::id
@ id
The identifier, usually a string.
Definition record.hpp:63
seqan3::field::seq
@ seq
The "sequence", usually a range of nucleotides or amino acids.
Definition record.hpp:62
seqan3::field::qual
@ qual
The qualities, usually in Phred score notation.
Definition record.hpp:64
header.hpp
Provides the seqan3::sam_file_header class.
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
optional
phred42.hpp
Provides seqan3::phred42 quality scores.
input_options.hpp
Provides seqan3::sam_file_input_options.
sam_flag.hpp
Provides helper data structures for the seqan3::sam_file_output.
sam_tag_dictionary.hpp
Provides the seqan3::sam_tag_dictionary class and auxiliaries.
string
seqan3::sam_file_input_options
The options type defines various option members that influence the behaviour of all or some formats.
Definition sam_file/input_options.hpp:26
seqan3::type_list
Type that contains multiple types.
Definition type_list.hpp:26
type_list.hpp
Provides seqan3::type_list.
vector
Hide me