Skip to content

Commit

Permalink
Merge pull request #289 from diogomart/minor_cleanup
Browse files Browse the repository at this point in the history
minor fixes and minor clean up
  • Loading branch information
diogomart authored Dec 17, 2024
2 parents 5727d7f + 2a756b0 commit c5e38dc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 41 deletions.
1 change: 1 addition & 0 deletions meeko/data/params/ad4_hb.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{"ad4_hb": [
{ "ad4_hb_hydrogen": false, "smarts": "[*]"},
{ "ad4_hb_hydrogen": true, "smarts": "[#1][#7,#8,#9,#15,#16]"},
{"ad4_hb_rij": 1.9, "ad4_hb_epsij": 5.0, "smarts": "[#8]"},
{"ad4_hb_rij": 1.9, "ad4_hb_epsij": 5.0, "smarts": "[#7;!+1;!+2;!$([#7X3v3][a]);!$([#7X3v3][#6X3v4])]"},
Expand Down
42 changes: 2 additions & 40 deletions meeko/molsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1903,45 +1903,6 @@ def get_smiles_and_order(self):
return smiles, order

# region Ring Construction
def _is_ring_aromatic(self, ring_atom_indices: list[(int, int)]):
"""
Determines whether a ring is aromatic.
Parameters
----------
ring_atom_indices: the atom indices in the ring.
Returns
-------
A boolean indicating whether this ring is aromatic.
"""
for atom_idx1, atom_idx2 in self.get_bonds_in_ring(ring_atom_indices):
bond = self.mol.GetBondBetweenAtoms(atom_idx1, atom_idx2)
if not bond.GetIsAromatic():
return False
return True

@staticmethod
def _construct_old_graph(atom_list: list[Atom]):
"""
To support older implementations of helper functions in Meeko, takes a list of atoms and uses it to create a
list of each atom's graph value, where the index of a graph in the list corresponds to the atom's atom_index.
Parameters
----------
atom_list: list[Atom]
A list of populated Atom objects.
Returns
-------
A dict mapping from atom index to lists of ints, where each list of ints represents the bonds from that
atom index to other atom indices.
"""
output_graph = {}
for atom in atom_list:
output_graph[atom.index] = atom.graph
return output_graph

def perceive_rings(self, keep_chorded_rings: bool, keep_equivalent_rings: bool):
"""
Uses Hanser-Jauffret-Kaufmann exhaustive ring detection to find the rings in the molecule
Expand All @@ -1957,7 +1918,8 @@ def perceive_rings(self, keep_chorded_rings: bool, keep_equivalent_rings: bool):
-------
None
"""
old_graph = self._construct_old_graph(self.atoms)

old_graph = {atom.index: atom.graph for atom in self.atoms}
hjk_ring_detection = utils.HJKRingDetection(old_graph)
rings = hjk_ring_detection.scan(keep_chorded_rings, keep_equivalent_rings)
for ring_atom_indices in rings:
Expand Down
2 changes: 1 addition & 1 deletion meeko/polymer.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def padder_from_dict(data):
def add_dict(self, data, overwrite=False):
bad_keys = set(data) - {"ambiguous", "residue_templates", "padders"}
if bad_keys:
raise ValueError("unexpected keys: {bad_keys}")
raise ValueError(f"unexpected keys: {bad_keys}")
new_ambiguous = data.get("ambiguous", {})
if overwrite:
self.ambiguous.update(new_ambiguous)
Expand Down

0 comments on commit c5e38dc

Please sign in to comment.