Skip to content

Commit

Permalink
Merge pull request #56 from openforcefield/pfizer
Browse files Browse the repository at this point in the history
use Pfizer minimial fragment in WBO fragmentation
  • Loading branch information
ChayaSt authored Feb 7, 2020
2 parents 5c6698c + 99db127 commit 5e7dc84
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions fragmenter/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ def _build_fragment(self, bond_tuple, heuristic='path_length', cap=True, **kwarg
if 'heuristic' not in self._options:
self._options['heuristic'] = heuristic
atoms, bonds = self._get_torsion_quartet(bond_tuple)
atom_map_idx, bond_tuples = self._get_ring_and_fgroups(atoms, bonds, central_bond=bond_tuple)
atom_map_idx, bond_tuples = self._get_ring_and_fgroups(atoms, bonds)

# bond = self.get_bond(bond_tuple=bond_tuple)
#
Expand Down Expand Up @@ -1264,14 +1264,12 @@ def _get_torsion_quartet(self, bond):

return atom_map_idx, bond_tuples

def _get_ring_and_fgroups(self, atoms, bonds, central_bond):
def _get_ring_and_fgroups(self, atoms, bonds):
"""
Keep ortho substituents
Parameters
----------
atoms : set ints atom indices
bonds: set of bond tuples
central_bond: bond tuple
torions_quartet : set of set of ints and set of bond tuples
Returns
-------
Expand All @@ -1295,24 +1293,24 @@ def _get_ring_and_fgroups(self, atoms, bonds, central_bond):
new_atoms.update(self.ring_systems[ring_idx][0])
new_bonds.update(self.ring_systems[ring_idx][1])

# Now check for ortho substituents to any bond bonded to central bond
# Now check for ortho substituents to any bond in the fragment
for bond in bonds:
# Only add ortho if the bond is bonded to the central bond to avoid having meta substituents come along without first evaluating if they are needed
if bond[0] in central_bond or bond[1] in central_bond:
oe_bond = self.get_bond(bond)
a1 = oe_bond.GetBgn()
a2 = oe_bond.GetEnd()
if not oe_bond.IsInRing() and (a1.IsInRing() or a2.IsInRing()) and (not a1.IsHydrogen() and not a2.IsHydrogen()):
if a1.IsInRing():
ring_idx = a1.GetData('ringsystem')
elif a2.IsInRing():
ring_idx = a2.GetData('ringsystem')
else:
print('Only one atom should be in a ring when checking for ortho substituents')
ortho = self._find_ortho_substituent(ring_idx=ring_idx, rot_bond=bond)
if ortho:
new_atoms.update(ortho[0])
new_bonds.update(ortho[1])
oe_bond = self.get_bond(bond)
a1 = oe_bond.GetBgn()
a2 = oe_bond.GetEnd()
if not oe_bond.IsInRing() and (a1.IsInRing() or a2.IsInRing()) and (
not a1.IsHydrogen() and not a2.IsHydrogen()):
if a1.IsInRing():
ring_idx = a1.GetData('ringsystem')
elif a2.IsInRing():
ring_idx = a2.GetData('ringsystem')
else:
print('Only one atom should be in a ring when checking for ortho substituents')
ortho = self._find_ortho_substituent(ring_idx=ring_idx, rot_bond=bond)
print('ortho: {}'.format(ortho))
if ortho:
new_atoms.update(ortho[0])
new_bonds.update(ortho[1])
atoms.update(new_atoms)
bonds.update(new_bonds)

Expand Down

0 comments on commit 5e7dc84

Please sign in to comment.