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

Interactions with a Mg atom #57

Closed
martutebon opened this issue Jun 11, 2022 · 1 comment · Fixed by #83
Closed

Interactions with a Mg atom #57

martutebon opened this issue Jun 11, 2022 · 1 comment · Fixed by #83
Labels
bug Something isn't working

Comments

@martutebon
Copy link

Hi,
Thank you very much for your work! Very useful piece of Software.

I am experiencing the following issue.
In my system there's a magnesium atom and the ligand is interacting with it.
The selections are working.

lig = u.select_atoms("resname LIG")
mg = u.select_atoms("resname MG")

Nevertheless, when I try to analyze the fingergerprints, I get:
AttributeError: No hydrogen atom could be found in the topology, but the converter requires all hydrogens to be explicit. You can use the parameter NoImplicit=False when using the converter to allow implicit hydrogens and disable inferring bond orders and charges. You can also use force=True to ignore this error.

ligand/protein and ligand/water interactions are working fine.

Am I doing something wrong?

Thank you very much!

@cbouy
Copy link
Member

cbouy commented Jun 13, 2022

Hi @martutebon and thank you!

Am I doing something wrong?

Nope! It's just that by default the RDKitConverter in MDAnalysis was set to automatically fail if a user is trying to convert a selection that doesn't have any hydrogen atom, since the RDKitConverter requires all hydrogen atoms to be explicit.
Since in your case it's normal that the Magnesium selection doesn't have any H atom, you'd have to pass force=True to the RDKitConverter.

I'm assuming you're doing the fingerprint analysis on a trajectory. Unfortunately the functionality to pass arguments to the RDKitConverter is not directly exposed when using fp.run, it's only available when you manually create a molecule with plf.Molecule.from_mda (which fp.run uses internally).
However here's a little "hack" to replace the plf.Molecule.from_mda function with one that automatically passes the force=True argument to the RDKitConverter:

import prolif as plf
import MDAnalysis as mda

def custom_from_mda(obj, selection=None, **kwargs):
     ag = obj.select_atoms(selection) if selection else obj.atoms
     assert ag.n_atoms > 0, "Empty atomgroup"
     mol = ag.convert_to.rdkit(force=True, **kwargs)
     return plf.Molecule(mol)

plf.Molecule.from_mda = custom_from_mda

# rests of your analysis script after this line

Then you should be able to use ProLIF as usual.
I'll try to add the possibility to pass arguments to the converter directly from fp.run in the future.

Tell me if that works for you.

@cbouy cbouy added the bug Something isn't working label Jun 13, 2022
@cbouy cbouy closed this as completed in #83 Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants