fn() guessStreamFormat
Check whether the data provided by reader is (one of) the specified format(s).

Defined in <seqan/seq_io.h>
Signature bool guessStreamFormat(reader, tag); bool guessStreamFormat(reader, tagSelector);

Parameters

reader The RecordReader to from.
tag A file format tag.
tagSelector The TagSelector to use.

Return Values

true true if (one of) the specified Tag(s) tested positive and False otherwise

Detailed Description

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> > is be 2.

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