artios 0.1.0__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.
- artios/__init__.py +0 -0
- artios/assets.py +179 -0
- artios/cli.py +535 -0
- artios/common/__init__.py +0 -0
- artios/common/atom_types.py +349 -0
- artios/common/ccd_sets.py +187 -0
- artios/common/chain_type.py +42 -0
- artios/common/constants.py +960 -0
- artios/common/elements.py +163 -0
- artios/common/residue_names.py +222 -0
- artios/common/residue_stats.py +451 -0
- artios/config/__init__.py +14 -0
- artios/config/config.py +299 -0
- artios/config/extend_types.py +55 -0
- artios/configs/__init__.py +0 -0
- artios/configs/configs_base.py +322 -0
- artios/configs/configs_data.py +262 -0
- artios/configs/configs_inference.py +23 -0
- artios/contacts/__init__.py +33 -0
- artios/contacts/aromatic.py +399 -0
- artios/contacts/geometry.py +338 -0
- artios/contacts/hydrogen_bonds.py +512 -0
- artios/contacts/valence.py +417 -0
- artios/data/__init__.py +0 -0
- artios/data/array_builder.py +746 -0
- artios/data/chem/__init__.py +0 -0
- artios/data/chem/ccd.py +513 -0
- artios/data/chem/perms.py +257 -0
- artios/data/chem/rdkit.py +451 -0
- artios/data/collate/__init__.py +0 -0
- artios/data/collate/collate.py +107 -0
- artios/data/collate/padding.py +75 -0
- artios/data/data_pipeline.py +210 -0
- artios/data/data_weights.py +526 -0
- artios/data/dataloader.py +520 -0
- artios/data/dataset.py +901 -0
- artios/data/engineering/__init__.py +12 -0
- artios/data/engineering/metrics/__init__.py +0 -0
- artios/data/engineering/metrics/structural.py +188 -0
- artios/data/engineering/pipeline/__init__.py +0 -0
- artios/data/engineering/pipeline/thresholds.py +97 -0
- artios/data/features/__init__.py +7 -0
- artios/data/features/context.py +868 -0
- artios/data/features/featurizer.py +823 -0
- artios/data/filter.py +763 -0
- artios/data/fragment.py +633 -0
- artios/data/infer_data_pipeline.py +228 -0
- artios/data/motif_maker.py +731 -0
- artios/data/msa/__init__.py +6 -0
- artios/data/msa/a3m.py +104 -0
- artios/data/msa/sampler.py +348 -0
- artios/data/parsing/__init__.py +0 -0
- artios/data/parsing/_biotite_compat.py +80 -0
- artios/data/parsing/bioassembly.py +562 -0
- artios/data/parsing/indexing.py +452 -0
- artios/data/parsing/json.py +414 -0
- artios/data/parsing/mmcif.py +482 -0
- artios/data/parsing/motif.py +164 -0
- artios/data/parsing/residue_repair.py +565 -0
- artios/data/pocket/__init__.py +15 -0
- artios/data/pocket/detect.py +322 -0
- artios/data/pocket/legacy.py +612 -0
- artios/data/pocket/pocket_rf.joblib +0 -0
- artios/data/pocket/sphere_rf.joblib +0 -0
- artios/data/pocket/tessellation.py +107 -0
- artios/data/structure/__init__.py +9 -0
- artios/data/structure/annotation.py +1220 -0
- artios/data/structure/cropping.py +620 -0
- artios/data/structure/id_transforms.py +159 -0
- artios/data/structure/structure.py +818 -0
- artios/data/structure/tokenization.py +192 -0
- artios/data/structure/tokenizer.py +99 -0
- artios/data/tokenizer.py +11 -0
- artios/data/utils.py +510 -0
- artios/electrostatics/__init__.py +31 -0
- artios/electrostatics/apbs.py +222 -0
- artios/electrostatics/core.py +242 -0
- artios/electrostatics/pqr.py +191 -0
- artios/electrostatics/surface.py +133 -0
- artios/metrics/__init__.py +0 -0
- artios/metrics/lddt_metrics.py +161 -0
- artios/metrics/rmsd.py +306 -0
- artios/model/__init__.py +0 -0
- artios/model/artios_backbone.py +373 -0
- artios/model/artios_potts.py +655 -0
- artios/model/generator.py +1006 -0
- artios/model/loss.py +455 -0
- artios/model/modules/__init__.py +0 -0
- artios/model/modules/components.py +235 -0
- artios/model/modules/diffusion_backbone.py +932 -0
- artios/model/modules/embedders.py +198 -0
- artios/model/modules/layout.py +266 -0
- artios/model/modules/message_passing.py +91 -0
- artios/model/modules/mpnn.py +349 -0
- artios/model/modules/mpnn_features.py +450 -0
- artios/model/modules/mpnn_layers.py +302 -0
- artios/model/modules/penalty.py +468 -0
- artios/model/modules/potts.py +589 -0
- artios/model/modules/primitives.py +397 -0
- artios/model/modules/transformer.py +576 -0
- artios/model/output.py +85 -0
- artios/model/utils.py +266 -0
- artios/potts/__init__.py +27 -0
- artios/potts/designer.py +340 -0
- artios/potts/structure.py +526 -0
- artios/runner/__init__.py +0 -0
- artios/runner/ema.py +88 -0
- artios/runner/inference.py +327 -0
- artios/runner/train_backbone.py +761 -0
- artios/runner/train_potts.py +633 -0
- artios/utils/__init__.py +0 -0
- artios/utils/casting.py +28 -0
- artios/utils/distributed.py +72 -0
- artios/utils/dssp.py +221 -0
- artios/utils/file_io.py +174 -0
- artios/utils/geometry.py +226 -0
- artios/utils/inference.py +8 -0
- artios/utils/logger.py +84 -0
- artios/utils/lr_scheduler.py +169 -0
- artios/utils/metrics.py +102 -0
- artios/utils/monitoring.py +106 -0
- artios/utils/muon.py +291 -0
- artios/utils/profiler.py +29 -0
- artios/utils/scatter_utils.py +154 -0
- artios/utils/seed.py +34 -0
- artios/utils/structure_io.py +450 -0
- artios/utils/tensor_utils.py +152 -0
- artios/utils/training.py +224 -0
- artios/utils/typing.py +51 -0
- artios-0.1.0.dist-info/METADATA +254 -0
- artios-0.1.0.dist-info/RECORD +136 -0
- artios-0.1.0.dist-info/WHEEL +5 -0
- artios-0.1.0.dist-info/entry_points.txt +2 -0
- artios-0.1.0.dist-info/licenses/LICENSE +208 -0
- artios-0.1.0.dist-info/licenses/NOTICE +117 -0
- artios-0.1.0.dist-info/top_level.txt +1 -0
artios/__init__.py
ADDED
|
File without changes
|
artios/assets.py
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"""Pinned release assets hosted on the Hugging Face Hub.
|
|
2
|
+
|
|
3
|
+
Model weights and the Chemical Component Dictionary (CCD) are downloaded from
|
|
4
|
+
immutable Hub revisions and checked against their SHA-256 checksums. Downloads
|
|
5
|
+
are cached by ``huggingface_hub``, so later runs reuse them without network
|
|
6
|
+
access.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import functools
|
|
10
|
+
import hashlib
|
|
11
|
+
import logging
|
|
12
|
+
import os
|
|
13
|
+
from dataclasses import dataclass
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
REPO_ROOT = Path(__file__).resolve().parent.parent
|
|
19
|
+
|
|
20
|
+
# Directory containing components.cif and components.cif.rdkit_mol.pkl.
|
|
21
|
+
CCD_DIR_ENV_VAR = "ARTIOS_CCD_DIR"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True)
|
|
25
|
+
class HubFile:
|
|
26
|
+
"""A file pinned to an immutable Hugging Face Hub revision."""
|
|
27
|
+
|
|
28
|
+
repo_id: str
|
|
29
|
+
filename: str
|
|
30
|
+
revision: str
|
|
31
|
+
sha256: str
|
|
32
|
+
size: int
|
|
33
|
+
repo_type: str = "model"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
POTTS_CHECKPOINT = HubFile(
|
|
37
|
+
repo_id="Ligo-Biosciences/ArtiosPotts",
|
|
38
|
+
filename="38400_ema_0.9999.pt",
|
|
39
|
+
revision="c98b78ebcd7691adb915138fed18adea45825439",
|
|
40
|
+
sha256="9c198c105e1d05c7e41d21ec6a898b6833ef5538570ac7afaa78e4e6259a7026",
|
|
41
|
+
size=10_435_129,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
BACKBONE_CHECKPOINT = HubFile(
|
|
45
|
+
repo_id="Ligo-Biosciences/ArtiosBackbone",
|
|
46
|
+
filename="280000_ema_0.9999.pt",
|
|
47
|
+
revision="3b8939e37aff1544cb74937bad3516673c9914ad",
|
|
48
|
+
sha256="0016f6cffa0a52406f2630d1a82ce1d2ca838f91d3ed923e261c1ce0d4b130fb",
|
|
49
|
+
size=546_762_475,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
CCD_COMPONENTS = HubFile(
|
|
53
|
+
repo_id="Ligo-Biosciences/Artios-CCD",
|
|
54
|
+
filename="components.cif",
|
|
55
|
+
revision="df1722f8aad777a3a4ec2474bb47fa97bee83f84",
|
|
56
|
+
sha256="fe7c0bf2ca0a51531805f5a5ca7094281ed4d9e9f93b9275d9e6feebe2510892",
|
|
57
|
+
size=427_767_291,
|
|
58
|
+
repo_type="dataset",
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
CCD_RDKIT_MOLS = HubFile(
|
|
62
|
+
repo_id="Ligo-Biosciences/Artios-CCD",
|
|
63
|
+
filename="components.cif.rdkit_mol.pkl",
|
|
64
|
+
revision="df1722f8aad777a3a4ec2474bb47fa97bee83f84",
|
|
65
|
+
sha256="2d6caced2d26c62015115a1d0a50f4106755a300e0c2a2d2b5c101c9038dcbcd",
|
|
66
|
+
size=125_903_802,
|
|
67
|
+
repo_type="dataset",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def sha256sum(path: Path) -> str:
|
|
72
|
+
digest = hashlib.sha256()
|
|
73
|
+
with open(path, "rb") as f:
|
|
74
|
+
for chunk in iter(lambda: f.read(1 << 20), b""):
|
|
75
|
+
digest.update(chunk)
|
|
76
|
+
return digest.hexdigest()
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def download(asset: HubFile) -> Path:
|
|
80
|
+
"""Return a local path to ``asset``, downloading it if it is not cached.
|
|
81
|
+
|
|
82
|
+
Raises:
|
|
83
|
+
RuntimeError: If the repository cannot be accessed, the file is not
|
|
84
|
+
cached while offline, or the checksum does not match.
|
|
85
|
+
"""
|
|
86
|
+
from huggingface_hub import hf_hub_download
|
|
87
|
+
from huggingface_hub.errors import LocalEntryNotFoundError, RepositoryNotFoundError
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
path = Path(
|
|
91
|
+
hf_hub_download(
|
|
92
|
+
repo_id=asset.repo_id,
|
|
93
|
+
filename=asset.filename,
|
|
94
|
+
revision=asset.revision,
|
|
95
|
+
repo_type=asset.repo_type,
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
except RepositoryNotFoundError as e:
|
|
99
|
+
raise RuntimeError(
|
|
100
|
+
f"Could not access {asset.repo_id} on the Hugging Face Hub. If the "
|
|
101
|
+
"repository is private, log in with `hf auth login` or set HF_TOKEN "
|
|
102
|
+
"to a token with read access."
|
|
103
|
+
) from e
|
|
104
|
+
except LocalEntryNotFoundError as e:
|
|
105
|
+
raise RuntimeError(
|
|
106
|
+
f"{asset.filename} from {asset.repo_id} is not in the local cache and "
|
|
107
|
+
"the Hugging Face Hub could not be reached."
|
|
108
|
+
) from e
|
|
109
|
+
|
|
110
|
+
actual = sha256sum(path)
|
|
111
|
+
if actual != asset.sha256:
|
|
112
|
+
raise RuntimeError(
|
|
113
|
+
f"Checksum mismatch for {path}: expected {asset.sha256}, got {actual}. "
|
|
114
|
+
"Delete the file and download it again."
|
|
115
|
+
)
|
|
116
|
+
return path
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@dataclass(frozen=True)
|
|
120
|
+
class CCDFiles:
|
|
121
|
+
components: Path
|
|
122
|
+
rdkit_mols: Path
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@functools.cache
|
|
126
|
+
def resolve_ccd_files() -> CCDFiles:
|
|
127
|
+
"""Locate the CCD components file and its matching RDKit molecule cache.
|
|
128
|
+
|
|
129
|
+
Locations are checked in order, and both files always come from the same one:
|
|
130
|
+
|
|
131
|
+
1. The directory named by the ``ARTIOS_CCD_DIR`` environment variable.
|
|
132
|
+
2. ``ccd_files/`` at the repository root (source checkouts).
|
|
133
|
+
3. The pinned Artios-CCD release on the Hugging Face Hub.
|
|
134
|
+
"""
|
|
135
|
+
env_dir = os.environ.get(CCD_DIR_ENV_VAR)
|
|
136
|
+
if env_dir:
|
|
137
|
+
files = _local_ccd_files(Path(env_dir))
|
|
138
|
+
if files is None:
|
|
139
|
+
raise FileNotFoundError(
|
|
140
|
+
f"{CCD_DIR_ENV_VAR}={env_dir} does not contain "
|
|
141
|
+
f"{CCD_COMPONENTS.filename} and {CCD_RDKIT_MOLS.filename}."
|
|
142
|
+
)
|
|
143
|
+
return files
|
|
144
|
+
|
|
145
|
+
files = _local_ccd_files(REPO_ROOT / "ccd_files")
|
|
146
|
+
if files is not None:
|
|
147
|
+
return files
|
|
148
|
+
|
|
149
|
+
logger.info(
|
|
150
|
+
f"Using CCD files from {CCD_COMPONENTS.repo_id}@{CCD_COMPONENTS.revision[:8]}"
|
|
151
|
+
)
|
|
152
|
+
return CCDFiles(
|
|
153
|
+
components=download(CCD_COMPONENTS), rdkit_mols=download(CCD_RDKIT_MOLS)
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def _local_ccd_files(directory: Path) -> CCDFiles | None:
|
|
158
|
+
files = CCDFiles(
|
|
159
|
+
components=directory / CCD_COMPONENTS.filename,
|
|
160
|
+
rdkit_mols=directory / CCD_RDKIT_MOLS.filename,
|
|
161
|
+
)
|
|
162
|
+
present = [files.components.exists(), files.rdkit_mols.exists()]
|
|
163
|
+
if not any(present):
|
|
164
|
+
return None
|
|
165
|
+
if not all(present):
|
|
166
|
+
raise FileNotFoundError(
|
|
167
|
+
f"{directory} must contain both {CCD_COMPONENTS.filename} and "
|
|
168
|
+
f"{CCD_RDKIT_MOLS.filename} from the same CCD snapshot."
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
sizes = (files.components.stat().st_size, files.rdkit_mols.stat().st_size)
|
|
172
|
+
if sizes != (CCD_COMPONENTS.size, CCD_RDKIT_MOLS.size):
|
|
173
|
+
logger.warning(
|
|
174
|
+
f"CCD files in {directory} differ from the pinned "
|
|
175
|
+
f"{CCD_COMPONENTS.repo_id} release; ligand featurization may not match "
|
|
176
|
+
"published results."
|
|
177
|
+
)
|
|
178
|
+
logger.info(f"Using CCD files from {directory}")
|
|
179
|
+
return files
|