comparison ensembl_variant_report.py @ 3:652d35c42bca draft

planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/ensembl_variant_report commit d3b7ff1c2f0a1eed7a65af7208e987a35627402c-dirty
author jjohnson
date Wed, 20 Mar 2019 15:27:02 -0400
parents f87fe6bc48f4
children
comparison
equal deleted inserted replaced
2:f87fe6bc48f4 3:652d35c42bca
114 alt_list = alts.split(',') 114 alt_list = alts.split(',')
115 pos = int(pos) 115 pos = int(pos)
116 qual = float(qual) 116 qual = float(qual)
117 dp = None 117 dp = None
118 dpr = None 118 dpr = None
119 ao = None
119 af = None 120 af = None
120 for info_item in info.split(';'): 121 for info_item in info.split(';'):
121 if info_item.find('=') < 0: continue 122 if info_item.find('=') < 0: continue
122 (key, val) = info_item.split('=', 1) 123 (key, val) = info_item.split('=', 1)
123 if key == 'DP': 124 if key == 'DP':
124 dp = int(val) 125 dp = int(val)
125 if key == 'DPR' or key == 'AD': 126 if key == 'DPR' or key == 'AD':
126 dpr = [int(x) for x in val.split(',')] 127 dpr = [int(x) for x in val.split(',')]
128 if key == 'AO':
129 ao = [int(x) for x in val.split(',')]
127 if key == 'AF': 130 if key == 'AF':
128 af = [float(x) for x in val.split(',')] 131 af = [float(x) for x in val.split(',')]
129 if key in ['EFF','ANN']: 132 if key in ['EFF','ANN']:
130 for effect in val.split(','): 133 for effect in val.split(','):
131 if options.debug: print >> sys.stderr, "\n%s" % (effect.split('|')) 134 if options.debug: print >> sys.stderr, "\n%s" % (effect.split('|'))
133 (alt,eff,impact,gene_name,gene_id,feature_type,transcript,biotype,exon,c_hgvs,p_hgvs,cdna,cds,aa,distance,info) = effect.split('|') 136 (alt,eff,impact,gene_name,gene_id,feature_type,transcript,biotype,exon,c_hgvs,p_hgvs,cdna,cds,aa,distance,info) = effect.split('|')
134 elif key == 'EFF': 137 elif key == 'EFF':
135 (eff, effs) = effect.rstrip(')').split('(') 138 (eff, effs) = effect.rstrip(')').split('(')
136 (impact, functional_class, codon_change, aa_change, aa_len, gene_name, biotype, coding, transcript, exon, alt) = effs.split('|')[0:11] 139 (impact, functional_class, codon_change, aa_change, aa_len, gene_name, biotype, coding, transcript, exon, alt) = effs.split('|')[0:11]
137 i = alt_list.index(alt) if alt in alt_list else 0 140 i = alt_list.index(alt) if alt in alt_list else 0
138 if af: 141 if ao:
139 freq = af[i] 142 freq = float(ao[i])/float(dp) if dp else \
143 float(dpr[i])/float(sum(ao))
140 elif dpr: 144 elif dpr:
141 freq = float(dpr[i+1])/float(dp) if dp else \ 145 freq = float(dpr[i+1])/float(dp) if dp else \
142 float(dpr[i+1])/float(sum(dpr)) 146 float(dpr[i+1])/float(sum(dpr))
147 elif af:
148 freq = af[i]
143 else: 149 else:
144 freq = None 150 freq = None
145 if freq: 151 if freq:
146 yield (transcript,pos,ref,alt,dp,freq) 152 yield (transcript,pos,ref,alt,dp,freq)
147 153