-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlinearsampling
More file actions
executable file
·42 lines (36 loc) · 2.22 KB
/
linearsampling
File metadata and controls
executable file
·42 lines (36 loc) · 2.22 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
#!/usr/bin/env python3
import gflags as flags
import subprocess
import sys
import os
FLAGS = flags.FLAGS
def setgflags():
flags.DEFINE_string('input_file', '', "input file containing RNA sequence(s); user can also use Linux pipe-style input", short_name='i')
flags.DEFINE_integer('beamsize', 100, "set beam size, (DEFAULT=100)", short_name='b')
flags.DEFINE_boolean('sharpturn', False, "enable sharp turn in prediction, (DEFAULT=FALSE)")
flags.DEFINE_boolean('verbose', False, "print out energy of each loop in the structure, (DEFAULT=FALSE)")
flags.DEFINE_integer('sample_number', 10, "sample number, (DEFAULT=10)", short_name='k')
flags.DEFINE_string('readforest', '', "read a pre-calculated state forest from a file", short_name='f')
flags.DEFINE_boolean('non_saving', False, "non_saving (non): do not save any hyperedges during sampling, i.e., like RNAsubopt -p 1000; \
(DEFAULT=False)")
flags.DEFINE_boolean('fasta', False, "input is in fasta format") # FASTA format
flags.DEFINE_string('shape', '', "import SHAPE data for SHAPE guided LinearPartition (DEFAULT: not use SHAPE data)", short_name='s') # SHAPE
argv = FLAGS(sys.argv)
def main():
input_file = str(FLAGS.input_file)
beamsize = str(FLAGS.beamsize)
is_sharpturn = '1' if FLAGS.sharpturn else '0'
is_verbose = '1' if FLAGS.verbose else '0'
sample_number = str(FLAGS.sample_number)
read_forest = str(FLAGS.readforest)
is_fasta = '1' if FLAGS.fasta else '0'
shape_file_path = str(FLAGS.shape)
path = os.path.dirname(os.path.abspath(__file__))
if int(beamsize) <= 0 and read_forest == '':
cmd = ["%s/%s" % (path, ('bin/exact_linearsampling_lazysaving' if not FLAGS.non_saving else 'bin/exact_linearsampling_nonsaving')), beamsize, is_sharpturn, is_verbose, sample_number, read_forest, is_fasta, input_file, shape_file_path]
else:
cmd = ["%s/%s" % (path, ('bin/linearsampling_lazysaving' if not FLAGS.non_saving else 'bin/linearsampling_nonsaving')), beamsize, is_sharpturn, is_verbose, sample_number, read_forest, is_fasta, input_file, shape_file_path]
subprocess.call(cmd, stdin=sys.stdin)
if __name__ == '__main__':
setgflags()
main()