Skip to content

Commit

Permalink
allowing non AF vcf
Browse files Browse the repository at this point in the history
  • Loading branch information
costero-e committed Nov 8, 2024
1 parent bd2ce68 commit 162a1bc
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions genomicVariations_vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ def generate(dict_properties):
try:
allele_frequency=v.INFO.get('AF')
if allele_frequency == None:
i+=1
pbar.update(1)
continue
pass
if isinstance(allele_frequency, tuple):
allele_frequency=list(allele_frequency)
allele_frequency=allele_frequency[0]
Expand All @@ -152,48 +150,48 @@ def generate(dict_properties):
continue
allele_number=v.INFO.get('AN')
if allele_number == None:
i+=1
continue
pass
elif isinstance(allele_number, tuple):
allele_number=list(allele_number)
allele_number[0]
else:
allele_number = float(allele_number)
allele_count=v.INFO.get('AC')
if allele_count == None:
i+=1
pbar.update(1)
continue
pass
elif isinstance(allele_count, tuple):
allele_count=list(allele_count)
allele_count[0]
allele_count=allele_count[0]
else:
allele_count = float(allele_count)
ac_hom=v.INFO.get('AC_Hom')
if ac_hom == None:
if allele_count == 0.0:
i+=1
pbar.update(1)
continue
ac_hom=v.INFO.get('AC_Hom')
if ac_hom == None:
pass
elif isinstance(ac_hom, tuple):
ac_hom=list(ac_hom)
ac_hom[0]
ac_hom=ac_hom[0]
else:
ac_hom = float(v.INFO.get('AC_Hom'))
ac_het=v.INFO.get('AC_Het')

if ac_het == None:
i+=1
continue
pass
elif isinstance(ac_het, tuple):
ac_het=list(ac_het)
ac_het[0]
ac_het=ac_het[0]
else:
ac_het = float(v.INFO.get('AC_Het'))
dict_to_xls['frequencyInPopulations|sourceReference']=pipeline["frequencyInPopulations|sourceReference"]
dict_to_xls['frequencyInPopulations|source']=pipeline["frequencyInPopulations|source"]
dict_to_xls['frequencyInPopulations|frequencies|population']=conf.datasetId
dict_to_xls['frequencyInPopulations|frequencies|alleleFrequency']=allele_frequency
if allele_frequency is not None:
dict_to_xls['frequencyInPopulations|sourceReference']=pipeline["frequencyInPopulations|sourceReference"]
dict_to_xls['frequencyInPopulations|source']=pipeline["frequencyInPopulations|source"]
dict_to_xls['frequencyInPopulations|frequencies|population']=conf.datasetId
dict_to_xls['frequencyInPopulations|frequencies|alleleFrequency']=allele_frequency
except Exception as e:
continue
pass
#print(allele_frequency)

#print(v)
Expand Down Expand Up @@ -614,10 +612,14 @@ def generate(dict_properties):
GenomicVariations(**definitivedict)
definitivedict["datasetId"]=conf.datasetId
try:
definitivedict["frequencyInPopulations"][0]["frequencies"][0]["alleleCount"]=allele_count
definitivedict["frequencyInPopulations"][0]["frequencies"][0]["alleleNumber"]=allele_number
definitivedict["frequencyInPopulations"][0]["frequencies"][0]["alleleCountHomozygous"]=ac_hom
definitivedict["frequencyInPopulations"][0]["frequencies"][0]["alleleCountHeterozygous"]=ac_het
if allele_count:
definitivedict["frequencyInPopulations"][0]["frequencies"][0]["alleleCount"]=allele_count
if allele_number:
definitivedict["frequencyInPopulations"][0]["frequencies"][0]["alleleNumber"]=allele_number
if ac_hom:
definitivedict["frequencyInPopulations"][0]["frequencies"][0]["alleleCountHomozygous"]=ac_hom
if ac_het:
definitivedict["frequencyInPopulations"][0]["frequencies"][0]["alleleCountHeterozygous"]=ac_het
except Exception:
pass
total_dict.append(definitivedict)
Expand Down

0 comments on commit 162a1bc

Please sign in to comment.