| Class BedStream High-level BED I/O class. class BedStream Include Headers seqan/bed_io.h Data Members
sequenceNames | The names of the sequences (StringSet of CharString), updated when new sequences are seen in BED file.
Member Functions
BedStream | Constructor.
Functions
addSequenceName | Add the name of a sequence to a BedStream.
atEnd | Query a BedStream for being at the end of the file.
close | Closes a BedStream
flush | Flush to a BedStream
isGood | Query a BedStream for errors.
open | Open a BedStream.
readRecord | Read a record from a BedStream
writeRecord | Write a record to a BedStream
Examples The following example demonstrates reading a BED file and printing the variant locations. File "bed_stream_read.cpp"
1 | #include <seqan/basic.h>
2 | #include <seqan/bed_io.h>
3 |
4 | using 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 |
12 | int 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 | }
See Also BedStream::Mode SeqAn - Sequence Analysis Library - www.seqan.de

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