trex-notation 0.1.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.
- trex_notation-0.1.0/LICENSE +21 -0
- trex_notation-0.1.0/PKG-INFO +176 -0
- trex_notation-0.1.0/README.md +159 -0
- trex_notation-0.1.0/pyproject.toml +36 -0
- trex_notation-0.1.0/setup.cfg +4 -0
- trex_notation-0.1.0/trex/__init__.py +13 -0
- trex_notation-0.1.0/trex/canon.py +40 -0
- trex_notation-0.1.0/trex/canon_fast.py +426 -0
- trex_notation-0.1.0/trex/canon_full.py +1067 -0
- trex_notation-0.1.0/trex/chirality.py +1020 -0
- trex_notation-0.1.0/trex/cli.py +168 -0
- trex_notation-0.1.0/trex/enumerate_trex.py +554 -0
- trex_notation-0.1.0/trex/geometry.py +530 -0
- trex_notation-0.1.0/trex/graph_hash.py +77 -0
- trex_notation-0.1.0/trex/isomer_compare.py +756 -0
- trex_notation-0.1.0/trex/model.py +130 -0
- trex_notation-0.1.0/trex/parse_full.py +276 -0
- trex_notation-0.1.0/trex/parse_min.py +78 -0
- trex_notation-0.1.0/trex/registry.py +109 -0
- trex_notation-0.1.0/trex/smiles_map_utils.py +284 -0
- trex_notation-0.1.0/trex/trex2mol.py +332 -0
- trex_notation-0.1.0/trex/trex_canon_helper.py +11 -0
- trex_notation-0.1.0/trex/validate.py +71 -0
- trex_notation-0.1.0/trex/xyz2mol_local.py +1289 -0
- trex_notation-0.1.0/trex/xyz2mol_tmc.py +632 -0
- trex_notation-0.1.0/trex/xyz_helper.py +399 -0
- trex_notation-0.1.0/trex/xyz_to_trex.py +789 -0
- trex_notation-0.1.0/trex_notation.egg-info/PKG-INFO +176 -0
- trex_notation-0.1.0/trex_notation.egg-info/SOURCES.txt +30 -0
- trex_notation-0.1.0/trex_notation.egg-info/dependency_links.txt +1 -0
- trex_notation-0.1.0/trex_notation.egg-info/requires.txt +6 -0
- trex_notation-0.1.0/trex_notation.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ilia Kevlishvili
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: trex-notation
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: T-REX — Trans-pair Relations EXpression for coordination topology
|
|
5
|
+
Author-email: Ilia Kevlishvili <ilia_kevlishvili@baylor.edu>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: typer>=0.12
|
|
11
|
+
Requires-Dist: pydantic>=2
|
|
12
|
+
Requires-Dist: ruamel.yaml
|
|
13
|
+
Requires-Dist: networkx
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: rdkit==2025.3.5
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# T-REX: Trans-Pairs Relations EXpression
|
|
19
|
+
|
|
20
|
+
**T-REX** is a modular string notation and Python library designed for the representation, manipulation, and canonicalization of Transition Metal Complexes (TMCs).
|
|
21
|
+
|
|
22
|
+
Unlike standard SMILES which often struggle with the dynamic coordination spheres of metals, T-REX explicitly encodes the metal center, oxidation state, ligand payloads (SMILES/SELFIES), and the geometric **trans-pair relations** of the coordination sphere.
|
|
23
|
+
|
|
24
|
+
## Key Features
|
|
25
|
+
|
|
26
|
+
* **3D to String:** Convert XYZ coordinates into T-REX strings with automatic ligand detection, charge estimation (EHT), and geometric classification. (`xyz_to_trex.py`)
|
|
27
|
+
* **String to Graph:** Deterministic conversion of T-REX strings into RDKit `Mol` objects, preserving dative bonds and adding virtual "trans" edges. (`trex2mol.py`)
|
|
28
|
+
* **Canonicalization:** Robust canonicalization handling ligand permutations, internal ligand symmetry (graph & ECFP), and stereoisomer equivalence. (`canon_full.py`)
|
|
29
|
+
* **Chirality Detection:** Metal-centered chirality computation supporting both point-central (`@`/`@@`) and helical (`Δ`/`Λ`) chirality across tetrahedral, trigonal bipyramidal, square pyramidal, and octahedral geometries. (`chirality.py`)
|
|
30
|
+
* **Enumeration:** Combinatorial generation of all valid stereoisomers for a given coordination formula. (`enumerate_trex.py`)
|
|
31
|
+
* **Isomer Classification:** Classify pairs of complexes as identical, enantiomers, coordination isomers, geometric isomers, and more. (`isomer_compare.py`)
|
|
32
|
+
|
|
33
|
+
## Stand-alone Scripts
|
|
34
|
+
|
|
35
|
+
* **Generative ligand substitution:** Generate novel structures through ligand substitution based on ligand topology matching: (`build_indices_and_parents.py` > `enumerate_children_mp.py` > `dedupe_canonical_batch.py`)
|
|
36
|
+
* **Graph Neural Networks:** GNNs using T-REX (`MPNN.py` — standard message passing neural network. `HyperMPNN.py` — hybrid message passing neural network with hyperedges)
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
### Prerequisites
|
|
41
|
+
|
|
42
|
+
T-REX relies on **RDKit**. It is recommended to use Conda/Mamba.
|
|
43
|
+
|
|
44
|
+
### Installation
|
|
45
|
+
|
|
46
|
+
1. Clone the repository:
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/iliak14/trex.git
|
|
49
|
+
cd trex
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
2. Create the environment:
|
|
53
|
+
```bash
|
|
54
|
+
conda env create -f environment.yml
|
|
55
|
+
conda activate trex
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
3. Install using pip:
|
|
59
|
+
```bash
|
|
60
|
+
pip install -e .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## T-REX String Format
|
|
64
|
+
|
|
65
|
+
A T-REX string is a pipe-delimited sequence of blocks:
|
|
66
|
+
```
|
|
67
|
+
HEAD | L=[ ligands ] | MAP:{ topology } | G:geometry | X:chirality
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- **HEAD** — metal symbol, oxidation state, and optional spin-multiplicity: `Fe{+3}` or `Co{+3,S=1}`
|
|
71
|
+
- **L=\[...\]** — comma-separated ligand payloads, each prefixed by type (e.g., `SMILES:`, `SELFIES:`, `INCHI:`, or `TOKEN:`).
|
|
72
|
+
- **MAP:{...}** — trans-pairs as `(site_a, site_b)` and singletons after `;`. Each site is `lig_index:atom_index` (1-based).
|
|
73
|
+
- **G:** — optional geometry flag (`O` = octahedral, `sqpl` = square planar, `sqpy` = square pyramidal, `trbp` = trigonal bipyramidal, etc.)
|
|
74
|
+
- **X:** — optional chirality flag (`@`, `@@`, `Δ`, `Λ`)
|
|
75
|
+
|
|
76
|
+
### Examples
|
|
77
|
+
|
|
78
|
+
Square planar Pt(II) with two ammine and two chlorido ligands, where NH₃ and Cl⁻ are trans to each other:
|
|
79
|
+
```
|
|
80
|
+
Pt{+2} | L=[ SMILES:[Cl-], SMILES:[Cl-], SMILES:N, SMILES:N ] | MAP:{ (1:1, 3:1), (2:1, 4:1) }
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Octahedral Fe(III) hexachlorido:
|
|
84
|
+
```
|
|
85
|
+
Fe{+3} | L=[ SMILES:[Cl-], SMILES:[Cl-], SMILES:[Cl-], SMILES:[Cl-], SMILES:[Cl-], SMILES:[Cl-] ] | MAP:{ (1:1, 2:1), (3:1, 4:1), (5:1, 6:1) } | G:O
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Octahedral Co(III) tris(ethylenediamine) with bidentate ligands:
|
|
89
|
+
```
|
|
90
|
+
Co{+3} | L=[ SMILES:NCCN, SMILES:NCCN, SMILES:NCCN ] | MAP:{ (1:1, 2:1), (1:4, 3:1), (2:4, 3:4) } | G:O
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Quick Start
|
|
94
|
+
|
|
95
|
+
### Parsing a T-REX string
|
|
96
|
+
```python
|
|
97
|
+
from trex.parse_full import parse_trex_full
|
|
98
|
+
|
|
99
|
+
trex_string = "Pt{+2} | L=[ SMILES:[Cl-], SMILES:[Cl-], SMILES:N, SMILES:N ] | MAP:{ (1:1, 3:1), (2:1, 4:1) }"
|
|
100
|
+
|
|
101
|
+
t = parse_trex_full(trex_string)
|
|
102
|
+
print(t.metal) # Pt
|
|
103
|
+
print(t.ox) # 2
|
|
104
|
+
print(t.cn()) # 4
|
|
105
|
+
print(t.get_geo_type()) # sqpl
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Canonicalizing a T-REX string
|
|
109
|
+
```python
|
|
110
|
+
from trex.parse_full import canonicalize_trex_full_string
|
|
111
|
+
|
|
112
|
+
raw = "Pt{+2} | L=[ SMILES:N, SMILES:N, SMILES:[Cl-], SMILES:[Cl-] ] | MAP:{ (1:1, 3:1), (2:1, 4:1) }"
|
|
113
|
+
canonical = canonicalize_trex_full_string(raw)
|
|
114
|
+
print(canonical)
|
|
115
|
+
# Pt{+2} | L=[ SMILES:[Cl-], SMILES:[Cl-], SMILES:N, SMILES:N ] | MAP:{ (1:1, 3:1), (2:1, 4:1) }
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Converting XYZ to T-REX
|
|
119
|
+
```python
|
|
120
|
+
from trex.xyz_to_trex import xyz_to_trex
|
|
121
|
+
|
|
122
|
+
trex_string = xyz_to_trex("complex.xyz")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Chirality Detection
|
|
126
|
+
|
|
127
|
+
T-REX handles two fundamentally different types of metal-centered chirality.
|
|
128
|
+
|
|
129
|
+
### Point-Central Chirality (`@` / `@@`)
|
|
130
|
+
|
|
131
|
+
Point chirality arises in all-monodentate complexes when no two equivalent ligands can be swapped by a symmetry operation. T-REX uses the **determinant method**: four coordination sites are selected according to geometry-specific rules and their signed volume (the scalar triple product) determines handedness.
|
|
132
|
+
|
|
133
|
+
Achirality conditions are checked per geometry before computing:
|
|
134
|
+
|
|
135
|
+
- **Tetrahedral** — achiral if any two sites are equivalent
|
|
136
|
+
- **Trigonal bipyramidal** — achiral if the axial trans partners are equivalent, or if any two equatorial sites are equivalent
|
|
137
|
+
- **Square pyramidal** — achiral if any trans partners within a pair are equivalent, or if the two basal pairs are equivalent (i.e. mirror plane not going through a site)
|
|
138
|
+
- **Octahedral** — achiral if any trans partners within a pair are equivalent, or if a set of two pairs are equivalent
|
|
139
|
+
|
|
140
|
+
### Helical Chirality (`Δ` / `Λ`)
|
|
141
|
+
|
|
142
|
+
Helical chirality is relevant for multidentate octahedral complexes where point-central chirality is absent (e.g., all sites may be equivalent) but a propeller-like twist exists. T-REX supports three cases:
|
|
143
|
+
|
|
144
|
+
- **Tris-bidentate** \[M(L∩L)₃\] — always helically chiral. Uses the propeller method: each chelate's bite vector forms a blade, and the twist of these blades around the pseudo-C₃ axis determines Δ or Λ.
|
|
145
|
+
- **Cis-bis-bidentate** \[M(L∩L)₂X₂\] — helically chiral when the two monodentate ligands are cis to each other (i.e. two bidentates are not on the same plane).
|
|
146
|
+
- **Fac-fac bis-tridentate** \[M(L∩L∩L)₂\] — helically chiral when both tridentates adopt facial coordination (no internal trans pairs). Computed by measuring the twist angle between the two triangular faces.
|
|
147
|
+
|
|
148
|
+
The `compute_chirality()` function is the main entry point: it checks point-central chirality first, then falls back to helical chirality, returning `@`, `@@`, `Δ`, `Λ`, or `None`.
|
|
149
|
+
|
|
150
|
+
## Dependencies
|
|
151
|
+
|
|
152
|
+
- [RDKit](https://www.rdkit.org/) — cheminformatics toolkit
|
|
153
|
+
- [NumPy](https://numpy.org/) — numerical computing
|
|
154
|
+
- [NetworkX](https://networkx.org/) — graph algorithms
|
|
155
|
+
- [Pydantic](https://docs.pydantic.dev/) (v2) — data validation
|
|
156
|
+
- [ruamel.yaml](https://yaml.readthedocs.io/) — YAML parsing
|
|
157
|
+
- [Typer](https://typer.tiangolo.com/) — CLI framework
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
This project is licensed under the MIT License.
|
|
162
|
+
|
|
163
|
+
## Citation
|
|
164
|
+
|
|
165
|
+
If you use T-REX in your research, please cite:
|
|
166
|
+
```bibtex
|
|
167
|
+
@article{kevlishvili2025trex,
|
|
168
|
+
title = {Taming {T-REX}: A Canonical Language for Geometry-Aware Generative Design of Transition Metal Complexes},
|
|
169
|
+
author = {Kevlishvili, Ilia},
|
|
170
|
+
journal = {ChemRxiv},
|
|
171
|
+
year = {2025},
|
|
172
|
+
doi = {10.26434/chemrxiv-2025-7s3gx}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Kevlishvili, I. "Taming T-REX: A Canonical Language for Geometry-Aware Generative Design of Transition Metal Complexes." *ChemRxiv*, 2025. DOI: [10.26434/chemrxiv-2025-7s3gx](https://doi.org/10.26434/chemrxiv-2025-7s3gx)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# T-REX: Trans-Pairs Relations EXpression
|
|
2
|
+
|
|
3
|
+
**T-REX** is a modular string notation and Python library designed for the representation, manipulation, and canonicalization of Transition Metal Complexes (TMCs).
|
|
4
|
+
|
|
5
|
+
Unlike standard SMILES which often struggle with the dynamic coordination spheres of metals, T-REX explicitly encodes the metal center, oxidation state, ligand payloads (SMILES/SELFIES), and the geometric **trans-pair relations** of the coordination sphere.
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
* **3D to String:** Convert XYZ coordinates into T-REX strings with automatic ligand detection, charge estimation (EHT), and geometric classification. (`xyz_to_trex.py`)
|
|
10
|
+
* **String to Graph:** Deterministic conversion of T-REX strings into RDKit `Mol` objects, preserving dative bonds and adding virtual "trans" edges. (`trex2mol.py`)
|
|
11
|
+
* **Canonicalization:** Robust canonicalization handling ligand permutations, internal ligand symmetry (graph & ECFP), and stereoisomer equivalence. (`canon_full.py`)
|
|
12
|
+
* **Chirality Detection:** Metal-centered chirality computation supporting both point-central (`@`/`@@`) and helical (`Δ`/`Λ`) chirality across tetrahedral, trigonal bipyramidal, square pyramidal, and octahedral geometries. (`chirality.py`)
|
|
13
|
+
* **Enumeration:** Combinatorial generation of all valid stereoisomers for a given coordination formula. (`enumerate_trex.py`)
|
|
14
|
+
* **Isomer Classification:** Classify pairs of complexes as identical, enantiomers, coordination isomers, geometric isomers, and more. (`isomer_compare.py`)
|
|
15
|
+
|
|
16
|
+
## Stand-alone Scripts
|
|
17
|
+
|
|
18
|
+
* **Generative ligand substitution:** Generate novel structures through ligand substitution based on ligand topology matching: (`build_indices_and_parents.py` > `enumerate_children_mp.py` > `dedupe_canonical_batch.py`)
|
|
19
|
+
* **Graph Neural Networks:** GNNs using T-REX (`MPNN.py` — standard message passing neural network. `HyperMPNN.py` — hybrid message passing neural network with hyperedges)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### Prerequisites
|
|
24
|
+
|
|
25
|
+
T-REX relies on **RDKit**. It is recommended to use Conda/Mamba.
|
|
26
|
+
|
|
27
|
+
### Installation
|
|
28
|
+
|
|
29
|
+
1. Clone the repository:
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/iliak14/trex.git
|
|
32
|
+
cd trex
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
2. Create the environment:
|
|
36
|
+
```bash
|
|
37
|
+
conda env create -f environment.yml
|
|
38
|
+
conda activate trex
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
3. Install using pip:
|
|
42
|
+
```bash
|
|
43
|
+
pip install -e .
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## T-REX String Format
|
|
47
|
+
|
|
48
|
+
A T-REX string is a pipe-delimited sequence of blocks:
|
|
49
|
+
```
|
|
50
|
+
HEAD | L=[ ligands ] | MAP:{ topology } | G:geometry | X:chirality
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- **HEAD** — metal symbol, oxidation state, and optional spin-multiplicity: `Fe{+3}` or `Co{+3,S=1}`
|
|
54
|
+
- **L=\[...\]** — comma-separated ligand payloads, each prefixed by type (e.g., `SMILES:`, `SELFIES:`, `INCHI:`, or `TOKEN:`).
|
|
55
|
+
- **MAP:{...}** — trans-pairs as `(site_a, site_b)` and singletons after `;`. Each site is `lig_index:atom_index` (1-based).
|
|
56
|
+
- **G:** — optional geometry flag (`O` = octahedral, `sqpl` = square planar, `sqpy` = square pyramidal, `trbp` = trigonal bipyramidal, etc.)
|
|
57
|
+
- **X:** — optional chirality flag (`@`, `@@`, `Δ`, `Λ`)
|
|
58
|
+
|
|
59
|
+
### Examples
|
|
60
|
+
|
|
61
|
+
Square planar Pt(II) with two ammine and two chlorido ligands, where NH₃ and Cl⁻ are trans to each other:
|
|
62
|
+
```
|
|
63
|
+
Pt{+2} | L=[ SMILES:[Cl-], SMILES:[Cl-], SMILES:N, SMILES:N ] | MAP:{ (1:1, 3:1), (2:1, 4:1) }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Octahedral Fe(III) hexachlorido:
|
|
67
|
+
```
|
|
68
|
+
Fe{+3} | L=[ SMILES:[Cl-], SMILES:[Cl-], SMILES:[Cl-], SMILES:[Cl-], SMILES:[Cl-], SMILES:[Cl-] ] | MAP:{ (1:1, 2:1), (3:1, 4:1), (5:1, 6:1) } | G:O
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Octahedral Co(III) tris(ethylenediamine) with bidentate ligands:
|
|
72
|
+
```
|
|
73
|
+
Co{+3} | L=[ SMILES:NCCN, SMILES:NCCN, SMILES:NCCN ] | MAP:{ (1:1, 2:1), (1:4, 3:1), (2:4, 3:4) } | G:O
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Quick Start
|
|
77
|
+
|
|
78
|
+
### Parsing a T-REX string
|
|
79
|
+
```python
|
|
80
|
+
from trex.parse_full import parse_trex_full
|
|
81
|
+
|
|
82
|
+
trex_string = "Pt{+2} | L=[ SMILES:[Cl-], SMILES:[Cl-], SMILES:N, SMILES:N ] | MAP:{ (1:1, 3:1), (2:1, 4:1) }"
|
|
83
|
+
|
|
84
|
+
t = parse_trex_full(trex_string)
|
|
85
|
+
print(t.metal) # Pt
|
|
86
|
+
print(t.ox) # 2
|
|
87
|
+
print(t.cn()) # 4
|
|
88
|
+
print(t.get_geo_type()) # sqpl
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Canonicalizing a T-REX string
|
|
92
|
+
```python
|
|
93
|
+
from trex.parse_full import canonicalize_trex_full_string
|
|
94
|
+
|
|
95
|
+
raw = "Pt{+2} | L=[ SMILES:N, SMILES:N, SMILES:[Cl-], SMILES:[Cl-] ] | MAP:{ (1:1, 3:1), (2:1, 4:1) }"
|
|
96
|
+
canonical = canonicalize_trex_full_string(raw)
|
|
97
|
+
print(canonical)
|
|
98
|
+
# Pt{+2} | L=[ SMILES:[Cl-], SMILES:[Cl-], SMILES:N, SMILES:N ] | MAP:{ (1:1, 3:1), (2:1, 4:1) }
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Converting XYZ to T-REX
|
|
102
|
+
```python
|
|
103
|
+
from trex.xyz_to_trex import xyz_to_trex
|
|
104
|
+
|
|
105
|
+
trex_string = xyz_to_trex("complex.xyz")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Chirality Detection
|
|
109
|
+
|
|
110
|
+
T-REX handles two fundamentally different types of metal-centered chirality.
|
|
111
|
+
|
|
112
|
+
### Point-Central Chirality (`@` / `@@`)
|
|
113
|
+
|
|
114
|
+
Point chirality arises in all-monodentate complexes when no two equivalent ligands can be swapped by a symmetry operation. T-REX uses the **determinant method**: four coordination sites are selected according to geometry-specific rules and their signed volume (the scalar triple product) determines handedness.
|
|
115
|
+
|
|
116
|
+
Achirality conditions are checked per geometry before computing:
|
|
117
|
+
|
|
118
|
+
- **Tetrahedral** — achiral if any two sites are equivalent
|
|
119
|
+
- **Trigonal bipyramidal** — achiral if the axial trans partners are equivalent, or if any two equatorial sites are equivalent
|
|
120
|
+
- **Square pyramidal** — achiral if any trans partners within a pair are equivalent, or if the two basal pairs are equivalent (i.e. mirror plane not going through a site)
|
|
121
|
+
- **Octahedral** — achiral if any trans partners within a pair are equivalent, or if a set of two pairs are equivalent
|
|
122
|
+
|
|
123
|
+
### Helical Chirality (`Δ` / `Λ`)
|
|
124
|
+
|
|
125
|
+
Helical chirality is relevant for multidentate octahedral complexes where point-central chirality is absent (e.g., all sites may be equivalent) but a propeller-like twist exists. T-REX supports three cases:
|
|
126
|
+
|
|
127
|
+
- **Tris-bidentate** \[M(L∩L)₃\] — always helically chiral. Uses the propeller method: each chelate's bite vector forms a blade, and the twist of these blades around the pseudo-C₃ axis determines Δ or Λ.
|
|
128
|
+
- **Cis-bis-bidentate** \[M(L∩L)₂X₂\] — helically chiral when the two monodentate ligands are cis to each other (i.e. two bidentates are not on the same plane).
|
|
129
|
+
- **Fac-fac bis-tridentate** \[M(L∩L∩L)₂\] — helically chiral when both tridentates adopt facial coordination (no internal trans pairs). Computed by measuring the twist angle between the two triangular faces.
|
|
130
|
+
|
|
131
|
+
The `compute_chirality()` function is the main entry point: it checks point-central chirality first, then falls back to helical chirality, returning `@`, `@@`, `Δ`, `Λ`, or `None`.
|
|
132
|
+
|
|
133
|
+
## Dependencies
|
|
134
|
+
|
|
135
|
+
- [RDKit](https://www.rdkit.org/) — cheminformatics toolkit
|
|
136
|
+
- [NumPy](https://numpy.org/) — numerical computing
|
|
137
|
+
- [NetworkX](https://networkx.org/) — graph algorithms
|
|
138
|
+
- [Pydantic](https://docs.pydantic.dev/) (v2) — data validation
|
|
139
|
+
- [ruamel.yaml](https://yaml.readthedocs.io/) — YAML parsing
|
|
140
|
+
- [Typer](https://typer.tiangolo.com/) — CLI framework
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
This project is licensed under the MIT License.
|
|
145
|
+
|
|
146
|
+
## Citation
|
|
147
|
+
|
|
148
|
+
If you use T-REX in your research, please cite:
|
|
149
|
+
```bibtex
|
|
150
|
+
@article{kevlishvili2025trex,
|
|
151
|
+
title = {Taming {T-REX}: A Canonical Language for Geometry-Aware Generative Design of Transition Metal Complexes},
|
|
152
|
+
author = {Kevlishvili, Ilia},
|
|
153
|
+
journal = {ChemRxiv},
|
|
154
|
+
year = {2025},
|
|
155
|
+
doi = {10.26434/chemrxiv-2025-7s3gx}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Kevlishvili, I. "Taming T-REX: A Canonical Language for Geometry-Aware Generative Design of Transition Metal Complexes." *ChemRxiv*, 2025. DOI: [10.26434/chemrxiv-2025-7s3gx](https://doi.org/10.26434/chemrxiv-2025-7s3gx)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "trex-notation"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "T-REX — Trans-pair Relations EXpression for coordination topology"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [{name="Ilia Kevlishvili", email="ilia_kevlishvili@baylor.edu"}]
|
|
13
|
+
dependencies = ["typer>=0.12","pydantic>=2","ruamel.yaml","networkx","numpy","rdkit==2025.3.5"]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
[tool.black]
|
|
17
|
+
line-length = 88
|
|
18
|
+
target-version = ["py39"]
|
|
19
|
+
|
|
20
|
+
[tool.ruff]
|
|
21
|
+
line-length = 100
|
|
22
|
+
target-version = "py39"
|
|
23
|
+
|
|
24
|
+
[tool.ruff.lint]
|
|
25
|
+
select = ["E", "F", "I", "B", "UP"]
|
|
26
|
+
ignore = ["E402"] # keep if you have local imports to avoid cycles
|
|
27
|
+
|
|
28
|
+
[tool.ruff.lint.per-file-ignores]
|
|
29
|
+
"trex/__init__.py" = ["F401"]
|
|
30
|
+
|
|
31
|
+
[tool.ruff.format]
|
|
32
|
+
quote-style = "double"
|
|
33
|
+
indent-style = "space"
|
|
34
|
+
line-ending = "lf"
|
|
35
|
+
skip-magic-trailing-comma = false
|
|
36
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# trex/__init__.py
|
|
2
|
+
from .model import LigandPayload, MapSite, TrexFull, TrexMin
|
|
3
|
+
|
|
4
|
+
# New public helper (supersedes the old canonicalize_smiles_with_map)
|
|
5
|
+
# from .smiles_canon import canonical_smiles_and_maps
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"TrexMin",
|
|
9
|
+
"TrexFull",
|
|
10
|
+
"LigandPayload",
|
|
11
|
+
"MapSite",
|
|
12
|
+
# "canonical_smiles_and_maps",
|
|
13
|
+
]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from collections import Counter
|
|
2
|
+
|
|
3
|
+
from .model import TrexMin
|
|
4
|
+
from .registry import Registry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def canonicalize_min(t: TrexMin, reg: Registry) -> TrexMin:
|
|
8
|
+
dent = Counter()
|
|
9
|
+
for i, j in t.pairs:
|
|
10
|
+
dent[i] += 1
|
|
11
|
+
dent[j] += 1
|
|
12
|
+
for i in t.singles:
|
|
13
|
+
dent[i] += 1
|
|
14
|
+
|
|
15
|
+
props = []
|
|
16
|
+
for idx, tok in enumerate(t.ligands, start=1):
|
|
17
|
+
li = reg.get(tok)
|
|
18
|
+
charge = li.charge
|
|
19
|
+
mw = li.mw_monoiso or 0.0
|
|
20
|
+
sign_rank = 0 if charge < 0 else (1 if charge == 0 else 2)
|
|
21
|
+
props.append((idx, tok, dent[idx], abs(charge), sign_rank, mw))
|
|
22
|
+
|
|
23
|
+
# priority: dent ↓, |charge| ↓, sign (anion<neutral<cation), MW ↓, token ↑
|
|
24
|
+
order = [p[0] for p in sorted(props, key=lambda p: (-p[2], -p[3], p[4], -p[5], p[1]))]
|
|
25
|
+
remap = {old: new for new, old in enumerate(order, start=1)}
|
|
26
|
+
|
|
27
|
+
ligs = [t.ligands[i - 1] for i in order]
|
|
28
|
+
pairs = sorted({tuple(sorted((remap[i], remap[j]))) for (i, j) in t.pairs})
|
|
29
|
+
singles = sorted({remap[i] for i in t.singles})
|
|
30
|
+
|
|
31
|
+
return TrexMin(
|
|
32
|
+
metal=t.metal,
|
|
33
|
+
ox=t.ox,
|
|
34
|
+
spin=t.spin,
|
|
35
|
+
ligands=ligs,
|
|
36
|
+
pairs=pairs,
|
|
37
|
+
singles=singles,
|
|
38
|
+
G=t.G,
|
|
39
|
+
X=t.X,
|
|
40
|
+
)
|