alphafold3-input 0.3.0__tar.gz

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.
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.3
2
+ Name: alphafold3-input
3
+ Version: 0.3.0
4
+ Summary: AlphaFold 3 input schema models.
5
+ Keywords: alphafold3,pydantic,bioinformatics,job-definition,input-generation,json,json-schema
6
+ Author: Igor Koop
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Classifier: Typing :: Typed
15
+ Requires-Dist: pydantic>=2.13.4
16
+ Requires-Dist: rdkit>=2026.3.3
17
+ Requires-Python: >=3.12
18
+ Project-URL: Documentation, https://github.com/igor-koop/alphafold3_input#readme
19
+ Project-URL: Issues, https://github.com/igor-koop/alphafold3_input/issues
20
+ Project-URL: Repository, https://github.com/igor-koop/alphafold3_input
21
+ Description-Content-Type: text/markdown
22
+
23
+ # alphafold3_input
24
+
25
+ [![Docs](https://img.shields.io/badge/docs-GitHub%20Pages-blue)](https://igor-koop.github.io/alphafold3_input/)
26
+ [![License](https://img.shields.io/github/license/igor-koop/alphafold3_input)](https://github.com/igor-koop/alphafold3_input/blob/main/LICENSE)
27
+ [![Coverage](https://codecov.io/gh/igor-koop/alphafold3_input/graph/badge.svg?token=9906JN8BN0)](https://codecov.io/gh/igor-koop/alphafold3_input)
28
+ [![Lint](https://img.shields.io/badge/linting-ruff-d7ff64)](https://docs.astral.sh/ruff/)
29
+ [![Type](https://img.shields.io/badge/typing-ty-7c3aed)](https://docs.astral.sh/ty/)
30
+ [![Actions](https://github.com/igor-koop/alphafold3_input/actions/workflows/actions.yml/badge.svg)](https://github.com/igor-koop/alphafold3_input/actions/workflows/actions.yml)
31
+
32
+
33
+ Pythonic, object-oriented models for constructing **AlphaFold 3** input files.
34
+
35
+ This package provides typed models and utilities that abstract the AlphaFold 3 JSON input format into a clean, validated Python interface.
36
+
37
+ For details on the underlying specification, see the official [AlphaFold 3 input specification](https://github.com/google-deepmind/alphafold3/blob/main/docs/input.md).
38
+
39
+ ---
40
+
41
+ ## Installation
42
+
43
+ Install the latest published release from PyPI:
44
+
45
+ ```bash
46
+ uv add alphafold3_input
47
+ ```
48
+
49
+ or:
50
+
51
+ ```bash
52
+ pip install alphafold3_input
53
+ ```
54
+
55
+ Install the current development version directly from GitHub:
56
+
57
+ ```bash
58
+ uv add git+https://github.com/igor-koop/alphafold3_input
59
+ ```
60
+
61
+ or:
62
+
63
+ ```bash
64
+ pip install "git+https://github.com/igor-koop/alphafold3_input"
65
+ ```
66
+
67
+ ## Documentation
68
+
69
+ Full API documentation is available at: https://igor-koop.github.io/alphafold3_input/
70
+
71
+ ## Development
72
+
73
+ ```bash
74
+ git clone https://github.com/igor-koop/alphafold3_input
75
+ cd alphafold3_input
76
+
77
+ uv sync --dev
78
+ ```
79
+
80
+ ## License
81
+
82
+ The scripts and documentation in this project are released under the [MIT License](https://github.com/igor-koop/alphafold3_input/blob/main/LICENSE).
@@ -0,0 +1,60 @@
1
+ # alphafold3_input
2
+
3
+ [![Docs](https://img.shields.io/badge/docs-GitHub%20Pages-blue)](https://igor-koop.github.io/alphafold3_input/)
4
+ [![License](https://img.shields.io/github/license/igor-koop/alphafold3_input)](https://github.com/igor-koop/alphafold3_input/blob/main/LICENSE)
5
+ [![Coverage](https://codecov.io/gh/igor-koop/alphafold3_input/graph/badge.svg?token=9906JN8BN0)](https://codecov.io/gh/igor-koop/alphafold3_input)
6
+ [![Lint](https://img.shields.io/badge/linting-ruff-d7ff64)](https://docs.astral.sh/ruff/)
7
+ [![Type](https://img.shields.io/badge/typing-ty-7c3aed)](https://docs.astral.sh/ty/)
8
+ [![Actions](https://github.com/igor-koop/alphafold3_input/actions/workflows/actions.yml/badge.svg)](https://github.com/igor-koop/alphafold3_input/actions/workflows/actions.yml)
9
+
10
+
11
+ Pythonic, object-oriented models for constructing **AlphaFold 3** input files.
12
+
13
+ This package provides typed models and utilities that abstract the AlphaFold 3 JSON input format into a clean, validated Python interface.
14
+
15
+ For details on the underlying specification, see the official [AlphaFold 3 input specification](https://github.com/google-deepmind/alphafold3/blob/main/docs/input.md).
16
+
17
+ ---
18
+
19
+ ## Installation
20
+
21
+ Install the latest published release from PyPI:
22
+
23
+ ```bash
24
+ uv add alphafold3_input
25
+ ```
26
+
27
+ or:
28
+
29
+ ```bash
30
+ pip install alphafold3_input
31
+ ```
32
+
33
+ Install the current development version directly from GitHub:
34
+
35
+ ```bash
36
+ uv add git+https://github.com/igor-koop/alphafold3_input
37
+ ```
38
+
39
+ or:
40
+
41
+ ```bash
42
+ pip install "git+https://github.com/igor-koop/alphafold3_input"
43
+ ```
44
+
45
+ ## Documentation
46
+
47
+ Full API documentation is available at: https://igor-koop.github.io/alphafold3_input/
48
+
49
+ ## Development
50
+
51
+ ```bash
52
+ git clone https://github.com/igor-koop/alphafold3_input
53
+ cd alphafold3_input
54
+
55
+ uv sync --dev
56
+ ```
57
+
58
+ ## License
59
+
60
+ The scripts and documentation in this project are released under the [MIT License](https://github.com/igor-koop/alphafold3_input/blob/main/LICENSE).
@@ -0,0 +1,93 @@
1
+ [project]
2
+ name = "alphafold3_input"
3
+ version = "0.3.0"
4
+ description = "AlphaFold 3 input schema models."
5
+ authors = [
6
+ { name = "Igor Koop" },
7
+ ]
8
+ readme = "README.md"
9
+ requires-python = ">=3.12"
10
+ dependencies = [
11
+ "pydantic>=2.13.4",
12
+ "rdkit>=2026.3.3",
13
+ ]
14
+ keywords = [
15
+ "alphafold3",
16
+ "pydantic",
17
+ "bioinformatics",
18
+ "job-definition",
19
+ "input-generation",
20
+ "json",
21
+ "json-schema",
22
+ ]
23
+ classifiers = [
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3 :: Only",
26
+ "Programming Language :: Python :: 3.12",
27
+ "License :: OSI Approved :: MIT License",
28
+ "Intended Audience :: Science/Research",
29
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
30
+ "Topic :: Software Development :: Libraries :: Python Modules",
31
+ "Typing :: Typed",
32
+ ]
33
+
34
+ [project.urls]
35
+ Repository = "https://github.com/igor-koop/alphafold3_input"
36
+ Issues = "https://github.com/igor-koop/alphafold3_input/issues"
37
+ Documentation = "https://github.com/igor-koop/alphafold3_input#readme"
38
+
39
+ [build-system]
40
+ requires = ["uv_build>=0.8.11,<0.9.0"]
41
+ build-backend = "uv_build"
42
+
43
+ [tool.uv.build-backend]
44
+ module-root = "src"
45
+ module-name = "alphafold3_input"
46
+
47
+ [dependency-groups]
48
+ dev = [
49
+ "furo>=2025.12.19",
50
+ "pytest>=9.0.2",
51
+ "pytest-cov>=7.0.0",
52
+ "ruff>=0.15.16",
53
+ "sphinx>=9.1.0",
54
+ "sphinx-autobuild>=2025.8.25",
55
+ "ty>=0.0.44",
56
+ ]
57
+
58
+ [tool.ruff]
59
+ line-length = 80
60
+ target-version = "py312"
61
+ src = ["src", "tests"]
62
+
63
+ [tool.ruff.lint]
64
+ select = ["ALL"]
65
+ fixable = ["ALL"]
66
+ ignore = ["COM812"]
67
+
68
+ [tool.ruff.lint.pydocstyle]
69
+ convention = "pep257"
70
+
71
+
72
+ [tool.ruff.lint.per-file-ignores]
73
+ "tests/**/*.py" = ["D100", "PLR2004", "S101"]
74
+ "docs/**/*.py" = ["A001", "B010", "FBT001", "FBT002", "INP001", "PLR0913"]
75
+ "src/**/*.py" = ["ANN401", "TC001", "TC002", "TC003"]
76
+
77
+ [tool.pytest.ini_options]
78
+ minversion = "9.0"
79
+ testpaths = ["tests"]
80
+ addopts = [
81
+ "--strict-config",
82
+ "--strict-markers",
83
+ "--cov=alphafold3_input",
84
+ "--cov-report=term-missing",
85
+ "--cov-fail-under=100",
86
+ ]
87
+
88
+ [tool.coverage.run]
89
+ source = ["alphafold3_input"]
90
+
91
+ [tool.coverage.report]
92
+ show_missing = true
93
+ skip_empty = true
@@ -0,0 +1,69 @@
1
+ """Package metadata for AlphaFold 3 input models.
2
+
3
+ Provides a normalized interface to distribution metadata for the package.
4
+
5
+ Exports:
6
+ - :data:`__title__`: Package title.
7
+ - :data:`__description__`: Package summary.
8
+ - :data:`__author__`: Package author.
9
+ - :data:`__version__`: Installed version.
10
+ - :data:`__package__`: Distribution name.
11
+ - :data:`__module_name__`: Import path.
12
+ - :data:`__repository__`: Repository URL.
13
+ - :data:`__documentation__`: Documentation URL.
14
+ - :data:`__issues__`: Issue tracker URL.
15
+ """
16
+
17
+ from importlib.metadata import PackageMetadata, metadata, version
18
+
19
+ __all__: list[str] = [
20
+ "__author__",
21
+ "__description__",
22
+ "__documentation__",
23
+ "__issues__",
24
+ "__module_name__",
25
+ "__package__",
26
+ "__repository__",
27
+ "__title__",
28
+ "__version__",
29
+ ]
30
+
31
+ __package__: str = "alphafold3_input"
32
+ """Distribution package name."""
33
+
34
+ __module_name__: str = "alphafold3_input"
35
+ """Importable top-level module name."""
36
+
37
+ __version__: str = version(__package__)
38
+ """Installed package version string."""
39
+
40
+ __metadata__: PackageMetadata = metadata(__package__)
41
+ """Raw distribution metadata."""
42
+
43
+ __title__: str = __metadata__["Name"]
44
+ """Distribution package name."""
45
+
46
+ __description__: str = __metadata__.get("Summary", "")
47
+ """Package summary."""
48
+
49
+ __author__: str = __metadata__.get("Author", "")
50
+ """Package author."""
51
+
52
+ __repository__: str = ""
53
+ """Repository URL."""
54
+
55
+ __documentation__: str = ""
56
+ """Documentation URL."""
57
+
58
+ __issues__: str = ""
59
+ """Issue tracker URL."""
60
+
61
+ for item in __metadata__.json.get("project_url", []):
62
+ label, url = item.split(", ", 1)
63
+ match label:
64
+ case "Repository":
65
+ __repository__ = url
66
+ case "Documentation":
67
+ __documentation__ = url
68
+ case "Issues":
69
+ __issues__ = url
@@ -0,0 +1,61 @@
1
+ """AlphaFold 3 input models.
2
+
3
+ This package provides models for constructing AlphaFold 3 input files.
4
+
5
+ It offers a Pythonic, object-oriented interface for defining AlphaFold 3
6
+ jobs, abstracting the underlying JSON input format into typed models and
7
+ validated structures. The implementation closely follows the official
8
+ AlphaFold 3 input specification provided by DeepMind.
9
+
10
+ For full details on the expected input format and supported features,
11
+ refer to the official `AlphaFold 3 input specification
12
+ <https://github.com/google-deepmind/alphafold3/blob/main/docs/input.md>`_.
13
+
14
+ Exports:
15
+ - :data:`JSON_SCHEMA_URL`: canonical JSON Schema URL for editor \
16
+ validation.
17
+ - :class:`Job`, :class:`Dialect`, :class:`Version`: top-level job model \
18
+ and input format enums.
19
+ - :class:`DNA`, :class:`RNA`, :class:`Protein`, :class:`Ligand`: \
20
+ entity models used under :attr:`Job.entities`.
21
+ - :class:`Modification`, :class:`Entity`: residue modification model and \
22
+ its entity-scope enum.
23
+ - :class:`Template`: structural template specification for proteins.
24
+ - :class:`Atom`, :class:`Bond`: covalent bond specification models.
25
+ - :class:`Operation`, :func:`trace`, :func:`reindex`, :func:`realign`: \
26
+ operation trace generation, reindexing, and realignment utilities.
27
+ - :func:`ccd`, :func:`component`: generation of custom chemical \
28
+ component dictionaries.
29
+ """
30
+
31
+ from .bond import Atom, Bond
32
+ from .dna import DNA
33
+ from .job import JSON_SCHEMA_URL, Dialect, Job, Version
34
+ from .ligand import Ligand
35
+ from .modification import Entity, Modification
36
+ from .protein import Protein
37
+ from .rna import RNA
38
+ from .template import Template
39
+ from .utils import Operation, ccd, component, realign, reindex, trace
40
+
41
+ __all__: list[str] = [
42
+ "DNA",
43
+ "JSON_SCHEMA_URL",
44
+ "RNA",
45
+ "Atom",
46
+ "Bond",
47
+ "Dialect",
48
+ "Entity",
49
+ "Job",
50
+ "Ligand",
51
+ "Modification",
52
+ "Operation",
53
+ "Protein",
54
+ "Template",
55
+ "Version",
56
+ "ccd",
57
+ "component",
58
+ "realign",
59
+ "reindex",
60
+ "trace",
61
+ ]
@@ -0,0 +1,222 @@
1
+ """Covalent bond models.
2
+
3
+ This submodule defines :class:`Atom` and :class:`Bond` for specifying
4
+ covalent bonds between entities in an AlphaFold 3 input.
5
+
6
+ Exports:
7
+ - :class:`Atom`: atom specification within an entity.
8
+ - :class:`Bond`: covalent bond between two atoms.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from collections.abc import Sequence
14
+ from typing import Any, Self
15
+
16
+ from pydantic import (
17
+ BaseModel,
18
+ ConfigDict,
19
+ Field,
20
+ model_serializer,
21
+ model_validator,
22
+ )
23
+
24
+ __all__: list[str] = [
25
+ "Atom",
26
+ "Bond",
27
+ ]
28
+
29
+
30
+ class Atom(BaseModel):
31
+ """Atom specification within an entity.
32
+
33
+ An atom is defined by an :attr:`entity` identifier, a 1-based
34
+ :attr:`residue` index, and an atom :attr:`name`.
35
+
36
+ Attributes:
37
+ entity (str): Entity identifier.
38
+ residue (int): Residue index within the entity.
39
+ name (str): Atom name within the residue.
40
+
41
+ Examples:
42
+ Atom definition.
43
+
44
+ >>> Atom(entity="A", residue=1, name="CB")
45
+ """
46
+
47
+ model_config = ConfigDict(
48
+ extra="forbid",
49
+ frozen=True,
50
+ validate_assignment=False,
51
+ validate_by_name=True,
52
+ validate_by_alias=True,
53
+ )
54
+
55
+ entity: str = Field(
56
+ title="entity",
57
+ alias="entity",
58
+ description="Entity identifier.",
59
+ pattern="^[A-Z]+$",
60
+ validation_alias="entity",
61
+ serialization_alias="entity",
62
+ )
63
+ """Entity identifier."""
64
+
65
+ residue: int = Field(
66
+ title="residue",
67
+ alias="residue",
68
+ description="Residue index within the entity.",
69
+ ge=1,
70
+ validation_alias="residue",
71
+ serialization_alias="residue",
72
+ )
73
+ """Residue index within the entity."""
74
+
75
+ name: str = Field(
76
+ title="name",
77
+ alias="name",
78
+ description="Atom name within the residue.",
79
+ min_length=1,
80
+ validation_alias="name",
81
+ serialization_alias="name",
82
+ )
83
+ """Atom name within the residue."""
84
+
85
+ @model_validator(mode="before")
86
+ @classmethod
87
+ def __validate_model(cls: type[Self], data: Any) -> Any:
88
+ """Coerce compact atom definitions to a mapping.
89
+
90
+ Accepts the AlphaFold 3 list form ``[entity, residue, name]`` and
91
+ converts it to a mapping compatible with field validation.
92
+
93
+ Args:
94
+ data (Any): Raw input data.
95
+
96
+ Returns:
97
+ Any: A mapping with keys ``entity``, ``residue``, and ``name`` if
98
+ ``data`` is a sequence, otherwise the original input.
99
+
100
+ Raises:
101
+ ValueError: If ``data`` is a sequence but does not contain exactly
102
+ three items.
103
+ """
104
+ if not isinstance(data, Sequence) or isinstance(
105
+ data,
106
+ (str, bytes, bytearray),
107
+ ):
108
+ return data
109
+
110
+ if len(data) != len(cls.model_fields):
111
+ msg: str = (
112
+ "Invalid atom definition: expected `[entity, residue, name]`."
113
+ )
114
+ raise ValueError(msg)
115
+ return {"entity": data[0], "residue": data[1], "name": data[2]}
116
+
117
+ @model_serializer(mode="plain")
118
+ def __serialize_model(self: Self) -> tuple[str, int, str]:
119
+ """Serialize the atom as ``[entity, residue, name]``.
120
+
121
+ Returns:
122
+ tuple[str, int, str]: Compact AlphaFold 3 atom representation.
123
+ """
124
+ return (self.entity, self.residue, self.name)
125
+
126
+
127
+ class Bond(BaseModel):
128
+ """Covalent bond specification.
129
+
130
+ Defines a covalent bond between the :attr:`source` and the :attr:`target`
131
+ atoms as an AlphaFold 3 bonded atom pair.
132
+
133
+ Bonds are intended for covalently linked multi-residue :class:`Ligand`
134
+ entities, for example glycans. Covalent bonds within or between polymer
135
+ entities such as :class:`DNA`, :class:`RNA`, or :class:`Protein` are not
136
+ supported by AlphaFold 3.
137
+
138
+ Attributes:
139
+ source (Atom): Source atom address.
140
+ target (Atom): Target atom address.
141
+
142
+ Examples:
143
+ Covalent bond between two entities.
144
+
145
+ >>> Bond(
146
+ ... source=Atom(entity="A", residue=1, name="CA"),
147
+ ... target=Atom(entity="G", residue=1, name="CHA"),
148
+ ... )
149
+
150
+ Covalent bond within a multi-residue entity.
151
+
152
+ >>> Bond(
153
+ ... source=Atom(entity="I", residue=1, name="O6"),
154
+ ... target=Atom(entity="I", residue=2, name="C1"),
155
+ ... )
156
+ """
157
+
158
+ model_config = ConfigDict(
159
+ extra="forbid",
160
+ frozen=False,
161
+ validate_assignment=True,
162
+ validate_by_name=True,
163
+ validate_by_alias=True,
164
+ )
165
+
166
+ source: Atom = Field(
167
+ title="source",
168
+ alias="source",
169
+ description="Source atom address.",
170
+ validation_alias="source",
171
+ serialization_alias="source",
172
+ )
173
+ """Source atom address."""
174
+
175
+ target: Atom = Field(
176
+ title="target",
177
+ alias="target",
178
+ description="Target atom address.",
179
+ validation_alias="target",
180
+ serialization_alias="target",
181
+ )
182
+ """Target atom address."""
183
+
184
+ @model_validator(mode="before")
185
+ @classmethod
186
+ def __validate_model(cls: type[Self], data: Any) -> Any:
187
+ """Coerce compact bond definitions to a mapping.
188
+
189
+ Accepts the AlphaFold 3 list form ``[[...], [...]]`` and converts it
190
+ to a mapping compatible with field validation.
191
+
192
+ Args:
193
+ data (Any): Raw input data.
194
+
195
+ Returns:
196
+ Any: A mapping with keys ``source`` and ``target`` if ``data`` is
197
+ a sequence, otherwise the original input.
198
+
199
+ Raises:
200
+ ValueError: If ``data`` is a sequence but does not contain exactly
201
+ two items.
202
+ """
203
+ if not isinstance(data, Sequence) or isinstance(
204
+ data,
205
+ (str, bytes, bytearray),
206
+ ):
207
+ return data
208
+
209
+ if len(data) != len(cls.model_fields):
210
+ msg: str = "Invalid bond definition: expected `[source, target]`."
211
+ raise ValueError(msg)
212
+ return {"source": data[0], "target": data[1]}
213
+
214
+ @model_serializer(mode="plain")
215
+ def __serialize_model(self: Self) -> tuple[Atom, Atom]:
216
+ """Serialize the bond as an AlphaFold 3 bonded atom pair.
217
+
218
+ Returns:
219
+ tuple[Atom, Atom]: Compact AlphaFold 3 bonded atom pair
220
+ representation.
221
+ """
222
+ return (self.source, self.target)