| 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
fileFormat | File format to use for writing.
sequenceNames | The names of the sequences (StringSet of CharString), updated when new sequences are seen in GFF file.
Member Functions
GffStream | Constructor.
Functions
addSequenceName | Add the name of a sequence to a GffStream.
atEnd | Query a GffStream for being at the end of the file.
close | Closes a GffStream
flush | Flush to a GffStream
isGood | Query a GffStream for errors.
open | Open a GffStream.
readRecord | Read a record from a GffStream
writeRecord | Write a record to a GffStream
Examples The following example demonstrates reading a GFF file and printing the annotation locations. File "gff_stream_read.cpp"
1 | #include <seqan/basic.h>
2 | #include <seqan/gff_io.h>
3 |
4 | using namespace seqan;
5 |
6 | // USAGE: gff_stream_read IN.gff
7 | //
8 | // Read GFF file and print the positions (reference, position) to stdout.
9 |
10 | int 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 | }
See Also GffStream::FileFormat SeqAn - Sequence Analysis Library - www.seqan.de

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