You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the following code, is there any way to Convert vertor to std:string as I want to handle C++ standard string?
Thanks,
Hai
auto input = R"(>TEST1ACGT>Test2AGGCTGA>Test3GGAGTATAATATATATATATATAT)";
intmain(int argc, constchar *argv[]) {
using sequence_file_input_type =
seqan3::sequence_file_input<seqan3::sequence_file_input_default_traits_dna,
seqan3::fields<seqan3::field::seq, seqan3::field::id>,
seqan3::type_list<seqan3::format_fasta>>;
sequence_file_input_type fin{std::istringstream{input}, seqan3::format_fasta{}};
// Retrieve the sequences and ids.for (auto &[seq, id]: fin) {
seqan3::debug_stream << "ID: " << id << '\n';
seqan3::debug_stream << "SEQ: " << seq << '\n';
// a quality field also exists, but is not printed, because we know it's empty for FASTA files.
}
return0;
}
The text was updated successfully, but these errors were encountered:
structmy_traits : seqan3::sequence_file_input_default_traits_dna
{
using sequence_alphabet = char; // instead of dna5template <typename alph>
using sequence_container = std::basic_string<alph>; // must be defined as a template!
};
that will automatically read the sequences as a std::string (std::string = std::basic_string<char>)
Full Solution:
#include<iostream>
#include<seqan3/io/sequence_file/all.hpp>
#include<seqan3/core/debug_stream.hpp>auto input = R"(>TEST1ACGT>Test2AGGCTGA>Test3GGAGTATAATATATATATATATAT)";
structmy_traits : seqan3::sequence_file_input_default_traits_dna
{
using sequence_alphabet = char; // instead of dna5template <typename alph>
using sequence_container = std::basic_string<alph>; // must be defined as a template!
};
intmain(int argc, constchar *argv[]) {
using sequence_file_input_type =
seqan3::sequence_file_input<my_traits,
seqan3::fields<seqan3::field::seq, seqan3::field::id>,
seqan3::type_list<seqan3::format_fasta>>;
sequence_file_input_type fin{std::istringstream{input}, seqan3::format_fasta{}};
// Retrieve the sequences and ids.for (auto &[seq, id]: fin) {
std::cout << "ID: " << id << '\n';
std::cout << "SEQ: " << seq << '\n';
// a quality field also exists, but is not printed, because we know it's empty for FASTA files.
}
return0;
}
Platform
Question
With the following code, is there any way to Convert vertor to std:string as I want to handle C++ standard string?
Thanks,
Hai
The text was updated successfully, but these errors were encountered: