-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlinearturbofold
executable file
·59 lines (49 loc) · 2.62 KB
/
linearturbofold
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
#!/usr/bin/env python3
from genericpath import exists
import gflags as flags
#import subprocess
import sys
import os
FLAGS = flags.FLAGS
def setgflags():
flags.DEFINE_string("input", "", "input file must in the fasta format", short_name='i')
flags.DEFINE_string("outDir", "", "output directory for predicted MSA and structures", short_name='o')
flags.DEFINE_integer("iter", 3, "set the number of iteration, (DEFAULT=3)", short_name='it')
flags.DEFINE_integer("hmmBeam", 100, "set beam size for LinearAlignment, (DEFAULT=-1, infinite beam size)", short_name='b1')
flags.DEFINE_integer("ckyBeam", 100, "set beam size for LinearPartition, (DEFAULT=100)", short_name='b2')
flags.DEFINE_boolean("saveBFs", False, "save Partition Function after the last iteraction, (DEFAULT=False)", short_name='pf')
flags.DEFINE_boolean("saveBPPs", False, "save base pair probabilities after the last iteraction, (DEFAULT=False)", short_name='bpp')
flags.DEFINE_boolean("verbose", False, "print more alignment, folding and runtime information, (DEFAULT=FALSE)", short_name='v')
flags.DEFINE_integer("TnMinHelixLength", 3, "set the min. length of helix in predicted structures in ThreshKnot, (DEFAULT=3)", short_name='tkhl')
flags.DEFINE_integer("TnIterations", 1, "set the number of iteration of ThreshKnot, (DEFAULT=1)", short_name='tkit')
flags.DEFINE_float("Threshold", 0.3, "set Threshold for ThreshKnot, (DEFAULT=0.3)", short_name='th')
argv = FLAGS(sys.argv)
def main():
input_file = FLAGS.input
output_dir = FLAGS.outDir
iteration = FLAGS.iter
hmm_beam = str(FLAGS.hmmBeam)
cky_beam = str(FLAGS.ckyBeam)
is_save_pfs = "1" if FLAGS.saveBFs else "0"
is_save_bpps = "1" if FLAGS.saveBPPs else "0"
is_verbose = "1" if FLAGS.verbose else "0"
TkMinHelixLength = str(FLAGS.TnMinHelixLength)
TkIterations = str(FLAGS.TnIterations)
Threshold = str(FLAGS.Threshold)
if not input_file:
print("Do not provide the input file (should in the fasta format).")
exit()
if not os.path.exists(output_dir):
os.mkdir(output_dir)
if iteration < 0:
print("Invalid TurboFold iterations given.")
path = os.path.dirname(os.path.abspath(__file__))
input_file = os.path.abspath(input_file)
output_dir = os.path.abspath(output_dir)
cmd = ["cd %s; %s/%s" % (path, path, 'bin/linearturbofold'), input_file, output_dir, hmm_beam, cky_beam, str(iteration), is_save_bpps, is_save_pfs, is_verbose, TkMinHelixLength, TkIterations, Threshold]
cmd=' '.join(cmd)
os.system(cmd)
#subprocess.call(cmd)
if __name__ == '__main__':
setgflags()
main()