annotate script.py @ 2:a9db23ac113f draft default tip

Uploaded new version formatted.
author adrian.diaz
date Tue, 02 Aug 2022 09:44:33 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
1 import optparse
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
2 import os.path
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
3 import unicodedata
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
4 import re
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
5 import numpy as np
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
6 import pandas as pd
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
7 from b2bTools import SingleSeq
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
8 import matplotlib.pyplot as plt
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
9
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
10
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
11 def slugify(value):
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
12 """
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
13 Taken from
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
14 https://github.com/django/django/blob/master/django/utils/text.py
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
15 Convert to ASCII if 'allow_unicode'. Convert spaces or repeated
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
16 dashes to single dashes. Remove characters that aren't alphanumerics,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
17 underscores, or hyphens. Convert to lowercase. Also strip leading and
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
18 trailing whitespace, dashes, and underscores.
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
19 """
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
20 value = str(value)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
21 value = unicodedata.normalize(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
22 'NFKD', value).encode(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
23 'ascii', 'ignore').decode('ascii')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
24 value = re.sub(r'[^\w\s-]', '', value.lower())
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
25 return re.sub(r'[-\s]+', '-', value).strip('-_')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
26
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
27
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
28 def check_min_max(predicted_values, former_min, former_max):
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
29 seq_max = max(predicted_values)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
30 seq_min = min(predicted_values)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
31 if seq_max + \
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
32 0.1 > former_max and not np.isnan(seq_max) \
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
33 and not np.isinf(seq_max):
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
34 former_max = seq_max + 0.1
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
35 if seq_min - \
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
36 0.1 < former_min and not np.isnan(seq_min) \
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
37 and not np.isinf(seq_min):
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
38 former_min = seq_min - 0.1
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
39 return former_min, former_max
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
40
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
41
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
42 def plot_prediction(prediction_name, highlighting_regions,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
43 pred_vals, seq_name):
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
44 thresholds_dict = {'backbone': {'membrane spanning': [1., 1.5],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
45 'rigid': [0.8, 1.],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
46 'context-dependent': [0.69, 0.8],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
47 'flexible': [-1.0, 0.69]},
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
48 'earlyFolding': {'early folds': [0.169, 2.],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
49 'late folds': [-1., 0.169]},
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
50 'disoMine': {'ordered': [-1., 0.5],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
51 'disordered': [0.5, 2.]},
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
52 }
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
53 ordered_regions_dict = {'backbone': ['flexible',
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
54 'context-dependent',
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
55 'rigid',
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
56 'membrane spanning'],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
57 'earlyFolding': ['late folds', 'early folds'],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
58 'disoMine': ['ordered', 'disordered'],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
59 }
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
60 colors = ['yellow', 'orange', 'pink', 'red']
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
61 ranges_dict = {
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
62 'backbone': [-0.2, 1.2],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
63 'sidechain': [-0.2, 1.2],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
64 'ppII': [-0.2, 1.2],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
65 'earlyFolding': [-0.2, 1.2],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
66 'disoMine': [-0.2, 1.2],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
67 'agmata': [-0.2, 1.2],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
68 'helix': [-1., 1.],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
69 'sheet': [-1., 1.],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
70 'coil': [-1., 1.],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
71 }
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
72 fig, ax = plt.subplots(1, 1)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
73 fig.set_figwidth(10)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
74 fig.set_figheight(5)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
75 ax.set_title(prediction_name + ' ' + 'prediction')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
76 min_value, max_value = ranges_dict[prediction_name]
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
77 if seq_name == 'all':
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
78 max_len = 0
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
79 for seq in pred_vals.keys():
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
80 predictions = pred_vals[seq]
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
81 min_value, max_value = check_min_max(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
82 predictions, min_value, max_value)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
83 ax.plot(range(len(predictions)), predictions, label=seq)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
84 if len(predictions) > max_len:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
85 max_len = len(predictions)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
86 ax.set_xlim([0, max_len - 1])
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
87 else:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
88 predictions = pred_vals
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
89 min_value, max_value = check_min_max(predictions, min_value, max_value)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
90 ax.plot(range(len(predictions)), predictions, label=seq_name)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
91 ax.set_xlim([0, len(predictions) - 1])
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
92 legend_lines = plt.legend(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
93 bbox_to_anchor=(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
94 1.04,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
95 1),
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
96 loc="upper left",
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
97 fancybox=True,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
98 shadow=True)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
99 ax.add_artist(legend_lines)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
100 # Define regions
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
101 if highlighting_regions:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
102 if prediction_name in ordered_regions_dict.keys():
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
103 for i, prediction in enumerate(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
104 ordered_regions_dict[prediction_name]):
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
105 lower = thresholds_dict[prediction_name][prediction][0]
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
106 upper = thresholds_dict[prediction_name][prediction][1]
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
107 color = colors[i]
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
108 ax.axhspan(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
109 lower,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
110 upper,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
111 alpha=0.3,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
112 color=color,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
113 label=prediction)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
114 # to sort it "from up to low"
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
115 included_in_regions_legend = list(reversed(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
116 [r_pred for r_pred in ordered_regions_dict[prediction_name]]))
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
117 # Get handles and labels
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
118 handles, labels = plt.gca().get_legend_handles_labels()
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
119 handles_dict = {label: handles[idx]
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
120 for idx, label in enumerate(labels)}
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
121 # Add legend for regions, if available
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
122 lgnd_labels = [handles_dict[r] for r in included_in_regions_legend]
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
123 lgnd_regions = [region for region in included_in_regions_legend]
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
124 region_legend = ax.legend(lgnd_labels,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
125 lgnd_regions,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
126 fancybox=True,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
127 shadow=True,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
128 loc='lower left',
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
129 bbox_to_anchor=(1.04, 0))
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
130 ax.add_artist(region_legend)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
131 ax.set_ylim([min_value, max_value])
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
132 ax.set_xlabel('residue index')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
133 ax.set_ylabel('prediction values')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
134 ax.grid(axis='y')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
135 plt.savefig(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
136 os.path.join(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
137 options.plot_output,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
138 "{0}_{1}.png".format(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
139 slugify(seq_name),
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
140 prediction_name)),
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
141 bbox_inches="tight")
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
142 plt.close()
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
143
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
144
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
145 def df_dict_to_dict_of_values(df_dict, predictor):
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
146 results_dict = {}
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
147 for seq in df_dict.keys():
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
148 df = pd.read_csv(df_dict[seq], sep='\t')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
149 results_dict[seq] = df[predictor]
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
150 return results_dict
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
151
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
152
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
153 def main(options):
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
154 single_seq = SingleSeq(options.input_fasta)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
155 b2b_tools = []
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
156 if options.dynamine:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
157 b2b_tools.append('dynamine')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
158 if options.disomine:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
159 b2b_tools.append('disomine')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
160 if options.efoldmine:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
161 b2b_tools.append('efoldmine')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
162 if options.agmata:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
163 b2b_tools.append('agmata')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
164
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
165 single_seq.predict(b2b_tools)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
166 predictions = single_seq.get_all_predictions()
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
167 results_json = single_seq.get_all_predictions_json('all')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
168 with open(options.json_output, 'w') as f:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
169 f.write(results_json)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
170 first_sequence_key = next(iter(predictions))
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
171 prediction_keys = predictions[first_sequence_key].keys()
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
172 df_dictionary = {}
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
173 for sequence_key, sequence_predictions in predictions.items():
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
174 residues = sequence_predictions['seq']
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
175 residues_count = len(residues)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
176 sequence_df = pd.DataFrame(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
177 columns=prediction_keys,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
178 index=range(residues_count))
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
179 sequence_df.index.name = 'residue_index'
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
180 for predictor in prediction_keys:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
181 sequence_df[predictor] = sequence_predictions[predictor]
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
182 sequence_df = sequence_df.rename(columns={"seq": "residue"})
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
183 sequence_df = sequence_df.round(decimals=2)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
184 filename = f'{options.output}/{slugify(sequence_key)}.tsv'
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
185 df_dictionary[sequence_key] = filename
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
186 sequence_df.to_csv(filename, sep="\t")
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
187 # Plot each individual plot (compatible with plot all)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
188 if options.plot:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
189 for predictor in prediction_keys:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
190 if predictor != 'seq':
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
191 plot_prediction(prediction_name=predictor,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
192 highlighting_regions=True,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
193 pred_vals=sequence_predictions[predictor],
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
194 seq_name=sequence_key)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
195 # Plot all together (compatible with plot individual)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
196 if options.plot_all:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
197 for predictor in prediction_keys:
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
198 if predictor != 'seq':
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
199 results_dictionary = df_dict_to_dict_of_values(
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
200 df_dict=df_dictionary, predictor=predictor)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
201 plot_prediction(prediction_name=predictor,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
202 highlighting_regions=True,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
203 pred_vals=results_dictionary,
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
204 seq_name='all')
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
205
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
206
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
207 if __name__ == "__main__":
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
208 parser = optparse.OptionParser()
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
209 parser.add_option("--dynamine", action="store_true", default=False)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
210 parser.add_option("--disomine", action="store_true", default=False)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
211 parser.add_option("--efoldmine", action="store_true", default=False)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
212 parser.add_option("--agmata", action="store_true", default=False)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
213 parser.add_option("--file", dest="input_fasta", default=False)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
214 parser.add_option("--output", dest="output", default=False)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
215 parser.add_option("--plot-output", dest="plot_output", default=False)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
216
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
217 parser.add_option("--json", dest="json_output", default=False)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
218 parser.add_option("--plot", action="store_true", default=False)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
219 parser.add_option("--plot_all", action="store_true", default=False)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
220 parser.add_option("--highlight", action="store_true", default=False)
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
221 options, _args = parser.parse_args()
a9db23ac113f Uploaded new version formatted.
adrian.diaz
parents:
diff changeset
222 main(options)