forked from LinearFold/LinearFold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinearfold
executable file
·50 lines (42 loc) · 2.37 KB
/
linearfold
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
#!/usr/bin/env python3
import gflags as flags
import subprocess
import sys
import os
FLAGS = flags.FLAGS
def setgflags():
flags.DEFINE_integer('beamsize', 100, "set beam size", short_name='b')
flags.DEFINE_boolean('Vienna', False, "use vienna parameters", short_name='V')
flags.DEFINE_boolean('sharpturn', False, "enable sharp turn in prediction")
flags.DEFINE_boolean('verbose', False, "print out energy of each loop in the structure", short_name='v')
flags.DEFINE_boolean('eval', False, "print out energy of a given structure") # adding eval mode
flags.DEFINE_boolean('constraints', False, "print out energy of a given structure") # adding eval mode
flags.DEFINE_boolean('zuker', False, "output Zuker suboptimal structures")
flags.DEFINE_float('delta', 5.0, "compute Zuker suboptimal structures with scores or energies(-V, kcal/mol) in a centain range of the optimum")
flags.DEFINE_string('shape', '', "specify a file name that contains SHAPE reactivity data (DEFAULT: not use SHAPE data)") # SHAPE
flags.DEFINE_boolean('fasta', False, "input is in fasta format") # FASTA format
flags.DEFINE_integer('dangles', 2, "the way to treat `dangling end' energies for bases adjacent to helices in free ends and multi-loops (only supporting `0' or `2', default=`2')", short_name="d")
flags.DEFINE_integer('threads', 1, "number of threads, default=`1')", short_name="t")
argv = FLAGS(sys.argv)
def main():
use_vienna = FLAGS.V
beamsize = str(FLAGS.b)
is_sharpturn = '1' if FLAGS.sharpturn else '0'
is_verbose = '1' if FLAGS.verbose else '0'
is_eval = '1' if FLAGS.eval else '0'
is_constraints = '1' if FLAGS.constraints else '0'
zuker_subopt = '1' if FLAGS.zuker else '0'
delta = str(FLAGS.delta)
shape_file_path = str(FLAGS.shape)
is_fasta = '1' if FLAGS.fasta else '0'
if FLAGS.dangles not in [0, 2]:
print("ERROR: --dangles currently only supports 0 or 2")
exit(1)
dangles = str(FLAGS.dangles)
threads = str(FLAGS.threads)
path = os.path.dirname(os.path.abspath(__file__))
cmd = ["%s/%s" % (path, ('bin/linearfold_v' if use_vienna else 'bin/linearfold_c')), beamsize, is_sharpturn, is_verbose, is_eval, is_constraints, zuker_subopt, delta, shape_file_path, is_fasta, dangles, threads]
subprocess.call(cmd, stdin=sys.stdin)
if __name__ == '__main__':
setgflags()
main()