Ejemplo n.º 1
0
 def test_meta_parsing(self):
     vi = VcfIterator(get_vcf_file_obj(None))
     meta = vi.getMeta()
     self.assertEquals(
         meta['FORMAT'],
         [
             {
                 'Description': 'Genotype',
                  'Type': 'String',
                  'ID': 'GT',
                  'Number': '1'
              },
              {
                  'Description': 'Genotype Quality',
                  'Type': 'Integer',
                  'ID': 'GQ',
                  'Number': '1'
              },
              {
                  'Description': 'Read Depth',
                  'Type': 'Integer',
                  'ID': 'DP',
                  'Number': '1'
              },
              {
                 'Description': 'Haplotype Quality',
                 'Type': 'Integer',
                 'ID': 'HQ',
                 'Number': '2'
             }
         ]
     )
Ejemplo n.º 2
0
import json
import sys
import argparse

from vcfiterator import VcfIterator

parser = argparse.ArgumentParser(
    "Iterates over a .vcf file, outputting one JSON structure per line")
parser.add_argument("vcf_file", help="Path to .vcf file")
parser.add_argument("--pretty", action="store_true", help="Pretty print JSON")

args = parser.parse_args()
path = args.vcf_file
v = VcfIterator(path)

for value in v.iter():
    kw = {}
    if args.pretty:
        kw['indent'] = 4
    print(json.dumps(value, **kw))
Ejemplo n.º 3
0
 def get_data(self):
     v = '20\t14370\trs6054257\tG\tA\t29\tPASS\tNS=3;DP=14;AF=0.5;DB;H2\tGT:GQ:DP:HQ\t0|0:48:1:51,51\t1|0:48:8:51,51\t1/1:43:5:.,.'
     vi = VcfIterator(get_vcf_file_obj(v))
     return list(vi.iter())[0]
Ejemplo n.º 4
0
 def test_get_samples(self):
     vi = VcfIterator(get_vcf_file_obj(None))
     self.assertEquals(
         vi.getSamples(),
         ['TESTSAMPLE1', 'TESTSAMPLE2', 'TESTSAMPLE3']
     )