Skip to content

Commit

Permalink
Fixed proper splitting for value R
Browse files Browse the repository at this point in the history
  • Loading branch information
moonso committed Feb 12, 2015
1 parent 87868c3 commit 49d814a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/test_vcf.vcf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##fileformat=VCFv4.1
##fileformat=VCFv4.2
##INFO=<ID=MQ,Number=1,Type=Float,Description="RMS Mapping Quality">
##INFO=<ID=CNT,Number=A,Type=Integer,Description="Number of times this allele was found in external db">
##contig=<ID=1,length=249250621,assembly=b37>
Expand Down
23 changes: 17 additions & 6 deletions vcf_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,23 +569,34 @@ def make_splitted_variants(self, variant_dict):
except KeyError:
print(""""\nOne of the FILTER lines is missing in vcf
header: %s \n""" % info, file=sys.stderr)
raise
raise
if info == 'CSQ':
try:
vep_dict[alternative] = variant_dict['vep_info'][alternative]
info_dict['CSQ'] = [self.build_new_vep_string(variant_dict['vep_info'][alternative])]
except KeyError:
pass
# If there if one value per allele we need to split it in
# the proper way
if number_of_values == 'A':
elif number_of_values == 'A':
try:
# When we split the alleles we only want to annotate with the correct number
info_dict[info] = [variant_dict['info_dict'][info][alternative_number]]
except IndexError:
# If there is only one annotation we choose that one
info_dict[info] = [variant_dict['info_dict'][info][0]]
# Choose the right vep info from the old variant
elif info == 'CSQ':
elif number_of_values == 'R':
reference_value = variant_dict['info_dict'][info][0]
new_info = [reference_value]
try:
vep_dict[alternative] = variant_dict['vep_info'][alternative]
info_dict['CSQ'] = [self.build_new_vep_string(variant_dict['vep_info'][alternative])]
except KeyError:
# When we split the alleles we only want to annotate with the correct number
new_info.append(variant_dict['info_dict'][info][alternative_number + 1])
info_dict[info] = new_info
except IndexError:
# If annotation is missing we keep the original annotation
pass

else:
info_dict[info] = variant_dict['info_dict'][info]

Expand Down

0 comments on commit 49d814a

Please sign in to comment.