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

Open Babel wrapper can't deal with gzipped files #55

Closed
RMeli opened this issue Jul 28, 2021 · 0 comments
Closed

Open Babel wrapper can't deal with gzipped files #55

RMeli opened this issue Jul 28, 2021 · 0 comments

Comments

@RMeli
Copy link
Owner

RMeli commented Jul 28, 2021

Describe the bug

python -m spyrmsd with Open Babel backend for I/O does not work with gzipped files.

Traceback (most recent call last):
  File "/home/lina3015/.conda/envs/gsoc/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/lina3015/.conda/envs/gsoc/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/lina3015/.conda/envs/gsoc/lib/python3.6/site-packages/spyrmsd/__main__.py", line 33, in <module>
    ref = io.loadmol(args.reference)
  File "/home/lina3015/.conda/envs/gsoc/lib/python3.6/site-packages/spyrmsd/io.py", line 66, in loadmol
    mol = load(fname)
  File "/home/lina3015/.conda/envs/gsoc/lib/python3.6/site-packages/spyrmsd/optional/obabel.py", line 33, in load
    obmol = next(pybel.readfile(fmt, fname))
  File "/home/lina3015/.conda/envs/gsoc/lib/python3.6/site-packages/openbabel/pybel.py", line 159, in readfile
    raise ValueError("%s is not a recognised Open Babel format" % format)
ValueError: gz is not a recognised Open Babel format

To Reproduce

python -m spyrmsd reference.sdf.gz docking.sdf.gz

Expected behavior

python -m spyrmsd should work with compressed files since Open Babel can deal with those.

Environment

  • OS: CentOS Linux 8
  • Python: Python 3.6.13
  • Package Manager [e.g. pip, conda]: conda

Additional Context

For file.ext.gz, the following return gz as extension:

name, ext = os.path.splitext(fname)

File extensions are used as format string for pybel

and therefore lead to errors.

fmt = utils.molformat(fname)
obmol = next(pybel.readfile(fmt, fname))

The function

spyrmsd/spyrmsd/utils.py

Lines 30 to 32 in 00207e3

def molformat(fname: str) -> str:
"""
Extract an OpenBabel-friendly format from file name.

needs to deal with this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant