Skip to content

Commit

Permalink
fixed missing values - FORMAT field
Browse files Browse the repository at this point in the history
  • Loading branch information
sigven committed Jan 25, 2022
1 parent c5f595f commit 8bdbba8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions vcf2tsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import math
import subprocess

version = '0.3.5'
version = '0.3.6'


def __main__():
Expand Down Expand Up @@ -115,7 +115,7 @@ def vcf2tsv(query_vcf, out_tsv, skip_info_data, skip_genotype_data, keep_rejecte
rec_filter = str(rec.FILTER)
if rec.FILTER is None:
rec_filter = 'PASS'

pos = int(rec.start) + 1
fixed_fields_string = str(rec.CHROM) + '\t' + str(pos) + '\t' + str(rec_id) + '\t' + str(rec.REF) + '\t' + str(alt) + '\t' + str(rec_qual) + '\t' + str(rec_filter)

Expand Down Expand Up @@ -169,6 +169,7 @@ def vcf2tsv(query_vcf, out_tsv, skip_info_data, skip_genotype_data, keep_rejecte
#print(str(vcf_info_data))
#dictionary, with sample names as keys, values being genotype data (dictionary with format tags as keys)
vcf_sample_genotype_data = {}

if len(samples) > 0 and skip_genotype_data is False:
gt_cyvcf = rec.gt_types
i = 0
Expand Down Expand Up @@ -212,11 +213,13 @@ def vcf2tsv(query_vcf, out_tsv, skip_info_data, skip_genotype_data, keep_rejecte
d = str(sample_dat[j])
if column_types[format_tag] == 'Integer':
d = str(sample_dat[j][0])
## undefined/missing value
if d == '-2147483648':
d = '.'
if samples[j] in vcf_sample_genotype_data:
vcf_sample_genotype_data[samples[j]][format_tag] = d
j = j + 1

#print(str(vcf_sample_genotype_data))
tsv_elements = []
tsv_elements.append(fixed_fields_string)
if skip_info_data is False:
Expand Down

0 comments on commit 8bdbba8

Please sign in to comment.