Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optionally allow breaking macrocycle bonds with A atom types #106

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions meeko/macrocycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class FlexMacrocycle:
def __init__(self, min_ring_size=7, max_ring_size=33, double_bond_penalty=50, max_breaks=4):
def __init__(self, min_ring_size=7, max_ring_size=33, double_bond_penalty=50, max_breaks=4, allow_A=False):
"""Initialize macrocycle typer.

Args:
Expand All @@ -25,6 +25,7 @@ def __init__(self, min_ring_size=7, max_ring_size=33, double_bond_penalty=50, ma
# accept also double bonds (if nothing better is found)
self._double_bond_penalty = double_bond_penalty
self.max_breaks = max_breaks
self.allow_A = allow_A

self.setup = None
self.breakable_rings = None
Expand Down Expand Up @@ -81,10 +82,12 @@ def _score_bond(self, bond):
bond_order = self.setup.bond[bond]['bond_order']
if bond_order not in [1, 2, 3]: # aromatic, double, made rigid explicitly (order=1.1 from --rigidify)
return -1
if self.setup.atom_type[atom_idx1] != "C":
return -1
if self.setup.atom_type[atom_idx2] != "C":
return -1
for i in (atom_idx1, atom_idx2):
if self.setup.atom_type[i] != "C":
if self.allow_A and self.setup.atom_type[i] == "A":
score -= 10
else:
return -1
# triple bond tolerated but not preferred (TODO true?)
if bond_order == 3:
score -= 30
Expand Down
6 changes: 5 additions & 1 deletion meeko/preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self,
keep_chorded_rings=False,
keep_equivalent_rings=False,
double_bond_penalty=50,
macrocycle_allow_A=False,
rigidify_bonds_smarts=[],
rigidify_bonds_indices=[],
input_atom_params=None,
Expand All @@ -83,6 +84,7 @@ def __init__(self,
self.keep_chorded_rings = keep_chorded_rings
self.keep_equivalent_rings = keep_equivalent_rings
self.double_bond_penalty = double_bond_penalty
self.macrocycle_allow_A = macrocycle_allow_A
self.rigidify_bonds_smarts = rigidify_bonds_smarts
self.rigidify_bonds_indices = rigidify_bonds_indices

Expand Down Expand Up @@ -126,8 +128,10 @@ def __init__(self,
self.remove_smiles = remove_smiles

self._bond_typer = BondTyperLegacy()

self._macrocycle_typer = FlexMacrocycle(
self.min_ring_size, self.max_ring_size, self.double_bond_penalty)
self.min_ring_size, self.max_ring_size, self.double_bond_penalty,
allow_A=self.macrocycle_allow_A)
self._flex_builder = FlexibilityBuilder()
self._water_builder = HydrateMoleculeLegacy()
self._classes_setup = {Chem.rdchem.Mol: RDKitMoleculeSetup}
Expand Down
2 changes: 2 additions & 0 deletions scripts/mk_prepare_ligand.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def cmd_lineparser():
action="store_true", help="equivalent rings have the same size and neighbors")
config_group.add_argument("--min_ring_size", dest="min_ring_size",
type=int, help="min nr of atoms in ring for opening")
config_group.add_argument("--macrocycle_allow_A", action="store_true",
help="allow bond break with atom type A, retyped as C")
config_group.add_argument("-w", "--hydrate", dest="hydrate",
action="store_true", help="add water molecules for hydrated docking")
config_group.add_argument( "--charge_model", choices=["gasteiger", "zero", "from_mol2"],
Expand Down
Loading