-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsingle_cov.py
executable file
·37 lines (33 loc) · 1.25 KB
/
single_cov.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
#!/usr/bin/env python
import argparse
import os
import subprocess
# arguments
parser = argparse.ArgumentParser()
parser.add_argument('-dir', help='Directory containing maf files to ensure single coverage for', required=True)
parser.add_argument('-ref_name', help='Name of reference species', required=True)
parser.add_argument('-evolgen', help='If specified will submit to lab queue', default=False, action='store_true')
args = parser.parse_args()
# variables
directory = args.dir
maf_list = [maf for maf in os.listdir(directory) if maf.endswith('.maf')]
out_dir = directory + 'single_coverage/'
if not os.path.isdir(out_dir):
os.mkdir(out_dir)
ref = args.ref_name
evolgen = args.evolgen
# run single_cov2
for maf in maf_list:
in_maf = directory + maf
output = out_dir + maf.rstrip('.maf') + '.sing.maf'
cmd_line = ('"single_cov2 ' +
in_maf + ' [R=' + ref + '] > ' +
output + '"')
qsub_cmd = ('python qsub_gen.py '
'-cmd ' + cmd_line + ' '
'-o ' + out_dir + 'single_cov2_' + maf.rstrip('.maf') + ' '
'-jid single_cov2_' + maf.rstrip('.maf') + '.sh '
'-OM q ')
if evolgen is True:
qsub_cmd += '-evolgen'
subprocess.call(qsub_cmd, shell=True)