Skip to content

Commit 32422e3

Browse files
moecompPythonFZclaudepre-commit-ci[bot]
authored
Propagate atom tags from selected image to packed box (#119)
* Propagate atom tags from selected image to packed box Add logic to propagate atom tags from selected conformer images to packed box. * test: verify atom tags propagate through pack Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Fabian Zills <fzills@icp.uni-stuttgart.de> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent d1fcc79 commit 32422e3

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/molify/pack.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ def _extract_atom_arrays(
137137
charges = np.concatenate([atom.get_initial_charges() for atom in selected_images])
138138
if any(charge != 0 for charge in charges):
139139
packed_atoms.set_initial_charges(charges)
140+
tags = np.concatenate([atom.get_tags() for atom in selected_images])
141+
if any(tag != 0 for tag in tags):
142+
packed_atoms.set_tags(tags)
140143
return packed_atoms
141144

142145

tests/test_solvate.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ def test_pack_charges():
109109
assert charges == [0, 0, 0, -1, 0, 1] + [1, 0, 0, -1, 0, 0, 0, 0, 0, 0]
110110

111111

112+
def test_pack_tags():
113+
water = smiles2conformers("O", 1)
114+
methane = smiles2conformers("C", 1)
115+
water[0].set_tags(range(1, 4)) # O, H, H -> 1, 2, 3
116+
methane[0].set_tags(range(4, 9)) # C, H, H, H, H -> 4, 5, 6, 7, 8
117+
118+
atoms = pack([water, methane], [2, 1], density=1000)
119+
npt.assert_array_equal(atoms.get_tags(), [1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8])
120+
121+
112122
def test_pack_ratio():
113123
water = smiles2conformers("O", 1)
114124
# pack a cubic box

0 commit comments

Comments
 (0)