Mercurial > repos > iuc > b2btools_single_sequence
annotate script.py @ 0:b694a77ca1e8 draft default tip
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
author | iuc |
---|---|
date | Tue, 09 Aug 2022 12:30:52 +0000 |
parents | |
children |
rev | line source |
---|---|
0
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
1 import json |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
2 import optparse |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
3 import os.path |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
4 import re |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
5 import unicodedata |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
6 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
7 import matplotlib.pyplot as plt |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
8 import numpy as np |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
9 import pandas as pd |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
10 from b2bTools import SingleSeq |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
11 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
12 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
13 def slugify(value): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
14 """ |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
15 From https://github.com/django/django/blob/master/django/utils/text.py |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
16 Convert to ASCII if 'allow_unicode'. Convert spaces or repeated |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
17 dashes to single dashes. Remove characters that aren't alphanumerics, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
18 underscores, or hyphens. Convert to lowercase. Also strip leading and |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
19 trailing whitespace, dashes, and underscores. |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
20 """ |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
21 value = str(value) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
22 value = ( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
23 unicodedata.normalize("NFKD", value) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
24 .encode("ascii", "ignore") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
25 .decode("ascii") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
26 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
27 value = re.sub(r"[^\w\s-]", "", value.lower()) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
28 return re.sub(r"[-\s]+", "-", value).strip("-_") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
29 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
30 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
31 def check_min_max(predicted_values, former_min, former_max): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
32 seq_max = max(predicted_values) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
33 seq_min = min(predicted_values) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
34 if ( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
35 seq_max + 0.1 > former_max |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
36 and not np.isnan(seq_max) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
37 and not np.isinf(seq_max) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
38 ): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
39 former_max = seq_max + 0.1 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
40 if ( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
41 seq_min - 0.1 < former_min |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
42 and not np.isnan(seq_min) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
43 and not np.isinf(seq_min) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
44 ): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
45 former_min = seq_min - 0.1 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
46 return former_min, former_max |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
47 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
48 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
49 def plot_prediction(pred_name, hlighting_regions, predicted_values, seq_name): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
50 thresholds_dict = { |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
51 "backbone": { |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
52 "membrane spanning": [1.0, 1.5], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
53 "rigid": [0.8, 1.0], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
54 "context-dependent": [0.69, 0.8], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
55 "flexible": [-1.0, 0.69], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
56 }, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
57 "earlyFolding": { |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
58 "early folds": [0.169, 2.0], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
59 "late folds": [-1.0, 0.169], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
60 }, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
61 "disoMine": {"ordered": [-1.0, 0.5], "disordered": [0.5, 2.0]}, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
62 } |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
63 ordered_regions_dict = { |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
64 "backbone": [ |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
65 "flexible", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
66 "context-dependent", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
67 "rigid", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
68 "membrane spanning", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
69 ], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
70 "earlyFolding": ["late folds", "early folds"], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
71 "disoMine": ["ordered", "disordered"], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
72 } |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
73 colors = ["yellow", "orange", "pink", "red"] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
74 ranges_dict = { |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
75 "backbone": [-0.2, 1.2], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
76 "sidechain": [-0.2, 1.2], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
77 "ppII": [-0.2, 1.2], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
78 "earlyFolding": [-0.2, 1.2], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
79 "disoMine": [-0.2, 1.2], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
80 "agmata": [-0.2, 1.2], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
81 "helix": [-1.0, 1.0], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
82 "sheet": [-1.0, 1.0], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
83 "coil": [-1.0, 1.0], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
84 } |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
85 fig, ax = plt.subplots(1, 1) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
86 fig.set_figwidth(10) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
87 fig.set_figheight(5) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
88 ax.set_title(pred_name + " " + "prediction") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
89 min_value, max_value = ranges_dict[pred_name] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
90 if seq_name == "all": |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
91 max_len = 0 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
92 for seq in predicted_values.keys(): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
93 predictions = predicted_values[seq] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
94 min_value, max_value = check_min_max( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
95 predictions, min_value, max_value |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
96 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
97 ax.plot(range(len(predictions)), predictions, label=seq) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
98 if len(predictions) > max_len: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
99 max_len = len(predictions) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
100 ax.set_xlim([0, max_len - 1]) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
101 else: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
102 predictions = predicted_values |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
103 min_value, max_value = check_min_max(predictions, min_value, max_value) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
104 ax.plot(range(len(predictions)), predictions, label=seq_name) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
105 ax.set_xlim([0, len(predictions) - 1]) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
106 legend_lines = plt.legend( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
107 bbox_to_anchor=(1.04, 1), loc="upper left", fancybox=True, shadow=True |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
108 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
109 ax.add_artist(legend_lines) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
110 # Define regions |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
111 if hlighting_regions: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
112 if pred_name in ordered_regions_dict.keys(): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
113 for i, prediction in enumerate(ordered_regions_dict[pred_name]): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
114 lower = thresholds_dict[pred_name][prediction][0] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
115 upper = thresholds_dict[pred_name][prediction][1] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
116 color = colors[i] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
117 ax.axhspan( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
118 lower, upper, alpha=0.3, color=color, label=prediction |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
119 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
120 included_in_regions_legend = list( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
121 reversed( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
122 [ |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
123 prediction |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
124 for prediction in ordered_regions_dict[pred_name] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
125 ] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
126 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
127 ) # to sort it "from up to low" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
128 # Get handles and labels |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
129 handles, labels = plt.gca().get_legend_handles_labels() |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
130 handles_dict = { |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
131 label: handles[idx] for idx, label in enumerate(labels) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
132 } |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
133 # Add legend for regions, if available |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
134 region_legend = ax.legend( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
135 [ |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
136 handles_dict[region] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
137 for region in included_in_regions_legend |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
138 ], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
139 [region for region in included_in_regions_legend], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
140 fancybox=True, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
141 shadow=True, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
142 loc="lower left", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
143 bbox_to_anchor=(1.04, 0), |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
144 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
145 ax.add_artist(region_legend) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
146 ax.set_ylim([min_value, max_value]) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
147 ax.set_xlabel("residue index") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
148 ax.set_ylabel("prediction values") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
149 ax.grid(axis="y") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
150 plt.savefig( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
151 os.path.join( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
152 options.plot_output, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
153 "{0}_{1}.png".format(slugify(seq_name), pred_name), |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
154 ), |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
155 bbox_inches="tight", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
156 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
157 plt.close() |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
158 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
159 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
160 def df_dict_to_dict_of_values(df_dict, predictor): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
161 results_dict = {} |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
162 for seq in df_dict.keys(): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
163 df = pd.read_csv(df_dict[seq], sep="\t") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
164 results_dict[seq] = df[predictor] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
165 return results_dict |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
166 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
167 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
168 def main(options): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
169 single_seq = SingleSeq(options.input_fasta) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
170 b2b_tools = [] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
171 if options.dynamine: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
172 b2b_tools.append("dynamine") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
173 if options.disomine: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
174 b2b_tools.append("disomine") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
175 if options.efoldmine: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
176 b2b_tools.append("efoldmine") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
177 if options.agmata: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
178 b2b_tools.append("agmata") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
179 single_seq.predict(b2b_tools) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
180 predictions = single_seq.get_all_predictions() |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
181 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
182 def rounder_function(value): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
183 return round(float(value), 3) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
184 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
185 rounded_predictions = json.loads( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
186 json.dumps(predictions), parse_float=rounder_function |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
187 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
188 results_json = json.dumps(rounded_predictions, indent=2, sort_keys=True) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
189 with open(options.json_output, "w") as f: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
190 f.write(results_json) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
191 first_sequence_key = next(iter(predictions)) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
192 prediction_keys = predictions[first_sequence_key].keys() |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
193 # Sort column names |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
194 tsv_column_names = list(prediction_keys) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
195 tsv_column_names.remove("seq") |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
196 tsv_column_names = ['residue', *sorted(tsv_column_names)] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
197 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
198 df_dictionary = {} |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
199 for sequence_key, seq_preds in predictions.items(): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
200 residues = seq_preds["seq"] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
201 residues_count = len(residues) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
202 sequence_df = pd.DataFrame( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
203 columns=prediction_keys, index=range(residues_count) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
204 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
205 sequence_df.index.name = "residue_index" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
206 for predictor in prediction_keys: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
207 sequence_df[predictor] = seq_preds[predictor] |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
208 sequence_df = sequence_df.rename(columns={"seq": "residue"}) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
209 sequence_df = sequence_df.round(decimals=3) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
210 filename = f"{options.output}/{slugify(sequence_key)}.tsv" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
211 df_dictionary[sequence_key] = filename |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
212 sequence_df.to_csv( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
213 filename, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
214 header=True, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
215 columns=tsv_column_names, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
216 sep="\t" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
217 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
218 # Plot each individual plot (compatible with plot all) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
219 if options.plot: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
220 for predictor in prediction_keys: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
221 if predictor != "seq": |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
222 plot_prediction( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
223 pred_name=predictor, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
224 hlighting_regions=True, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
225 predicted_values=seq_preds[predictor], |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
226 seq_name=sequence_key, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
227 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
228 # Plot all together (compatible with plot individual) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
229 if options.plot_all: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
230 for predictor in prediction_keys: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
231 if predictor != "seq": |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
232 results_dictionary = df_dict_to_dict_of_values( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
233 df_dictionary, predictor |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
234 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
235 plot_prediction( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
236 pred_name=predictor, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
237 hlighting_regions=True, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
238 predicted_values=results_dictionary, |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
239 seq_name="all", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
240 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
241 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
242 |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
243 if __name__ == "__main__": |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
244 parser = optparse.OptionParser() |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
245 parser.add_option( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
246 "--dynamine", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
247 action="store_true" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
248 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
249 parser.add_option( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
250 "--disomine", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
251 action="store_true" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
252 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
253 parser.add_option( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
254 "--efoldmine", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
255 action="store_true" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
256 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
257 parser.add_option( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
258 "--agmata", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
259 action="store_true" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
260 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
261 parser.add_option( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
262 "--file", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
263 dest="input_fasta", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
264 type="string" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
265 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
266 parser.add_option( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
267 "--output", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
268 dest="output", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
269 type="string" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
270 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
271 parser.add_option( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
272 "--plot-output", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
273 type="string", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
274 dest="plot_output" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
275 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
276 parser.add_option( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
277 "--json", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
278 dest="json_output", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
279 type="string" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
280 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
281 parser.add_option( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
282 "--plot", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
283 action="store_true" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
284 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
285 parser.add_option( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
286 "--plot_all", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
287 action="store_true" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
288 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
289 parser.add_option( |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
290 "--highlight", |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
291 action="store_true" |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
292 ) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
293 try: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
294 options, args = parser.parse_args() |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
295 if not (options.dynamine or options.disomine or options.efoldmine or options.agmata): |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
296 parser.error('At least one predictor is required') |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
297 if not options.input_fasta: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
298 parser.error('Input file not given (--file)') |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
299 if not options.output: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
300 parser.error('Output directory not given (--output)') |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
301 if (options.plot or options.plot_all) and not options.plot_output: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
302 parser.error('Plot output directory not given (--plot-output)') |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
303 if not options.json_output: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
304 parser.error('Json output file not given (--json)') |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
305 main(options) |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
306 except optparse.OptionError as exc: |
b694a77ca1e8
planemo upload commit 599e1135baba020195b3f7576449d595bca9af75
iuc
parents:
diff
changeset
|
307 raise RuntimeError(f"Invalid arguments: {args}") from exc |