helmkit 0.5.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: helmkit
3
- Version: 0.5.1
3
+ Version: 0.5.2
4
4
  Summary: Parse HELM strings into RDKit molecules
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.11
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "helmkit"
3
- version = "0.5.1"
3
+ version = "0.5.2"
4
4
  description = "Parse HELM strings into RDKit molecules"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,3 +1,4 @@
1
+ import bisect
1
2
  import multiprocessing
2
3
  import re
3
4
  import warnings
@@ -739,11 +740,24 @@ class Molecule:
739
740
  matches = self.mol.GetSubstructMatches(pattern)
740
741
  atoms_to_delete = sorted({idx for match in matches for idx in match})
741
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
+
742
755
  self.offset = [
743
- offset - sum(d <= offset for d in atoms_to_delete) for offset in self.offset
756
+ offset - sum(d < offset for d in atoms_to_delete) for offset in self.offset
744
757
  ]
745
758
 
746
- def get_broken_bond_idx(self) -> List[int]:
759
+ @property
760
+ def bond_indices(self) -> List[int]:
747
761
  return [
748
762
  self.mol.GetBondBetweenAtoms(
749
763
  self.offset[monomer1_idx] + atom1_idx,
@@ -752,6 +766,13 @@ class Molecule:
752
766
  for monomer1_idx, atom1_idx, monomer2_idx, atom2_idx in self.bondlist
753
767
  ]
754
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
+ ]
775
+
755
776
 
756
777
  def _init_pool(monomer_df: MonomerLibrary):
757
778
  global _monomer_df
@@ -196,7 +196,7 @@ wheels = [
196
196
 
197
197
  [[package]]
198
198
  name = "helmkit"
199
- version = "0.5.1"
199
+ version = "0.5.2"
200
200
  source = { editable = "." }
201
201
  dependencies = [
202
202
  { name = "rdkit" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes