Function
guessStreamFormat
check whether the data provided by reader is (one of) the specified format(s).
Include Headers
seqan/stream.h
Parameters
The RecordReader to read from RecordReader to query. Types: RecordReader | |
The tag to check against. | |
A TagSelector object that contains the list of tags to check and provides a tagId member with index of the detected tag. | |
Format indicator |
Remarks
With the help of LimitRecordReaderInScope these functions do not (permanently) alter the position in the stream.
The tagId-member of the TagSelector holds the index in inside-to-outside order and begins counting at one. E.g. The Index of FASTQ in TagList<Fastq, TagList<Fasta > > would be 2.
Return Values
Types: bool
Member of
Examples
The following example guesses the sequence file format of the already open fstream in .
After the call to guessStreamFormat() , the tagSelector.tagId contains the 1-based index of the matching tag.
Here, we use the AutoSeqStreamFormat tag selector.
AutoSeqStreamFormat tagSelector;
bool b = guessStreamFormat(reader, tagSelector);
// b is true if any format was detected successfully.
if (tagSelector.tagId == 1)
std::cerr << "Detected FASTA." << std::endl;
else if (tagSelector.tagId == 2)
std::cerr << "Detected FASTQ." << std::endl;
else
std::cerr << "Unknown file format!" << std::endl;
Alternatively, we can define your own tag selector.
Note that we reverse the order of FASTA and FASTQ in respect to AutoSeqStreamFormat
RecordReader<std::fstream, SinglePass<> > reader(in);
AutoSeqStreamFormat tagSelector;
MyTagSelector tagSelector;
bool b = guessStreamFormat(reader, tagSelector);
// b is true if any format was detected successfully.
if (tagSelector.tagId == 1)
std::cerr << "Detected FASTQ." << std::endl;
else if (tagSelector.tagId == 2)
std::cerr << "Detected FASTA." << std::endl;
else
std::cerr << "Unknown file format!" << std::endl;
SeqAn - Sequence Analysis Library - www.seqan.de