Class
GffStream
High-level GFF/GTF I/O class.
The GffStream class allows to read and write GTF and GFF files.
class GffStream
Include Headers
seqan/gff_io.h
Remarks
Note that the class GffStream allows to read both GFF 2, 3, and GTF. For writing, only GFF 3 and GTF are supported.
Data Members
fileFormatFile format to use for writing.
sequenceNamesThe names of the sequences (StringSet of CharString), updated when new sequences are seen in GFF file.
Member Functions
GffStreamConstructor.
Functions
addSequenceNameAdd the name of a sequence to a GffStream.
atEndQuery a GffStream for being at the end of the file.
closeCloses a GffStream
flushFlush to a GffStream
isGoodQuery a GffStream for errors.
openOpen a GffStream.
readRecordRead a record from a GffStream
writeRecordWrite a record to a GffStream
Examples
The following example demonstrates reading a GFF file and printing the annotation locations.
1#include <seqan/basic.h>
2#include <seqan/gff_io.h>
3
4using namespace seqan;
5
6// USAGE: gff_stream_read IN.gff
7//
8// Read GFF file and print the positions (reference, position) to stdout.
9
10int main(int argc, char ** argv)
11{
12    if (argc != 2)
13    {
14        std::cerr << "USAGE: " << argv[1] << " IN.gff\n";
15        return 1;
16    }
17
18    GffStream gffIn(argv[1]);
19    if (!isGood(gffIn))
20    {
21        std::cerr << "ERROR: Could not open " << argv[1] << " for reading!\n";
22        return 1;
23    }
24
25    GffRecord record;
26    while (!atEnd(gffIn))
27    {
28        if (readRecord(record, gffIn) != 0)
29        {
30            std::cerr << "ERROR: Problem reading from " << argv[1] << "\n";
31            return 1;
32        }
33
34        // Note that we print the position 1-based since we use text output
35        // whereas it is 0-based in the GffRecord.
36        std::cout << gffIn.sequenceNames[record.rID]
37                  << "\t" << (record.beginPos + 1) << "\n";
38    }
39
40    return 0;
41}
SeqAn - Sequence Analysis Library - www.seqan.de
 

Page built @2013/07/11 09:12:34