helmkit 0.5.0__tar.gz → 0.5.2__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.
- {helmkit-0.5.0 → helmkit-0.5.2}/PKG-INFO +1 -1
- {helmkit-0.5.0 → helmkit-0.5.2}/pyproject.toml +1 -1
- {helmkit-0.5.0 → helmkit-0.5.2}/src/helmkit/molecule.py +37 -1
- {helmkit-0.5.0 → helmkit-0.5.2}/uv.lock +1 -1
- {helmkit-0.5.0 → helmkit-0.5.2}/.gitignore +0 -0
- {helmkit-0.5.0 → helmkit-0.5.2}/.python-version +0 -0
- {helmkit-0.5.0 → helmkit-0.5.2}/LICENSE +0 -0
- {helmkit-0.5.0 → helmkit-0.5.2}/README.md +0 -0
- {helmkit-0.5.0 → helmkit-0.5.2}/src/helmkit/__init__.py +0 -0
- {helmkit-0.5.0 → helmkit-0.5.2}/src/helmkit/data/monomers.sdf +0 -0
- {helmkit-0.5.0 → helmkit-0.5.2}/src/helmkit/py.typed +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import bisect
|
|
1
2
|
import multiprocessing
|
|
2
3
|
import re
|
|
3
4
|
import warnings
|
|
@@ -735,7 +736,42 @@ class Molecule:
|
|
|
735
736
|
|
|
736
737
|
def _sanitize(self) -> None:
|
|
737
738
|
"""Clean up the molecule by removing dummy atoms."""
|
|
738
|
-
|
|
739
|
+
pattern = Chem.MolFromSmarts("[#0]")
|
|
740
|
+
matches = self.mol.GetSubstructMatches(pattern)
|
|
741
|
+
atoms_to_delete = sorted({idx for match in matches for idx in match})
|
|
742
|
+
self.mol = Chem.DeleteSubstructs(self.mol, pattern)
|
|
743
|
+
|
|
744
|
+
def correction(offset: int, idx: int) -> int:
|
|
745
|
+
return bisect.bisect_left(atoms_to_delete, idx) - bisect.bisect_left(
|
|
746
|
+
atoms_to_delete, offset
|
|
747
|
+
)
|
|
748
|
+
|
|
749
|
+
for i, (m1, a1, m2, a2) in enumerate(self.bondlist):
|
|
750
|
+
offset1 = self.offset[m1]
|
|
751
|
+
offset2 = self.offset[m2]
|
|
752
|
+
self.bondlist[i][1] -= correction(offset1, offset1 + a1)
|
|
753
|
+
self.bondlist[i][3] -= correction(offset2, offset2 + a2)
|
|
754
|
+
|
|
755
|
+
self.offset = [
|
|
756
|
+
offset - sum(d < offset for d in atoms_to_delete) for offset in self.offset
|
|
757
|
+
]
|
|
758
|
+
|
|
759
|
+
@property
|
|
760
|
+
def bond_indices(self) -> List[int]:
|
|
761
|
+
return [
|
|
762
|
+
self.mol.GetBondBetweenAtoms(
|
|
763
|
+
self.offset[monomer1_idx] + atom1_idx,
|
|
764
|
+
self.offset[monomer2_idx] + atom2_idx,
|
|
765
|
+
).GetIdx()
|
|
766
|
+
for monomer1_idx, atom1_idx, monomer2_idx, atom2_idx in self.bondlist
|
|
767
|
+
]
|
|
768
|
+
|
|
769
|
+
@property
|
|
770
|
+
def monomer_indices(self) -> List[int]:
|
|
771
|
+
return [
|
|
772
|
+
bisect.bisect_right(self.offset, i) - 1
|
|
773
|
+
for i in range(self.mol.GetNumAtoms())
|
|
774
|
+
]
|
|
739
775
|
|
|
740
776
|
|
|
741
777
|
def _init_pool(monomer_df: MonomerLibrary):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|