libqdx 0.8.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.
Files changed (106) hide show
  1. libqdx-0.8.0/.github/workflows/python.yml +102 -0
  2. libqdx-0.8.0/.github/workflows/rust.yml +28 -0
  3. libqdx-0.8.0/.gitignore +5 -0
  4. libqdx-0.8.0/AGENTS.md +86 -0
  5. libqdx-0.8.0/Cargo.lock +3805 -0
  6. libqdx-0.8.0/Cargo.toml +65 -0
  7. libqdx-0.8.0/PKG-INFO +5 -0
  8. libqdx-0.8.0/README.md +26 -0
  9. libqdx-0.8.0/flake.lock +160 -0
  10. libqdx-0.8.0/flake.nix +54 -0
  11. libqdx-0.8.0/libqdx.pyi +357 -0
  12. libqdx-0.8.0/py/Cargo.toml +17 -0
  13. libqdx-0.8.0/py/libqdx.pyi +357 -0
  14. libqdx-0.8.0/py/py.typed +0 -0
  15. libqdx-0.8.0/py/src/lib.rs +761 -0
  16. libqdx-0.8.0/py/uv.lock +74 -0
  17. libqdx-0.8.0/py.typed +0 -0
  18. libqdx-0.8.0/pyproject.toml +22 -0
  19. libqdx-0.8.0/rust-toolchain.toml +4 -0
  20. libqdx-0.8.0/src/amino_acid_template.rs +1590 -0
  21. libqdx-0.8.0/src/atom.rs +209 -0
  22. libqdx-0.8.0/src/bin/extract_residues.rs +46 -0
  23. libqdx-0.8.0/src/bin/from_mmcif.rs +55 -0
  24. libqdx-0.8.0/src/bin/from_pdb.rs +55 -0
  25. libqdx-0.8.0/src/bin/from_sdf.rs +41 -0
  26. libqdx-0.8.0/src/bin/from_xyz.rs +46 -0
  27. libqdx-0.8.0/src/bin/merge_trcs.rs +69 -0
  28. libqdx-0.8.0/src/bin/perceive_bonds.rs +52 -0
  29. libqdx-0.8.0/src/bin/perceive_formal_charges.rs +70 -0
  30. libqdx-0.8.0/src/bin/to_pdb.rs +43 -0
  31. libqdx-0.8.0/src/bin/to_sdf.rs +36 -0
  32. libqdx-0.8.0/src/bin/to_xyz.rs +52 -0
  33. libqdx-0.8.0/src/bin/validate_trc.rs +39 -0
  34. libqdx-0.8.0/src/binding.rs +82 -0
  35. libqdx-0.8.0/src/bond.rs +157 -0
  36. libqdx-0.8.0/src/chain.rs +710 -0
  37. libqdx-0.8.0/src/constraints.rs +7 -0
  38. libqdx-0.8.0/src/convert/mmcif.rs +1791 -0
  39. libqdx-0.8.0/src/convert/mod.rs +6 -0
  40. libqdx-0.8.0/src/convert/parity.rs +315 -0
  41. libqdx-0.8.0/src/convert/pdb.rs +2398 -0
  42. libqdx-0.8.0/src/convert/sdf.rs +1737 -0
  43. libqdx-0.8.0/src/convert/xyz.rs +147 -0
  44. libqdx-0.8.0/src/element.rs +524 -0
  45. libqdx-0.8.0/src/error.rs +89 -0
  46. libqdx-0.8.0/src/fragment.rs +325 -0
  47. libqdx-0.8.0/src/interaction.rs +102 -0
  48. libqdx-0.8.0/src/lib.rs +81 -0
  49. libqdx-0.8.0/src/mbe.rs +91 -0
  50. libqdx-0.8.0/src/method.rs +115 -0
  51. libqdx-0.8.0/src/nmer.rs +133 -0
  52. libqdx-0.8.0/src/object.rs +530 -0
  53. libqdx-0.8.0/src/optim.rs +10 -0
  54. libqdx-0.8.0/src/qm/external_charges.rs +12 -0
  55. libqdx-0.8.0/src/qm/keywords.rs +1106 -0
  56. libqdx-0.8.0/src/qm/mod.rs +50 -0
  57. libqdx-0.8.0/src/qm/output.rs +26 -0
  58. libqdx-0.8.0/src/qm/params.rs +229 -0
  59. libqdx-0.8.0/src/residue.rs +864 -0
  60. libqdx-0.8.0/src/rex.rs +16 -0
  61. libqdx-0.8.0/src/smiles.rs +31 -0
  62. libqdx-0.8.0/src/symbol.rs +83 -0
  63. libqdx-0.8.0/src/tensor.rs +59 -0
  64. libqdx-0.8.0/src/topology.rs +1147 -0
  65. libqdx-0.8.0/src/traj.rs +79 -0
  66. libqdx-0.8.0/src/trc.rs +834 -0
  67. libqdx-0.8.0/src/ts.rs +15 -0
  68. libqdx-0.8.0/src/version.rs +130 -0
  69. libqdx-0.8.0/src/wasm/mod.rs +138 -0
  70. libqdx-0.8.0/src/xyz.rs +124 -0
  71. libqdx-0.8.0/tests/convert.rs +542 -0
  72. libqdx-0.8.0/tests/data/mmcif/7pjq.cif +6967 -0
  73. libqdx-0.8.0/tests/data/mmcif/7pjq.json +83604 -0
  74. libqdx-0.8.0/tests/data/mmcif/7pjq.pdb +4009 -0
  75. libqdx-0.8.0/tests/data/mmcif/9atq.cif +33827 -0
  76. libqdx-0.8.0/tests/data/mmcif/9atq.json +590090 -0
  77. libqdx-0.8.0/tests/data/mmcif/9atq.pdb +27821 -0
  78. libqdx-0.8.0/tests/data/mmcif/9dbu.cif +3664 -0
  79. libqdx-0.8.0/tests/data/mmcif/9dbu.json +19102 -0
  80. libqdx-0.8.0/tests/data/mmcif/9dbu.pdb +2004 -0
  81. libqdx-0.8.0/tests/data/mmcif/9gql.cif +8157 -0
  82. libqdx-0.8.0/tests/data/mmcif/9hj7.cif +8102 -0
  83. libqdx-0.8.0/tests/data/mmcif/9hj7.json +110982 -0
  84. libqdx-0.8.0/tests/data/mmcif/9hj7.pdb +5332 -0
  85. libqdx-0.8.0/tests/data/mmcif/9jbd.cif +3437 -0
  86. libqdx-0.8.0/tests/data/mmcif/9jbd.json +26447 -0
  87. libqdx-0.8.0/tests/data/mmcif/9jbd.pdb +1491 -0
  88. libqdx-0.8.0/tests/data/mmcif/9jm5.cif +4628 -0
  89. libqdx-0.8.0/tests/data/mmcif/9jm5.json +52826 -0
  90. libqdx-0.8.0/tests/data/mmcif/9jm5.pdb +2735 -0
  91. libqdx-0.8.0/tests/data/pdb/4hhb.pdb +5839 -0
  92. libqdx-0.8.0/tests/data/pdb/7l5o.pdb +3518 -0
  93. libqdx-0.8.0/tests/data/pdb/af2rave_output.pdb +4996 -0
  94. libqdx-0.8.0/tests/data/sdf/alt_charge.sdf +61 -0
  95. libqdx-0.8.0/tests/data/sdf/auto3d_out.sdf +1619 -0
  96. libqdx-0.8.0/tests/data/sdf/constraints.sdf +137 -0
  97. libqdx-0.8.0/tests/data/sdf/dg.sdf +82 -0
  98. libqdx-0.8.0/tests/data/sdf/isopropyl.sdf +41 -0
  99. libqdx-0.8.0/tests/data/sdf/ligand_1a30.sdf +118 -0
  100. libqdx-0.8.0/tests/data/sdf/multiple_entries.sdf +1650 -0
  101. libqdx-0.8.0/tests/data/sdf/multiple_entries_errs.sdf +1650 -0
  102. libqdx-0.8.0/tests/data/sdf/rank_1.sdf +61 -0
  103. libqdx-0.8.0/tests/data/sdf/rdkit.sdf +213 -0
  104. libqdx-0.8.0/tests/data/sdf/v3000.sdf +43 -0
  105. libqdx-0.8.0/tests/data/trc/isopropyl.json +24 -0
  106. libqdx-0.8.0/tests/rex.rs +230 -0
@@ -0,0 +1,102 @@
1
+ name: Python
2
+
3
+ on:
4
+ push:
5
+ branches: ["master"]
6
+ paths:
7
+ - "py/**"
8
+ - "src/**"
9
+ - "Cargo.toml"
10
+ - "Cargo.lock"
11
+ pull_request:
12
+ branches: ["master"]
13
+ paths:
14
+ - "py/**"
15
+ - "src/**"
16
+ - "Cargo.toml"
17
+ - "Cargo.lock"
18
+
19
+ env:
20
+ CARGO_TERM_COLOR: always
21
+ CARGO_NET_GIT_FETCH_WITH_CLI: true
22
+
23
+ permissions:
24
+ contents: read
25
+
26
+ jobs:
27
+ # Build wheels for Linux, macOS, and Windows
28
+ build:
29
+ name: ${{ matrix.platform.target }} / py${{ matrix.python-version }}
30
+ strategy:
31
+ fail-fast: false
32
+ matrix:
33
+ python-version: ["3.12", "3.13"]
34
+ platform:
35
+ - runner: ubuntu-latest
36
+ os: linux
37
+ target: x86_64-unknown-linux-gnu
38
+ - runner: macos-latest
39
+ os: macos
40
+ target: aarch64-apple-darwin
41
+ - runner: windows-latest
42
+ os: windows
43
+ target: x86_64-pc-windows-msvc
44
+ runs-on: ${{ matrix.platform.runner }}
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+ - uses: actions/setup-python@v5
48
+ if: matrix.platform.os != 'linux'
49
+ with:
50
+ python-version: ${{ matrix.python-version }}
51
+ - name: Build wheels (Linux)
52
+ if: matrix.platform.os == 'linux'
53
+ uses: PyO3/maturin-action@v1
54
+ with:
55
+ target: ${{ matrix.platform.target }}
56
+ args: --release --out dist --manifest-path py/Cargo.toml -i python${{ matrix.python-version }}
57
+ manylinux: auto
58
+ - name: Build wheels (macOS/Windows)
59
+ if: matrix.platform.os != 'linux'
60
+ uses: PyO3/maturin-action@v1
61
+ with:
62
+ target: ${{ matrix.platform.target }}
63
+ args: --release --out dist --manifest-path py/Cargo.toml -i python
64
+ - uses: actions/upload-artifact@v4
65
+ with:
66
+ name: wheels-${{ matrix.platform.target }}-py${{ matrix.python-version }}
67
+ path: dist
68
+
69
+ # Build source distribution
70
+ sdist:
71
+ runs-on: ubuntu-latest
72
+ steps:
73
+ - uses: actions/checkout@v4
74
+ - name: Build sdist
75
+ uses: PyO3/maturin-action@v1
76
+ with:
77
+ command: sdist
78
+ args: --out dist --manifest-path py/Cargo.toml
79
+ - uses: actions/upload-artifact@v4
80
+ with:
81
+ name: wheels-sdist
82
+ path: dist
83
+
84
+ # Publish to PyPI on push to master (only if py/ or src/ changed)
85
+ publish:
86
+ needs: [build, sdist]
87
+ runs-on: ubuntu-latest
88
+ if: github.event_name == 'push' && github.ref == 'refs/heads/master'
89
+ environment:
90
+ name: pypi
91
+ url: https://pypi.org/p/libqdx
92
+ permissions:
93
+ contents: read
94
+ id-token: write
95
+ steps:
96
+ - uses: actions/download-artifact@v4
97
+ with:
98
+ pattern: wheels-*
99
+ merge-multiple: true
100
+ path: dist
101
+ - name: Publish to PyPI
102
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,28 @@
1
+ name: Rust
2
+
3
+ on:
4
+ push:
5
+ branches: ["master"]
6
+ pull_request:
7
+ branches: ["master"]
8
+
9
+ env:
10
+ CARGO_TERM_COLOR: always
11
+ CARGO_NET_GIT_FETCH_WITH_CLI: true
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - run: rustup toolchain install beta --profile minimal
20
+ - uses: Swatinem/rust-cache@v2
21
+ - name: Build
22
+ run: cargo clippy
23
+ - name: format
24
+ run: cargo fmt --check
25
+ - name: Build
26
+ run: cargo build --verbose
27
+ - name: Run tests
28
+ run: cargo test --verbose
@@ -0,0 +1,5 @@
1
+ **/target
2
+ .direnv
3
+ .envrc
4
+ .env
5
+ test_cache/
libqdx-0.8.0/AGENTS.md ADDED
@@ -0,0 +1,86 @@
1
+ # AGENTS.md — AI Coding Context for libqdx
2
+
3
+ ## Project Overview
4
+
5
+ **libqdx** is a Rust library for molecular structure representation and conversion. It provides the core data structures and parsers for the QDX ecosystem.
6
+
7
+ ### Key Concepts
8
+
9
+ - **TRC** (Topology, Residues, Chains): The central data structure combining molecular topology (atoms, bonds), residue assignments, and chain information (including secondary structure).
10
+ - **Topology**: Atoms, bonds, coordinates, charges, etc.
11
+ - **Residues**: Mapping of atoms to residues (amino acids, ligands, etc.).
12
+ - **Chains**: Chain assignments, labels, alpha helices, beta sheets.
13
+
14
+ ### Use Cases
15
+
16
+ TRCs are used to store molecular systems for **Tengu modules**, where Tengu is QDX's job runner backend. A module is a specific program or capability that can be run on Tengu. One of the main modules does protein preparation and leverages the protein-specific capabilities like `perceive_bonds`, `perceive_formal_charges`. This library should serve as a general-purpose toolkit for manipulating molecules in the context of supplementing and completing the capabilities required by Tengu modules and the platform in general. Some of these capabilities are (or are planned to be) exported to our Python and TypeScript libraries.
17
+
18
+ ### Supported Formats
19
+
20
+ - **PDB** (`src/convert/pdb.rs`): Fixed-width column format. Parser uses 0-indexed column ranges.
21
+ - **mmCIF** (`src/convert/mmcif.rs`): Key-value and loop-based format. Data can appear as loops (multiple records) or single key-value pairs (one record) — both must be handled.
22
+ - **SDF** (`src/convert/sdf.rs`): Structure-data format for small molecules.
23
+ - **XYZ** (`src/convert/xyz.rs`): Simple coordinate format.
24
+
25
+ ## Architecture
26
+
27
+ ```
28
+ src/
29
+ lib.rs # Re-exports, public API
30
+ trc.rs # TRC struct definition
31
+ topology.rs # Topology (atoms, bonds, coordinates)
32
+ residue.rs # Residue definitions
33
+ chain.rs # Chains, AlphaHelices, BetaSheets, HelixClass, StrandSense
34
+ convert/
35
+ mod.rs # Conversion module
36
+ pdb.rs # PDB parser/writer (~2000 lines)
37
+ mmcif.rs # mmCIF parser (~1400 lines)
38
+ parity.rs # Cross-format comparison diagnostics
39
+ sdf.rs # SDF parser
40
+ xyz.rs # XYZ parser
41
+ version.rs # SchemaVersion (data format version, separate from crate version)
42
+ tests/
43
+ convert.rs # Integration tests: PDB/mmCIF parity tests, roundtrip tests
44
+ data/ # Test data files (PDB, mmCIF, JSON snapshots)
45
+ ```
46
+
47
+ ## Conventions
48
+
49
+ ### Code Style
50
+ - Rust edition 2024.
51
+ - `cargo fmt` is enforced (runs automatically as a hook or by the user).
52
+ - Helper functions are placed **above** their call sites.
53
+ - Prefer extracting local variables over inline expressions in struct literals for readability.
54
+ - No unnecessary abstractions — three similar lines are better than a premature helper.
55
+
56
+ ### mmCIF Parsing Patterns
57
+ - `get_loop_data(block, category)` returns `Option<(&[String], &[Vec<String>])>` for loop-format data.
58
+ - `get_single_data(block, field)` returns `Option<&str>` for single key-value pair data.
59
+ - **Both formats must be handled** for any mmCIF category — use `if let Some(...) = get_loop_data(...) { ... } else { ... get_single_data(...) ... }`.
60
+ - `row_str(row, idx)` filters missing mmCIF values (`""`, `"?"`, `"."`). `get_single_data` does **not** filter — callers must use `.filter(|v| !is_missing_mmcif_value(v))` when needed.
61
+ - `ins_code_or_tilde(value: Option<&str>)` returns `"~"` for missing insertion codes.
62
+
63
+ ### PDB Parsing Patterns
64
+ - Fixed-width columns, 0-indexed in parser code.
65
+ - `ins_code_or_tilde(code: &str)` returns `"~"` for empty insertion codes.
66
+ - `chain_id_for_pdb(chains, chain_ref)` resolves chain labels for output.
67
+ - `put_left`/`put_right` for fixed-width field formatting in PDB output.
68
+
69
+ ### ResidueId
70
+ - Used in both parsers for residue lookup: `{ chain_id, sequence_number, insertion_code, residue_name }`.
71
+ - Insertion code sentinel: `"~"` means no insertion code.
72
+ - Defined separately in each parser module (not shared).
73
+
74
+ ### Testing
75
+ - `cargo test` runs unit tests (fast, ~18 tests).
76
+ - `cargo test --test convert` runs integration tests (~39 parity tests comparing PDB vs mmCIF parsing).
77
+ - Parity tests download structures from RCSB, parse both formats, and compare the resulting TRC structs.
78
+ - Test data cached in `test_cache/` (gitignored) and `tests/data/` (committed JSON snapshots).
79
+
80
+ ### Versioning
81
+ - Crate version in `Cargo.toml` follows semver.
82
+ - `SchemaVersion` in `src/version.rs` is the **data format** version (currently 0.2.0), independent of the crate version. Only bump if the serialized TRC format changes in a breaking way.
83
+
84
+ ### Git
85
+ - Conventional commit messages: `feat:`, `fix:`, `refactor:`, `chore:`.
86
+ - Main branch: `master`.