-
Notifications
You must be signed in to change notification settings - Fork 4
/
post_maf_filter.py
31 lines (23 loc) · 965 Bytes
/
post_maf_filter.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
import os, os.path, sys
import gzip, csv
import itertools
def main(args):
with gzip.open(args.INFILE, 'rb') as fi, gzip.open(args.OUTFILE, 'wb') as fo:
reader = csv.DictReader(itertools.ifilter(lambda x: x[0]!='#', fi), delimiter = '\t')
fo.write('# version 2.4\n')
writer = csv.DictWriter(fo, fieldnames = reader.fieldnames, delimiter = '\t')
writer.writeheader()
for i, record in enumerate(reader):
if i % 1000 == 0:
print "processed %s lines" % str(i)
if 'PINDEL' in record['CENTERS']:
if int(record['t_alt_count']) < 3:
continue
writer.writerow(record)
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('INFILE', type = str, help = 'input file')
parser.add_argument('OUTFILE', type = str, help = 'output file')
args = parser.parse_args()
main(args)