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

TypeError: Fingerprint.to_dataframe() got an unexpected keyword argument 'return_atoms' #181

Closed theabhijitdn closed 6 months ago

theabhijitdn commented 6 months ago

sudo pip install rdkit prolif Installing collected packages: rdkit, prolif Successfully installed prolif-2.0.1 rdkit-2023.9.3

Code: import prolif as plf import MDAnalysis as mda from MDAnalysis.coordinates import PDB from prolif.plotting.network import LigNetwork abc = "reference_ligand"

Load protein

prot = mda.Universe("pro.pdb") prot = plf.Molecule.from_mda(prot) prot.n_residues

Load ligands

lig_suppl = list(plf.sdf_supplier(f'{abc}.sdf'))

lig_suppl = list(plf.molecule.mol2_supplier('KM07672_ADT.mol2'))

Generate fingerprint

fp = plf.Fingerprint() fp.run_from_iterable(lig_suppl, prot) results_df = fp.to_dataframe(return_atoms=True)

Save results dataframe as CSV

results_df.to_csv(f'{abc}.csv', index=False)

Generate LigNetwork

net = LigNetwork.from_ifp(results_df, lig_suppl[0], kind="frame", frame=0, rotation=270)

Save LigNetwork display as HTML

html_content = net.display()._reprhtml() with open(f'{abc}network_image.html', 'w') as html_file: html_file.write(html_content)

gives 100%|█████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 29.70it/s] Traceback (most recent call last): File "/mnt/d/#cds/works9-Prolif-Archived2/Prolif1.0.py", line 18, in results_df = fp.to_dataframe(return_atoms=True) TypeError: Fingerprint.to_dataframe() got an unexpected keyword argument 'return_atoms'

cbouy commented 6 months ago

Hi,

ProLIF v2 contains some breaking changes compared to the syntax in v1 (which you use in your script). Quite a few things have changed since then, so please refer to the latest tutorials.

Feel free to reopen this issue if you have other related questions

theabhijitdn commented 6 months ago

Thanks it is working. Sharing the corrected code for the larger interest

import prolif as plf import MDAnalysis as mda from MDAnalysis.coordinates import PDB from prolif.plotting.network import LigNetwork

Load protein

prot = mda.Universe("pro.pdb") prot = plf.Molecule.from_mda(prot) prot.n_residues

Load ligands

lig_suppl = list(plf.sdf_supplier('reference_ligand.sdf'))

lig_suppl = list(plf.molecule.mol2_supplier('KM07672_ADT.mol2'))

Generate fingerprint

fp = plf.Fingerprint() fp.run_from_iterable(lig_suppl, prot) results_df = fp.to_dataframe()

Save results dataframe as CSV

results_df.to_csv('results.csv', index=False)

Generate LigNetwork

net = fp.plot_lignetwork(lig_suppl[0], kind="frame", frame=0)

Save LigNetwork display as HTML

html_content = net._reprhtml() with open("network.html", "w") as f: f.write(html_content)