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

Implement Saturated Ring Sampling Conformation Feature #34

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1ede47a
Implement Saturated Ring Sampling Conformation Feature
Feriolet May 11, 2024
99c5fc8
Change [id for id in atomIds] to atomIds in GetConformerRMSFromAtomIds
Feriolet May 11, 2024
e474dc4
Type hints for created functions
Feriolet May 11, 2024
d763851
Type hints for created functions
Feriolet May 11, 2024
9fb8c35
Type hints for created functions
Feriolet May 11, 2024
4ff1122
Explicitly print error message if PDBQTWriterLegacy can't generate pdbqt
Feriolet May 11, 2024
8671e46
Fix code according to reviews
Feriolet May 13, 2024
999fe40
Fix where arr is not truncated to surviving cids for nkeep_conf
Feriolet May 13, 2024
3efb624
remove hard coded nkeep_conf=1
Feriolet May 13, 2024
3b04c35
Changing any to all to reflect that all atom should be sp3 in aring
Feriolet May 13, 2024
cfea4f9
Fix based on reviews
Feriolet May 13, 2024
9af0c2a
fix arr for keep_nconf
Feriolet May 14, 2024
b214983
clean_up
Feriolet May 14, 2024
b1ae4b0
Add substituent index to saturated ring index
Feriolet May 15, 2024
105223b
fix indexing
Feriolet May 25, 2024
4bb4515
filter rms threshold until all matrix > rms
Feriolet May 27, 2024
a2c28f9
accomodate when conformer with max number of low rms is also the conf…
Feriolet May 27, 2024
b28dae4
remove debugging code
Feriolet May 27, 2024
558541d
calculate keep_nconf based on ring num and size
Feriolet May 29, 2024
5ce28fc
improve find_saturated_ring_with_substituent and remove hard coded co…
Feriolet May 29, 2024
6f1e015
remove iterative procedure
Feriolet May 30, 2024
66ddfe3
fix mk_prepare_ligand to prepare ligand if some confomers are valid
Feriolet Jun 7, 2024
1389e70
Merge branch 'ci-lab-cz:master' into ring_conformer
Feriolet Jul 26, 2024
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
Prev Previous commit
Next Next commit
Fix based on reviews
  • Loading branch information
Feriolet committed May 13, 2024
commit cfea4f9bbfe0c87ca9675684c93deb6cc9438221
23 changes: 9 additions & 14 deletions easydock/preparation_for_docking.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def GetConformerRMSMatrixForSaturatedRingMolecule(mol: Chem.Mol, atomIds:list[li
"""

cmat_list = []
total_ring_atoms = sum([len(atom_in_ring) for atom_in_ring in atomIds])
for atom_id_in_ring in atomIds:
# if necessary, align the conformers
# Note: the reference conformer is always the first one
Expand All @@ -162,11 +163,10 @@ def GetConformerRMSMatrixForSaturatedRingMolecule(mol: Chem.Mol, atomIds:list[li
for j in range(1, i):
cmat_per_ring.append(GetConformerRMSFromAtomIds(mol, confIds[i], confIds[j], atomIds=atom_id_in_ring, prealigned=True))

cmat_list.append(np.array(cmat_per_ring))
cmat_list.append(np.square(np.array(cmat_per_ring))*len(atom_id_in_ring))

cmat_list_array = np.array(cmat_list)

return list(np.mean(cmat_list_array, axis=0))
return list(np.sqrt(np.sum(cmat_list_array, axis=0)/total_ring_atoms))


def mol_embedding_3d(mol: Chem.Mol, seed: int=43) -> Chem.Mol:
Expand All @@ -176,7 +176,7 @@ def find_saturated_ring(mol: Chem.Mol) -> list[list[int]]:
saturated_ring_list = []
for ring in ssr:
is_atom_saturated_array = [mol.GetAtomWithIdx(atom_id).GetHybridization() == Chem.HybridizationType.SP3 for atom_id in ring]
if all(is_atom_saturated_array):
if any(is_atom_saturated_array):
saturated_ring_list.append(ring)
return saturated_ring_list

Expand Down Expand Up @@ -236,21 +236,16 @@ def gen_ids(ids: int) -> Iterator[int]:
if mol.GetNumConformers() == 1:
return mol

if keep_nconf:
if mol.GetNumConformers() <= keep_nconf:
return mol

cids = [c.GetId() for c in mol.GetConformers()]
arr = arr[np.ix_(cids, cids)]

if keep_nconf and mol.GetNumConformers() > keep_nconf:
arr = arr[np.ix_(keep_ids, keep_ids)]
cl = AgglomerativeClustering(n_clusters=keep_nconf, linkage='complete', metric='precomputed').fit(arr)

keep_ids = []
keep_ids_nconf_filter = []
for i in set(cl.labels_):
ids = np.where(cl.labels_ == i)[0]
j = arr[np.ix_(ids, ids)].mean(axis=0).argmin()
keep_ids.append(cids[j])
remove_ids = set(cids) - set(keep_ids)
keep_ids_nconf_filter.append(cids[j])
remove_ids = set(keep_ids) - set(keep_ids_nconf_filter)

for cid in sorted(remove_ids, reverse=True):
mol.RemoveConformer(cid)
Expand Down