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

Unable to read sdf file [BUG] #8

Closed
kexul opened this issue Feb 14, 2023 · 2 comments
Closed

Unable to read sdf file [BUG] #8

kexul opened this issue Feb 14, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@kexul
Copy link
Contributor

kexul commented Feb 14, 2023

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Load the files TAD-03001_minimised.zip
  2. Run the code
import BioSimSpace as BSS
mol = BSS.IO.readMolecules('TAD-03001_minimised.sdf')
  1. This is the exception that was raised / this is what went wrong.
Unable to read the file. Errors are below.



== /data/temp/TAD-03001_minimised.sdf ==

This file could not be parsed by any of the file parsers! It was recognised as a file of type sdf, but all parsers failed to parse this file. The errors from the parsers associated with the suffix sdf are printed below:

*-- Failed to parse '/data/temp/TAD-03001_minimised.sdf' with parser 'SDF'.
The file is not recognised as being of the required format.
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>                                                                                      │
│                                                                                                  │
│ ❱ 1 mola = BSS.IO.readMolecules('TAD-03001_minimised.sdf')                                       │
│   2                                                                                              │
│                                                                                                  │
│ /data/miniconda3/envs/openbiosim-dev/lib/python3.9/site-packages/BioSimSpace/IO/_io.py:528 in    │
│ readMolecules                                                                                    │
│                                                                                                  │
│    525 │   │   │   │   if _isVerbose():                                                          │
│    526 │   │   │   │   │   raise IOError(msg) from e0                                            │
│    527 │   │   │   │   else:                                                                     │
│ ❱  528 │   │   │   │   │   raise IOError(msg) from None                                          │
│    529 │                                                                                         │
│    530 │   return _System(system)                                                                │
│    531                                                                                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
OSError: Failed to read molecules from: ['TAD-03001_minimised.sdf']

Expected behavior
It should not raise an exception.

  • OS: Linux (centos)
  • Version of Python: 3.9
  • Version of sire: latest dev
@kexul kexul added the bug Something isn't working label Feb 14, 2023
@chryswoods
Copy link
Contributor

Thanks for reporting. The issue is that sire's SDF parser is expecting every molecule to end with a separator line ($$$$). Because this isn't present, it doesn't think that there are any SDF molecules in the file.

This is a bug, caused by my mis-reading of the specification. I'll fix it by assuming that there is only one molecule if we are missing the separator line.

For now, you can read your file by adding the separator to the end of your file. Just add $$$$ as the last line, e.g.

 36 69  1  0
 36 70  1  0
M  END
$$$$

chryswoods added a commit that referenced this issue Feb 14, 2023
@chryswoods chryswoods mentioned this issue Feb 14, 2023
@kexul
Copy link
Contributor Author

kexul commented Feb 14, 2023

Thanks! Adding $$$$ works!

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

No branches or pull requests

2 participants