Open asiomchen opened 7 months ago
The following seems to work, the only caveat is that you'll need to run the analysis with n_jobs=1
:
import prolif as plf
import MDAnalysis as mda
from rdkit import Chem
from rdkit.Chem import AllChem
u = mda.Universe("mini_system.pdb", "mini_system.xtc")
ligand = u.select_atoms("resname LIG")
protein = u.select_atoms("not resname LIG")
protein.guess_bonds()
ligand.guess_bonds()
lig_template = Chem.MolFromSmiles("Cc1ncnc(C(=O)N2CCCCC2)c1[O-]")
original_from_mda = plf.Molecule.from_mda
def from_mda(atomgroup, **kwargs):
if atomgroup is ligand:
raw_mol = atomgroup.convert_to.rdkit(NoImplicit=False, **kwargs)
with plf.utils.catch_rdkit_logs():
mol = AllChem.AssignBondOrdersFromTemplate(lig_template, raw_mol)
return plf.Molecule(mol)
return original_from_mda(atomgroup, **kwargs)
plf.Molecule.from_mda = from_mda
And you'll have to lower the threshold in the lignetwork plot to 0.2
.
Not sure why your original solution doesn't work though...
Anyway, I've made a PR in MDAnalysis (https://github.com/MDAnalysis/mdanalysis/pull/4305) some time ago to allow bypassing the step that infers bond orders and charges and use your own template molecule as shown here, hopefully it can get reviewed soon so that we won't need this dirty workaround!
I'm trying to calculate ligand-aminoacid interaction from OpenMM simulation from pdb topology and xtc trajectory. Ligand structure is show below
But due to the use of pdb, MDAnalysis makes the bonds guess and it is not correct, leading to the structure below:
As a result salt bridge between wrong oxygen and arginine is detected
To fix that I was trying to just hardcode modification which is needed to fix bonding
This solution work well for visualization, and when used in
Molecule
like this:This code produces correct visuals:
But when used in
Fingerprint
it still detect wrong interaction, but this time with the good molecule visualizationSo my question is, @cbouy does more straightforward way to ensure good ligand bond orders exists?Or maybe you have some clues why my solution is not working? I believe that this could potentially be a good edition to prolif's functionality
Whole notebook and files are available as a issue.zip