-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunners.py
70 lines (63 loc) · 2.07 KB
/
runners.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
from utils import log
#from multiprocessing import Pool, TimeoutError
def run(cmd, shell=True, OUT=subprocess.PIPE, ERR=subprocess.PIPE) :
if ERR == "devnull" :
ERR = subprocess.DEVNULL
proc = subprocess.Popen(cmd, shell=shell, stdout=OUT, stderr=ERR)
proc.communicate()
def run_log(cmd, log_file) :
if not log_file : # log_file == None
run(cmd, ERR=subprocess.DEVNULL)
else :
lf = open(log_file, "w")
lf.write(cmd + "\n")
run(cmd, OUT=lf, ERR=lf)
lf.close()
def run_FP(job) :
cmd = job[0]
number = job[1]
log("Running FastP job number {}".format(number), newline=False)
run(cmd)
log("Finished FastP job number {}".format(number), newline=False)
def run_picard_(job) :
cmd = job[0]
log_file = job[1]
number = job[2]
log("Running GenotypeGVCFs job number {}".format(number), newline=False)
if not log_file :
run(cmd, ERR=subprocess.DEVNULL)
else :
lf = open(log_file, "w")
lf.write(cmd + "\n")
run(cmd, ERR=lf)
lf.close()
log("Finished GenotypeGVCFs job number {}".format(number), newline=False)
def run_GG(job) :
cmd = job[0]
log_file = job[1]
number = job[2]
log("Running GenotypeGVCFs job number {}".format(number), newline=False)
if not log_file :
run(cmd, ERR=subprocess.DEVNULL)
else :
lf = open(log_file, "w")
lf.write(cmd + "\n")
run(cmd, ERR=lf)
lf.close()
log("Finished GenotypeGVCFs job number {}".format(number), newline=False)
def run_HC(job) :
cmd = job[0]
log_file = job[1]
number = job[2]
log("Running HaplotypeCaller job number {}".format(number), newline=False)
if not log_file : # if do not log do not keep stderr
run(cmd, ERR=subprocess.DEVNULL)
else :
lf = open(log_file, "w")
lf.write(cmd + "\n")
run(cmd, ERR=lf) # if output logs -> go to log_file
lf.close()
log("Finished HaplotypeCaller job number {}".format(number), newline=False)