LBC-LNBio / pyKVFinder

pyKVFinder: Python-C parallel KVFinder
https://lbc-lnbio.github.io/pyKVFinder/
GNU General Public License v3.0
19 stars 10 forks source link

[Bug]: help me understand use of pyKVFinder #61

Closed pippo1990 closed 11 months ago

pippo1990 commented 11 months ago

Bug summary

In pyKVFinder/pyKVFinder/main.py I have as an example of how to run it:

>>> import os
>>> import pyKVFinder
>>> pdb = os.path.join(os.path.dirname(pyKVFinder.__file__), 'data', 'tests', '1FMO.pdb')
>>> results = pyKVFinder.run_workflow(pdb)
>>> results..... (result.export() , results.results.cavities etc etc )

and this works fine with me; but then I have multiple instances of :

>>> from pyKVFinder import pyKVFinder
>>> import os
>>> pdb = os.path.join(os.path.dirname(pyKVFinder.__file__), 'data', 'tests', '1FMO.pdb')
>>> results = pyKVFinder(pdb)
>>> results.export()

and this fails to me with : ImportError: cannot import name 'pyKVFinder' from 'pyKVFinder'

what am I doing wrong ?

Code for reproduction

>>> from pyKVFinder import pyKVFinder
>>> import os
>>> pdb = os.path.join(os.path.dirname(pyKVFinder.__file__), 'data', 'tests', '1FMO.pdb')
>>> results = pyKVFinder(pdb)
>>> results.export()

Actual outcome

ImportError: cannot import name 'pyKVFinder' from 'pyKVFinder'

Expected outcome

run flawless like with:

>>> import os
 >>> import pyKVFinder
 >>> pdb = os.path.join(os.path.dirname(pyKVFinder.__file__), 'data', 'tests', '1FMO.pdb')
 >>> results = pyKVFinder.run_workflow(pdb)
 >>> results

Additional information

No response

Operating system

No response

Python version

No response

pyKVFinder Version

0.6.1

Numpy Version

No response

Jupyter version

No response

Installation

pip

jvsguerra commented 11 months ago

Hi @pippo1990,

It seems like you're encountering an ImportError because you're trying to import the pyKVFinder module incorrectly. To run the cavity detection workflow, you should import it as follows:

from pyKVFinder import run_workflow

The pyKVFinder module itself doesn't exist, which is why you're getting the ImportError.

Once you've imported run_workflow correctly, you can use it in your code as shown below:

import os
import pyKVFinder
from pyKVFinder import run_workflow

pdb = os.path.join(os.path.dirname(pyKVFinder.__file__), 'data', 'tests', '1FMO.pdb')
results = run_workflow(pdb)
results.export()

This should allow you to run the cavity detection workflow without any issues.

For more detailed information on how to use pyKVFinder and its features, please refer to the official tutorial: pyKVFinder Tutorial.

If you encounter any further issues or have additional questions, please feel free to ask for assistance.

pippo1990 commented 11 months ago

Hi @jvsguerra , this is what I expected, the :

>>> from pyKVFinder import pyKVFinder
>>> import os
>>> pdb = os.path.join(os.path.dirname(pyKVFinder.__file__), 'data', 'tests', '1FMO.pdb')
>>> results = pyKVFinder(pdb)
>>> results.export()

is in your main.py code :

https://github.com/LBC-LNBio/pyKVFinder/blob/e1a790259374068c59f4329f48a28a2449cf6f7c/pyKVFinder/main.py#L472

https://github.com/LBC-LNBio/pyKVFinder/blob/e1a790259374068c59f4329f48a28a2449cf6f7c/pyKVFinder/main.py#L516

https://github.com/LBC-LNBio/pyKVFinder/blob/e1a790259374068c59f4329f48a28a2449cf6f7c/pyKVFinder/main.py#L571

https://github.com/LBC-LNBio/pyKVFinder/blob/e1a790259374068c59f4329f48a28a2449cf6f7c/pyKVFinder/main.py#L634

I dont know how to issue a pull request though, just to let you Know that your documentation contain bugs

Cheers P.

jvsguerra commented 11 months ago

Thank you, @pippo1990, for bringing this to my attention.

I appreciate your willingness to contribute to improving the documentation. These outdated code snippets can indeed be confusing for users, so it's crucial to keep our documentation accurate and up to date.

No worries. I've opened and merged PR #62 to address these inconsistencies.

If you encounter any further issues or have additional questions, please feel free to ask for assistance.

pippo1990 commented 11 months ago

👍

jvsguerra commented 11 months ago

@pippo1990, I am closing this issue for now. If you feel that the issue is still relevant or have any further questions, please feel free to re-open it and provide any additional information that may be helpful in resolving the issue.