Class
BedStream
High-level BED I/O class.
class BedStream
Include Headers
seqan/bed_io.h
Data Members
sequenceNamesThe names of the sequences (StringSet of CharString), updated when new sequences are seen in BED file.
Member Functions
BedStreamConstructor.
Functions
addSequenceNameAdd the name of a sequence to a BedStream.
atEndQuery a BedStream for being at the end of the file.
closeCloses a BedStream
flushFlush to a BedStream
isGoodQuery a BedStream for errors.
openOpen a BedStream.
readRecordRead a record from a BedStream
writeRecordWrite a record to a BedStream
Examples
The following example demonstrates reading a BED file and printing the variant locations.
1#include <seqan/basic.h>
2#include <seqan/bed_io.h>
3
4using namespace seqan;
5
6// USAGE: bed_stream_read IN.bed
7//
8// Read BED file and print the positions (reference, position) to stdout.
9//
10// We only read BED 3 here but the example can be easily adjusted to more complex examples.
11
12int main(int argc, char ** argv)
13{
14    if (argc != 2)
15    {
16        std::cerr << "USAGE: " << argv[1] << " IN.bed\n";
17        return 1;
18    }
19
20    BedStream bedIn(argv[1]);
21    if (!isGood(bedIn))
22    {
23        std::cerr << "ERROR: Could not open " << argv[1] << " for reading!\n";
24        return 1;
25    }
26
27    BedRecord<Bed3> record;
28    while (!atEnd(bedIn))
29    {
30        if (readRecord(record, bedIn) != 0)
31        {
32            std::cerr << "ERROR: Problem reading from " << argv[1] << "\n";
33            return 1;
34        }
35
36        std::cout << record.ref << "\t" << record.beginPos << "\n";
37    }
38    
39    return 0;
40}
SeqAn - Sequence Analysis Library - www.seqan.de
 

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