annotate scripts/outputs.py @ 21:e7f1b552a695 draft

planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
author galaxy-australia
date Tue, 29 Oct 2024 02:15:36 +0000
parents 6ab1a261520a
children 3f188450ca4f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
1 """Generate additional output files not produced by AlphaFold.
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
2
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
3 Currently this is includes:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
4 - model confidence scores
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
5 - per-residue confidence scores (pLDDTs - optional output)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
6 - model_*.pkl files renamed with rank order
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
7
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
8 N.B. There have been issues with this script breaking between AlphaFold
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
9 versions due to minor changes in the output directory structure across minor
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
10 versions. It will likely need updating with future releases of AlphaFold.
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
11
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
12 This code is more complex than you might expect due to the output files
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
13 'moving around' considerably, depending on run parameters. You will see that
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
14 several output paths are determined dynamically.
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
15 """
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
17 import argparse
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
18 import json
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
19 import numpy as np
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
20 import os
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
21 import pickle as pk
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
22 import shutil
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
23 from pathlib import Path
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
24 from typing import Dict, List
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
25
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
26 from matplotlib import pyplot as plt
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
27
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
28 # Output file paths
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
29 OUTPUT_DIR = 'extra'
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
30 OUTPUTS = {
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
31 'model_pkl': OUTPUT_DIR + '/ranked_{rank}.pkl',
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
32 'model_pae': OUTPUT_DIR + '/pae_ranked_{rank}.csv',
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
33 'model_plot': OUTPUT_DIR + '/ranked_{rank}.png',
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
34 'model_confidence_scores': OUTPUT_DIR + '/model_confidence_scores.tsv',
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
35 'plddts': OUTPUT_DIR + '/plddts.tsv',
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
36 'relax': OUTPUT_DIR + '/relax_metrics_ranked.json',
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
37 'msa': OUTPUT_DIR + '/msa_coverage.png',
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
38 }
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
39
20
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
40 HTML_PATH = Path(__file__).parent / "alphafold.html"
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
41 HTML_OUTPUT_FILENAME = 'alphafold.html'
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
42 HTML_BUTTON_ATTR = 'class="btn" id="btn-ranked_{rank}"'
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
43 HTML_BUTTON_ATTR_DISABLED = (
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
44 'class="btn disabled" id="btn-ranked_{rank}" disabled')
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
45
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
46
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
47 class PLDDT_KEY:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
48 """Dict keys for accessing confidence data from JSON/pkl files."
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
49 Changes depending on which model PRESET was used.
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
50 """
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
51 monomer = 'plddts'
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
52 multimer = 'iptm+ptm'
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
53
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
54
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
55 class PRESETS:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
56 monomer = 'monomer'
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
57 monomer_ptm = 'monomer_ptm'
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
58 multimer = 'multimer'
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
59
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
60
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
61 class Settings:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
62 """Parse and store settings/config."""
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
63 def __init__(self):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
64 self.workdir = None
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
65 self.output_confidence_scores = True
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
66 self.output_residue_scores = False
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
67 self.is_multimer = False
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
68 self.parse()
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
69
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
70 def parse(self) -> None:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
71 parser = argparse.ArgumentParser()
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
72 parser.add_argument(
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
73 "workdir",
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
74 help="alphafold output directory",
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
75 type=str,
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
76 )
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
77 parser.add_argument(
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
78 "-s",
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
79 "--confidence-scores",
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
80 help="output per-residue confidence scores (pLDDTs)",
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
81 action="store_true",
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
82 )
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
83 parser.add_argument(
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
84 "--pkl",
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
85 help="rename model pkl outputs with rank order",
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
86 action="store_true",
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
87 )
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
88 parser.add_argument(
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
89 "--pae",
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
90 help="extract PAE from pkl files to CSV format",
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
91 action="store_true",
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
92 )
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
93 parser.add_argument(
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
94 "--plot",
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
95 help="Plot pLDDT and PAE for each model",
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
96 action="store_true",
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
97 )
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
98 parser.add_argument(
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
99 "--plot-msa",
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
100 help="Plot multiple-sequence alignment coverage as a heatmap",
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
101 action="store_true",
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
102 )
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
103 args = parser.parse_args()
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
104 self.workdir = Path(args.workdir.rstrip('/'))
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
105 self.output_residue_scores = args.confidence_scores
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
106 self.output_model_pkls = args.pkl
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
107 self.output_model_plots = args.plot
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
108 self.output_pae = args.pae
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
109 self.plot_msa = args.plot_msa
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
110 self.model_preset = self._sniff_model_preset()
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
111 self.output_dir = self.workdir / OUTPUT_DIR
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
112 os.makedirs(self.output_dir, exist_ok=True)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
113
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
114 def _sniff_model_preset(self) -> bool:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
115 """Check if the run was multimer or monomer."""
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
116 with open(self.workdir / 'relax_metrics.json') as f:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
117 if '_multimer_' in f.read():
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
118 return PRESETS.multimer
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
119 if '_ptm_' in f.read():
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
120 return PRESETS.monomer_ptm
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
121 return PRESETS.monomer
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
122
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
123
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
124 class ExecutionContext:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
125 """Collect file paths etc."""
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
126 def __init__(self, settings: Settings):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
127 self.settings = settings
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
128 if settings.model_preset == PRESETS.multimer:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
129 self.plddt_key = PLDDT_KEY.multimer
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
130 else:
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
131 self.plddt_key = PLDDT_KEY.monomer
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
132
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
133 def get_model_key(self, ix: int) -> str:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
134 """Return json key for model index.
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
135
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
136 The key format changed between minor AlphaFold versions so this
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
137 function determines the correct key.
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
138 """
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
139 with open(self.ranking_debug) as f:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
140 data = json.load(f)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
141 model_keys = list(data[self.plddt_key].keys())
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
142 for k in model_keys:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
143 if k.startswith(f"model_{ix}_"):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
144 return k
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
145 return KeyError(
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
146 f'Could not find key for index={ix} in'
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
147 ' ranking_debug.json')
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
148
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
149 @property
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
150 def ranking_debug(self) -> str:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
151 return self.settings.workdir / 'ranking_debug.json'
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
152
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
153 @property
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
154 def relax_metrics(self) -> str:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
155 return self.settings.workdir / 'relax_metrics.json'
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
156
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
157 @property
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
158 def relax_metrics_ranked(self) -> str:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
159 return self.settings.workdir / 'relax_metrics_ranked.json'
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
160
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
161 @property
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
162 def model_pkl_paths(self) -> List[str]:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
163 return sorted([
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
164 self.settings.workdir / f
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
165 for f in os.listdir(self.settings.workdir)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
166 if f.startswith('result_model_') and f.endswith('.pkl')
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
167 ])
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
168
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
169
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
170 class ResultModelPrediction:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
171 """Load and manipulate data from result_model_*.pkl files."""
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
172 def __init__(self, path: str, context: ExecutionContext):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
173 self.context = context
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
174 self.path = path
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
175 self.name = os.path.basename(path).replace('result_', '').split('.')[0]
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
176 with open(path, 'rb') as path:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
177 self.data = pk.load(path)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
178
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
179 @property
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
180 def plddts(self) -> List[float]:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
181 """Return pLDDT scores for each residue."""
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
182 return list(self.data['plddt'])
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
183
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
184
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
185 class ResultRanking:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
186 """Load and manipulate data from ranking_debug.json file."""
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
187
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
188 def __init__(self, context: ExecutionContext):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
189 self.path = context.ranking_debug
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
190 self.context = context
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
191 with open(self.path, 'r') as f:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
192 self.data = json.load(f)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
193
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
194 @property
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
195 def order(self) -> List[str]:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
196 """Return ordered list of model indexes."""
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
197 return self.data['order']
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
198
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
199 def get_plddt_for_rank(self, rank: int) -> List[float]:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
200 """Get pLDDT score for model instance."""
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
201 return self.data[self.context.plddt_key][self.data['order'][rank - 1]]
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
202
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
203 def get_rank_for_model(self, model_name: str) -> int:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
204 """Return 0-indexed rank for given model name.
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
205
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
206 Model names are expressed in result_model_*.pkl file names.
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
207 """
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
208 return self.data['order'].index(model_name)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
209
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
210
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
211 def write_confidence_scores(ranking: ResultRanking, context: ExecutionContext):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
212 """Write per-model confidence scores."""
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
213 outfile = context.settings.workdir / OUTPUTS['model_confidence_scores']
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
214 scores: Dict[str, list] = {}
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
215 header = ['model', context.plddt_key]
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
216
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
217 for i, path in enumerate(context.model_pkl_paths):
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
218 rank = int(path.name.split('model_')[-1][0])
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
219 scores_ls = [ranking.get_plddt_for_rank(rank)]
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
220 with open(path, 'rb') as f:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
221 data = pk.load(f)
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
222 if 'ptm' in data:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
223 scores_ls.append(data['ptm'])
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
224 if i == 0:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
225 header += ['ptm']
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
226 if 'iptm' in data:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
227 scores_ls.append(data['iptm'])
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
228 if i == 0:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
229 header += ['iptm']
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
230 scores[rank] = scores_ls
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
231
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
232 with open(outfile, 'w') as f:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
233 f.write('\t'.join(header) + '\n')
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
234 for rank, score_ls in scores.items():
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
235 row = [f"ranked_{rank - 1}"] + [str(x) for x in score_ls]
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
236 f.write('\t'.join(row) + '\n')
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
237
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
238
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
239 def write_per_residue_scores(
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
240 ranking: ResultRanking,
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
241 context: ExecutionContext,
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
242 ):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
243 """Write per-residue plddts for each model.
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
244
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
245 A row of plddt values is written for each model in tabular format.
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
246 """
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
247 model_plddts = {}
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
248 for i, path in enumerate(context.model_pkl_paths):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
249 model = ResultModelPrediction(path, context)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
250 rank = ranking.get_rank_for_model(model.name)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
251 model_plddts[rank] = model.plddts
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
252
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
253 path = context.settings.workdir / OUTPUTS['plddts']
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
254 with open(path, 'w') as f:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
255 for i in sorted(list(model_plddts.keys())):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
256 row = [f'ranked_{i}'] + [
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
257 str(x) for x in model_plddts[i]
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
258 ]
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
259 f.write('\t'.join(row) + '\n')
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
260
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
261
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
262 def rename_model_pkls(ranking: ResultRanking, context: ExecutionContext):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
263 """Rename model.pkl files so the rank order is implicit."""
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
264 for path in context.model_pkl_paths:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
265 model = ResultModelPrediction(path, context)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
266 rank = ranking.get_rank_for_model(model.name)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
267 new_path = (
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
268 context.settings.workdir
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
269 / OUTPUTS['model_pkl'].format(rank=rank)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
270 )
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
271 shutil.copyfile(path, new_path)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
272
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
273
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
274 def extract_pae_to_csv(ranking: ResultRanking, context: ExecutionContext):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
275 """Extract predicted alignment error matrix from pickle files.
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
276
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
277 Creates a CSV file for each of five ranked models.
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
278 """
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
279 for path in context.model_pkl_paths:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
280 model = ResultModelPrediction(path, context)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
281 rank = ranking.get_rank_for_model(model.name)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
282 with open(path, 'rb') as f:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
283 data = pk.load(f)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
284 if 'predicted_aligned_error' not in data:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
285 print("Skipping PAE output"
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
286 f" - not found in {path}."
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
287 " Running with model_preset=monomer?")
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
288 return
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
289 pae = data['predicted_aligned_error']
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
290 out_path = (
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
291 context.settings.workdir
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
292 / OUTPUTS['model_pae'].format(rank=rank)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
293 )
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
294 with open(out_path, 'w') as f:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
295 for row in pae:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
296 f.write(','.join([str(x) for x in row]) + '\n')
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
297
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
298
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
299 def rekey_relax_metrics(ranking: ResultRanking, context: ExecutionContext):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
300 """Replace keys in relax_metrics.json with 0-indexed rank."""
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
301 with open(context.relax_metrics) as f:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
302 data = json.load(f)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
303 for k in list(data.keys()):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
304 rank = ranking.get_rank_for_model(k)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
305 data[f'ranked_{rank}'] = data.pop(k)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
306 new_path = context.settings.workdir / OUTPUTS['relax']
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
307 with open(new_path, 'w') as f:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
308 json.dump(data, f)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
309
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
310
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
311 def plddt_pae_plots(ranking: ResultRanking, context: ExecutionContext):
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
312 """Generate a pLDDT + PAE plot for each model."""
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
313 for path in context.model_pkl_paths:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
314 num_plots = 2
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
315 model = ResultModelPrediction(path, context)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
316 rank = ranking.get_rank_for_model(model.name)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
317 png_path = (
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
318 context.settings.workdir
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
319 / OUTPUTS['model_plot'].format(rank=rank)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
320 )
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
321 plddts = model.data['plddt']
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
322 if 'predicted_aligned_error' in model.data:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
323 pae = model.data['predicted_aligned_error']
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
324 max_pae = model.data['max_predicted_aligned_error']
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
325 else:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
326 num_plots = 1
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
327
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
328 plt.figure(figsize=[8 * num_plots, 6])
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
329 plt.subplot(1, num_plots, 1)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
330 plt.plot(plddts)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
331 plt.title('Predicted LDDT')
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
332 plt.xlabel('Residue')
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
333 plt.ylabel('pLDDT')
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
334
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
335 if num_plots == 2:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
336 plt.subplot(1, 2, 2)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
337 plt.imshow(pae, vmin=0., vmax=max_pae, cmap='Greens_r')
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
338 plt.colorbar(fraction=0.046, pad=0.04)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
339 plt.title('Predicted Aligned Error')
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
340 plt.xlabel('Scored residue')
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
341 plt.ylabel('Aligned residue')
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
342
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
343 plt.savefig(png_path)
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
344 plt.close()
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
345
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
346
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
347 def plot_msa(wdir: Path, dpi: int = 150):
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
348 """Plot MSA as a heatmap."""
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
349 with open(wdir / 'features.pkl', 'rb') as f:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
350 features = pk.load(f)
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
351
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
352 msa = features.get('msa')
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
353 if msa is None:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
354 print("Could not plot MSA coverage - 'msa' key not found in"
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
355 " features.pkl")
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
356 return
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
357 seqid = (np.array(msa[0] == msa).mean(-1))
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
358 seqid_sort = seqid.argsort()
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
359 non_gaps = (msa != 21).astype(float)
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
360 non_gaps[non_gaps == 0] = np.nan
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
361 final = non_gaps[seqid_sort] * seqid[seqid_sort, None]
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
362
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
363 plt.figure(figsize=(6, 4))
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
364 # plt.subplot(111)
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
365 plt.title("Sequence coverage")
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
366 plt.imshow(final,
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
367 interpolation='nearest', aspect='auto',
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
368 cmap="rainbow_r", vmin=0, vmax=1, origin='lower')
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
369 plt.plot((msa != 21).sum(0), color='black')
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
370 plt.xlim(-0.5, msa.shape[1] - 0.5)
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
371 plt.ylim(-0.5, msa.shape[0] - 0.5)
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
372 plt.colorbar(label="Sequence identity to query", )
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
373 plt.xlabel("Positions")
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
374 plt.ylabel("Sequences")
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
375 plt.tight_layout()
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
376 plt.savefig(wdir / OUTPUTS['msa'], dpi=dpi)
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
377 plt.close()
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
378
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
379
20
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
380 def template_html(context: ExecutionContext):
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
381 """Template HTML file.
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
382
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
383 Remove buttons that are redundant with limited model outputs.
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
384 """
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
385 print("Templating HTML file...")
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
386 with open(HTML_PATH) as f:
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
387 html = f.read()
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
388 for i in range(len(context.model_pkl_paths), 5):
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
389 btn_id = HTML_BUTTON_ATTR.format(rank=i)
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
390 btn_attr_disabled = HTML_BUTTON_ATTR_DISABLED.format(rank=i)
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
391 html = html.replace(btn_id, btn_attr_disabled)
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
392 with open(context.settings.output_dir / HTML_OUTPUT_FILENAME, 'w') as f:
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
393 f.write(html)
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
394
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
395
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
396 def main():
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
397 """Parse output files and generate additional output files."""
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
398 settings = Settings()
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
399 context = ExecutionContext(settings)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
400 ranking = ResultRanking(context)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
401 write_confidence_scores(ranking, context)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
402 rekey_relax_metrics(ranking, context)
20
6ab1a261520a planemo upload for repository https://github.com/usegalaxy-au/tools-au commit c3a90eb12ada44d477541baa4dd6182be29cd554-dirty
galaxy-australia
parents: 16
diff changeset
403 template_html(context)
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
404
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
405 # Optional outputs
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
406 if settings.output_model_pkls:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
407 rename_model_pkls(ranking, context)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
408 if settings.output_model_plots:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
409 plddt_pae_plots(ranking, context)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
410 if settings.output_pae:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
411 # Only created by monomer_ptm and multimer models
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
412 extract_pae_to_csv(ranking, context)
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
413 if settings.output_residue_scores:
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
414 write_per_residue_scores(ranking, context)
21
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
415 if settings.plot_msa:
e7f1b552a695 planemo upload for repository https://github.com/usegalaxy-au/tools-au commit 628c9fdcb77489063145a2307b6bb6a450416dd6-dirty
galaxy-australia
parents: 20
diff changeset
416 plot_msa(context.settings.workdir)
16
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
417
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
418
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
419 if __name__ == '__main__':
f9eb041c518c planemo upload for repository https://github.com/usegalaxy-au/tools-au commit ee77734f1800350fa2a6ef28b2b8eade304a456f-dirty
galaxy-australia
parents:
diff changeset
420 main()