-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaggregate_tsvs.py
executable file
·48 lines (43 loc) · 1.19 KB
/
aggregate_tsvs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
import argparse
import os
import subprocess as sp
#define the user inputs
def get_args():
parser = argparse.ArgumentParser()
#parser.add_argument("-i", "--in_dir", required=True, help="REQUIRED: list of vcf summary files from the summarize_vcfs modules.")
return parser.parse_args()
def combine_summaries():
#write the outfile for all samples
outfile='all_samples.vcf.summary.txt'
if os.path.exists(outfile):
os.remove(outfile)
fh_out=open(outfile,'w')
fh_out.write(
'run' + '\t' + \
'sample'+ '\t' + \
'coord' + '\t' + \
'refBase' + '\t' + \
'altBase' + '\t' + \
'totalDP' + '\t' + \
'altDP' + '\t' + \
'altQual' + '\t' + \
'altFreq' + '\t' + \
'altPval' + '\t' + \
'GFFfeature' + '\t' + \
'RefCodon' + '\t' + \
'RefAA' + '\t' + \
'AltCodon' + '\t' + \
'AltAA' + '\n')
for f in os.listdir('.'):
if f.endswith('_ivar_summary.txt'):
fh=open(f,'r')
for line in fh.readlines()[1:]:
line=line.strip()
fh_out.write(line+'\n')
def main():
#define the arguments
args = get_args()
combine_summaries()
if __name__ == '__main__':
main()