annotate reprof.py @ 14:8c83f1fb30f6 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 98288bb0ee8760018924574b81c8759bac55b529
author iuc
date Fri, 11 Dec 2015 14:26:29 -0500
parents fb0936cf5bef
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
1 #!/usr/bin/env python
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
2 import re
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
3 import os
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
4 import argparse
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
5 import subprocess
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
6 import tempfile
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
7 from Bio import SeqIO
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
8 from BCBio import GFF
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
9 from Bio.Seq import Seq
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
10 from Bio.SeqRecord import SeqRecord
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
11 from Bio.SeqFeature import SeqFeature, FeatureLocation
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
12
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
13 def run_reprof(query_path, modeldir):
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
14 outtmp = tempfile.NamedTemporaryFile(delete=False)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
15 cmd = [
1
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
16 'reprof',
0
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
17 '-i', query_path,
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
18 '--modeldir=%s' % modeldir,
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
19 '-o', outtmp.name
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
20 ]
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
21 subprocess.check_call(cmd)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
22 outtmp.seek(0)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
23 data = outtmp.read()
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
24 outtmp.close()
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
25 os.unlink(outtmp.name)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
26 return data
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
27
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
28 def process_reprof_report(data):
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
29 KEYS = ['idx', 'AA', 'PHEL', 'RI_S', 'pH', 'pE', 'pL', 'PACC', 'PREL', 'P10', 'RI_A', 'Pbe', 'Pbie']
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
30 data_tracks = {k: [] for k in KEYS}
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
31
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
32 for line in data.split('\n'):
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
33 if line.startswith('#') or line.startswith('No') or len(line.strip()) == 0:
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
34 continue
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
35
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
36 for idx, (key, value) in enumerate(zip(KEYS, line.strip().split('\t'))):
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
37 # numerical columns
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
38 if idx not in (1, 2, 11, 12):
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
39 value = int(value)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
40
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
41 data_tracks[key].append(value)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
42 return data_tracks
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
43
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
44 def storeWigData(idx, data, id, path):
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
45 with open(path, 'a') as handle:
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
46 handle.write('variableStep chrom=%s\n' % id)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
47 for (pos, val) in zip(idx, data):
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
48 handle.write('%s %s\n' % (pos, val))
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
49
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
50 def storeGff3Data(path, id, positions, values, decodeMap):
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
51 merged = ''.join(values)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
52 # http://stackoverflow.com/a/19683549
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
53 regions = [(x[0][0].upper(), len(x[0])) for x in re.findall('((.)(\\2*))', merged)]
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
54
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
55 location = 1
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
56
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
57 rec = SeqRecord(Seq("ACTG"), id=id)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
58 for (region_char, region_length) in regions:
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
59 # If we don't wish to decode this region, skip it.
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
60 if region_char not in decodeMap:
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
61 location += region_length
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
62 continue
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
63
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
64 region_info = decodeMap[region_char]
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
65 # Create a feature representing this region
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
66 region_feat = SeqFeature(
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
67 FeatureLocation(location - 1, location - 1 + region_length),
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
68 type=region_info['type'], strand=0,
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
69 qualifiers={k: v for (k, v) in region_info.iteritems() if k != 'type'}
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
70 )
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
71 # Update our start location
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
72 location += region_length
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
73 rec.features.append(region_feat)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
74
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
75 with open(path, 'a') as handle:
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
76 GFF.write([rec], handle)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
77
1
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
78 def storeClassData(path, id, phel):
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
79 h = float(phel.count('H')) / float(len(phel))
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
80 e = float(phel.count('E')) / float(len(phel))
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
81
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
82 if h > .45 and e < .05:
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
83 classification = 'all-alpha'
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
84 elif h < .05 and e > .45:
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
85 classification = 'all-beta'
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
86 elif h > .3 and e > .2:
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
87 classification = 'alpha-beta'
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
88 else:
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
89 classification = 'mixed'
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
90
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
91 with open(path, 'a') as handle:
7
fb0936cf5bef planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit db55deda35d1623ff48fbea7b3d0690a2cd9cd9f-dirty
iuc
parents: 1
diff changeset
92 handle.write('# id\t% alpha\t% beta\tclass\n')
fb0936cf5bef planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit db55deda35d1623ff48fbea7b3d0690a2cd9cd9f-dirty
iuc
parents: 1
diff changeset
93 handle.write('{0}\t{1:.2f}\t{2:.2f}\t{3}'.format(id, h, e, classification))
1
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
94
0
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
95 def main(fasta, modeldir):
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
96 for record in SeqIO.parse(fasta, 'fasta'):
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
97 tmp = tempfile.NamedTemporaryFile(delete=False)
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
98 SeqIO.write([record], tmp, 'fasta')
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
99 tmp.close()
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
100
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
101 # Run reprof
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
102 data = process_reprof_report(run_reprof(tmp.name, modeldir))
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
103 for col in ('RI_S', 'P10', 'RI_A', 'PACC', 'PREL', 'pH', 'pE', 'pL'):
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
104 storeWigData(data['idx'], data[col], record.id, col + '.wig')
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
105
1
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
106 eco = ['{ECO:0000255|reprof_1.0.1}']
0
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
107 storeGff3Data(
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
108 'secondary_structure.gff3', record.id, data['idx'], data['PHEL'],
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
109 {
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
110 'H': {
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
111 'type': 'peptide_helix',
1
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
112 'description': ['Helix'],
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
113 'evidence': eco,
0
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
114 },
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
115 'E': {
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
116 'type': 'beta_strand',
1
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
117 'description': ['Extended/Sheet'],
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
118 'evidence': eco,
0
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
119 },
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
120 'L': {
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
121 'type': 'loop',
1
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
122 'description': ['Loop'],
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
123 'evidence': eco,
0
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
124 }
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
125 }
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
126 )
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
127
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
128 storeGff3Data(
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
129 'solvent_accessibility.gff3', record.id, data['idx'], data['Pbe'],
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
130 {
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
131 'B': {
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
132 'type': 'experimental_result_region',
1
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
133 'description': ['Buried'],
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
134 'evidence': eco,
0
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
135 },
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
136 'E': {
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
137 'type': 'experimental_result_region',
1
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
138 'description': ['Exposed'],
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
139 'evidence': eco,
0
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
140 },
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
141 }
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
142 )
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
143
1
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
144 storeClassData('report.tsv', record.id, data['PHEL'])
141da185be70 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit 3aca39eed712c5b3ab8faac62accab588704ffd9
iuc
parents: 0
diff changeset
145
0
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
146
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
147 if __name__ == '__main__':
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
148 # Grab all of the filters from our plugin loader
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
149 parser = argparse.ArgumentParser(description='Wrapper for reprof')
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
150 parser.add_argument('fasta', type=file, help='Fasta Input')
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
151 parser.add_argument('modeldir')
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
152 args = parser.parse_args()
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
153
7c33ed152672 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/reprof commit cc30e84dcc309a93f49f75250aa3344f926cee5e-dirty
iuc
parents:
diff changeset
154 main(**vars(args))