| Class VcfStream High-level VCF I/O class. class VcfStream Include Headers seqan/vcf_io.h Member Functions
VcfStream | Constructor.
Functions
atEnd | Query a VcfStream for being at the end of the file.
close | Closes a VcfStream
flush | Flush to a VcfStream
isGood | Query a VcfStream for errors.
open | Open a VcfStream.
readRecord | Read a record from a VcfStream
writeRecord | Write a record to a VcfStream
Examples The following example demonstrates reading a VCF file and printing the variant locations. File "vcf_stream_read.cpp"
1 | #include <seqan/basic.h>
2 | #include <seqan/vcf_io.h>
3 |
4 | using namespace seqan;
5 |
6 | int main()
7 | {
8 | CharString path = SEQAN_PATH_TO_ROOT();
9 | append(path, "/extras/demos/vcf_io/example.vcf");
10 |
11 | VcfStream vcfIn(toCString(path));
12 | if (!isGood(vcfIn))
13 | {
14 | std::cerr << "ERROR: Could not open " << path << " for reading!\n";
15 | return 1;
16 | }
17 |
18 | VcfRecord record;
19 | while (!atEnd(vcfIn))
20 | {
21 | if (readRecord(record, vcfIn) != 0)
22 | {
23 | std::cerr << "ERROR: Problem reading from " << path << "\n";
24 | return 1;
25 | }
26 |
27 | // Note that we print the position 1-based since we use text output
28 | // whereas it is 0-based in the VcfRecord.
29 | std::cout << vcfIn.header.sequenceNames[record.rID]
30 | << "\t" << (record.beginPos + 1) << "\n";
31 | }
32 |
33 | return 0;
34 | }
SeqAn - Sequence Analysis Library - www.seqan.de

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