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

re-implement residue.is_flexres_atom, and minor fixes #197

Merged
1 commit merged into from
Oct 22, 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
16 changes: 16 additions & 0 deletions meeko/linked_rdkit_chorizo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,22 @@ def flexibilize_sidechain(self, residue_id, mk_prep):
residue.molsetup,
root_atom_index=link_atoms[0],
)

molsetup = residue.molsetup
is_rigid_atom = [False for _ in molsetup.atoms]
graph = molsetup.flexibility_model["rigid_body_graph"]
root_body_idx = molsetup.flexibility_model["root"]
conn = molsetup.flexibility_model["rigid_body_connectivity"]
rigid_index_by_atom = molsetup.flexibility_model["rigid_index_by_atom"]
# from the root, use only the atom that is bonded to the only rotatable bond
print(graph)
print(rigid_index_by_atom)
print(len(rigid_index_by_atom))
for other_body_idx in graph[root_body_idx]:
root_link_atom_idx = conn[(root_body_idx, other_body_idx)][0]
for atom_idx, body_idx in rigid_index_by_atom.items():
if body_idx != root_body_idx or atom_idx == root_link_atom_idx:
residue.is_flexres_atom[atom_idx] = True
return

@staticmethod
Expand Down
7 changes: 4 additions & 3 deletions scripts/mk_prepare_receptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,9 @@ def get_args():

if args.write_pdbqt is not None:
if args.write_pdbqt:
if args.write_pdbqt.endswith(".pdbqt"):
fn_base = args.write_pdbqt.rstrip(".pdbqt")
if args.write_pdbqt[0].endswith(".pdbqt"):
# may need to suffix _rigid/_flex with flexres
fn_base = str(pathlib.Path(args.write_pdbqt[0]).with_suffix(""))
else:
fn_base = args.write_pdbqt[0]
else:
Expand Down Expand Up @@ -713,7 +714,7 @@ def warn_flexres_outside_box(chorizo, box_center, box_size):
if not res.is_movable:
continue
for atom in res.molsetup.atoms:
if not res.is_flexres_atom[atom.index]: # TODO: not implemented
if not res.is_flexres_atom[atom.index]:
continue
if gridbox.is_point_outside_box(atom.coord, box_center, box_size, spacing=1.0):
print(
Expand Down
5 changes: 4 additions & 1 deletion test/linked_rdkit_chorizo_creation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def test_flexres_pdbqt():
set_templates,
blunt_ends=[(":5", 0), (":18", 2)],
)
res11 = chorizo.residues[":11"]
assert sum(res11.is_flexres_atom) == 0
chorizo.flexibilize_sidechain(":11", mk_prep)
assert sum(res11.is_flexres_atom) == 9
rigid, flex_dict = PDBQTWriterLegacy.write_from_linked_rdkit_chorizo(chorizo)
nr_rigid_atoms = len(rigid.splitlines())
assert nr_rigid_atoms == 124
Expand Down Expand Up @@ -368,7 +371,7 @@ def test_altloc():
chem_templates,
mk_prep,
)
assert str(err_msg.value).startswith("Handle AltLocs")
assert "altloc" in str(err_msg.value).lower()

chorizo = LinkedRDKitChorizo.from_pdb_string(
pdb_text,
Expand Down
Loading