Class
VcfStream
High-level VCF I/O class.
class VcfStream
Include Headers
seqan/vcf_io.h
Member Functions
VcfStreamConstructor.
Functions
atEndQuery a VcfStream for being at the end of the file.
closeCloses a VcfStream
flushFlush to a VcfStream
isGoodQuery a VcfStream for errors.
openOpen a VcfStream.
readRecordRead a record from a VcfStream
writeRecordWrite a record to a VcfStream
Examples
The following example demonstrates reading a VCF file and printing the variant locations.
1#include <seqan/basic.h>
2#include <seqan/vcf_io.h>
3
4using namespace seqan;
5
6// USAGE: vcf_stream_read IN.vcf
7//
8// Read VCF 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.vcf\n";
15        return 1;
16    }
17
18    VcfStream vcfIn(argv[1]);
19    if (!isGood(vcfIn))
20    {
21        std::cerr << "ERROR: Could not open " << argv[1] << " for reading!\n";
22        return 1;
23    }
24
25    VcfRecord record;
26    while (!atEnd(vcfIn))
27    {
28        if (readRecord(record, vcfIn) != 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 VcfRecord.
36        std::cout << vcfIn.header.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:35