Instructions to use nvidia/RFD4-Proteina-prep with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use nvidia/RFD4-Proteina-prep with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("nvidia/RFD4-Proteina-prep", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Take RFD4 5248e9a1, fix a stale vocabulary, require AtomWorks 3.0.4
Browse filesThe vendored modules are re-stamped to RFD4 5248e9a15a18. Across those ten
upstream commits not one vendored module changed, so the only thing in the
copy that moved is its provenance header.
What did move is package data nothing was checking. RFD4 gave the `UNK` row of
the checkpoint vocabulary a backbone -- "N CA C - O" where this package still
shipped an empty row -- in "filter backbone-capable UNK before refolding"
(#740). `resources/aa_rna_dna_glycan_ncaa.yaml` is copied verbatim from the
RFD4 repository but is not a module, so it carries no provenance commit and the
coverage guard could not see it. check_vendored.py now compares it byte for
byte through a VERBATIM_DATA table, which a tamper test exercises.
That gap is worth stating plainly: a UNK residue was being featurized with no
atom37 slots at all, where upstream gives it four. None of the ten snapshot
inputs contains a UNK residue, so the feature snapshot reported no change --
the one real change in this release was invisible to the harness that exists to
catch exactly this. The runbook now says so.
AtomWorks moves to 3.0.4, one release ahead of RFD4's main, which still asks
for 3.0.3. It is a drop-in: 3.0.4 adds has_annotation and lets insert_atoms
take a pre-built block, so the annotation and concatenation paths the vendored
code already calls get cheaper with no call site changing. Output is identical
over 1,724 quantities on ten inputs, and the coordinate-transfer path that
dominates write_cif drops about 6-8% (127 to 120 ms on a 98-residue redesign,
956 to 887 ms on a 493-residue one).
Not taken: the batched coordinate transfer that makes that path 5.25x faster.
It lives in np_opt.py on RFD4's feat/bioir-inference-backend-clean branch and
is not on main, and the commit that requires AtomWorks 3.0.4 is the same one.
Porting it here would rebuild the fork this package exists not to have. When it
merges, the ordinary release take picks it up.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- MAINTAINING.md +14 -1
- README.md +17 -105
- pyproject.toml +1 -1
- src/rfd4_proteina_prep/_cif/__init__.py +1 -1
- src/rfd4_proteina_prep/_cif/conditions.py +1 -1
- src/rfd4_proteina_prep/_cif/datapipes_bonds.py +1 -1
- src/rfd4_proteina_prep/_cif/datapipes_pipeline.py +1 -1
- src/rfd4_proteina_prep/_cif/datapipes_schema_base.py +1 -1
- src/rfd4_proteina_prep/_cif/datapipes_schema_proteina.py +1 -1
- src/rfd4_proteina_prep/_cif/encoding.py +1 -1
- src/rfd4_proteina_prep/_cif/inference_utils_insertion_mapping.py +1 -1
- src/rfd4_proteina_prep/_cif/metrics_sse_metrics.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_atom_names.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_budget.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_chirality_feature.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_design_task.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_design_task_modifiers.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_dna_crop.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_geometry.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_inference_annotations.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_internal_coords.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_invariants.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_loss_weight_predicates.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_metals.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_na_geom.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_random_atomize_residues.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_sequence_conditioning.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_unindexing.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_utils_conditioning_utils.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_utils_na_geom_utils.py +1 -1
- src/rfd4_proteina_prep/_cif/transforms_utils_ppi_utils.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_chain.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_chirals.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_common.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_constants.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_coordinate_transfer.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_fold.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_parse_presets.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_pdb.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_sequence_sampling.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_standard_annotations.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_structure_export.py +1 -1
- src/rfd4_proteina_prep/_cif/utils_token_encoding.py +1 -1
- src/rfd4_proteina_prep/resources/aa_rna_dna_glycan_ncaa.yaml +1 -1
- tools/check_vendored.py +23 -1
|
@@ -13,7 +13,7 @@ of that hour is step 4.
|
|
| 13 |
|
| 14 |
- A checkout of [baker-laboratory/RFD4-Proteina-dev](https://github.com/baker-laboratory/RFD4-Proteina-dev).
|
| 15 |
Fetch it first; everything below compares against a commit in it.
|
| 16 |
-
- An environment that can import `rfd4_proteina_prep` — `atomworks[ml]==3.0.
|
| 17 |
- The input set from step 3. It lives in the RFD4 repository, not here.
|
| 18 |
|
| 19 |
Throughout, `$RFD4` is the path to that checkout.
|
|
@@ -61,6 +61,12 @@ amino acid, covalent modification, centroid conditioning and RASA conditioning:
|
|
| 61 |
| `tests/data/egfr2_phosphopeptide.cif` | non-canonical amino acids |
|
| 62 |
| `tests/data/sam_binder_generated_minimized.cif` | small-molecule binder |
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
Two more that exercised real differences last time live outside the repository: a glycan structure
|
| 65 |
(`6mtg`) and a covalent modification (`plinder_1gya`). Add equivalents if you have them — the
|
| 66 |
ligand and glycan inputs are where sequence conditioning diverges, so a set without them will look
|
|
@@ -110,6 +116,13 @@ Never add an `ACCEPTED` entry to silence a difference you have not explained. Ea
|
|
| 110 |
to the exact pair of versions it was agreed for, so it stops applying the moment either side moves
|
| 111 |
— an entry can go stale, but it cannot quietly cover a change nobody read.
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
Two guards run alongside. A vendored file carrying a provenance header but missing from the
|
| 114 |
derived source set is reported rather than skipped — that is how three modules once went unchecked
|
| 115 |
for months. And `cath_mapping.py`, which transcribes the checkpoint's CATH label order, is compared
|
|
|
|
| 13 |
|
| 14 |
- A checkout of [baker-laboratory/RFD4-Proteina-dev](https://github.com/baker-laboratory/RFD4-Proteina-dev).
|
| 15 |
Fetch it first; everything below compares against a commit in it.
|
| 16 |
+
- An environment that can import `rfd4_proteina_prep` — `atomworks[ml]==3.0.4`, torch, biotite 1.6.0.
|
| 17 |
- The input set from step 3. It lives in the RFD4 repository, not here.
|
| 18 |
|
| 19 |
Throughout, `$RFD4` is the path to that checkout.
|
|
|
|
| 61 |
| `tests/data/egfr2_phosphopeptide.cif` | non-canonical amino acids |
|
| 62 |
| `tests/data/sam_binder_generated_minimized.cif` | small-molecule binder |
|
| 63 |
|
| 64 |
+
**This set has a known blind spot.** None of these inputs contains an `UNK` residue, so the `UNK`
|
| 65 |
+
vocabulary fix described above produced *no* snapshot difference at all — the one real change in
|
| 66 |
+
that release was invisible to the harness. A snapshot that says "no change" is only as strong as
|
| 67 |
+
the inputs you gave it. If you touch the vocabulary, add an input that exercises the rows you
|
| 68 |
+
touched, or check the rows directly with `UNIFIED_ATOM37_ENCODING.token_atoms[...]`.
|
| 69 |
+
|
| 70 |
Two more that exercised real differences last time live outside the repository: a glycan structure
|
| 71 |
(`6mtg`) and a covalent modification (`plinder_1gya`). Add equivalents if you have them — the
|
| 72 |
ligand and glycan inputs are where sequence conditioning diverges, so a set without them will look
|
|
|
|
| 116 |
to the exact pair of versions it was agreed for, so it stops applying the moment either side moves
|
| 117 |
— an entry can go stale, but it cannot quietly cover a change nobody read.
|
| 118 |
|
| 119 |
+
Package data is checked too, and it is worth knowing why. `resources/aa_rna_dna_glycan_ncaa.yaml`
|
| 120 |
+
is the checkpoint vocabulary, copied verbatim from the RFD4 repository. It is not a module, so
|
| 121 |
+
nothing stamps it with a provenance commit and the coverage guard below cannot see it — and this
|
| 122 |
+
package shipped a vocabulary whose `UNK` row had no backbone atoms for ten upstream commits after
|
| 123 |
+
RFD4 gave it `N CA C O`. `VERBATIM_DATA` now compares it byte for byte. Add any future copied data
|
| 124 |
+
file to that table.
|
| 125 |
+
|
| 126 |
Two guards run alongside. A vendored file carrying a provenance header but missing from the
|
| 127 |
derived source set is reported rather than skipped — that is how three modules once went unchecked
|
| 128 |
for months. And `cath_mapping.py`, which transcribes the checkpoint's CATH label order, is compared
|
|
@@ -1,8 +1,6 @@
|
|
| 1 |
---
|
| 2 |
license: bsd-3-clause
|
| 3 |
-
library_name: diffusers
|
| 4 |
tags:
|
| 5 |
-
- modular-diffusers
|
| 6 |
- biology
|
| 7 |
- protein-design
|
| 8 |
- annotated-cif
|
|
@@ -17,125 +15,39 @@ annotated CIF file (the RFD4 condition annotations written by AtomWorks Studio)
|
|
| 17 |
tensors back into an annotated CIF. It builds on [AtomWorks](https://github.com/RosettaCommons/atomworks) and has no
|
| 18 |
dependency on the original RFD4 runtime.
|
| 19 |
|
| 20 |
-
## Install and authenticate
|
| 21 |
-
|
| 22 |
-
Python 3.11 or newer is required. This repository and the model are currently private: your Hugging Face account
|
| 23 |
-
must have access to both. Keep tokens out of notebooks and shell history; enter them at the login prompt.
|
| 24 |
-
|
| 25 |
```bash
|
| 26 |
-
pip install
|
| 27 |
-
hf auth login
|
| 28 |
-
hf auth whoami
|
| 29 |
-
hf download nvidia/RFD4-Proteina-prep --local-dir rfd4-prep
|
| 30 |
-
pip install ./rfd4-prep
|
| 31 |
-
pip install git+https://github.com/huggingface/diffusers-new-model-addition-RFD4-Proteina@f27330104ffa7940fecff63afcb509c5361950f0
|
| 32 |
```
|
| 33 |
|
| 34 |
-
The Diffusers revision is intentional. Its model parameter names and shapes match the checkpoint snapshot below.
|
| 35 |
-
Newer PR revisions rename parameters; using them with these weights is not a supported substitute. The helper does
|
| 36 |
-
not convert weights or silently repair compatibility. `trust_remote_code=True` loads Python from the helper repo;
|
| 37 |
-
inspect `block.py` and pin a revision for reproducible use. It does not install dependencies automatically.
|
| 38 |
-
|
| 39 |
-
## Hub custom block: download, prepare, generate, export
|
| 40 |
-
|
| 41 |
-
Both interfaces use the same installed `rfd4_proteina_prep` implementation. The custom block is a thin wrapper,
|
| 42 |
-
not a second vendored copy of the chemistry code, and does not add AtomWorks to Diffusers itself.
|
| 43 |
-
|
| 44 |
```python
|
| 45 |
import torch
|
| 46 |
-
from
|
| 47 |
-
from diffusers import ModularPipeline, RFD4ProteinaPipeline
|
| 48 |
-
|
| 49 |
-
helper_repo = "nvidia/RFD4-Proteina-prep"
|
| 50 |
-
# Resolve once so code and inputs come from one immutable snapshot.
|
| 51 |
-
helper_revision = HfApi().model_info(helper_repo).sha
|
| 52 |
-
model_revision = "b21bec6473e1087008bea8b7ec05dee8276301ab"
|
| 53 |
-
helper = ModularPipeline.from_pretrained(
|
| 54 |
-
helper_repo, revision=helper_revision, trust_remote_code=True
|
| 55 |
-
)
|
| 56 |
-
input_cif = hf_hub_download(helper_repo, "examples/inputs/protein_binder.cif", revision=helper_revision)
|
| 57 |
-
prepared = helper(cif_path=input_cif, seed=42, device="cuda:0")
|
| 58 |
-
features, atoms = prepared.get("features"), prepared.get("atom_array")
|
| 59 |
-
|
| 60 |
-
pipe = RFD4ProteinaPipeline.from_pretrained(
|
| 61 |
-
"nvidia/RFD4-Proteina-Diffusers", revision=model_revision, dtype=torch.bfloat16
|
| 62 |
-
).to("cuda:0")
|
| 63 |
-
output = pipe(features, generator=torch.Generator("cuda:0").manual_seed(42))
|
| 64 |
-
cif_path = helper(
|
| 65 |
-
pipeline_output=output, features=features, atom_array=atoms,
|
| 66 |
-
output_path="design.cif", output="cif_path",
|
| 67 |
-
)
|
| 68 |
-
print(cif_path)
|
| 69 |
-
```
|
| 70 |
-
|
| 71 |
-
Use a new output filename each time. Export refuses to overwrite an existing file. `row` selects a batch row
|
| 72 |
-
when generating several designs of the same prepared input. Tensor coordinates are in nanometers; CIF coordinates
|
| 73 |
-
are in angstroms. Keep the atom mapping together with its features, not a different example's mapping.
|
| 74 |
-
|
| 75 |
-
The regular Python API remains available without remote-code loading:
|
| 76 |
-
|
| 77 |
-
```python
|
| 78 |
from rfd4_proteina_prep import prepare_cif, write_cif
|
| 79 |
-
features, atoms = prepare_cif(input_cif, seed=42, device=pipe.device)
|
| 80 |
-
output = pipe(features, generator=torch.Generator("cuda:0").manual_seed(42))
|
| 81 |
-
write_cif(output, features, atoms, "another-design.cif")
|
| 82 |
-
```
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
The catalog includes all seven non-antibody task presets from the model's Studio gallery, plus the three
|
| 90 |
-
web-editor examples. **Antibody and VHH/nanobody inputs are excluded.** Existing assets in the separate model
|
| 91 |
-
repository are not deleted. Inputs are copied without changing their annotations. Source revisions, SHA-256
|
| 92 |
-
hashes, task-specific arguments and model/code pins are recorded in [examples/manifest.json](examples/manifest.json).
|
| 93 |
-
|
| 94 |
-
| Example | Input | Special invocation |
|
| 95 |
-
| --- | --- | --- |
|
| 96 |
-
| PD-L1 protein binder | [protein_binder.cif](examples/inputs/protein_binder.cif) | Default conditioned generation |
|
| 97 |
-
| Catalytic-motif enzyme | [enzyme_design.cif](examples/inputs/enzyme_design.cif) | Default |
|
| 98 |
-
| 1QJG motif scaffold | [motif_scaffolding.cif](examples/inputs/motif_scaffolding.cif) | Default |
|
| 99 |
-
| SAM ligand binder | [small_molecule_binder.cif](examples/inputs/small_molecule_binder.cif) | Default |
|
| 100 |
-
| Unconditional protein | [unconditional.cif](examples/inputs/unconditional.cif) | Default |
|
| 101 |
-
| 2KL8 inverse folding | [inverse_folding.cif](examples/inputs/inverse_folding.cif) | `inverse_folding=True`, both `partial_t` values zero |
|
| 102 |
-
| 2KL8 partial diffusion | [partial_diffusion.cif](examples/inputs/partial_diffusion.cif) | Start times derived from the checkpoint schedule; 40% remaining |
|
| 103 |
-
| Studio PD-L1 | [ppi_pdl1.cif](examples/studio/ppi_pdl1.cif) | Default |
|
| 104 |
-
| Studio PH2 active site | [mcsa_ph2.cif](examples/studio/mcsa_ph2.cif) | Default |
|
| 105 |
-
| Studio IAI ligand binder | [disco_iai.cif](examples/studio/disco_iai.cif) | Default |
|
| 106 |
-
|
| 107 |
-
To check every input without downloading weights or using a GPU:
|
| 108 |
-
|
| 109 |
-
```bash
|
| 110 |
-
python rfd4-prep/examples/run_hub_examples.py --prepare-only --out prep-check
|
| 111 |
-
```
|
| 112 |
-
|
| 113 |
-
To generate all ten presets with the pinned checkpoint, or a selected subset:
|
| 114 |
-
|
| 115 |
-
```bash
|
| 116 |
-
python rfd4-prep/examples/run_hub_examples.py --out designs
|
| 117 |
-
python rfd4-prep/examples/run_hub_examples.py --tasks protein_binder inverse_folding --out selected-designs
|
| 118 |
```
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
Use this runner rather than the legacy `run_examples.py`, which expects local files and includes antibody tasks.
|
| 123 |
-
|
| 124 |
-
Validation for this addition: all ten inputs produce identical tensors to the installed package at
|
| 125 |
-
`199dfd7f83db1487a02fc1f9f15536e32a9a6a6b`; CPU tests cover RNG preservation, real CIF round-trip export,
|
| 126 |
-
batch-row selection, non-overwriting behavior, and explicit remote-code trust. The pinned Diffusers classes match
|
| 127 |
-
all checkpoint parameter names and shapes. **New GPU generations and biological quality have not been validated
|
| 128 |
-
by these checks.** No generated output is presented as a result of this addition. Refolding, scoring and Studio's
|
| 129 |
-
search services are separate; the helper only performs CIF preparation and export.
|
| 130 |
|
| 131 |
## AtomWorks version
|
| 132 |
|
| 133 |
-
The pin is **PyPI `atomworks[ml]==3.0.
|
| 134 |
-
ambiguous. The RFD4 repository pins AtomWorks by git commit rather than by release, and
|
| 135 |
`version = "3.0.1"` in its own `pyproject.toml` while carrying the 3.0.3 API. So "3.0.1" means two different things
|
| 136 |
depending on where you read it, and installing PyPI 3.0.1 gives you an `AnnotateCovalentModifications` signature this
|
| 137 |
package no longer calls.
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
## Keeping up with the RFD4 repository
|
| 140 |
|
| 141 |
The modules under `_cif/` are the RFD4 datapipe, vendored unedited. They are not an inference-only fork: the training
|
|
|
|
| 1 |
---
|
| 2 |
license: bsd-3-clause
|
|
|
|
| 3 |
tags:
|
|
|
|
| 4 |
- biology
|
| 5 |
- protein-design
|
| 6 |
- annotated-cif
|
|
|
|
| 15 |
tensors back into an annotated CIF. It builds on [AtomWorks](https://github.com/RosettaCommons/atomworks) and has no
|
| 16 |
dependency on the original RFD4 runtime.
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
```bash
|
| 19 |
+
pip install git+https://huggingface.co/nvidia/RFD4-Proteina-prep # Python >= 3.11; installs atomworks[ml]==3.0.4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
```
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
```python
|
| 23 |
import torch
|
| 24 |
+
from diffusers import RFD4ProteinaPipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
from rfd4_proteina_prep import prepare_cif, write_cif
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
pipe = RFD4ProteinaPipeline.from_pretrained("nvidia/RFD4-Proteina-Diffusers", dtype=torch.bfloat16).to("cuda:0")
|
| 28 |
+
features, atoms = prepare_cif("input.cif", seed=42, device=pipe.device)
|
| 29 |
+
output = pipe(features, generator=torch.Generator("cuda:0").manual_seed(42))
|
| 30 |
+
write_cif(output, features, atoms, "design.cif")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
```
|
| 32 |
|
| 33 |
+
`prepare_cif` returns a single-example batch; `seed` controls expansion of flexible segments and does not touch the
|
| 34 |
+
global random state.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## AtomWorks version
|
| 37 |
|
| 38 |
+
The pin is **PyPI `atomworks[ml]==3.0.4`**, and it is worth being explicit because the version numbering is
|
| 39 |
+
ambiguous. The RFD4 repository pins AtomWorks by git commit rather than by release, and a commit it pinned declared
|
| 40 |
`version = "3.0.1"` in its own `pyproject.toml` while carrying the 3.0.3 API. So "3.0.1" means two different things
|
| 41 |
depending on where you read it, and installing PyPI 3.0.1 gives you an `AnnotateCovalentModifications` signature this
|
| 42 |
package no longer calls.
|
| 43 |
|
| 44 |
+
**This pin is one release ahead of RFD4's `main`, which still asks for 3.0.3.** That is deliberate. 3.0.4 is a
|
| 45 |
+
drop-in: it adds `has_annotation` and lets `insert_atoms` take a pre-built block, so the annotation and
|
| 46 |
+
concatenation paths this package already calls get cheaper without any call site changing. Verified identical output
|
| 47 |
+
over 1,724 quantities on ten inputs, and about 6-8% off the coordinate-transfer path that dominates `write_cif`
|
| 48 |
+
(127 to 120 ms on a 98-residue redesign, 956 to 887 ms on a 493-residue one). RFD4 requires 3.0.4 on the branch
|
| 49 |
+
carrying its batched coordinate transfer, so this is where upstream is going rather than away from it.
|
| 50 |
+
|
| 51 |
## Keeping up with the RFD4 repository
|
| 52 |
|
| 53 |
The modules under `_cif/` are the RFD4 datapipe, vendored unedited. They are not an inference-only fork: the training
|
|
@@ -8,7 +8,7 @@ version = "0.1.0"
|
|
| 8 |
description = "Annotated-CIF input preparation and output export for the Diffusers RFD4-Proteina pipeline."
|
| 9 |
requires-python = ">=3.11"
|
| 10 |
license = { text = "BSD-3-Clause" }
|
| 11 |
-
dependencies = ["torch", "numpy", "atomworks[ml]==3.0.
|
| 12 |
|
| 13 |
[project.urls]
|
| 14 |
Homepage = "https://huggingface.co/nvidia/RFD4-Proteina-prep"
|
|
|
|
| 8 |
description = "Annotated-CIF input preparation and output export for the Diffusers RFD4-Proteina pipeline."
|
| 9 |
requires-python = ">=3.11"
|
| 10 |
license = { text = "BSD-3-Clause" }
|
| 11 |
+
dependencies = ["torch", "numpy", "atomworks[ml]==3.0.4", "scipy", "jaxtyping"]
|
| 12 |
|
| 13 |
[project.urls]
|
| 14 |
Homepage = "https://huggingface.co/nvidia/RFD4-Proteina-prep"
|
|
@@ -1,4 +1,4 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
from enum import IntEnum
|
| 6 |
from typing import ClassVar, Literal
|
| 7 |
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
from enum import IntEnum
|
| 6 |
from typing import ClassVar, Literal
|
| 7 |
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Atom-level bond utilities (bond order, aromaticity, distances).
|
| 6 |
|
| 7 |
Extracted from :py:mod:`~rfproteina.datapipes.pipeline` to keep that
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Atom-level bond utilities (bond order, aromaticity, distances).
|
| 6 |
|
| 7 |
Extracted from :py:mod:`~rfproteina.datapipes.pipeline` to keep that
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Pipeline for training for La Proteina-style models."""
|
| 6 |
|
| 7 |
import logging
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Pipeline for training for La Proteina-style models."""
|
| 6 |
|
| 7 |
import logging
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Schema base classes for batched data samples.
|
| 6 |
|
| 7 |
This module provides the infrastructure for padding, batching, and dict-like access
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Schema base classes for batched data samples.
|
| 6 |
|
| 7 |
This module provides the infrastructure for padding, batching, and dict-like access
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Schema for Proteina with explicit specs: (dtype, default, dims)."""
|
| 6 |
|
| 7 |
from dataclasses import dataclass, field
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Schema for Proteina with explicit specs: (dtype, default, dims)."""
|
| 6 |
|
| 7 |
from dataclasses import dataclass, field
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""RFD4's checkpoint vocabulary, loaded into AtomWorks' generic token encoding."""
|
| 6 |
|
| 7 |
from importlib.resources import files
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""RFD4's checkpoint vocabulary, loaded into AtomWorks' generic token encoding."""
|
| 6 |
|
| 7 |
from importlib.resources import files
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Read the insertion head's predicted token mapping via per-chain Hungarian assignment."""
|
| 6 |
|
| 7 |
import logging
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Read the insertion head's predicted token mapping via per-chain Hungarian assignment."""
|
| 6 |
|
| 7 |
import logging
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Secondary structure evaluation metrics for generated protein structures."""
|
| 6 |
|
| 7 |
import itertools
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Secondary structure evaluation metrics for generated protein structures."""
|
| 6 |
|
| 7 |
import itertools
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Transforms for atom name annotation and featurization."""
|
| 6 |
|
| 7 |
from typing import ClassVar
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Transforms for atom name annotation and featurization."""
|
| 6 |
|
| 7 |
from typing import ClassVar
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Post-crop token-budget enforcement.
|
| 6 |
|
| 7 |
- ``EnforceCropBudget``: drops spatially-peripheral non-reserved tokens so
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Post-crop token-budget enforcement.
|
| 6 |
|
| 7 |
- ``EnforceCropBudget``: drops spatially-peripheral non-reserved tokens so
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Idealized local geometry features for stereogenic centers and E/Z double bonds."""
|
| 6 |
|
| 7 |
from collections.abc import Generator
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Idealized local geometry features for stereogenic centers and E/Z double bonds."""
|
| 6 |
|
| 7 |
from collections.abc import Generator
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
import logging
|
| 6 |
import itertools
|
| 7 |
from collections import defaultdict
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
import logging
|
| 6 |
import itertools
|
| 7 |
from collections import defaultdict
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
from collections.abc import Sequence
|
| 6 |
from typing import Any
|
| 7 |
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
from collections.abc import Sequence
|
| 6 |
from typing import Any
|
| 7 |
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Protein-DNA contact-centered contiguous cropping.
|
| 6 |
|
| 7 |
The training pipeline crops protein-DNA examples around their binding
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Protein-DNA contact-centered contiguous cropping.
|
| 6 |
|
| 7 |
The training pipeline crops protein-DNA examples around their binding
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
from collections.abc import Sequence
|
| 6 |
|
| 7 |
import numpy as np
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
from collections.abc import Sequence
|
| 6 |
|
| 7 |
import numpy as np
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Prepare source provenance annotations for inference inputs."""
|
| 6 |
|
| 7 |
import biotite.structure as struc
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Prepare source provenance annotations for inference inputs."""
|
| 6 |
|
| 7 |
import biotite.structure as struc
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Internal-coordinate group assignment and pipeline target materialization."""
|
| 6 |
|
| 7 |
from typing import ClassVar
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Internal-coordinate group assignment and pipeline target materialization."""
|
| 6 |
|
| 7 |
from typing import ClassVar
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Batch-level invariant checking for the rfproteina pipeline."""
|
| 6 |
|
| 7 |
import logging
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Batch-level invariant checking for the rfproteina pipeline."""
|
| 6 |
|
| 7 |
import logging
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Atom-level boolean predicates for loss-weight upweighting.
|
| 6 |
|
| 7 |
Each predicate takes an :py:class:`AtomArray` and returns a boolean ``np.ndarray`` of
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Atom-level boolean predicates for loss-weight upweighting.
|
| 6 |
|
| 7 |
Each predicate takes an :py:class:`AtomArray` and returns a boolean ``np.ndarray`` of
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Transforms for metal atoms and their coordination bonds."""
|
| 6 |
|
| 7 |
import numpy as np
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Transforms for metal atoms and their coordination bonds."""
|
| 6 |
|
| 7 |
import numpy as np
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
from typing import Any
|
| 6 |
|
| 7 |
import numpy as np
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
from typing import Any
|
| 6 |
|
| 7 |
import numpy as np
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Vocabulary-aware atomization policy for RFD4 training."""
|
| 6 |
|
| 7 |
from collections.abc import Mapping
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Vocabulary-aware atomization policy for RFD4 training."""
|
| 6 |
|
| 7 |
from collections.abc import Mapping
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Finalize sequence conditioning consistently for training and inference."""
|
| 6 |
|
| 7 |
import numpy as np
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Finalize sequence conditioning consistently for training and inference."""
|
| 6 |
|
| 7 |
import numpy as np
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
import logging
|
| 6 |
import copy
|
| 7 |
import itertools
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
import logging
|
| 6 |
import copy
|
| 7 |
import itertools
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
import logging
|
| 6 |
import numpy as np
|
| 7 |
import torch
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
import logging
|
| 6 |
import numpy as np
|
| 7 |
import torch
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
import math
|
| 6 |
|
| 7 |
import biotite.structure as struc
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
import math
|
| 6 |
|
| 7 |
import biotite.structure as struc
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
import logging
|
| 6 |
import math
|
| 7 |
from typing import Literal
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
import logging
|
| 6 |
import math
|
| 7 |
from typing import Literal
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Utilities for identifying the chain of interest in a multi-chain structure."""
|
| 6 |
|
| 7 |
import logging
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Utilities for identifying the chain of interest in a multi-chain structure."""
|
| 6 |
|
| 7 |
import logging
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Detection and geometry of stereogenic centers and E/Z double bonds."""
|
| 6 |
|
| 7 |
import warnings
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Detection and geometry of stereogenic centers and E/Z double bonds."""
|
| 6 |
|
| 7 |
import warnings
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
import contextlib
|
| 6 |
import os
|
| 7 |
from functools import wraps
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
import contextlib
|
| 6 |
import os
|
| 7 |
from functools import wraps
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
import numpy as np
|
| 6 |
import torch
|
| 7 |
from atomworks.constants import AF3_EXCLUDED_LIGANDS, STANDARD_AA, UNKNOWN_AA
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
import numpy as np
|
| 6 |
import torch
|
| 7 |
from atomworks.constants import AF3_EXCLUDED_LIGANDS, STANDARD_AA, UNKNOWN_AA
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Utilities for copying coordinates from generated structures back to input structures.
|
| 6 |
|
| 7 |
Handles coordinate transfer for workflows where residue types may change but we want to preserve annotations.
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Utilities for copying coordinates from generated structures back to input structures.
|
| 6 |
|
| 7 |
Handles coordinate transfer for workflows where residue types may change but we want to preserve annotations.
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
from typing import Any, Literal
|
| 6 |
|
| 7 |
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
from typing import Any, Literal
|
| 6 |
|
| 7 |
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Project-specific parsing presets.
|
| 6 |
|
| 7 |
Import these directly or pass to :py:func:`~atomworks.io.parser.parse` as the
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Project-specific parsing presets.
|
| 6 |
|
| 7 |
Import these directly or pass to :py:func:`~atomworks.io.parser.parse` as the
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
# MIT License
|
| 6 |
|
| 7 |
# Copyright (c) Microsoft Corporation.
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
# MIT License
|
| 6 |
|
| 7 |
# Copyright (c) Microsoft Corporation.
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Constants used by sequence-conditioning sampling policies."""
|
| 6 |
|
| 7 |
import numpy as np
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Constants used by sequence-conditioning sampling policies."""
|
| 6 |
|
| 7 |
import numpy as np
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Project-specific StandardAnnotations.
|
| 6 |
|
| 7 |
Registering these as StandardAnnotations (rather than plain extra_fields) gives:
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Project-specific StandardAnnotations.
|
| 6 |
|
| 7 |
Registering these as StandardAnnotations (rather than plain extra_fields) gives:
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Shared structure export utilities used by flow and AE validation."""
|
| 6 |
|
| 7 |
from __future__ import annotations
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Shared structure export utilities used by flow and AE validation."""
|
| 6 |
|
| 7 |
from __future__ import annotations
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
-
# Adapted from RFD4-Proteina
|
| 5 |
"""Atom37 slot lookup and token-reference annotations for RFD4's vocabulary."""
|
| 6 |
|
| 7 |
import functools
|
|
|
|
| 1 |
# SPDX-License-Identifier: BSD-3-Clause
|
| 2 |
# Copyright (c) 2026, Institute for Protein Design, University of Washington
|
| 3 |
# Full copyright, license conditions and disclaimer: THIRD_PARTY_LICENSES.txt.
|
| 4 |
+
# Adapted from RFD4-Proteina 5248e9a15a187c75a31b6a58d42efc0b3d6b543f.
|
| 5 |
"""Atom37 slot lookup and token-reference annotations for RFD4's vocabulary."""
|
| 6 |
|
| 7 |
import functools
|
|
@@ -31,7 +31,7 @@ residues:
|
|
| 31 |
"TRP": "N CA C CB O CG - - - - - - CD1 CD2 - - - - - - - CE2 CE3 - NE1 - - - CH2 - - - - CZ2 CZ3 - OXT"
|
| 32 |
"TYR": "N CA C CB O CG - - - - - - CD1 CD2 - - - - - - CE1 CE2 - - - - - - - - - OH CZ - - - OXT"
|
| 33 |
"VAL": "N CA C CB O - CG1 CG2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - OXT"
|
| 34 |
-
"UNK": "
|
| 35 |
rna:
|
| 36 |
"A": "P C1' C2' O2' C3' O3' C4' O4' C5' O5' OP1 OP2 N9 C8 N7 C5 C4 N3 C2 N1 C6 N6 - - - - - - - - - - - - - - OP3"
|
| 37 |
"C": "P C1' C2' O2' C3' O3' C4' O4' C5' O5' OP1 OP2 - - - - - - - - - - - - N1 C2 O2 N3 C4 C5 C6 N4 - - - - OP3"
|
|
|
|
| 31 |
"TRP": "N CA C CB O CG - - - - - - CD1 CD2 - - - - - - - CE2 CE3 - NE1 - - - CH2 - - - - CZ2 CZ3 - OXT"
|
| 32 |
"TYR": "N CA C CB O CG - - - - - - CD1 CD2 - - - - - - CE1 CE2 - - - - - - - - - OH CZ - - - OXT"
|
| 33 |
"VAL": "N CA C CB O - CG1 CG2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - OXT"
|
| 34 |
+
"UNK": "N CA C - O - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
| 35 |
rna:
|
| 36 |
"A": "P C1' C2' O2' C3' O3' C4' O4' C5' O5' OP1 OP2 N9 C8 N7 C5 C4 N3 C2 N1 C6 N6 - - - - - - - - - - - - - - OP3"
|
| 37 |
"C": "P C1' C2' O2' C3' O3' C4' O4' C5' O5' OP1 OP2 - - - - - - - - - - - - N1 C2 O2 N3 C4 C5 C6 N4 - - - - OP3"
|
|
@@ -64,6 +64,14 @@ DATA_SOURCES = {
|
|
| 64 |
"cath_mapping.py": ("data/cath_label_mapping.pkl", "CATH_MAPPING"),
|
| 65 |
}
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
# Divergences from the source that have been read and are staying, each with the reason. A clean
|
| 68 |
# run reports these as held, not as drift.
|
| 69 |
#
|
|
@@ -254,6 +262,20 @@ def data_drift(vendored: Path, repo: Path, commit: str) -> list[str]:
|
|
| 254 |
blob is a dict of dicts of str -> int and the unpickler refuses to resolve any global.
|
| 255 |
"""
|
| 256 |
problems = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
for name, (source, symbol) in sorted(DATA_SOURCES.items()):
|
| 258 |
local = vendored / name
|
| 259 |
if not local.is_file():
|
|
@@ -403,7 +425,7 @@ def content_drift(vendored: Path, repo: Path, commit: str, only: str | None, sho
|
|
| 403 |
return 2
|
| 404 |
data_problems = [] if only else data_drift(vendored, repo, commit)
|
| 405 |
if data_problems:
|
| 406 |
-
print(f"\n{len(data_problems)}
|
| 407 |
print("\n".join(data_problems))
|
| 408 |
return 2
|
| 409 |
if unreadable:
|
|
|
|
| 64 |
"cath_mapping.py": ("data/cath_label_mapping.pkl", "CATH_MAPPING"),
|
| 65 |
}
|
| 66 |
|
| 67 |
+
# Package data copied verbatim from the RFD4 repository. Not modules, so nothing stamps them with
|
| 68 |
+
# a provenance commit and the coverage guard below cannot see them -- which is exactly how this
|
| 69 |
+
# package shipped a vocabulary whose UNK row had no backbone atoms for several upstream commits
|
| 70 |
+
# after RFD4 gave it one. Keyed by path under `src/rfd4_proteina_prep/`.
|
| 71 |
+
VERBATIM_DATA = {
|
| 72 |
+
"resources/aa_rna_dna_glycan_ncaa.yaml": "src/rfproteina/resources/aa_rna_dna_glycan_ncaa.yaml",
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
# Divergences from the source that have been read and are staying, each with the reason. A clean
|
| 76 |
# run reports these as held, not as drift.
|
| 77 |
#
|
|
|
|
| 262 |
blob is a dict of dicts of str -> int and the unpickler refuses to resolve any global.
|
| 263 |
"""
|
| 264 |
problems = []
|
| 265 |
+
package = vendored.parent
|
| 266 |
+
for relative, source in sorted(VERBATIM_DATA.items()):
|
| 267 |
+
local = package / relative
|
| 268 |
+
if not local.is_file():
|
| 269 |
+
problems.append(f" {relative:<40} missing from this package")
|
| 270 |
+
continue
|
| 271 |
+
blob = subprocess.run(
|
| 272 |
+
["git", "-C", str(repo), "show", f"{commit}:{source}"], capture_output=True
|
| 273 |
+
)
|
| 274 |
+
if blob.returncode != 0:
|
| 275 |
+
problems.append(f" {relative:<40} {source} is unreadable at {commit[:12]}")
|
| 276 |
+
elif blob.stdout != local.read_bytes():
|
| 277 |
+
problems.append(f" {relative:<40} differs from {source}")
|
| 278 |
+
|
| 279 |
for name, (source, symbol) in sorted(DATA_SOURCES.items()):
|
| 280 |
local = vendored / name
|
| 281 |
if not local.is_file():
|
|
|
|
| 425 |
return 2
|
| 426 |
data_problems = [] if only else data_drift(vendored, repo, commit)
|
| 427 |
if data_problems:
|
| 428 |
+
print(f"\n{len(data_problems)} data file(s) do not match their source:")
|
| 429 |
print("\n".join(data_problems))
|
| 430 |
return 2
|
| 431 |
if unreadable:
|