Skip to content

Commit 235058d

Browse files
committed
refactor: sync CLI and file I/O cleanup
1 parent 9d92e1e commit 235058d

12 files changed

Lines changed: 16 additions & 52 deletions

File tree

‎.github/workflows/release_and_docs.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ jobs:
6666
core/bin/python -c "import importlib.util; assert importlib.util.find_spec('torch') is None"
6767
core/bin/python smoke.py
6868
if core/bin/aw --help >cli.log 2>&1; then exit 1; fi
69-
grep -F "pip install 'atomworks[scripts]'" cli.log
70-
core/bin/python -m pip install "$GITHUB_WORKSPACE/dist/$(basename "$GITHUB_WORKSPACE"/dist/*.whl)[scripts]"
69+
grep -F "pip install 'atomworks[cli]'" cli.log
70+
core/bin/python -m pip install "$GITHUB_WORKSPACE/dist/$(basename "$GITHUB_WORKSPACE"/dist/*.whl)[cli]"
7171
core/bin/aw --help
7272
core/bin/aw msa --help
7373
if core/bin/aw msa >msa.log 2>&1; then exit 1; fi

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Compatibility
1111

1212
- Require Python 3.12 or newer, NumPy 2.1 or newer, and Biotite 2.0.0.
13-
- Move command-line dependencies to the `scripts` extra; install `atomworks[scripts]` to use `aw`.
13+
- Move command-line dependencies to the `cli` extra; install `atomworks[cli]` to use `aw`.
1414
- Remove the retired RF2AA pipeline and feature adapters.
1515
- `atom_array_from_file` now uses minimal parsing, including first-conformer selection and normalized identifiers. `to_cif_file` is an alias with the `atom_array_to_file` signature; `to_cif_buffer` and `to_cif_string` are removed.
1616

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ AtomWorks requires Python 3.12 or newer. Pip installs its dependencies automatic
8181
```shell
8282
pip install atomworks # base installation version without torch (for only atomworks.io)
8383
pip install "atomworks[ml]" # with torch and ML dependencies (for atomworks.io plus atomworks.ml)
84-
pip install "atomworks[scripts]" # command-line tools
84+
pip install "atomworks[cli]" # command-line tools
8585
pip install "atomworks[dev]" # with development dependencies
8686
pip install "atomworks[openbabel]" # with [Open Babel](https://openbabel.org/) and its dependencies
8787
pip install "atomworks[ml,openbabel,dev]" # ML, Open Babel, and development tools

‎docs/installation.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Requires Python 3.12 or newer. Choose the installation that fits your workflow:
77
88
pip install atomworks # IO library
99
pip install "atomworks[ml]" # IO + ML library
10-
pip install "atomworks[ml,scripts]" # IO + ML + command-line tools
10+
pip install "atomworks[ml,cli]" # IO + ML + command-line tools
1111
1212
.. _optional-integrations:
1313

@@ -18,7 +18,7 @@ Requires Python 3.12 or newer. Choose the installation that fits your workflow:
1818
``posebusters`` (structure validation), or ``catcif`` (CIF archives).
1919
For example: ``pip install "atomworks[ml,s3]"``.
2020

21-
Use ``atomworks[scripts]`` for CLI tools without ML, ``atomworks[dev]`` for
21+
Use ``atomworks[cli]`` for CLI tools without ML, ``atomworks[dev]`` for
2222
ML, CLI, visualization, notebooks, and test/lint tools, or ``atomworks[docs]``
2323
to build the documentation. Specialized integrations remain opt-in.
2424

‎docs/migration/migration-long.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ The parser now caches complete results as Zstandard-compressed pickles in a `par
188188

189189
## I/O environment and validation
190190

191-
AtomWorks 3.1 requires Python ≥3.12 and NumPy ≥2.1, pins Biotite to 2.0.0, and checks the version at import time. Install the `scripts` extra for CLI tools and the `ml` extra for ML dependencies. The retired RF2AA pipeline and feature adapters have been removed. Optional S3 and catcif integrations have extras. Regenerate a locked environment instead of upgrading Biotite in isolation. [Dependency manifest](https://github.com/RosettaCommons/atomworks/blob/production/pyproject.toml).
191+
AtomWorks 3.1 requires Python ≥3.12 and NumPy ≥2.1, pins Biotite to 2.0.0, and checks the version at import time. Install the `cli` extra for CLI tools and the `ml` extra for ML dependencies. The retired RF2AA pipeline and feature adapters have been removed. Optional S3 and catcif integrations have extras. Regenerate a locked environment instead of upgrading Biotite in isolation. [Dependency manifest](https://github.com/RosettaCommons/atomworks/blob/production/pyproject.toml).
192192

193193
Lock both environments, migrate parser calls and configuration, then compare a fixed set of structures covering covalent modifications, alternate conformers and assemblies. Review atom identities, charges, bond orders and hydrogen counts before adopting the new parser or regenerating cached outputs.
194194

‎docs/migration/migration-short.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ Round trips are structural, not byte-for-byte identity: order/dtypes and some de
3636

3737
## 5. Refresh the environment and parser caches
3838

39-
Install into a fresh environment and regenerate your dependency lock: AtomWorks 3.1 requires Python ≥3.12, `biotite==2.0.0`, and NumPy ≥2.1. Install the `scripts` extra for CLI tools and the `ml` extra for ML dependencies. The retired RF2AA pipeline and feature adapters have been removed. Rebuild or separate parser caches when adopting the new chemistry and conformer policies. [Dependencies](https://github.com/RosettaCommons/atomworks/blob/production/pyproject.toml).
39+
Install into a fresh environment and regenerate your dependency lock: AtomWorks 3.1 requires Python ≥3.12, `biotite==2.0.0`, and NumPy ≥2.1. Install the `cli` extra for CLI tools and the `ml` extra for ML dependencies. The retired RF2AA pipeline and feature adapters have been removed. Rebuild or separate parser caches when adopting the new chemistry and conformer policies. [Dependencies](https://github.com/RosettaCommons/atomworks/blob/production/pyproject.toml).
4040

4141
Before switching, compare a small fixed set of structures under both environments: selected model/assembly, atom identities and counts, bonds, charges and implicit hydrogens. If these structures feed an existing model, check its predictions with the new parser output.

‎docs/mirrors.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Data Mirrors
33

44
AtomWorks uses local mirrors of the PDB and CCD databases for parsing structures and training models. This page explains how to set up these mirrors.
55

6-
Install ``atomworks[scripts]`` to use the commands below.
6+
Install ``atomworks[cli]`` to use the commands below.
77

88
Setting Up Mirrors
99
------------------

‎pyproject.toml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ml = [
5353
"pyarrow>=23.0.1",
5454
]
5555

56-
scripts = [
56+
cli = [
5757
"typer>=0.12.5",
5858
"python-dotenv>=1.2.2",
5959
"tqdm>=4.66.3", # CLI download progress
@@ -89,7 +89,7 @@ catcif = [
8989
]
9090

9191
dev = [
92-
"atomworks[ml,scripts]",
92+
"atomworks[ml,cli]",
9393
"py3Dmol>=2.2.1",
9494
"pymol-remote>=0.0.5",
9595
"ipykernel>=6.28.0",
@@ -105,7 +105,7 @@ dev = [
105105
]
106106

107107
docs = [
108-
"atomworks[ml,scripts]", # API and CLI documentation
108+
"atomworks[ml,cli]", # API and CLI documentation
109109
"py3Dmol>=2.2.1", # Visualization examples
110110
"pymol-remote>=0.0.5",
111111
"pygments>=2.20.0", # Security floor for Sphinx's dependency
@@ -122,7 +122,7 @@ docs = [
122122
# Reference optional dependencies for native uv compatability (in addition to the pip compatability)
123123
dev = ["atomworks[dev]"]
124124
ml = ["atomworks[ml]"]
125-
scripts = ["atomworks[scripts]"]
125+
cli = ["atomworks[cli]"]
126126
docs = ["atomworks[docs]"]
127127
openbabel = ["atomworks[openbabel]"]
128128
posebusters = ["atomworks[posebusters]"]

‎src/atomworks/io/transforms/categories.py‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,15 @@
99
import re
1010
from contextlib import suppress
1111
from datetime import datetime
12-
from typing import TYPE_CHECKING
1312

1413
import numpy as np
1514
from biotite.structure.io.pdbx import BinaryCIFBlock, BinaryCIFCategory, CIFBlock, CIFCategory
1615

1716
from atomworks.common import exists
1817

19-
if TYPE_CHECKING:
20-
import pandas as pd
21-
2218
logger = logging.getLogger("atomworks.io")
2319

2420

25-
def category_to_df(
26-
cif_block_or_category: CIFBlock | BinaryCIFBlock | CIFCategory | BinaryCIFCategory, category: str | None = None
27-
) -> pd.DataFrame | None:
28-
"""Convert CIF component to pandas DataFrame.
29-
30-
Accepts either ``(CIFBlock, category_name)`` or ``(CIFCategory)`` directly.
31-
Supports both text CIF and binary CIF (BinaryCIF) formats.
32-
33-
Args:
34-
cif_block_or_category: :py:class:`~biotite.structure.io.pdbx.CIFBlock`,
35-
:py:class:`~biotite.structure.io.pdbx.BinaryCIFBlock`, or
36-
:py:class:`~biotite.structure.io.pdbx.CIFCategory` | :py:class:`~biotite.structure.io.pdbx.BinaryCIFCategory`
37-
category: Category name when passing CIFBlock/BinaryCIFBlock, omit when passing CIFCategory
38-
39-
Returns:
40-
DataFrame containing the category data, or None if category doesn't exist (CIFBlock mode only)
41-
"""
42-
import pandas as pd
43-
44-
# Check for both CIFBlock and BinaryCIFBlock
45-
if isinstance(cif_block_or_category, CIFBlock | BinaryCIFBlock):
46-
# Extract category from CIFBlock or BinaryCIFBlock
47-
cif_block = cif_block_or_category
48-
if category in cif_block:
49-
return pd.DataFrame(category_to_dict(cif_block, category))
50-
return None
51-
else:
52-
# Convert CIFCategory directly
53-
category_obj = cif_block_or_category
54-
return pd.DataFrame(category_to_dict(category_obj))
55-
56-
5721
def category_to_dict(
5822
cif_block_or_category: CIFBlock | BinaryCIFBlock | CIFCategory | BinaryCIFCategory, category: str | None = None
5923
) -> dict[str, np.ndarray]:

‎src/atomworks/io/utils/io_utils.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ def atom_array_to_file(
13461346
buffer = io.BytesIO() if "bcif" in file_type else io.StringIO()
13471347
file_obj.write(buffer)
13481348
content = buffer.getvalue()
1349-
if "." in file_type:
1349+
if file_type.endswith((".gz", ".gzip", ".zst")):
13501350
content = content.encode() if isinstance(content, str) else content
13511351
content = zstd.compress(content) if file_type.endswith(".zst") else gzip.compress(content, mtime=0)
13521352
if dest is not None:

0 commit comments

Comments
 (0)