Loading...
Searching...
No Matches
seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ > Class Template Reference
IO » Structure File

A class for reading structured sequence files, e.g. Stockholm, Connect, Vienna, ViennaRNA bpp matrix ... More...

`#include <seqan3/io/structure_file/input.hpp>`

## Public Types

using | field_ids
| The subset of seqan3::field IDs that are valid for this file; order corresponds to the types in field_types.
Template arguments
Exposed as member types for public access.
using | traits_type = traits_type_
| A traits type that defines aliases and template for storage of the fields.
using | selected_field_ids = selected_field_ids_
| A seqan3::fields list with the fields selected for the record.
using | valid_formats = valid_formats_
| A seqan3::type_list with the possible formats.
using | stream_char_type = char
| Character type of the stream(s).
Field types and record type
These types are relevant for record/row-based reading; they may be manipulated via the traits_type to achieve different storage behaviour.
using | seq_type = typename traits_type::template seq_container<typename traits_type::seq_alphabet>
| The type of the sequence field (default std::vector of seqan3::rna5).
using | id_type = typename traits_type::template id_container<typename traits_type::id_alphabet>
| The type of the ID field (default std::string).
using | bpp_type
| The type of the base pair probabilies (default std::vector of std::set<std::pair<double, size_t>>).
using | structure_type = typename traits_type::template structure_container<typename traits_type::structure_alphabet>
| The type of the structure field (default std::vector of seqan3::wuss51).
using | structured_seq_type
| The type of the sequence-structure field (default std::vector of structured_rna<rna5, wuss51>).
using | energy_type = typename traits_type::energy_type
| The type of the energy field (default double).
using | react_type = typename traits_type::template react_container<typename traits_type::react_type>
| The type of the reactivity and reactivity error fields (default double).
using | comment_type = typename traits_type::template comment_container<typename traits_type::comment_alphabet>
| The type of the comment field (default double).
using | offset_type = typename traits_type::offset_type
| The type of the offset field (default size_t).
using | field_types
| The previously defined types aggregated in a seqan3::type_list.
using | record_type
| The type of the record, a specialisation of seqan3::record; acts as a tuple of the selected field types.
Range associated types
The types necessary to facilitate the behaviour of an input range (used in record-wise reading).
using | value_type = record_type
| The value_type is the record_type.
using | reference = record_type &
| The reference type.
using | const_reference = void
| The const_reference type is void, because files are not const-iterable.
using | size_type = size_t
| An unsigned integer type, usually std::size_t.
using | difference_type = std::make_signed_t<size_t>
| A signed integer type, usually std::ptrdiff_t.
using | iterator = detail::in_file_iterator<structure_file_input>
| The iterator type of this view (an input iterator).
using | const_iterator = void
| The const iterator type is void, because files are not const-iterable.
using | sentinel = std::default_sentinel_t
| The type returned by end().

## Public Member Functions

Constructors, destructor and assignment
| structure_file_input ()=delete
| Default constructor is explicitly deleted, you need to give a stream or file name.
| structure_file_input (structure_file_input const &)=delete
| Copy construction is explicitly deleted, because you cannot have multiple access to the same file.
structure_file_input & | operator= (structure_file_input const &)=delete
| Copy assignment is explicitly deleted, because you cannot have multiple access to the same file.
| structure_file_input (structure_file_input &&)=default
| Move construction is defaulted.
structure_file_input & | operator= (structure_file_input &&)=default
| Move assignment is defaulted.
| ~structure_file_input ()=default
| Destructor is defaulted.
| structure_file_input (std::filesystem::path filename, selected_field_ids const &fields_tag=selected_field_ids{})
| Construct from filename.
template<input_stream stream_t, structure_file_input_format file_format> requires std::same_as<typename std::remove_reference_t<stream_t>::char_type, char>
| structure_file_input (stream_t &stream, file_format const &format_tag, selected_field_ids const &fields_tag=selected_field_ids{})
| Construct from an existing stream and with specified format.
template<input_stream stream_t, structure_file_input_format file_format> requires std::same_as<typename std::remove_reference_t<stream_t>::char_type, char>
| structure_file_input (stream_t &&stream, file_format const &format_tag, selected_field_ids const &fields_tag=selected_field_ids{})
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Range interface
Provides functions for record based reading of the file.
iterator | begin ()
| Returns an iterator to current position in the file.
sentinel | end () noexcept
| Returns a sentinel for comparison with iterator.
reference | front () noexcept
| Return the record we are currently at in the file.

## Public Attributes

structure_file_input_options< typename traits_type::seq_legal_alphabet, selected_field_ids::contains(field::structured_seq)> | options
| The options are public and its members can be set directly.

## Related Symbols

(Note that these are not member symbols.)
Type deduction guides
template<input_stream stream_type, structure_file_input_format file_format, detail::fields_specialisation selected_field_ids>
| structure_file_input (stream_type &&stream, file_format const &, selected_field_ids const &) -> structure_file_input< typename structure_file_input<>::traits_type, selected_field_ids, type_list< file_format > >
| Deduction of the selected fields, the file format and the stream type.
template<input_stream stream_type, structure_file_input_format file_format, detail::fields_specialisation selected_field_ids>
| structure_file_input (stream_type &stream, file_format const &, selected_field_ids const &) -> structure_file_input< typename structure_file_input<>::traits_type, selected_field_ids, type_list< file_format > >
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## Detailed Description

template<structure_file_input_traits traits_type_ = structure_file_input_default_traits_rna, detail::fields_specialisation selected_field_ids_ = fields<field::seq, field::id, field::structure>, detail::type_list_of_structure_file_input_formats valid_formats_ = type_list<format_vienna>>
class seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ >

A class for reading structured sequence files, e.g. Stockholm, Connect, Vienna, ViennaRNA bpp matrix ...

Template Parameters

  traits_type | An auxiliary type that defines certain member types and constants, must satisfy seqan3::structure_file_input_traits.
  selected_field_ids | A seqan3::fields type with the list and order of desired record entries; all fields must be in seqan3::structure_file_input::field_ids.
  valid_formats | A seqan3::type_list of the selectable formats (each must meet seqan3::structure_file_input_format).

### Reading structure files

Structured sequence files contain intra-molecular interactions of RNA or protein. Usually, but not necessarily, they contain the nucleotide or amino acid sequences and descriptions as well. Interactions can be represented either as fixed secondary structure, where every character is assigned at most one interaction partner (structure of minimum free energy), or an annotated sequence, where every character is assigned a set of interaction partners with specific base pair probabilities.
The structured sequence file abstraction supports reading ten different fields:

1. seqan3::field::seq (sequence)
2. seqan3::field::id (identifier)
3. seqan3::field::bpp (annotated sequence)
4. seqan3::field::structure (secondary structure)
5. seqan3::field::structured_seq (sequence and structure in one range)
6. seqan3::field::energy (minimum free energy)
7. seqan3::field::react (reactivity)
8. seqan3::field::react_err (reactivity error)
9. seqan3::field::comment (free text)
10. seqan3::field::offset (index of first sequence character)

The first three fields are retrieved by default (and in that order). The seqan3::field::structured_seq may be selected to have sequence and structure directly stored in a more memory-efficient combined container. If you select this field you must not select seqan3::field::seq or seqan3::field::structure.

#### Construction and specialisation

This class comes with two constructors, one for construction from a file name and one for construction from an existing stream and a known format. The first one automatically picks the format based on the extension of the file name. The second can be used if you have a non-file stream, like std::cin or std::istringstream, that you want to read from and/or if you cannot use file-extension based detection, but know that your input file has a certain format.
In most cases the template parameters are deduced completely automatically, e.g. reading from a std::istringstream:

// 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 <filesystem>
#include <sstream>
#include <seqan3/alphabet/nucleotide/rna4.hpp>
#include <seqan3/alphabet/structure/wuss.hpp>
#include <seqan3/io/structure_file/input.hpp>
#include <seqan3/io/structure_file/output.hpp>
auto input = R"(> S.cerevisiae_tRNA-PHE M10740/1-73
GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUUUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCA
(((((((..((((........)))).((((.........)))).....(((((.......)))))))))))). (-17.50)
> example
UUGGAGUACACAACCUGUACACUCUUUC
..(((((..(((...)))..)))))... (-3.71))";
int main()
{
auto tmp_file = std::filesystem::temp_directory_path() / "my.dbn";
using namespace seqan3::literals;
// First, make /tmp/input.dbn
{
seqan3::structure_file_output fout{tmp_file};
fout.emplace_back("GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUUUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCA"_rna4,
"S.cerevisiae_tRNA-PHE M10740/1-73",
"(((((((..((((........)))).((((.........)))).....(((((.......))))))))))))."_wuss51);
fout.emplace_back("UUGGAGUACACAACCUGUACACUCUUUC"_rna4, "example", "..(((((..(((...)))..)))))..."_wuss51);
}
seqan3::structure_file_input sf{tmp_file}; // Vienna with RNA sequences assumed, use regular std::ifstream as stream
seqan3::structure_file_input fin{std::istringstream{input}, seqan3::format_vienna{}};
// ^ no need to specify the template arguments
std::filesystem::remove(tmp_file);
}
std::istringstream
seqan3::format_vienna
The Vienna format (dot bracket notation) for RNA sequences with secondary structure.
Definition format_vienna.hpp:83
seqan3::structure_file_input
A class for reading structured sequence files, e.g. Stockholm, Connect, Vienna, ViennaRNA bpp matrix ...
Definition structure_file/input.hpp:358
seqan3::structure_file_output
A class for writing structured sequence files, e.g. Stockholm, Connect, Vienna, ViennaRNA bpp matrix ...
Definition io/structure_file/output.hpp:60
seqan3::structure_file_output::emplace_back
void emplace_back(arg_t &&arg, arg_types &&... args)
Write a record to the file by passing individual fields.
Definition io/structure_file/output.hpp:363
filesystem
output.hpp
Provides seqan3::structure_file_output and corresponding traits classes.
seqan3::literals
The SeqAn namespace for literals.
std::filesystem::remove
T remove(T... args)
rna4.hpp
Provides seqan3::rna4, container aliases and string literals.
sstream
input.hpp
Provides seqan3::structure_file_input and corresponding traits classes.
std::filesystem::temp_directory_path
T temp_directory_path(T... args)
wuss.hpp
Provides the WUSS format for RNA structure.

Note that this is not the same as writing structure_file_input<> (with angle brackets). In the latter case they are explicitly set to their default values, in the former case automatic deduction happens which chooses different parameters depending on the constructor arguments. For opening from file, structure_file_input<> would have also worked, but for opening from stream it would not have.
In some cases, you do need to specify the arguments, e.g. if you want to read amino acids:

// 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 <sstream>
#include <seqan3/io/structure_file/input.hpp>
auto input = R"(> S.cerevisiae_tRNA-PHE M10740/1-73
GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUUUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCA
(((((((..((((........)))).((((.........)))).....(((((.......)))))))))))). (-17.50)
> example
UUGGAGUACACAACCUGUACACUCUUUC
..(((((..(((...)))..)))))... (-3.71))";
int main()
{
seqan3::structure_file_input<seqan3::structure_file_input_default_traits_rna> fin{std::istringstream{input},
seqan3::format_vienna{}};
}

You can define your own traits type to further customise the types used by and returned by this class, see seqan3::structure_file_default_traits_rna for more details. As mentioned above, specifying at least one template parameter yourself means that you loose automatic deduction so if you want to read amino acids and want to read from a string stream you need to give all types yourself:

// 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 <sstream>
#include <seqan3/io/structure_file/input.hpp>
#include <seqan3/utility/type_list/type_list.hpp>
auto input = R"(> S.cerevisiae_tRNA-PHE M10740/1-73
ACEWACEW
HGEBHHHH
> example
ACEWACEWACEWACEW
HGEBHHHHHGEBHHHH)";
int main()
{
// ... input had amino acid sequences
seqan3::structure_file_input<seqan3::structure_file_input_default_traits_aa,
seqan3::fields<seqan3::field::seq, seqan3::field::id, seqan3::field::structure>,
seqan3::type_list<seqan3::format_vienna>>
fin{std::istringstream{input}, seqan3::format_vienna{}};
}
seqan3::fields
A class template that holds a choice of seqan3::field.
Definition record.hpp:125
seqan3::structure_file_input_default_traits_aa
A traits type that specifies input as amino acids.
Definition structure_file/input.hpp:318
seqan3::type_list
Type that contains multiple types.
Definition type_list.hpp:26
type_list.hpp
Provides seqan3::type_list.

#### Reading record-wise

You can iterate over this file record-wise:

// 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 <sstream>
#include <seqan3/alphabet/views/to_char.hpp>
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/io/structure_file/input.hpp>
#include <seqan3/utility/type_list/type_list.hpp>
auto input = R"(> S.cerevisiae_tRNA-PHE M10740/1-73
ACEWACEW
HGEBHHHH
> example
ACEWACEWACEWACEW
HGEBHHHHHGEBHHHH)";
int main()
{
using structure_file_input_t =
seqan3::structure_file_input<seqan3::structure_file_input_default_traits_aa,
seqan3::fields<seqan3::field::seq, seqan3::field::id, seqan3::field::structure>,
seqan3::type_list<seqan3::format_vienna>>;
structure_file_input_t fin{std::istringstream{input}, seqan3::format_vienna{}};
for (auto & rec : fin)
{
seqan3::debug_stream << "ID: " << rec.id() << '\n';
// sequence and structure are converted to char on-the-fly
seqan3::debug_stream << "SEQ: " << (rec.sequence() | seqan3::views::to_char) << '\n';
seqan3::debug_stream << "STRUCTURE: " << (rec.sequence_structure() | seqan3::views::to_char) << '\n';
}
}
debug_stream.hpp
Provides seqan3::debug_stream and related types.
seqan3::views::to_char
auto const to_char
A view that calls seqan3::to_char() on each element in the input range.
Definition to_char.hpp:60
seqan3::debug_stream
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:38
to_char.hpp
Provides seqan3::views::to_char.

In the above example, rec has the type seqan3::structure_file_input::record_type which is a specialisation of seqan3::record and behaves like a std::tuple (that's why we can access it via get). Instead of using the seqan3::field based interface on the record, you could also use std::get<0> or even std::get<rna4_vector> to retrieve the sequence, but it is not recommended, because it is more error-prone.
Note: It is important to write auto & and not just auto, otherwise you will copy the record on every iteration. Since the buffer gets "refilled" on every iteration, you can also move the data out of the record if you want to store it somewhere without copying:

// 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 <sstream>
#include <utility>
#include <vector>
#include <seqan3/io/structure_file/input.hpp>
auto input = R"(> S.cerevisiae_tRNA-PHE M10740/1-73
GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUUUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCA
(((((((..((((........)))).((((.........)))).....(((((.......)))))))))))). (-17.50)
> example
UUGGAGUACACAACCUGUACACUCUUUC
..(((((..(((...)))..)))))... (-3.71))";
int main()
{
seqan3::structure_file_input fin{std::istringstream{input}, seqan3::format_vienna{}};
using record_type = typename decltype(fin)::record_type;
std::vector<record_type> records;
for (auto & rec : fin)
records.push_back(std::move(rec));
}
std::vector::push_back
T push_back(T... args)
utility
vector

#### Reading record-wise (decomposed records)

Instead of using get on the record, you can also use structured bindings to decompose the record into its elements:

// 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 <sstream>
#include <seqan3/alphabet/views/to_char.hpp>
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/io/structure_file/input.hpp>
#include <seqan3/utility/type_list/type_list.hpp>
auto input = R"(> S.cerevisiae_tRNA-PHE M10740/1-73
ACEWACEW
HGEBHHHH
> example
ACEWACEWACEWACEW
HGEBHHHHHGEBHHHH)";
int main()
{
using seqan3::get;
using structure_file_input_t =
seqan3::structure_file_input<seqan3::structure_file_input_default_traits_aa,
seqan3::fields<seqan3::field::seq, seqan3::field::id, seqan3::field::structure>,
seqan3::type_list<seqan3::format_vienna>>;
structure_file_input_t fin{std::istringstream{input}, seqan3::format_vienna{}};
for (auto & [seq, id, structure] : fin)
{
seqan3::debug_stream << "ID: " << id << '\n';
// sequence and structure are converted to char on-the-fly
seqan3::debug_stream << "SEQ: " << (seq | seqan3::views::to_char) << '\n';
seqan3::debug_stream << "STRUCTURE: " << (structure | seqan3::views::to_char) << '\n';
}
}
seqan3::field::structure
@ structure
Fixed interactions, usually a string of structure alphabet characters.
Definition record.hpp:70
seqan3::field::seq
@ seq
The "sequence", usually a range of nucleotides or amino acids.
Definition record.hpp:62
seqan3::get
constexpr auto const & get(configuration< configs_t... > const &config) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition configuration.hpp:412

In this case you immediately get the three elements of the tuple: seq of seqan3::structure_file_input::seq_type, id of seqan3::structure_file_input::id_type and structure of seqan3::structure_file_input::structure_type. But beware: with structured bindings you do need to get the order of elements correctly!

#### Reading record-wise (custom fields)

If you want to skip specific fields from the record you can pass a non-empty fields trait object to the structure_file_input constructor to select the fields that should be read from the input. For example to choose a combined field for SEQ and STRUCTURE (see above). Or to never actually read the STRUCTURE, if you don't need it. The following snippets demonstrate the usage of such a fields trait object.

// 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 <sstream>
#include <seqan3/alphabet/views/to_char.hpp>
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/io/structure_file/input.hpp>
#include <seqan3/utility/views/elements.hpp>
auto input = R"(> S.cerevisiae_tRNA-PHE M10740/1-73
GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUUUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCA
(((((((..((((........)))).((((.........)))).....(((((.......)))))))))))). (-17.50)
> example
UUGGAGUACACAACCUGUACACUCUUUC
..(((((..(((...)))..)))))... (-3.71))";
int main()
{
using seqan3::get;
seqan3::structure_file_input fin{std::istringstream{input},
seqan3::format_vienna{},
seqan3::fields<seqan3::field::id, seqan3::field::structured_seq>{}};
// note that the order is now different, "id" comes first, because it was specified first
for (auto & [id, struc_seq] : fin)
{
seqan3::debug_stream << "ID: " << id << '\n';
// sequence and structure are part of the same vector, of type std::vector<structured_rna<rna5, wuss51>>
// sequence and structure strings are extracted and converted to char on-the-fly
seqan3::debug_stream << "SEQ: " << (struc_seq | seqan3::views::elements<0> | seqan3::views::to_char) << '\n';
seqan3::debug_stream << "STRUCTURE: " << (struc_seq | seqan3::views::elements<1> | seqan3::views::to_char)
<< '\n';
}
}
elements.hpp
Provides seqan3::views::elements.
seqan3::views::elements
constexpr auto elements
A view calling get on each element in a range.
Definition elements.hpp:77

When reading a file, all fields not present in the file (but requested implicitly or via the selected_field_ids parameter) are ignored.

#### Views on files

Since SeqAn files are ranges, you can also create views over files. A useful example is to filter the records based on certain criteria, e.g. minimum length of the sequence field:

// 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 <ranges>
#include <sstream>
#include <seqan3/alphabet/views/to_char.hpp>
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/io/structure_file/input.hpp>
auto input = R"(> S.cerevisiae_tRNA-PHE M10740/1-73
GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUUUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCA
(((((((..((((........)))).((((.........)))).....(((((.......)))))))))))). (-17.50)
> example
UUGGAGUACACAACCUGUACACUCUUUC
..(((((..(((...)))..)))))... (-3.71))";
int main()
{
seqan3::structure_file_input fin{std::istringstream{input}, seqan3::format_vienna{}};
auto minimum_length5_filter = std::views::filter(
[](auto const & rec)
{
return std::ranges::size(rec.sequence()) >= 5;
});
for (auto & rec : fin | minimum_length5_filter) // only record with sequence length >= 5 will "appear"
seqan3::debug_stream << (rec.sequence() | seqan3::views::to_char) << '\n';
}

#### End of file

You can check whether a file is at end by comparing begin() and end() (if they are the same, the file is at end).

#### Formats

Currently, the only implemented format is seqan3::format_vienna. More formats will follow soon.

Remarks
  For a complete overview, take a look at Structure File

## Member Typedef Documentation

## bpp_type

template<structure_file_input_traits traits_type_ = structure_file_input_default_traits_rna, detail::fields_specialisation selected_field_ids_ = fields<field::seq, field::id, field::structure>, detail::type_list_of_structure_file_input_formats valid_formats_ = type_list<format_vienna>>

using seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ >::bpp_type

Initial value:
typename traits_type::template bpp_container<typename traits_type::template bpp_queue<
typename traits_type::template bpp_item<typename traits_type::bpp_prob, typename traits_type::bpp_partner>>>

The type of the base pair probabilies (default std::vector of std::set<std::pair<double, size_t>>).

## field_ids

template<structure_file_input_traits traits_type_ = structure_file_input_default_traits_rna, detail::fields_specialisation selected_field_ids_ = fields<field::seq, field::id, field::structure>, detail::type_list_of_structure_file_input_formats valid_formats_ = type_list<format_vienna>>

using seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ >::field_ids

Initial value:
fields<field::seq,
field::id,
field::bpp,
field::structure,
field::structured_seq,
field::energy,
field::react,
field::react_err,
field::comment,
field::offset>
seqan3::field::energy
@ energy
Energy of a folded sequence, represented by one float number.
Definition record.hpp:72
seqan3::field::comment
@ comment
Comment field of arbitrary content, usually a string.
Definition record.hpp:75
seqan3::field::bpp
@ bpp
Base pair probability matrix of interactions, usually a matrix of float numbers.
Definition record.hpp:69
seqan3::field::react
@ react
Reactivity values of the sequence characters given in a vector of float numbers.
Definition record.hpp:73
seqan3::field::react_err
@ react_err
Reactivity error values given in a vector corresponding to seqan3::field::react.
Definition record.hpp:74
seqan3::field::offset
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
Definition record.hpp:66
seqan3::field::structured_seq
@ structured_seq
Sequence and fixed interactions combined in one range.
Definition record.hpp:71
seqan3::field::id
@ id
The identifier, usually a string.
Definition record.hpp:63

The subset of seqan3::field IDs that are valid for this file; order corresponds to the types in field_types.

## field_types

template<structure_file_input_traits traits_type_ = structure_file_input_default_traits_rna, detail::fields_specialisation selected_field_ids_ = fields<field::seq, field::id, field::structure>, detail::type_list_of_structure_file_input_formats valid_formats_ = type_list<format_vienna>>

using seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ >::field_types

Initial value:
type_list<seq_type,
id_type,
bpp_type,
structure_type,
structured_seq_type,
energy_type,
react_type,
react_type,
comment_type,
offset_type>
seqan3::sam_file_input::id_type
typename traits_type::template id_container< char > id_type
The type of field::id (default std::string by default).
Definition sam_file/input.hpp:275
seqan3::structure_file_input::structured_seq_type
typename traits_type::template structured_seq_container< typename traits_type::template structured_seq_alphabet< typename traits_type::seq_alphabet, typename traits_type::structure_alphabet > > structured_seq_type
The type of the sequence-structure field (default std::vector of structured_rna<rna5,...
Definition structure_file/input.hpp:423
seqan3::structure_file_input::bpp_type
typename traits_type::template bpp_container< typename traits_type::template bpp_queue< typename traits_type::template bpp_item< typename traits_type::bpp_prob, typename traits_type::bpp_partner > > > bpp_type
The type of the base pair probabilies (default std::vector of std::set<std::pair<double,...
Definition structure_file/input.hpp:418
seqan3::structure_file_input::seq_type
typename traits_type::template seq_container< typename traits_type::seq_alphabet > seq_type
The type of the sequence field (default std::vector of seqan3::rna5).
Definition structure_file/input.hpp:414
seqan3::structure_file_input::comment_type
typename traits_type::template comment_container< typename traits_type::comment_alphabet > comment_type
The type of the comment field (default double).
Definition structure_file/input.hpp:431
seqan3::structure_file_input::structure_type
typename traits_type::template structure_container< typename traits_type::structure_alphabet > structure_type
The type of the structure field (default std::vector of seqan3::wuss51).
Definition structure_file/input.hpp:421
seqan3::structure_file_input::energy_type
typename traits_type::energy_type energy_type
The type of the energy field (default double).
Definition structure_file/input.hpp:427
seqan3::structure_file_input::offset_type
typename traits_type::offset_type offset_type
The type of the offset field (default size_t).
Definition structure_file/input.hpp:433
seqan3::structure_file_input::react_type
typename traits_type::template react_container< typename traits_type::react_type > react_type
The type of the reactivity and reactivity error fields (default double).
Definition structure_file/input.hpp:429

The previously defined types aggregated in a seqan3::type_list.

## record_type

template<structure_file_input_traits traits_type_ = structure_file_input_default_traits_rna, detail::fields_specialisation selected_field_ids_ = fields<field::seq, field::id, field::structure>, detail::type_list_of_structure_file_input_formats valid_formats_ = type_list<format_vienna>>

using seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ >::record_type

Initial value:
structure_record<detail::select_types_with_ids_t<field_types, field_ids, selected_field_ids>,
selected_field_ids>
seqan3::sam_file_input::selected_field_ids
selected_field_ids_ selected_field_ids
A seqan3::fields list with the fields selected for the record.
Definition sam_file/input.hpp:245
seqan3::structure_record
The record type of seqan3::structure_file_input.
Definition structure_file/record.hpp:26

The type of the record, a specialisation of seqan3::record; acts as a tuple of the selected field types.

## structured_seq_type

template<structure_file_input_traits traits_type_ = structure_file_input_default_traits_rna, detail::fields_specialisation selected_field_ids_ = fields<field::seq, field::id, field::structure>, detail::type_list_of_structure_file_input_formats valid_formats_ = type_list<format_vienna>>

using seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ >::structured_seq_type

Initial value:
typename traits_type::template structured_seq_container<
typename traits_type::template structured_seq_alphabet<typename traits_type::seq_alphabet,
typename traits_type::structure_alphabet>>

The type of the sequence-structure field (default std::vector of structured_rna<rna5, wuss51>).

## Constructor & Destructor Documentation

## structure_file_input() [1/2]

template<structure_file_input_traits traits_type_ = structure_file_input_default_traits_rna, detail::fields_specialisation selected_field_ids_ = fields<field::seq, field::id, field::structure>, detail::type_list_of_structure_file_input_formats valid_formats_ = type_list<format_vienna>>

seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ >::structure_file_input | ( | std::filesystem::path | filename,
|  | selected_field_ids const & | fields_tag = selected_field_ids{} )

inline

Construct from filename.

Parameters

  [in] | filename | Path to the file you wish to open.
  [in] | fields_tag | A seqan3::fields tag. [optional]

Exceptions

  seqan3::file_open_error | if the file could not be opened, e.g. non-existent, non-readable, unknown format.

In addition to the file name, you may specify a custom seqan3::fields type which may be easier than defining all the template parameters.

### Decompression

This constructor transparently applies a decompression stream on top of the file stream in case the file is detected as being compressed. See the section on compression and decompression for more information.

## structure_file_input() [2/2]

template<structure_file_input_traits traits_type_ = structure_file_input_default_traits_rna, detail::fields_specialisation selected_field_ids_ = fields<field::seq, field::id, field::structure>, detail::type_list_of_structure_file_input_formats valid_formats_ = type_list<format_vienna>>
template<input_stream stream_t, structure_file_input_format file_format>
requires std::same_as<typename std::remove_reference_t<stream_t>::char_type, char>

seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ >::structure_file_input | ( | stream_t & | stream,
|  | file_format const & | format_tag,
|  | selected_field_ids const & | fields_tag = selected_field_ids{} )

inline

Construct from an existing stream and with specified format.

Template Parameters

  file_format | The format of the file in the stream, must satisfy seqan3::structure_file_input_format.

Parameters

  [in] | stream | The stream to operate on; must be derived of std::basic_istream.
  [in] | format_tag | The file format tag.
  [in] | fields_tag | A seqan3::fields tag. [optional]

### Decompression

This constructor transparently applies a decompression stream on top of the stream in case the file is detected as being compressed. See the section on compression and decompression for more information.

## Member Function Documentation

## begin()

template<structure_file_input_traits traits_type_ = structure_file_input_default_traits_rna, detail::fields_specialisation selected_field_ids_ = fields<field::seq, field::id, field::structure>, detail::type_list_of_structure_file_input_formats valid_formats_ = type_list<format_vienna>>

iterator seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ >::begin | ( |  | ) |

inline

Returns an iterator to current position in the file.

Returns
  An iterator pointing to the current position in the file.

Exceptions

  seqan3::format_error |

Equals end() if the file is at end.

### Complexity

Constant.

### Exceptions

Throws seqan3::format_error if the first record could not be read into the buffer.

## end()

template<structure_file_input_traits traits_type_ = structure_file_input_default_traits_rna, detail::fields_specialisation selected_field_ids_ = fields<field::seq, field::id, field::structure>, detail::type_list_of_structure_file_input_formats valid_formats_ = type_list<format_vienna>>

sentinel seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ >::end | ( |  | ) |

inline noexcept

Returns a sentinel for comparison with iterator.

Returns
  Iterator to the first element.

This element acts as a placeholder; attempting to dereference it results in undefined behaviour.

### Complexity

Constant.

### Exceptions

No-throw guarantee.

## front()

template<structure_file_input_traits traits_type_ = structure_file_input_default_traits_rna, detail::fields_specialisation selected_field_ids_ = fields<field::seq, field::id, field::structure>, detail::type_list_of_structure_file_input_formats valid_formats_ = type_list<format_vienna>>

reference seqan3::structure_file_input< traits_type_, selected_field_ids_, valid_formats_ >::front | ( |  | ) |

inline noexcept

Return the record we are currently at in the file.

Returns
  A reference to the currently buffered record.

This function returns a reference to the currently buffered record, it is identical to dereferencing begin(), but begin also always points to the current record on single pass input ranges:

// 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 <sstream>
#include <seqan3/io/structure_file/input.hpp>
auto input = R"(> S.cerevisiae_tRNA-PHE M10740/1-73
GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUUUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCA
(((((((..((((........)))).((((.........)))).....(((((.......)))))))))))). (-17.50)
> example
UUGGAGUACACAACCUGUACACUCUUUC
..(((((..(((...)))..)))))... (-3.71))";
int main()
{
seqan3::structure_file_input fin{std::istringstream{input}, seqan3::format_vienna{}};
auto it = std::ranges::begin(fin);
// the following are equivalent:
auto & rec0 = *it;
auto & rec1 = fin.front();
std::cout << std::boolalpha << (rec0.id() == rec1.id()) << '\n'; // true
// both become invalid after incrementing "it"!
}
std::boolalpha
T boolalpha(T... args)
seqan3::structure_file_input::front
reference front() noexcept
Return the record we are currently at in the file.
Definition structure_file/input.hpp:642
std::cout

It most situations using the iterator interface or a range-based for-loop are preferable to using front(), because you can only move to the next record via the iterator.

In any case, don't forget the reference! If you want to save the data from the record elsewhere, use move:

// 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 <sstream>
#include <utility>
#include <seqan3/io/structure_file/input.hpp>
auto input = R"(> S.cerevisiae_tRNA-PHE M10740/1-73
GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUUUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCA
(((((((..((((........)))).((((.........)))).....(((((.......)))))))))))). (-17.50)
> example
UUGGAGUACACAACCUGUACACUCUUUC
..(((((..(((...)))..)))))... (-3.71))";
int main()
{
seqan3::structure_file_input fin{std::istringstream{input}, seqan3::format_vienna{}};
auto rec0 = std::move(fin.front());
}

### Complexity

Constant.

### Exceptions

No-throw guarantee.

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

- structure_file/input.hpp

Hide me