7 bases
= ['A','C','G','T']
8 header
= ['rsID','Chr','Pos']
9 headerstr
= '\t'.join(header
+bases
+['sum','dbg'])
12 with
open( infile
, 'r' ) as theFile
:
13 reader
= csv
.DictReader(theFile
,dialect
=csv
.excel_tab
)
15 # line is { 'workers': 'w0', 'constant': 7.334, 'age': -1.406, ... }
16 # e.g. print( line[ 'workers' ] ) yields 'w0'
18 freqs
= dict.fromkeys(bases
, 0)
19 freqs
[line
['Alt1']] = line
['Freq1']
20 freqs
[line
['Alt2']] = line
['Freq2']
21 freqs
[line
['Alt3']] = line
['Freq3']
22 dbgstr
= ','.join([line
['Alt1'],line
['Freq1'],line
['Alt2'],line
['Freq2'],line
['Alt3'],line
['Freq3']])
23 outlist
= [line
['rsID'],line
['Chr'],line
['Pos']]
26 sumfreq
+= float(freqs
[e
])
27 outlist
.append(str(freqs
[e
]))
28 outlist
.append(str(sumfreq
))
29 outlist
.append(dbgstr
)
30 outstr
= '\t'.join(outlist
)