Mercurial > repos > rnateam > cofold
comparison cofold.py @ 0:76d9140e8fa5 draft
Imported from capsule None
author | bjoern-gruening |
---|---|
date | Fri, 13 Feb 2015 05:33:32 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:76d9140e8fa5 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import sys, os | |
4 import argparse | |
5 import shlex | |
6 import subprocess | |
7 | |
8 parser = argparse.ArgumentParser() | |
9 parser.add_argument('-i', '--input', help='Input file name') | |
10 parser.add_argument('-o1','--output1', help='tabular output file') | |
11 parser.add_argument('-s', '--parameters', help='arguments') | |
12 args=parser.parse_args() | |
13 | |
14 myinput = open(args.input) | |
15 | |
16 parameters = args.parameters | |
17 | |
18 # we assume that the param files are located next to the python dir | |
19 script_dir = os.path.dirname(os.path.realpath(__file__)) | |
20 parameters = args.parameters.replace('-P ', '-P %s/' % script_dir) | |
21 p = subprocess.check_output(shlex.split('CoFold '+ parameters), stdin=myinput) | |
22 | |
23 lines=p.split('\n') | |
24 # FASTA header | |
25 o=lines[0].replace('\t',' ') | |
26 | |
27 for x in range(1, len(lines)): | |
28 if x % 3 == 2: | |
29 [seq,st]=lines[x].split(' ',1) | |
30 st=st.strip().lstrip('(').rstrip(')') | |
31 o+='\t' + seq + '\t' + st | |
32 if x % 3 == 1: | |
33 o+='\t'+lines[x] | |
34 if x % 3 == 0: | |
35 o+='\n'+lines[x].replace('\t',' ') | |
36 out=open(args.output1,'w') | |
37 out.write(o) | |
38 out.close() | |
39 | |
40 | |
41 | |
42 | |
43 |