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

Sire::IO::SDF can't handle a stereo value of 3 #270

Open
avnikonenko opened this issue Dec 19, 2024 · 3 comments
Open

Sire::IO::SDF can't handle a stereo value of 3 #270

avnikonenko opened this issue Dec 19, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@avnikonenko
Copy link

avnikonenko commented Dec 19, 2024

Hello!
I am just starting to work with BioSimSpace and got a problem with reading one of my SDF files.
I run the simplest code:

import BioSimSpace as BSS
lig = BSS.IO.readMolecules('ligand.sdf')[0]

I consistently get the following error:

INFO:numexpr.utils:Note: NumExpr detected 64 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 16.
INFO:numexpr.utils:NumExpr defaulting to 16 threads.
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│a3fe/test/script.py:2   │
│ in <module>                                                                                      │
│                                                                                                  │
│   1 import BioSimSpace as BSS                                                                    │
│ ❱ 2 lig = BSS.IO.readMolecules('ligand.sdf')[0]                                                  │
│   3 #lig = BSS.IO.readMolecules("ligand_benzene.sdf")[0]                                         │
│   4 #lig_param = BSS.Parameters.openff_unconstrained_2_0_0(lig).getMolecule()                    │
│   5 #BSS.IO.saveMolecules("lig_param", lig_param, ["prm7", "rst7"])                              │
│                                                                                                  │
│ Miniconda3/envs/a3fe/lib/python3.12/site-packages/BioSimSpace/I │
│ O/_io.py:556 in readMolecules                                                                    │
│                                                                                                  │
│    553 │   │   │   │   if _isVerbose():                                                          │
│    554 │   │   │   │   │   raise IOError(msg) from e0                                            │
│    555 │   │   │   │   else:                                                                     │
│ ❱  556 │   │   │   │   │   raise IOError(msg) from None                                          │
│    557 │                                                                                         │
│    558 │   # Add a file format shared property.                                                  │
│    559 │   prop = property_map.get("fileformat", "fileformat")                                   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

While when I try to read a benzene sdf file (which was obtained the same way as the ligand.sdf, RDKit version 2024.03.2) everything works just fine.

I have attached my input files: ligand.sdf (where the error occurs) and ligand_benzene.sdf (works fine).
ligands.zip

OS: Rocky Linux 8.9 (Green Obsidian)
Version of Python: 3.12.8
Version of BioSimSpace: 2024.4.0.dev+34.g357beaf2

Could you help me please?
Thank you!

@avnikonenko avnikonenko added the bug Something isn't working label Dec 19, 2024
@fjclark
Copy link
Collaborator

fjclark commented Dec 19, 2024

Hi!

To get a more helpful error message, you can set

export BSS_VERBOSE_ERRORS=1 

before running your script.

This shows that the problem is invalid stereochemistry for the double bond between atoms 21 and 22

OSError: SireError::io_error: Cannot load the molecules: Invalid stereo type '3'. Should be an integer in [-1, 0, 1, 6]

3 specifies either cis or trans, but if set to 0 the stereochemistry is defined by the input coordinates.

Specifying the stereochemistry by setting this to 0 allows your molecule to be read in.

@lohedges
Copy link
Contributor

Thanks, @fjclark. I was just typing the same thing and you beat me to it. Just to say that you can also enable verbose errors per script by adding BSS.setVerbose(True) at the start. By default, we only print summary messages due to inconsistencies in formatting and verbosity by the underlying engines.

I'll move this over to the Sire issue since it's ultimately an issue related to the SDF parser. I think that we should just parse the value of 3 since this would only (really) be used if we were to convert the molecule to another format, e.g. RDKit. If we were to just ignore or set to zero then we wouldn't guarantee round-trip self-consistency, i.e. converting from Sire to RDKit and back again.

Just to note that we are mostly away on holidays now. I'll pick this up again when I'm back in the New Year.

Cheers.

@lohedges lohedges changed the title OSError: Failed to read molecules from: ['ligand.sdf'] Sire::IO::SDF can't handle a stereo value of 3 Dec 19, 2024
@lohedges lohedges transferred this issue from OpenBioSim/biosimspace Dec 19, 2024
@lohedges lohedges self-assigned this Dec 19, 2024
@avnikonenko
Copy link
Author

Thanks to both of you!

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

3 participants