chemosim-lab / ProLIF

Interaction Fingerprints for protein-ligand complexes and more
https://prolif.readthedocs.io
Apache License 2.0
337 stars 66 forks source link

Saving position of ligand interactor on metadata #182

Closed jparcon closed 4 months ago

jparcon commented 6 months ago

I guess this is out of the scope of fingerprinting molecular interactions, but maybe it is useful to extend the capabilities of the software.

Would it be feasible for future releases to save the 3D coordinates in space of the ligand atomic interactors on the ifp metadata? I'm thinking on results from docking, and getting interaction "hot spots" on ligand positions by clustering in space ligand interactors of the same type that arise on multiple different ligands.

cbouy commented 5 months ago

It's a relatively easy post-processing step to do once you've generated the IFP metadata which contains atom indices, from there you just have to extract the coordinates from the corresponding molecules. While I agree that it can be useful it's a bit too far from the "fingerprint" scope, so I'd say it's quite unlikely to happen.

jparcon commented 5 months ago

Ok. I just post a simple code to extract ligand atomic positions for each interaction:

for i, frame_ifp in fp.ifp.items():
    print("pose =", i)
    for (ligres, protres), residue_ifp in frame_ifp.items():
        for int_name, metadata_tuple in residue_ifp.items():
            for metadata in metadata_tuple:
                prot_atoms = ",".join([protein_mol.GetAtomWithIdx(x).GetMonomerInfo().GetName()
                                      for x in metadata["parent_indices"]["protein"]])
                print("  interaction =", (str(protres), int_name, prot_atoms.replace(" ", "")))
                lig_atom_ids = [x for x in metadata["parent_indices"]["ligand"]]
                for lig_atom_id in lig_atom_ids:
                    lig_atom_name = pose_iterable[i].GetAtomWithIdx(lig_atom_id).GetMonomerInfo().GetName()
                    pos = pose_iterable[i].GetConformer().GetAtomPosition(lig_atom_id)
                    print("    lig atom =", lig_atom_name, lig_atom_id, (pos.x, pos.y, pos.z))