Skip to content

Windows + RDKit: BaseFeatures.fdef and .sdf reading errors #8

Description

@jacrossley

Hi,

I'm running into some issues on Windows after following the installation instructions. See the output of pytest below:

`(automartiniM3) C:\Users\Joel\Automartini_M3>pytest -v
================================================= test session starts =================================================
platform win32 -- Python 3.8.20, pytest-8.3.4, pluggy-1.5.0 -- C:\Users\Joel\anaconda3\envs\automartiniM3\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\Joel\Automartini_M3
configfile: pyproject.toml
testpaths: auto_martiniM3/tests
collected 0 items / 2 errors

======================================================= ERRORS ========================================================
_________________________________ ERROR collecting auto_martiniM3/tests/test_basic.py _________________________________
auto_martiniM3\tests\test_basic.py:10: in <module>
    import auto_martiniM3
..\anaconda3\envs\automartiniM3\lib\site-packages\auto_martiniM3\__init__.py:30: in <module>
    from . import solver, topology
..\anaconda3\envs\automartiniM3\lib\site-packages\auto_martiniM3\solver.py:30: in <module>
    from . import optimization, output, topology
..\anaconda3\envs\automartiniM3\lib\site-packages\auto_martiniM3\optimization.py:33: in <module>
    from . import topology # AutoM3 change
..\anaconda3\envs\automartiniM3\lib\site-packages\auto_martiniM3\topology.py:40: in <module>
    factory = ChemicalFeatures.BuildFeatureFactory(fdefName)
E   OSError: File: C:/Users/Joel/anaconda3/envs/automartiniM3/Library\share/RDKit\Data\BaseFeatures.fdef could not be opened.
________________________________ ERROR collecting auto_martiniM3/tests/test_version.py ________________________________
auto_martiniM3\tests\test_version.py:5: in <module>
    import auto_martiniM3
..\anaconda3\envs\automartiniM3\lib\site-packages\auto_martiniM3\__init__.py:30: in <module>
    from . import solver, topology
..\anaconda3\envs\automartiniM3\lib\site-packages\auto_martiniM3\solver.py:30: in <module>
    from . import optimization, output, topology
..\anaconda3\envs\automartiniM3\lib\site-packages\auto_martiniM3\optimization.py:33: in <module>
    from . import topology # AutoM3 change
..\anaconda3\envs\automartiniM3\lib\site-packages\auto_martiniM3\topology.py:40: in <module>
    factory = ChemicalFeatures.BuildFeatureFactory(fdefName)
E   OSError: File: C:/Users/Joel/anaconda3/envs/automartiniM3/Library\share/RDKit\Data\BaseFeatures.fdef could not be opened.
=============================================== short test summary info ===============================================
ERROR auto_martiniM3/tests/test_basic.py - OSError: File: C:/Users/Joel/anaconda3/envs/automartiniM3/Library\share/RDKit\Data\BaseFeatures.fdef could not be o...
ERROR auto_martiniM3/tests/test_version.py - OSError: File: C:/Users/Joel/anaconda3/envs/automartiniM3/Library\share/RDKit\Data\BaseFeatures.fdef could not be o...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================== 2 errors in 0.63s ==================================================`

After some googling it seems the BaseFeatures.fdef could not be opened might be specific to the Windows conda-forge build of RDKit (see rdkit/rdkit#7803). I downgraded from 2024.03.5 to 2024.03.4 and managed to fix the issue, but now i get the following:

(automartiniM3) C:\Users\Joel\Automartini_M3>pytest -v auto_martiniM3\tests
============================================================================= test session starts =============================================================================
platform win32 -- Python 3.8.20, pytest-8.3.4, pluggy-1.5.0 -- C:\Users\Joel\anaconda3\envs\automartiniM3\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\Joel\Automartini_M3
configfile: pyproject.toml
collected 7 items

auto_martiniM3/tests/test_basic.py::test_auto_martini_imported PASSED                                                                                                    [ 14%]
auto_martiniM3/tests/test_basic.py::test_connection_to_ALOGPS[CC(=O)OC1=CC=CC=C1C(=O)O] PASSED                                                                           [ 28%]
auto_martiniM3/tests/test_basic.py::test_auto_martini_run_smiles[CC(=O)OC1=CC=CC=C1C(=O)O-ASP-5] PASSED                                                                  [ 42%]
auto_martiniM3/tests/test_basic.py::test_auto_martini_run_smiles[CCC-PRO-1] PASSED                                                                                       [ 57%]
auto_martiniM3/tests/test_basic.py::test_auto_martini_run_sdf[sdf_file0-BENZ-3] FAILED                                                                                   [ 71%]
auto_martiniM3/tests/test_basic.py::test_auto_martini_run_sdf[sdf_file1-IBUP-6] FAILED                                                                                   [ 85%]
auto_martiniM3/tests/test_version.py::test_auto_martini_version PASSED                                                                                                   [100%]

================================================================================== FAILURES ===================================================================================
_________________________________________________________________ test_auto_martini_run_sdf[sdf_file0-BENZ-3] _________________________________________________________________

sdf_file = WindowsPath('tests/files/benzene.sdf'), name = 'BENZ', num_beads = 3

    @pytest.mark.parametrize(
        "sdf_file,name,num_beads",
        [
            (dpath / "benzene.sdf", "BENZ", 3),
            (dpath / "ibuprofen.sdf", "IBUP", 6)
        ],
    )

    def test_auto_martini_run_sdf(sdf_file: str, name:str, num_beads: int):
>       mol = auto_martiniM3.topology.gen_molecule_sdf(str(sdf_file))

auto_martiniM3\tests\test_basic.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

sdf = 'tests\\files\\benzene.sdf'

    def gen_molecule_sdf(sdf):
        """Generate mol object from SD file"""
        logger.debug("Entering gen_molecule_sdf()")
>       suppl = Chem.SDMolSupplier(sdf)
E       OSError: File error: Bad input file tests\files\benzene.sdf

..\anaconda3\envs\automartiniM3\lib\site-packages\auto_martiniM3\topology.py:120: OSError
_________________________________________________________________ test_auto_martini_run_sdf[sdf_file1-IBUP-6] _________________________________________________________________

sdf_file = WindowsPath('tests/files/ibuprofen.sdf'), name = 'IBUP', num_beads = 6

    @pytest.mark.parametrize(
        "sdf_file,name,num_beads",
        [
            (dpath / "benzene.sdf", "BENZ", 3),
            (dpath / "ibuprofen.sdf", "IBUP", 6)
        ],
    )

    def test_auto_martini_run_sdf(sdf_file: str, name:str, num_beads: int):
>       mol = auto_martiniM3.topology.gen_molecule_sdf(str(sdf_file))

auto_martiniM3\tests\test_basic.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

sdf = 'tests\\files\\ibuprofen.sdf'

    def gen_molecule_sdf(sdf):
        """Generate mol object from SD file"""
        logger.debug("Entering gen_molecule_sdf()")
>       suppl = Chem.SDMolSupplier(sdf)
E       OSError: File error: Bad input file tests\files\ibuprofen.sdf

..\anaconda3\envs\automartiniM3\lib\site-packages\auto_martiniM3\topology.py:120: OSError
=========================================================================== short test summary info ===========================================================================
FAILED auto_martiniM3/tests/test_basic.py::test_auto_martini_run_sdf[sdf_file0-BENZ-3] - OSError: File error: Bad input file tests\files\benzene.sdf
FAILED auto_martiniM3/tests/test_basic.py::test_auto_martini_run_sdf[sdf_file1-IBUP-6] - OSError: File error: Bad input file tests\files\ibuprofen.sdf
========================================================================= 2 failed, 5 passed in 2.90s =========================================================================

Which i think is a result of RDKit now not being able to read the .sdf files. Im not familiar with the package, so I thought I'd open this issue before proceeding to see what you would advise and ask if you've seen similar issues.

Many thanks in advance,
Joel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions