alphafold3-seqvis-toolkit 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- alphafold3_seqvis_toolkit/__init__.py +4 -0
- alphafold3_seqvis_toolkit/cli.py +246 -0
- alphafold3_seqvis_toolkit/modules/__init__.py +7 -0
- alphafold3_seqvis_toolkit/modules/confidence_metrics_plot.py +548 -0
- alphafold3_seqvis_toolkit/modules/contact_map_comparison_monomer.py +455 -0
- alphafold3_seqvis_toolkit/modules/contact_map_comparison_multimer.py +769 -0
- alphafold3_seqvis_toolkit/modules/contact_map_visualization_with_track.py +554 -0
- alphafold3_seqvis_toolkit/modules/contact_map_visualization_without_track.py +234 -0
- alphafold3_seqvis_toolkit/utils/__init__.py +0 -0
- alphafold3_seqvis_toolkit/utils/track_utils.py +217 -0
- alphafold3_seqvis_toolkit-0.2.1.dist-info/METADATA +1490 -0
- alphafold3_seqvis_toolkit-0.2.1.dist-info/RECORD +15 -0
- alphafold3_seqvis_toolkit-0.2.1.dist-info/WHEEL +4 -0
- alphafold3_seqvis_toolkit-0.2.1.dist-info/entry_points.txt +2 -0
- alphafold3_seqvis_toolkit-0.2.1.dist-info/licenses/LICENSE +674 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
from .modules import confidence_metrics_plot, contact_map_comparison_monomer, contact_map_comparison_multimer, contact_map_visualization_with_track, contact_map_visualization_without_track
|
|
2
|
+
|
|
3
|
+
__all__ = ["contact_map_diff_monomer", "contact_map_diff_multimer", "plot_local_confidence", "plot_global_confidence", "contact_map_vis_with_track", "contact_map_vis_without_track"]
|
|
4
|
+
__version__ = "0.2.1"
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import typer # For building CLI applications, command-line interfaces
|
|
2
|
+
from typing import List, Optional, Dict, Any
|
|
3
|
+
import os
|
|
4
|
+
from alphafold3_seqvis_toolkit.modules.confidence_metrics_plot import plot_local_confidence, plot_global_confidence
|
|
5
|
+
from alphafold3_seqvis_toolkit.modules.contact_map_comparison_monomer import contact_map_diff_monomer
|
|
6
|
+
from alphafold3_seqvis_toolkit.modules.contact_map_comparison_multimer import contact_map_diff_multimer
|
|
7
|
+
from alphafold3_seqvis_toolkit.modules.contact_map_visualization_with_track import contact_map_vis_with_track
|
|
8
|
+
from alphafold3_seqvis_toolkit.modules.contact_map_visualization_without_track import contact_map_vis_without_track
|
|
9
|
+
|
|
10
|
+
app = typer.Typer(help="AlphaFold3 SeqVis Toolkit", no_args_is_help=True)
|
|
11
|
+
|
|
12
|
+
@app.command(
|
|
13
|
+
"confidence",
|
|
14
|
+
no_args_is_help=True
|
|
15
|
+
)
|
|
16
|
+
def confidence_cmd(
|
|
17
|
+
global_json: Optional[str] = typer.Option(None, "--global-json", help="fold_{YOUR-JOB-NAME}_summary_confidences_{i}.json (Required for global/all mode)", rich_help_panel="Input"),
|
|
18
|
+
full_json: Optional[str] = typer.Option(None, "--full-json", help="fold_{YOUR-JOB-NAME}_full_data_{i}.json (Required for local/all mode)", rich_help_panel="Input"),
|
|
19
|
+
output_path: str = typer.Option(".", "--output-path", "-o", help="Directory for outputs, default is current directory", rich_help_panel="Output"),
|
|
20
|
+
mode: str = typer.Option("all", "--mode", "-m", help="Analysis mode: 'all' (default), 'global', or 'local'.", rich_help_panel="Mode"),
|
|
21
|
+
chains: Optional[List[str]] = typer.Option(None, "--chains", "-c", help="Repeatable: chain IDs for local subset. Only used in 'local' or 'all' mode with --full-json.", rich_help_panel="Local Plot Options"),
|
|
22
|
+
tick_step: int = typer.Option(100, "--tick-step", help="Residue tick step for local plots", rich_help_panel="Local Plot Options"),
|
|
23
|
+
):
|
|
24
|
+
"""
|
|
25
|
+
Plot global (ipTM/pTM etc.) and/or local (PAE/contact/atom pLDDT) confidence metrics.
|
|
26
|
+
|
|
27
|
+
\b
|
|
28
|
+
Notes:
|
|
29
|
+
- 1, Use --mode to control the scope:
|
|
30
|
+
- 'all' (default): Plots everything possible based on provided JSON files. If only one file is provided, it plots that one.
|
|
31
|
+
- 'global': Only plots global metrics (requires --global-json).
|
|
32
|
+
- 'local': Only plots local metrics (requires --full-json).
|
|
33
|
+
- 2, [--chains] option is only effective for LOCAL metrics (PAE, contact probs, atom pLDDT).
|
|
34
|
+
- 3, There may be NULL values in the above metrics produced by AlphaFold3, so we will convert them to NaN (these values may appear as NA when output, and this handling also applies to plotting). Therefore, if you are confused about the output, it is recommended to first check your original data.
|
|
35
|
+
- 4, All residue indices in this module are 0-based logic driven.
|
|
36
|
+
|
|
37
|
+
\b
|
|
38
|
+
Examples:
|
|
39
|
+
- 1, Plot EVERYTHING (Global + Local) for a job:
|
|
40
|
+
af3-vis confidence \
|
|
41
|
+
--global-json summary_confidences.json \
|
|
42
|
+
--full-json full_data.json \
|
|
43
|
+
-o out_path
|
|
44
|
+
- 2, Only plot Global metrics:
|
|
45
|
+
af3-vis confidence --mode global --global-json summary_confidences.json -o out_path
|
|
46
|
+
- 3, Only plot Local metrics for specific chains:
|
|
47
|
+
af3-vis confidence --mode local --full-json full_data.json -c A -c B -o out_path
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
# Basic validation
|
|
51
|
+
if mode == "all" and not global_json and not full_json:
|
|
52
|
+
raise typer.Exit("Error: In 'all' mode, need at least one of --global-json or --full-json.")
|
|
53
|
+
|
|
54
|
+
import os
|
|
55
|
+
os.makedirs(output_path, exist_ok=True)
|
|
56
|
+
|
|
57
|
+
# Logic for Global
|
|
58
|
+
if mode in ["all", "global"]:
|
|
59
|
+
if global_json:
|
|
60
|
+
plot_global_confidence(confid_json_file_path=global_json, output_path=output_path)
|
|
61
|
+
elif mode == "global":
|
|
62
|
+
raise typer.Exit("Error: --global-json is required when mode is 'global'.")
|
|
63
|
+
|
|
64
|
+
# Logic for Local
|
|
65
|
+
if mode in ["all", "local"]:
|
|
66
|
+
if full_json:
|
|
67
|
+
plot_local_confidence(
|
|
68
|
+
full_json_file_path=full_json,
|
|
69
|
+
output_path=output_path,
|
|
70
|
+
chains=chains,
|
|
71
|
+
tick_step=tick_step,
|
|
72
|
+
)
|
|
73
|
+
elif mode == "local":
|
|
74
|
+
raise typer.Exit("Error: --full-json is required when mode is 'local'.")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@app.command(
|
|
78
|
+
"contact-map-diff",
|
|
79
|
+
no_args_is_help=True
|
|
80
|
+
)
|
|
81
|
+
def contact_map_diff_cmd(
|
|
82
|
+
mmcif_a: str = typer.Option(..., "--mmcif-a", help="Path to mmCIF file A", rich_help_panel="Inputs"),
|
|
83
|
+
mmcif_b: str = typer.Option(..., "--mmcif-b", help="Path to mmCIF file B", rich_help_panel="Inputs"),
|
|
84
|
+
chain_a: Optional[str] = typer.Option(..., "--chain-a", help="Chain ID(s) for mmCIF file A. Monomer mode: single chain (e.g. 'A'). Multimer mode: one or more chains (e.g. 'A' or 'A,B').", rich_help_panel="Inputs"),
|
|
85
|
+
chain_b: Optional[str] = typer.Option(..., "--chain-b", help="Chain ID(s) for mmCIF file B. Must align with chain-a (⚠️ same number and sequence!).", rich_help_panel="Inputs"),
|
|
86
|
+
region_1: Optional[str] = typer.Option(None, "--region-1", help="(Legacy) Select a region to focus on/compare (highlighted with a green box). In multimer mode, supports 'Chain:Start:End'.", rich_help_panel="Legacy"),
|
|
87
|
+
region_2: Optional[str] = typer.Option(None, "--region-2", help="(Legacy) Select a second region to compare against region-1.", rich_help_panel="Legacy"),
|
|
88
|
+
region_pair: List[str] = typer.Option(None, "--region-pair", help="Repeatable region pair(s) selected to focus on/compare (highlighted with green boxes): 'Start:End,Start:End' format like 'a:b,c:d' or 'a-b,c-d' for monomer mode, Chains-specified 'Chain:Start:End' format like 'A:a:b,B:c:d' or 'A:a-b,B:c-d' for multimer mode. Use multiple --region-pair to add more.", rich_help_panel="Regions"),
|
|
89
|
+
vmax: Optional[float] = typer.Option(None, help="vmax for distance heatmap", rich_help_panel="Color scaling"),
|
|
90
|
+
vmax_percentile: float = typer.Option(95.0, help="Percentile used if vmax is not set", rich_help_panel="Color scaling"),
|
|
91
|
+
vdiff: Optional[float] = typer.Option(None, help="Max abs value for diff heatmap (0-centered)", rich_help_panel="Color scaling"),
|
|
92
|
+
vdiff_percentile: float = typer.Option(95.0, help="Percentile used if vdiff is not set", rich_help_panel="Color scaling"),
|
|
93
|
+
include_nonstandard_residue: bool = typer.Option(False, "--include-nonstandard/--no-include-nonstandard", help="Include non-standard amino acid residues"),
|
|
94
|
+
out_path: Optional[str] = typer.Option(".", "--out-path", help="Directory to save figure files (png/pdf), default is current directory", rich_help_panel="Output"),
|
|
95
|
+
mode: str = typer.Option("multimer", "--mode", "-m", help="Comparison mode: 'multimer' (default) or 'monomer'.", rich_help_panel="Mode"),
|
|
96
|
+
tick_step: int = typer.Option(100, "--tick-step", help="Step size for ticks on the axes (multimer mode only)", rich_help_panel="Plot Options"),
|
|
97
|
+
):
|
|
98
|
+
"""
|
|
99
|
+
Compare contact maps between two AlphaFold3/General mmCIF structures (for the same molecule with an identical sequence), and plot the distance/diff matrices. Supports both monomer and multimer modes.
|
|
100
|
+
|
|
101
|
+
\b
|
|
102
|
+
Notes:
|
|
103
|
+
- 1, Designed for comparing the same protein sequence under different conditions.
|
|
104
|
+
- 2, Regions are 0-based and inclusive: 'start:end' means [start, end].
|
|
105
|
+
- 3, If region_2 is omitted, region_1 is applied symmetrically.
|
|
106
|
+
- 4, We strongly recommend using --region-pair for multiple region comparisons, as it is more flexible and clearer.
|
|
107
|
+
And you can also use --region-pair to replace the legacy --region-1/--region-2 options.
|
|
108
|
+
- 5, Use --mode to switch between 'monomer' and 'multimer' (default) comparison logic.
|
|
109
|
+
- 6, All residue indices in this module are 0-based logic driven.
|
|
110
|
+
- 7, chain_a and chain_b should strictly align in order with same sequence! E.g., in multimer mode, if chain_a is "A,B,C", chain_b is "D,E,F", then it should be A aligns with D, B aligns with E, and C aligns with F.
|
|
111
|
+
|
|
112
|
+
\b
|
|
113
|
+
Examples:
|
|
114
|
+
\b
|
|
115
|
+
- 1, Basic diff on one region (Multimer default):
|
|
116
|
+
af3-vis contact-map-diff \
|
|
117
|
+
--mmcif-a A.cif --mmcif-b B.cif \
|
|
118
|
+
--region-1 0:200 --chain-a A --chain-b A --out-path .
|
|
119
|
+
\b
|
|
120
|
+
- 2, Diff between two regions (Monomer mode):
|
|
121
|
+
af3-vis contact-map-diff \
|
|
122
|
+
--mmcif-a A.cif --mmcif-b B.cif \
|
|
123
|
+
--region-1 0-200 --region-2 300-500 \
|
|
124
|
+
--chain-a A --chain-b A --mode monomer \
|
|
125
|
+
--out-path .
|
|
126
|
+
\b
|
|
127
|
+
- 3, Multiple region pairs (Multimer, Chain A vs Chain A):
|
|
128
|
+
af3-vis contact-map-diff \
|
|
129
|
+
--mmcif-a A.cif --mmcif-b B.cif \
|
|
130
|
+
--region-pair 265:576,0:15 \
|
|
131
|
+
--region-pair 265:576,42:54 \
|
|
132
|
+
--region-pair 265:576,83:93 \
|
|
133
|
+
--region-pair 265:576,170:189 \
|
|
134
|
+
--region-pair 265:576,214:241 \
|
|
135
|
+
--region-pair 265:576,578:589 \
|
|
136
|
+
--region-pair 265:576,606:639 \
|
|
137
|
+
--region-pair 265:576,691:720 \
|
|
138
|
+
--chain-a A --chain-b A \
|
|
139
|
+
--out-path .
|
|
140
|
+
\b
|
|
141
|
+
- 4, Multimer Complex (Chain A,B vs Chain A,B) with specific chain regions: (🌟 RECOMMENDED IN ANY CASE!)
|
|
142
|
+
af3-vis contact-map-diff \
|
|
143
|
+
--mmcif-a complex_v1.cif --mmcif-b complex_v2.cif \
|
|
144
|
+
--chain-a A,B --chain-b A,B \
|
|
145
|
+
--region-pair A:10:50,B:10:50 \
|
|
146
|
+
--region-pair A:100:150,A:100:150 \
|
|
147
|
+
--out-path .
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
if mode == "monomer":
|
|
151
|
+
contact_map_diff_monomer(
|
|
152
|
+
mmcif_file_a=mmcif_a,
|
|
153
|
+
mmcif_file_b=mmcif_b,
|
|
154
|
+
chain_a=chain_a,
|
|
155
|
+
chain_b=chain_b,
|
|
156
|
+
region_1=region_1,
|
|
157
|
+
region_2=region_2,
|
|
158
|
+
region_pairs=region_pair if region_pair else None,
|
|
159
|
+
vmax=vmax,
|
|
160
|
+
vmax_percentile=vmax_percentile,
|
|
161
|
+
vdiff=vdiff,
|
|
162
|
+
vdiff_percentile=vdiff_percentile,
|
|
163
|
+
include_nonstandard_residue=include_nonstandard_residue,
|
|
164
|
+
out_path=out_path,
|
|
165
|
+
)
|
|
166
|
+
else: # multimer mode
|
|
167
|
+
contact_map_diff_multimer(
|
|
168
|
+
mmcif_file_a=mmcif_a,
|
|
169
|
+
mmcif_file_b=mmcif_b,
|
|
170
|
+
chain_a=chain_a,
|
|
171
|
+
chain_b=chain_b,
|
|
172
|
+
region_1=region_1,
|
|
173
|
+
region_2=region_2,
|
|
174
|
+
region_pairs=region_pair if region_pair else None,
|
|
175
|
+
vmax=vmax,
|
|
176
|
+
vmax_percentile=vmax_percentile,
|
|
177
|
+
vdiff=vdiff,
|
|
178
|
+
vdiff_percentile=vdiff_percentile,
|
|
179
|
+
include_nonstandard_residue=include_nonstandard_residue,
|
|
180
|
+
out_path=out_path,
|
|
181
|
+
tick_step=tick_step,
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
@app.command(
|
|
185
|
+
"contact-map-vis",
|
|
186
|
+
no_args_is_help=True
|
|
187
|
+
)
|
|
188
|
+
def contact_map_vis_cmd(
|
|
189
|
+
mmcif_file: str = typer.Option(..., "--mmcif-file", help="Path to mmCIF file", rich_help_panel="Input"),
|
|
190
|
+
chains: Optional[List[str]] = typer.Option(None, "--chains", "-c", help="Repeatable: chain IDs to include, default is all chains", rich_help_panel="Input"),
|
|
191
|
+
out_path: str = typer.Option(".", "--out-path", "-o", help="Directory for outputs, default is current directory", rich_help_panel="Output"),
|
|
192
|
+
mode: str = typer.Option("no-track", "--mode", "-m", help="Visualization mode: 'no-track' (default) or 'track'.", rich_help_panel="Mode"),
|
|
193
|
+
track_bed_file: Optional[str] = typer.Option(None, "--track-bed-file", help="Path to BED file for custom tracks, e.g., domains、IDRs (Required if mode is 'track')", rich_help_panel="Custom Tracks"),
|
|
194
|
+
color_config: Optional[str] = typer.Option("tab10", "--color-config", help="Path to color config file (JSON) or colormap name (Only used if mode is 'track')", rich_help_panel="Custom Tracks"),
|
|
195
|
+
tick_step: int = typer.Option(100, "--tick-step", help="Step size for ticks on the axes", rich_help_panel="Plot Options"),
|
|
196
|
+
):
|
|
197
|
+
"""
|
|
198
|
+
Visualize contact map from an AlphaFold3 mmCIF structure or a general mmCIF structure. Supports 'no-track' (simple) and 'track' (custom annotation) modes.
|
|
199
|
+
|
|
200
|
+
\b
|
|
201
|
+
Notes:
|
|
202
|
+
- 1, Use --mode to switch between 'no-track' (default) and 'track' visualization.
|
|
203
|
+
- 2, 'no-track' mode: Generates a standard contact map.
|
|
204
|
+
- 3, 'track' mode: Generates a contact map with custom annotation tracks (e.g., domains, IDRs).
|
|
205
|
+
- Requires --track-bed-file.
|
|
206
|
+
- Tracks can be numerical (line plot) or categorical (bar/strip plot).
|
|
207
|
+
- The track bed file must be 0-based indexed!
|
|
208
|
+
- 4, By default, all chains in the mmCIF file are included. Use --chains to specify particular chains if needed.
|
|
209
|
+
- 5, A color configuration file can be provided to customize the colors of categorical tracks (only for 'track' mode).
|
|
210
|
+
- 6, Modify the tick_step parameter to adjust the spacing of residue ticks on the axes as needed.
|
|
211
|
+
|
|
212
|
+
\b
|
|
213
|
+
Examples:
|
|
214
|
+
- 1, Basic contact map visualization (Default no-track):
|
|
215
|
+
af3-vis contact-map-vis --mmcif-file model.cif -o out_path
|
|
216
|
+
- 2, Contact map with custom annotation tracks:
|
|
217
|
+
af3-vis contact-map-vis \
|
|
218
|
+
--mmcif-file model.cif \
|
|
219
|
+
--mode track \
|
|
220
|
+
--track-bed-file custom_tracks.bed \
|
|
221
|
+
--color-config color_config.json \
|
|
222
|
+
-o out_path
|
|
223
|
+
"""
|
|
224
|
+
|
|
225
|
+
if mode == "track":
|
|
226
|
+
if not track_bed_file:
|
|
227
|
+
raise typer.Exit("Error: --track-bed-file is required when --mode is 'track'")
|
|
228
|
+
|
|
229
|
+
contact_map_vis_with_track(
|
|
230
|
+
mmcif_file=mmcif_file,
|
|
231
|
+
chains=chains,
|
|
232
|
+
out_path=out_path,
|
|
233
|
+
track_bed_file=track_bed_file,
|
|
234
|
+
color_config=color_config,
|
|
235
|
+
tick_step=tick_step,
|
|
236
|
+
)
|
|
237
|
+
else: # no-track mode
|
|
238
|
+
contact_map_vis_without_track(
|
|
239
|
+
mmcif_file=mmcif_file,
|
|
240
|
+
chains=chains,
|
|
241
|
+
out_path=out_path,
|
|
242
|
+
tick_step=tick_step,
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
if __name__ == "__main__":
|
|
246
|
+
app()
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from .confidence_metrics_plot import plot_local_confidence, plot_global_confidence
|
|
2
|
+
from .contact_map_comparison_monomer import contact_map_diff_monomer
|
|
3
|
+
from .contact_map_comparison_multimer import contact_map_diff_multimer
|
|
4
|
+
from .contact_map_visualization_with_track import contact_map_vis_with_track
|
|
5
|
+
from .contact_map_visualization_without_track import contact_map_vis_without_track
|
|
6
|
+
|
|
7
|
+
__all__ = ["plot_local_confidence", "plot_global_confidence", "contact_map_diff_monomer", "contact_map_diff_multimer", "contact_map_vis_with_track", "contact_map_vis_without_track"]
|