alphafold3-tools 0.3.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_tools-0.3.1.dist-info/METADATA +356 -0
- alphafold3_tools-0.3.1.dist-info/RECORD +23 -0
- alphafold3_tools-0.3.1.dist-info/WHEEL +4 -0
- alphafold3_tools-0.3.1.dist-info/entry_points.txt +10 -0
- alphafold3_tools-0.3.1.dist-info/licenses/LICENSE +24 -0
- alphafold3tools/__init__.py +7 -0
- alphafold3tools/ciftoseqres.py +129 -0
- alphafold3tools/fastatojson.py +109 -0
- alphafold3tools/ipsae.py +1877 -0
- alphafold3tools/jsontomsa.py +270 -0
- alphafold3tools/log.py +16 -0
- alphafold3tools/modjson.py +363 -0
- alphafold3tools/msa_conversion.py +337 -0
- alphafold3tools/msatojson.py +571 -0
- alphafold3tools/paeplot.py +510 -0
- alphafold3tools/pdbtocif.py +3466 -0
- alphafold3tools/sdftoccd.py +319 -0
- alphafold3tools/searchtemplates.py +1342 -0
- alphafold3tools/structure/mmcif_parser.py +437 -0
- alphafold3tools/structure/mmcif_utils.py +271 -0
- alphafold3tools/structure_stores.py +103 -0
- alphafold3tools/superpose_ciffiles.py +144 -0
- alphafold3tools/utils.py +66 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: alphafold3_tools
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Toolkit for alphafold3 input and output files
|
|
5
|
+
Project-URL: Homepage, https://github.com/cddlab/alphafold3_tools
|
|
6
|
+
Project-URL: Issues, https://github.com/cddlab/alphafold3_tools/issues
|
|
7
|
+
Author-email: Yoshitaka Moriwaki <moriwaki.yoshitaka@tmd.ac.jp>
|
|
8
|
+
License-Expression: BSD-2-Clause
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Requires-Dist: biopython>=1.85
|
|
14
|
+
Requires-Dist: gemmi>=0.7.5
|
|
15
|
+
Requires-Dist: loguru
|
|
16
|
+
Requires-Dist: matplotlib
|
|
17
|
+
Requires-Dist: pip
|
|
18
|
+
Requires-Dist: rdkit>=2024.3.2
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# alphafold3_tools
|
|
22
|
+
|
|
23
|
+
Toolkit for alphafold3 input generation and output analysis
|
|
24
|
+
|
|
25
|
+
[](https://www.python.org/downloads/release/python-3100/) [](https://opensource.org/licenses/BSD-2-Clause)
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
Requirements:
|
|
30
|
+
|
|
31
|
+
- Python 3.12 or later
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# install from GitHub
|
|
35
|
+
python3 -m pip install alphafold3-tools
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
More detailed usage information can be found by running the commands with the `-h` option. The version information will be displayed with the `-v` option.
|
|
41
|
+
|
|
42
|
+
### msatojson
|
|
43
|
+
|
|
44
|
+
`msatojson` is a command to convert an a3m-formatted multiple sequence alignment (MSA) file to JSON format. The input name can be specified with the `-n` option.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
msatojson -i input.a3m -o input.json -n inputname
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The input a3m MSA file can be generated by MMSeqs2 webserver (or ColabFold). `colabfold_batch --msa-only` option is useful to generate a3m MSA files only.
|
|
51
|
+
|
|
52
|
+
`msatojson` can accept a directory containing multiple a3m files. In this case, the output JSON files will be saved in the specified output directory.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
msatojson -i /path/to/a3m_containing/directory -o /path/to/output/directory
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
From version 0.2.0, templates can be also added to the output JSON file. Use the `--include_templates` option to include templates. The directory path `/path/to/mmcif_files` containing mmCIF files and the corresponding `pdb_seqres.txt` file must be specified with the `--pdb_database_path` and `--seqres_database_path` options, respectively.
|
|
59
|
+
|
|
60
|
+
- `--max_template_date` option can be used to set the maximum template date. The default value is `2099-09-30`, which means no filtering based on template date. **If you want to the same results as AlphaFold3, set this value to `2021-09-30`.**
|
|
61
|
+
- `--max_subsequence_ratio` option can be used to set the maximum subsequence ratio for template filtering. The default value is `0.95` (same as the default value of AlphaFold3). However, if you want to include all templates regardless of the subsequence ratio, set this option to `1.0`.
|
|
62
|
+
- `-d` option can be used to enable debug mode, which will print debug information during the template search process.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Example command to include templates in the output JSON file
|
|
66
|
+
msatojson -i input.a3m -o output.json \
|
|
67
|
+
--include_templates \
|
|
68
|
+
--pdb_database_path /path/to/mmcif_files \
|
|
69
|
+
--seqres_database_path /path/to/pdb_seqres.txt \
|
|
70
|
+
--max_template_date 2099-09-30 \
|
|
71
|
+
--hmmbuild_binary_path /path/to/hmmbuild \
|
|
72
|
+
--hmmsearch_binary_path /path/to/hmmsearch \
|
|
73
|
+
--save_hmmsto \
|
|
74
|
+
--max_subsequence_ratio 1.0 \
|
|
75
|
+
-d
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
> [!NOTE]
|
|
79
|
+
>
|
|
80
|
+
> - This feature requires HMMER 3 or later to be installed and accessible in your PATH. For macOS users, you can install HMMER via Homebrew:
|
|
81
|
+
>
|
|
82
|
+
> ```bash
|
|
83
|
+
> brew install hmmer
|
|
84
|
+
> ```
|
|
85
|
+
>
|
|
86
|
+
> - `--hmmbuild_binary_path` and `--hmmsearch_binary_path` options can be used to specify the paths to the `hmmbuild` and `hmmsearch` binaries, respectively, if they are not in your PATH.
|
|
87
|
+
> - `--save_hmmsto` option can be used to save HMMER's intermediate file.
|
|
88
|
+
> - The `pdb_seqres.txt` file can be downloaded from [wwPDB](https://files.rcsb.org/pub/pdb/derived_data/pdb_seqres.txt). The file size is about 356 MB (as of Dec. 2025).
|
|
89
|
+
>
|
|
90
|
+
|
|
91
|
+
### fastatojson
|
|
92
|
+
|
|
93
|
+
`fastatojson` is a command to convert a FASTA file to JSON format compatible with AlphaFold3.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
fastatojson -i input.fasta [-s 1 2 3 ...] [-d]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- `-i`: Input FASTA file. Mandatory.
|
|
100
|
+
- `-s`: Model seeds to be used. Optional. Default is `1`. Multiple seeds can be specified.
|
|
101
|
+
- `-d`: Debug mode. Optional. If specified, the command will print debug information.
|
|
102
|
+
|
|
103
|
+
For example, if you have a FASTA file containing two sequences, `input.fasta`:
|
|
104
|
+
|
|
105
|
+
```shell
|
|
106
|
+
>P12345
|
|
107
|
+
KAKDLSKCLS
|
|
108
|
+
>Q67890
|
|
109
|
+
KADFILCSLK
|
|
110
|
+
>I23L45_I3PLS2
|
|
111
|
+
LAKDCL:KKALS
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
You will obtain three JSON files, `p12345.json`, `q67890.json`, and `i23l45_i3pls2.json`. The last one contains two sequences, `LAKDCL` and `KKALS`, which are separated by a colon (`:`). The output JSON files will look like this:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"name": "i23l45_i3pls2",
|
|
119
|
+
"dialect": "alphafold3",
|
|
120
|
+
"version": 1,
|
|
121
|
+
"sequences": [
|
|
122
|
+
{
|
|
123
|
+
"protein": {
|
|
124
|
+
"id": ["A"],
|
|
125
|
+
"sequence": "LAKDCL"
|
|
126
|
+
},
|
|
127
|
+
"protein": {
|
|
128
|
+
"id": ["B"],
|
|
129
|
+
"sequence": "KKALS"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
"modelSeeds": [1],
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### modjson
|
|
138
|
+
|
|
139
|
+
`modjson` is a command to modify an existing AlphaFold3 input json file. This tool is useful to add/modify the ligand entities and User-provided CCD string in an input json file.
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
modjson -i input.json -o output.json [-n jobname] [-p] \
|
|
143
|
+
[-a smiles "CCOCCC" 1 -a ccdCodes PRD 2] \
|
|
144
|
+
[-u userccd1.cif userccd2.cif]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
- `-i`: Input json file. Mandatory.
|
|
148
|
+
- `-o`: Output json file. Mandatory.
|
|
149
|
+
- `-n`: Job name. Optional. Sets the job name in the input JSON file.
|
|
150
|
+
- `-p`: Purge all ligand entities from the input JSON file at first.
|
|
151
|
+
- `-a`: Add ligand to the input JSON file. Provide 'ligand type', 'ligand name', and 'number of the ligand molecule'. The 'ligand type' must be either 'smiles' or 'ccdCodes'. Multiple ligands can be added.
|
|
152
|
+
- Example: `-a smiles "CCOCCC" 1 -a ccdCodes PRD 2 -a ...`
|
|
153
|
+
- `-u`: Add user provided ccdCodes to the input JSON file. Multiple files can be provided.
|
|
154
|
+
- Example: `-u userccd1.cif userccd2.cif`
|
|
155
|
+
|
|
156
|
+
> [!NOTE]
|
|
157
|
+
> A `*_data.json` file in the AlphaFold3's output directory can be also used as an input JSON file of `modjson`.
|
|
158
|
+
|
|
159
|
+
### paeplot
|
|
160
|
+
|
|
161
|
+
`paeplot` is a command to plot the predicted aligned error (PAE). The color map can be specified with the `-c` option. The default color map is `bwr` (ColabFold-like), but `Greens_r` is also available for AlphaFold Structure Database (AFDB)-like coloring.
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
paeplot -i /path/to/alphafold3_output/directory [-c {Greens_r,bwr}] [--dpi 300] [-n foo] [-f {png,svg}] [-a] [-t "PAE Plot"] [--chain-cmap {pymol,unhcr,<matplotlib_colormap_name>}]
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+

|
|
168
|
+

|
|
169
|
+
|
|
170
|
+
arguments:
|
|
171
|
+
|
|
172
|
+
- `-i`: Input directory containing the AlphaFold3 output files. Mandatory.
|
|
173
|
+
- `-c`: Color map for the PAE plot. Optional. Default is `bwr`. Choose either `Greens_r` or `bwr`.
|
|
174
|
+
- `--dpi`: DPI of the output image. Optional. Default is `100`, but `300` is recommended for publication-quality images.
|
|
175
|
+
- `-n`: Name prefix for the output image file. Optional.
|
|
176
|
+
- `-f`: Output image file format. Optional. Choose either `png` or `svg`. Default is `png`.
|
|
177
|
+
- `-a`: If specified, the plot will include all models in the output directory.
|
|
178
|
+
- `-t`: Title of the plot. Optional.
|
|
179
|
+
- `--chain-cmap`: Color map for chain coloring on top and right. Optional. Choose either `pymol`, `unhcr`, or any valid matplotlib colormap name. (e.g. `tab20`) Default is `pymol`.
|
|
180
|
+
|
|
181
|
+
### superpose_ciffiles
|
|
182
|
+
|
|
183
|
+
`superpose_ciffiles` is a command to superpose the output mmCIF files. The command creates a multi-model mmCIF file containing all the predicted `model.cif` subdirectories. The output file name can be specified with the `-o` option. By default, the output file will be saved as `foo_superposed.cif` in the input directory.
|
|
184
|
+
`-c` option can be used to specify the chain ID to be superposed.
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
superpose_ciffiles -i /path/to/alphafold3_output/directory [-o /path/to/output/directory/foo_superposed.cif] [-c A]
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
In [PyMOL](https://www.pymol.org/), the following command will be useful to visualize the plDDT values.
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
color 0x0053D6, b < 100
|
|
194
|
+
color 0x65CBF3, b < 90
|
|
195
|
+
color 0xFFDB13, b < 70
|
|
196
|
+
color 0xFF7D45, b < 50
|
|
197
|
+
util.cnc
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+

|
|
201
|
+
|
|
202
|
+
> [!NOTE]
|
|
203
|
+
> To visualize only an object of `seed-1_sample-0` with plddt values, type the following command in PyMOL.
|
|
204
|
+
>
|
|
205
|
+
> ```bash
|
|
206
|
+
> color 0x0053D6, seed-1_sample-0 and b < 100
|
|
207
|
+
> color 0x65CBF3, seed-1_sample-0 and b < 90
|
|
208
|
+
> color 0xFFDB13, seed-1_sample-0 and b < 70
|
|
209
|
+
> color 0xFF7D45, seed-1_sample-0 and b < 50
|
|
210
|
+
> ```
|
|
211
|
+
|
|
212
|
+
### sdftoccd
|
|
213
|
+
|
|
214
|
+
`sdftoccd` is a command to convert sdf file to ccd format. Please refer to the [AlphaFold3's input document](https://github.com/google-deepmind/alphafold3/blob/main/docs/input.md#user-provided-ccd-format) for the detail of User-provided CCD format.
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
sdftoccd -i input.sdf -o userccd.cif -n STR
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### jsontomsa
|
|
221
|
+
|
|
222
|
+
`jsontomsa` is a command to extract MSA from the AlphaFold3 input JSON file. The output file name can be specified with the `-o` option.
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
jsontomsa -i /path/to/alphafold3_data.json -o /path/to/out.a3m
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### pdbtocif
|
|
229
|
+
|
|
230
|
+
`pdbtocif` is a command to convert a PDB file to mmCIF format. The output file name can be specified with the `-o` option.
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
pdbtocif -i input.pdb -o output.cif [--pdb_id XXXX]
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
This tool is useful for converting legacy PDB-formatted files into mmCIF format, which is required for template search in msatojson as well as for input to AlphaFold 3.
|
|
237
|
+
The `--pdb_id` option allows users to specify the PDB ID assigned to the output mmCIF file. This is particularly useful when using predicted structures (e.g., from the AlphaFold Structure Database) as templates, because such structures often have nonstandard identifiers (e.g., AF-P12345-F1-model_v1) that are not suitable for template search. By default, the PDB ID in the output mmCIF file is set to `xxxx`. The PDB ID must be a four-character string consisting of lowercase letters and/or digits, as the template search in `msatojson` is case-sensitive and the template database uses lowercase PDB IDs.
|
|
238
|
+
|
|
239
|
+
Other tools are being developed and will be added.
|
|
240
|
+
|
|
241
|
+
## ipsae
|
|
242
|
+
|
|
243
|
+
`ipsae` calculates [ipSAE](https://www.biorxiv.org/content/10.1101/2025.02.10.637595v2) and related interaction scores (ipTM, [pDockQ](https://www.nature.com/articles/s41467-022-28865-w), [pDockQ2](https://academic.oup.com/bioinformatics/article/39/7/btad424/7219714), [LIS](https://www.biorxiv.org/content/10.1101/2024.02.19.580970v1)) for protein–protein (and protein–nucleic acid) complexes predicted by AlphaFold3, ColabFold, or Boltz. It is a reimplementation of [ipsae.py](https://github.com/DunbrackLab/IPSAE) (MIT License) by Roland L. Dunbrack Jr., extended with JSON output and batch processing support.
|
|
244
|
+
|
|
245
|
+
### Basic usage — explicit file paths
|
|
246
|
+
|
|
247
|
+
Specify PAE and structure files directly, equivalent to the original `ipsae.py` interface:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
ipsae -p model_scores_rank_001.json -s model_relaxed_rank_001.pdb [-pc 10 -dc 10]
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Options:
|
|
254
|
+
|
|
255
|
+
- `-p / --pae_file`: PAE file (`.json` for AF2/AF3, `.npz` for Boltz)
|
|
256
|
+
- `-s / --struct_file`: Structure file (`.pdb` for AF2/Boltz, `.cif` for AF3/Boltz)
|
|
257
|
+
- `-pc / --pae_cutoff`: PAE threshold in Å (default: `10.0`)
|
|
258
|
+
- `-dc / --dist_cutoff`: Cβ distance threshold in Å (default: `10.0`)
|
|
259
|
+
|
|
260
|
+
### Directory mode — automatic input detection
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
ipsae -i /path/to/output_directory
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
When a directory is passed with `-i`, `ipsae` auto-detects the prediction format:
|
|
267
|
+
|
|
268
|
+
| Format | PAE file | Structure file |
|
|
269
|
+
| -------- | ---------- | ---------------- |
|
|
270
|
+
| AlphaFold3 | `*_confidences.json` | `*_model.cif` |
|
|
271
|
+
| ColabFold | `*_scores_rank_001_alphafold2_multimer_v3_model_*_seed_*.json` | `*_relaxed_rank_001_*.pdb` (falls back to `*_unrelaxed_*` if absent) |
|
|
272
|
+
|
|
273
|
+
#### Batch processing for ColabFold outputs
|
|
274
|
+
|
|
275
|
+
When the directory contains multiple ColabFold predictions, `ipsae` automatically processes all of them in one run. A prediction with prefix `foobar` is considered complete when both `foobar.done.txt` and `foobar_coverage.png` exist in the same directory. Prefix validation runs in parallel across all available CPU cores.
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
# Process all completed predictions in a ColabFold output directory
|
|
279
|
+
ipsae -i /path/to/colabfold_output_dir
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Output files
|
|
283
|
+
|
|
284
|
+
Three files are written next to each structure file:
|
|
285
|
+
|
|
286
|
+
| File | Description |
|
|
287
|
+
| ------ | ------------- |
|
|
288
|
+
| `{stem}_{pae}_{dist}.txt` | Summary score table |
|
|
289
|
+
| `{stem}_{pae}_{dist}_byres.txt` | Per-residue score table |
|
|
290
|
+
| `{stem}_{pae}_{dist}.pml` | PyMOL script for interface visualisation |
|
|
291
|
+
|
|
292
|
+
### JSON output with ipSAE\_min / ipSAE\_max
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
ipsae -i /path/to/output_directory --json
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
The `--json` flag replaces the `.txt` summary with a `.json` file. The JSON format extends the original ipSAE output by providing, for each chain pair, the **asymmetric** score for each direction as well as `max` and `min` values across the two asymmetric directions (`ipSAE_max` and `ipSAE_min`):
|
|
299
|
+
|
|
300
|
+
```json
|
|
301
|
+
{
|
|
302
|
+
"model_name": {
|
|
303
|
+
"pae_cutoff": 10,
|
|
304
|
+
"dist_cutoff": 10,
|
|
305
|
+
"A-B": {
|
|
306
|
+
"asym": [
|
|
307
|
+
{"chain1": "A", "chain2": "B", "ipSAE": 0.382, "ipSAE_d0chn": 0.412, "ipSAE_d0dom": 0.401, "ipTM_af": 0.65, "pDockQ": 0.731, "pDockQ2": 0.612, "LIS": 0.524, "...": "..."},
|
|
308
|
+
{"chain1": "B", "chain2": "A", "ipSAE": 0.315, "ipSAE_d0chn": 0.298, "ipSAE_d0dom": 0.307, "ipTM_af": 0.65, "pDockQ": 0.731, "pDockQ2": 0.589, "LIS": 0.511, "...": "..."}
|
|
309
|
+
],
|
|
310
|
+
"max": {"chain1": "A", "chain2": "B", "ipSAE": 0.382, "...": "..."},
|
|
311
|
+
"min": {"chain1": "A", "chain2": "B", "ipSAE": 0.315, "...": "..."}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### All usage examples
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
# AF2/ColabFold — explicit file paths (original ipsae.py interface)
|
|
321
|
+
ipsae -p foo_scores_rank_001_alphafold2_multimer_v3_model_1_seed_000.json \
|
|
322
|
+
-s foo_relaxed_rank_001_alphafold2_multimer_v3_model_1_seed_000.pdb
|
|
323
|
+
|
|
324
|
+
# AlphaFold3 — directory auto-detection
|
|
325
|
+
ipsae -i /path/to/af3_seed-1_sample-0
|
|
326
|
+
|
|
327
|
+
# ColabFold — batch processing of an entire output directory
|
|
328
|
+
ipsae -i /path/to/colabfold_output_dir
|
|
329
|
+
|
|
330
|
+
# Custom cutoffs
|
|
331
|
+
ipsae -i /path/to/af3_seed-1_sample-0 -pc 15 -dc 15
|
|
332
|
+
|
|
333
|
+
# JSON output (includes ipSAE_min and ipSAE_max per chain pair)
|
|
334
|
+
ipsae -i /path/to/af3_seed-1_sample-0 --json
|
|
335
|
+
|
|
336
|
+
# ColabFold batch with JSON output
|
|
337
|
+
ipsae -i /path/to/colabfold_output_dir --json
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## Acknowledgements
|
|
341
|
+
|
|
342
|
+
This tool uses the following libraries:
|
|
343
|
+
|
|
344
|
+
- [RDKit](https://www.rdkit.org/)
|
|
345
|
+
- [matplotlib](https://matplotlib.org/)
|
|
346
|
+
- [numpy](https://numpy.org/)
|
|
347
|
+
- [gemmi](https://gemmi.readthedocs.io/en/latest/)
|
|
348
|
+
- [loguru](https://loguru.readthedocs.io/en/stable/)
|
|
349
|
+
- [IPSAE](https://github.com/DunbrackLab/IPSAE)
|
|
350
|
+
|
|
351
|
+
[PDBeurope/ccdutils](https://github.com/PDBeurope/ccdutils) is used for the conversion of sdf to ccd.
|
|
352
|
+
RCSB PDB's [MAXIT](https://sw-tools.rcsb.org/apps/MAXIT/source.html) v11.400 is used as a reference for the conversion of PDB to mmCIF.
|
|
353
|
+
|
|
354
|
+
## How do I reference this work?
|
|
355
|
+
|
|
356
|
+
- Moriwaki Y et al. [High-throughput prediction of protein–protein interactions uncovers hidden molecular networks in biosynthetic gene clusters](https://www.biorxiv.org/content/10.1101/2025.10.26.684697v2), bioRxiv 2025.10.26.684697; doi: [10.1101/2025.10.26.684697](https://doi.org/10.1101/2025.10.26.684697v2)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
alphafold3tools/__init__.py,sha256=c2iIlcSd0ViHzCLDb68DDCqIKQsGzvo15kk8TStXtDI,229
|
|
2
|
+
alphafold3tools/ciftoseqres.py,sha256=vyLUEe9XOn8tjjzKtF2R1_wR82kOIejQpaS8nzq6QGw,3847
|
|
3
|
+
alphafold3tools/fastatojson.py,sha256=8vPpq6G7AZpHxftD_zSwfiRQWWMmfaLZS0O4usaDOjc,3412
|
|
4
|
+
alphafold3tools/ipsae.py,sha256=K9qO0OMO9vFrZ3dfeMAgr6qPl0rvyXJDno6rB3uaUGs,64397
|
|
5
|
+
alphafold3tools/jsontomsa.py,sha256=7tXFl8jKCW1jbshfqlZmGNwbUkEcgy72INOG76rLnrQ,9596
|
|
6
|
+
alphafold3tools/log.py,sha256=LvpyafvVUTAULQe8c7A_BBxgduCA7raRtFNbX_a4JEE,313
|
|
7
|
+
alphafold3tools/modjson.py,sha256=Iq38F1pjbC-XomkYJGkFNDDztlX4cYh_aI-zOIwjEeM,11872
|
|
8
|
+
alphafold3tools/msa_conversion.py,sha256=kt0AykdkmMp_FenD4zYOR-K_kFafPsqn2kj_YVHHPf4,11707
|
|
9
|
+
alphafold3tools/msatojson.py,sha256=Clg8Qx5X2QSJ4ZNLG482PsunQAUY6QnivQeCL3NuSyk,21319
|
|
10
|
+
alphafold3tools/paeplot.py,sha256=ctzOYKCs2GmrN_55m7Ih3wB9pK_vqfimsk3z2VdXAls,16176
|
|
11
|
+
alphafold3tools/pdbtocif.py,sha256=3KmuZxmDEwirEnFmUIjeQIZ6HW6aw3IwB2WVH1hSMcY,118657
|
|
12
|
+
alphafold3tools/sdftoccd.py,sha256=mcEGcRH9AgkOtqduFC1lnUYahaze_IOp3AJCVp2EDPM,9155
|
|
13
|
+
alphafold3tools/searchtemplates.py,sha256=UyuVzqyavh6ZLMR8ptTB4ch-PWLqFWUiSUyU8PhJtsY,52854
|
|
14
|
+
alphafold3tools/structure_stores.py,sha256=KxgVRzBSlgjdFQvOwaF8wTW92-wkYssYTdX-SD7ZPqI,3855
|
|
15
|
+
alphafold3tools/superpose_ciffiles.py,sha256=LChMRvWdkH7bE1fN0i7fZVT9mxlZbBA0PsbfDoKJ8Hw,5397
|
|
16
|
+
alphafold3tools/utils.py,sha256=m9Ufk-LQWs0o_bXPsWI37ittmZWBP5Biq85m-Yrrhfs,2046
|
|
17
|
+
alphafold3tools/structure/mmcif_parser.py,sha256=EuVagRQY0hy2nP-lmGuafBFSrX7xYpSnvvT4JL1KVfY,17407
|
|
18
|
+
alphafold3tools/structure/mmcif_utils.py,sha256=LVfQM6YbSxHq0_no_8WExpDTjzo5bE1jzK0z7soOueE,9782
|
|
19
|
+
alphafold3_tools-0.3.1.dist-info/METADATA,sha256=lHFL3651rd-CKdJYrkzy4DCYLINJT6zcbunHNrEYJQc,15221
|
|
20
|
+
alphafold3_tools-0.3.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
21
|
+
alphafold3_tools-0.3.1.dist-info/entry_points.txt,sha256=TWXCwE2D2y-ctPUmNxIpU5_OYsNYuYi8-sGU3wbswhI,407
|
|
22
|
+
alphafold3_tools-0.3.1.dist-info/licenses/LICENSE,sha256=6aZEi8wOB35LlBSMWBoVQCiBabH8X0rxn3zxXiwlPA8,1295
|
|
23
|
+
alphafold3_tools-0.3.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
fastatojson = alphafold3tools.fastatojson:main
|
|
3
|
+
ipsae = alphafold3tools.ipsae:main
|
|
4
|
+
jsontomsa = alphafold3tools.jsontomsa:main
|
|
5
|
+
modjson = alphafold3tools.modjson:main
|
|
6
|
+
msatojson = alphafold3tools.msatojson:main
|
|
7
|
+
paeplot = alphafold3tools.paeplot:main
|
|
8
|
+
pdbtocif = alphafold3tools.pdbtocif:main
|
|
9
|
+
sdftoccd = alphafold3tools.sdftoccd:main
|
|
10
|
+
superpose_ciffiles = alphafold3tools.superpose_ciffiles:main
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, cddlab
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import gemmi
|
|
5
|
+
from loguru import logger
|
|
6
|
+
|
|
7
|
+
from alphafold3tools.log import log_setup
|
|
8
|
+
from alphafold3tools.utils import add_version_option
|
|
9
|
+
|
|
10
|
+
_MOL_TYPE: dict[str, str] = {
|
|
11
|
+
"polypeptide(L)": "protein",
|
|
12
|
+
"polypeptide(D)": "protein",
|
|
13
|
+
"polyribonucleotide": "na",
|
|
14
|
+
"polydeoxyribonucleotide": "na",
|
|
15
|
+
"polydeoxyribonucleotide/polyribonucleotide hybrid": "na",
|
|
16
|
+
"other": "other",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _parse_cif_for_seqres(cif_path: Path) -> list[tuple[str, str, str, str, str]]:
|
|
21
|
+
"""Parse a single CIF file and return records for pdb_seqres.txt.
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
List of (pdb_id_lower, auth_asym_id, mol_type, sequence, title) tuples.
|
|
25
|
+
"""
|
|
26
|
+
doc = gemmi.cif.read(str(cif_path))
|
|
27
|
+
block = doc.sole_block()
|
|
28
|
+
|
|
29
|
+
pdb_id = block.name.lower()
|
|
30
|
+
|
|
31
|
+
keywords = block.find_value("_struct_keywords.text")
|
|
32
|
+
if keywords and keywords not in ("?", "."):
|
|
33
|
+
title = gemmi.cif.as_string(keywords)
|
|
34
|
+
else:
|
|
35
|
+
struct_title = block.find_value("_struct.title")
|
|
36
|
+
if struct_title and struct_title not in ("?", "."):
|
|
37
|
+
title = gemmi.cif.as_string(struct_title)
|
|
38
|
+
else:
|
|
39
|
+
title = "no_title"
|
|
40
|
+
|
|
41
|
+
poly_table = block.find(
|
|
42
|
+
"_entity_poly.",
|
|
43
|
+
["entity_id", "type", "pdbx_seq_one_letter_code_can", "pdbx_strand_id"],
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
records: list[tuple[str, str, str, str, str]] = []
|
|
47
|
+
for row in poly_table:
|
|
48
|
+
poly_type = gemmi.cif.as_string(row[1])
|
|
49
|
+
seq_raw = gemmi.cif.as_string(row[2])
|
|
50
|
+
strand_ids_raw = gemmi.cif.as_string(row[3])
|
|
51
|
+
|
|
52
|
+
sequence = seq_raw.replace("\n", "").replace(" ", "").replace("\r", "")
|
|
53
|
+
|
|
54
|
+
mol_type = _MOL_TYPE.get(poly_type, "other")
|
|
55
|
+
|
|
56
|
+
strand_ids = [s.strip() for s in strand_ids_raw.split(",") if s.strip()]
|
|
57
|
+
|
|
58
|
+
for chain_id in strand_ids:
|
|
59
|
+
records.append((pdb_id, chain_id, mol_type, sequence, title))
|
|
60
|
+
|
|
61
|
+
return records
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def cif_to_seqres(input_path: str, output_path: str) -> None:
|
|
65
|
+
"""Convert CIF file(s) to pdb_seqres.txt format.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
input_path: Path to a CIF file or directory containing CIF files.
|
|
69
|
+
output_path: Path to the output pdb_seqres.txt file.
|
|
70
|
+
"""
|
|
71
|
+
p = Path(input_path)
|
|
72
|
+
if p.is_dir():
|
|
73
|
+
cif_files = sorted(p.glob("*.cif"))
|
|
74
|
+
if not cif_files:
|
|
75
|
+
cif_files = sorted(p.glob("**/*.cif"))
|
|
76
|
+
logger.info(f"Found {len(cif_files)} CIF file(s) in {p}")
|
|
77
|
+
else:
|
|
78
|
+
cif_files = [p]
|
|
79
|
+
|
|
80
|
+
lines: list[str] = []
|
|
81
|
+
for cif_file in cif_files:
|
|
82
|
+
logger.info(f"Processing {cif_file}")
|
|
83
|
+
records = _parse_cif_for_seqres(cif_file)
|
|
84
|
+
for pdb_id, chain_id, mol_type, sequence, title in records:
|
|
85
|
+
length = len(sequence)
|
|
86
|
+
header = f">{pdb_id}_{chain_id} mol:{mol_type} length:{length} {title}"
|
|
87
|
+
lines.append(header)
|
|
88
|
+
lines.append(sequence)
|
|
89
|
+
|
|
90
|
+
Path(output_path).write_text("\n".join(lines) + "\n")
|
|
91
|
+
logger.info(f"Written to {output_path}")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def main() -> None:
|
|
95
|
+
parser = argparse.ArgumentParser(
|
|
96
|
+
description="Convert mmCIF file(s) to pdb_seqres.txt format.",
|
|
97
|
+
formatter_class=argparse.RawTextHelpFormatter,
|
|
98
|
+
)
|
|
99
|
+
parser.add_argument(
|
|
100
|
+
"-i",
|
|
101
|
+
"--input",
|
|
102
|
+
dest="input",
|
|
103
|
+
required=True,
|
|
104
|
+
help="Input CIF file or directory containing CIF files.",
|
|
105
|
+
)
|
|
106
|
+
parser.add_argument(
|
|
107
|
+
"-o",
|
|
108
|
+
"--output",
|
|
109
|
+
default="pdb_seqres.txt",
|
|
110
|
+
help="Output file path (default: pdb_seqres.txt).",
|
|
111
|
+
)
|
|
112
|
+
parser.add_argument(
|
|
113
|
+
"-d",
|
|
114
|
+
"--debug",
|
|
115
|
+
dest="log_level",
|
|
116
|
+
action="store_const",
|
|
117
|
+
const="DEBUG",
|
|
118
|
+
default="SUCCESS",
|
|
119
|
+
help="Enable debug logging.",
|
|
120
|
+
)
|
|
121
|
+
add_version_option(parser)
|
|
122
|
+
args = parser.parse_args()
|
|
123
|
+
|
|
124
|
+
log_setup(args.log_level)
|
|
125
|
+
cif_to_seqres(args.input, args.output)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
if __name__ == "__main__":
|
|
129
|
+
main()
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import json
|
|
3
|
+
from argparse import ArgumentParser, RawTextHelpFormatter
|
|
4
|
+
|
|
5
|
+
from Bio import SeqIO
|
|
6
|
+
from loguru import logger
|
|
7
|
+
|
|
8
|
+
from alphafold3tools.log import log_setup
|
|
9
|
+
from alphafold3tools.utils import add_version_option, int_id_to_str_id, sanitised_name
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _write_protein_seq_section(seq: str) -> list:
|
|
13
|
+
"""
|
|
14
|
+
Write the protein sequence section in JSON format.
|
|
15
|
+
|
|
16
|
+
This function formats protein sequence data into the JSON structure required by AlphaFold3.
|
|
17
|
+
If the input sequence contains colon separators, it will be split into multiple sequences
|
|
18
|
+
with incremental IDs.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
seq (str): The protein sequence string. May contain multiple sequences separated by colons.
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
list: A list of dictionaries, each containing a protein ID and its corresponding sequence.
|
|
25
|
+
e.g.
|
|
26
|
+
seq = "MKTAYIAKQRQISFVKSHFSR:MKTA"
|
|
27
|
+
expected = (
|
|
28
|
+
{"protein": {"id": ["A"], "sequence": "MKTAYIAKQRQISFVKSHFSR"}},
|
|
29
|
+
{"protein": {"id": ["B"], "sequence": "MKTA"}},
|
|
30
|
+
)
|
|
31
|
+
"""
|
|
32
|
+
if ":" in seq:
|
|
33
|
+
seqs = seq.split(":")
|
|
34
|
+
return [
|
|
35
|
+
{"protein": {"id": [int_id_to_str_id(i + 1)], "sequence": s}}
|
|
36
|
+
for i, s in enumerate(seqs)
|
|
37
|
+
]
|
|
38
|
+
else:
|
|
39
|
+
return [{"protein": {"id": [int_id_to_str_id(1)], "sequence": seq}}]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def convert_fasta_to_json(inputfile: str, seeds: tuple[int] = (1,)) -> None:
|
|
43
|
+
"""
|
|
44
|
+
Convert a FASTA file contatining multiple protein sequences to JSON format
|
|
45
|
+
compatible with AlphaFold3.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
inputfile (str): Path to the input FASTA file.
|
|
49
|
+
"""
|
|
50
|
+
if seeds is None:
|
|
51
|
+
seeds = [1]
|
|
52
|
+
with open(inputfile, "r") as input_handle:
|
|
53
|
+
for record in SeqIO.parse(input_handle, "fasta"):
|
|
54
|
+
content = {
|
|
55
|
+
"name": sanitised_name(record.id),
|
|
56
|
+
"dialect": "alphafold3",
|
|
57
|
+
"version": 1,
|
|
58
|
+
}
|
|
59
|
+
content["sequences"] = _write_protein_seq_section(str(record.seq))
|
|
60
|
+
content["modelSeeds"] = list(seeds)
|
|
61
|
+
with open(record.id + ".json", "w") as output_handle:
|
|
62
|
+
json.dump(content, output_handle, indent=2)
|
|
63
|
+
logger.info(f"Converted {record.id} to JSON format.")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def main():
|
|
67
|
+
parser = ArgumentParser(
|
|
68
|
+
description="Convert FASTA file to JSON format compatible with AlphaFold3.",
|
|
69
|
+
formatter_class=RawTextHelpFormatter,
|
|
70
|
+
)
|
|
71
|
+
add_version_option(parser)
|
|
72
|
+
parser.add_argument(
|
|
73
|
+
"-i",
|
|
74
|
+
"--input",
|
|
75
|
+
help="input FASTA file to convert to JSON file",
|
|
76
|
+
type=str,
|
|
77
|
+
required=True,
|
|
78
|
+
)
|
|
79
|
+
parser.add_argument(
|
|
80
|
+
"-s",
|
|
81
|
+
"--seeds",
|
|
82
|
+
help="model seeds to use for the conversion (default: 1)",
|
|
83
|
+
type=int,
|
|
84
|
+
nargs="+",
|
|
85
|
+
default=(1,),
|
|
86
|
+
)
|
|
87
|
+
parser.add_argument(
|
|
88
|
+
"-d",
|
|
89
|
+
"--debug",
|
|
90
|
+
help="Print lots of debugging statements",
|
|
91
|
+
dest="loglevel",
|
|
92
|
+
action="store_const",
|
|
93
|
+
const="DEBUG",
|
|
94
|
+
default="SUCCESS",
|
|
95
|
+
)
|
|
96
|
+
args = parser.parse_args()
|
|
97
|
+
inputfile = args.input
|
|
98
|
+
seeds = args.seeds
|
|
99
|
+
log_setup(level=args.loglevel)
|
|
100
|
+
|
|
101
|
+
if not inputfile.endswith(".fasta") and not inputfile.endswith(".fa"):
|
|
102
|
+
raise ValueError(
|
|
103
|
+
"Input file must be a FASTA file with .fasta or .fa extension."
|
|
104
|
+
)
|
|
105
|
+
convert_fasta_to_json(inputfile, seeds=seeds)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
if __name__ == "__main__":
|
|
109
|
+
main()
|