forked from fjruizruano/ngs-protocols
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsat_subfam2fam_multi.py
More file actions
executable file
·64 lines (46 loc) · 1.3 KB
/
Copy pathsat_subfam2fam_multi.py
File metadata and controls
executable file
·64 lines (46 loc) · 1.3 KB
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
#!/usr/bin/python
import sys
import commands
from subprocess import call, Popen
from os import listdir
from os.path import isfile, join
print "sat_subfam2fam_multi.py AlignFile PatternFile Threads"
try:
dat = sys.argv[1]
except:
dat = raw_input("Introduce align file: ")
try:
pat = sys.argv[2]
except:
pat = raw_input("Introduce pattern file: ")
try:
th = sys.argv[3]
except:
th = raw_input("Introduce number of threads: ")
th = int(th)
c = commands.getstatusoutput("wc -l %s" % dat)
c = c[1]
c = c.split()
c = int(c[0])
lines = (c/th)+1
call("split -l %s %s %s " % (str(lines), dat, dat), shell=True)
onlyfiles = [f for f in listdir(".") if isfile(join(".",f))]
splits = []
for f in onlyfiles:
if f.startswith(dat+"a"):
splits.append(f)
splits.sort()
commands = []
for n in range(0,len(splits)):
com = "sat_subfam2fam_multi_support.py %s %s" % (splits[n],pat)
commands.append(com)
processes = [Popen(cmd, shell=True) for cmd in commands]
for p in processes:
p.wait()
splits_fam = []
for s in splits:
splits_fam.append(s+".fam")
call("cat %s > %s.fam" % (" ".join(splits_fam), dat), shell=True)
print splits
call("rm %s %s" % (" ".join(splits), " ".join(splits_fam)), shell=True)
call("calcDivergenceFromAlign.pl -s %s.fam.divsum %s.fam" % (dat,dat), shell=True)