Function
guessStreamFormat
check whether the data provided by reader is (one of) the specified format(s).
guessStreamFormat(TRecordReader & reader, TTag const &)
guessStreamFormat(TRecordReader & reader, TagSelector<TTagList> & formats)
guessStreamFormat(reader, tag)
Include Headers
seqan/stream.h
Parameters

reader | The RecordReader to read from RecordReader to query. Types: RecordReader
TTag | The tag to check against.
formats | A TagSelector object that contains the list of tags to check and provides a tagId member with index of the detected tag.
tag | Format indicator Types: Fasta, Fastq, File Format

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
true if (one of) the specified Tag(s) tested positive and False otherwise
bool, indicating whether the file of reader is of the given format.
Types: bool
Member of
RecordReader
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.
RecordReader<std::fstream, SinglePass<> > reader(in);
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
typedef TagSelector<TagList<Fasta, TagList<Fastq> > > MyTagSelector;
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;
See Also
AutoSeqStreamFormat, getAutoSeqStreamFormatName, LimitRecordReaderInScope
SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2014/10/13 16:12:58