ProLIF icon indicating copy to clipboard operation
ProLIF copied to clipboard

LigNetwork for molecules with more than 1 residue

Open misakadam97 opened this issue 3 years ago • 1 comments

I'm trying to visualize the interactions between a peptide ligand and a protein receptor with LigNetwork, but get "ValueError: No ring containing this atom index was found in the given molecule" when it's trying to find an atomindex in self._ring_info.AtomRings(). I think the issue is that _get_ring_centroid expects a "global" atom index, but _make_interactions gives a "local"/"residue" atom index. If i get rid of the residue name,-ids in the peptide ligand (w/ the 2 lines below l = u.atoms.select_atoms("segid B")) the code runs.

from prolif.plotting.network import LigNetwork import prolif as plf import MDAnalysis as mda from MDAnalysis.topology.guessers import guess_types

tp = 'AT1R-TRV026_from_TRV026-crystal_dh125.psf' tj = 'F1.nc'

u = mda.Universe(tp, tj) if not hasattr(u, "elements"): guessed_elements = guess_types(u.atoms.names) u.add_TopologyAttr('elements', guessed_elements)

l = u.atoms.select_atoms("segid B") #l.residues.resnames = np.array(["lig"]*len(l.residues.resnames)) #l.residues.resids = np.array([1]*len(l.residues.resids)) p = u.atoms.select_atoms("segid A") fp = plf.Fingerprint() fp.run(u.trajectory[::100], l, p) df = fp.to_dataframe(return_atoms=True)

lmol = plf.Molecule.from_mda(l) pmol = plf.Molecule.from_mda(p) net = LigNetwork.from_ifp(df, lmol, kind="aggregate", threshold=.3, rotation=270) net.display() 100%|██████████| 6/6 [00:10<00:00, 1.67s/it] /home/miska/anaconda3/envs/at2rt1/lib/python3.9/site-packages/pandas/core/algorithms.py:798: FutureWarning: In a future version, the Index constructor will not infer numeric dtypes when passed object-dtype sequences (matching Series behavior) uniques = Index(uniques) Traceback (most recent call last): File "/home/miska/anaconda3/envs/at2rt1/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3369, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 27, in <cell line: 27> net.display() File "/home/miska/anaconda3/envs/at2rt1/lib/python3.9/site-packages/prolif/utils.py", line 30, in wrapper return func(*args, **kwargs) File "/home/miska/anaconda3/envs/at2rt1/lib/python3.9/site-packages/prolif/plotting/network.py", line 692, in display html = self._get_html(**kwargs) File "/home/miska/anaconda3/envs/at2rt1/lib/python3.9/site-packages/prolif/plotting/network.py", line 544, in _get_html return self._HTML_TEMPLATE % dict(js=self._get_js(**kwargs)) File "/home/miska/anaconda3/envs/at2rt1/lib/python3.9/site-packages/prolif/plotting/network.py", line 520, in _get_js self._make_graph_data() File "/home/miska/anaconda3/envs/at2rt1/lib/python3.9/site-packages/prolif/plotting/network.py", line 506, in _make_graph_data self._make_interactions() File "/home/miska/anaconda3/envs/at2rt1/lib/python3.9/site-packages/prolif/plotting/network.py", line 446, in _make_interactions centroid = self._get_ring_centroid(lig_id) File "/home/miska/anaconda3/envs/at2rt1/lib/python3.9/site-packages/prolif/plotting/network.py", line 476, in _get_ring_centroid raise ValueError("No ring containing this atom index was found in " ValueError: No ring containing this atom index was found in the given molecule

misakadam97 avatar Apr 28 '22 23:04 misakadam97

Ah yes, the LigNetwork plot was initially designed with ligands containing a single residue in mind, so the only way to make it work for peptides is indeed to regroup all the residues as a single one.

cbouy avatar Apr 29 '22 00:04 cbouy

Will be fixed in release 2.0.0 coming soon

cbouy avatar Aug 13 '23 17:08 cbouy