Loading...
Searching...
No Matches
seqan3::record< field_types, field_ids > Struct Template Reference
IO

The class template that file records are based on; behaves like a std::tuple. More...

`#include <seqan3/io/record.hpp>`

Inheritance diagram for seqan3::record< field_types, field_ids >:
[legend]

## Public Types

using | base_type = detail::transfer_template_args_onto_t<field_types, std::tuple>
| A specialisation of std::tuple.

## Public Member Functions

void | clear () noexcept(noexcept(std::apply(expander, std::declval< record & >().as_base())))
| Clears containers that provide .clear() and (re-)initialises all other elements with = {}.
Constructors, destructor and assignment
| record ()=default
| Defaulted.
| record (record const &)=default
| Defaulted.
record & | operator= (record const &)=default
| Defaulted.
| record (record &&)=default
| Defaulted.
record & | operator= (record &&)=default
| Defaulted.
| ~record ()=default
| Defaulted.

## Additional Inherited Members

Related Symbols inherited from tuple_like
size_t | tuple_size_v
| A unary type trait that holds the number of elements in the tuple.
| tuple_elment_t
| A transformation trait that holds the type of elements in the tuple.
auto && | get (type &&val)
| Return the i-th element of the tuple.

## Detailed Description

template<typename field_types, typename field_ids>
struct seqan3::record< field_types, field_ids >

The class template that file records are based on; behaves like a std::tuple.

Template Parameters

  field_types | The types of the fields in this record as a seqan3::type_list.
  field_ids | A seqan3::fields type with seqan3::field IDs corresponding to field_types.

This class template behaves just like a std::tuple, with the exception that it provides an additional get-interface that takes a seqan3::field identifier. The traditional get interfaces (via index and via type) are also supported, but discouraged, because accessing via seqan3::field is unambiguous and better readable.

### Example

For input files this template is specialised automatically and provided by the file via its record_type member. For output files you my define it locally and pass instances of this to the output file's push_back().

This is how it works:

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <string>
#include <vector>
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/io/record.hpp>
#include <seqan3/utility/type_list/type_list.hpp>
int main()
{
using namespace seqan3::literals;
// The order of the types below represent a mapping between the type and the key.
using types = seqan3::type_list<seqan3::dna4_vector, std::string, std::vector<seqan3::phred42>>;
using types_as_ids = seqan3::fields<seqan3::field::seq, seqan3::field::id, seqan3::field::qual>;
using record_type = seqan3::record<types, types_as_ids>;
// record_type now mimics std::tuple<std::string, dna4_vector, std::vector<phred42>>,
// the order also depends on selected_ids
record_type my_record{};
std::get<1>(my_record) = "the most important sequence in the database"; // access via index
std::get<std::string>(my_record) = "the least important sequence in the database"; // access via type
}
dna4.hpp
Provides seqan3::dna4, container aliases and string literals.
seqan3::literals
The SeqAn namespace for literals.
phred42.hpp
Provides seqan3::phred42 quality scores.
record.hpp
Provides the seqan3::record template and the seqan3::field enum.
string
seqan3::fields
A class template that holds a choice of seqan3::field.
Definition record.hpp:125
seqan3::record
The class template that file records are based on; behaves like a std::tuple.
Definition record.hpp:190
seqan3::type_list
Type that contains multiple types.
Definition type_list.hpp:26
type_list.hpp
Provides seqan3::type_list.
vector

The documentation for this struct was generated from the following file:

- record.hpp

Hide me