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

mol_from_binary_mol results in NoneType molecule field #12

Open
mwinokan opened this issue Jan 16, 2024 · 2 comments
Open

mol_from_binary_mol results in NoneType molecule field #12

mwinokan opened this issue Jan 16, 2024 · 2 comments

Comments

@mwinokan
Copy link

Related to #11, I have been able to write rdkit.Chem.Mol objects to a table using the mol_from_smiles function provided by the chemicalite extension, however when I write an arbitrary Mol object to the table using the mol_from_binary_mol function, only None is stored.

See the following minimal example returns:

import sqlite3
from rdkit import Chem

connection = sqlite3.connect('test.db')

connection.enable_load_extension(True)
connection.load_extension('chemicalite')
connection.enable_load_extension(False)

connection.execute("CREATE TABLE compounds(id INTEGER PRIMARY KEY, name TEXT, smiles TEXT, molecule MOL)")

# this works fine
connection.cursor().execute("INSERT INTO compounds(name, smiles, molecule) "
                            "VALUES(?1, ?2, mol_from_smiles(?2))", ("acetone","CC(=O)C"))

# here the molecule field contains None
connection.cursor().execute("INSERT INTO compounds(name, smiles, molecule) "
                            "VALUES(?1, ?2, mol_from_binary_mol(?3))", ("acetone","CC(=O)C",Chem.MolFromSmiles("CC(=O)C").ToBinary()))

# see the contents of the table
connection.cursor().execute("SELECT * FROM compounds").fetchall()

The last line returns:

[(b'MOL\x00\xef\xbe\xad\xde\x00\x00\x00\x00\r\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x04\x00\x00\x00\x03\x00\x00\x00\x80\x01\x06\x00`\x00\x00\x00\x01\x03\x06\x00(\x00\x00\x00\x03\x04\x08\x00(\x00\x00\x00\x03\x02\x06\x00`\x00\x00\x00\x01\x03\x0b\x00\x01\x00\x01\x02\x08\x02\x01\x03\x00\x14\x00@\t\x00\x00\x00\x00\x00\x00\x00?\x00\x00\x00\x00\x12f\x00\x00\x00\x03\x00\x00\x00\x0f\x00\x00\x00__computedProps\x06\x02\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00numArom\x0f\x00\x00\x00_StereochemDone\x07\x00\x00\x00numArom\x01\x00\x00\x00\x00\x0f\x00\x00\x00_StereochemDone\x01\x01\x00\x00\x00\x13:\xf4\x00\x00\x00\x02\x00\x00\x00\x0f\x00\x00\x00__computedProps\x06\x01\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00_CIPRank\x08\x00\x00\x00_CIPRank\x02\x00\x00\x00\x00\x02\x00\x00\x00\x0f\x00\x00\x00__computedProps\x06\x01\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00_CIPRank\x08\x00\x00\x00_CIPRank\x02\x01\x00\x00\x00\x02\x00\x00\x00\x0f\x00\x00\x00__computedProps\x06\x01\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00_CIPRank\x08\x00\x00\x00_CIPRank\x02\x02\x00\x00\x00\x02\x00\x00\x00\x0f\x00\x00\x00__computedProps\x06\x01\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00_CIPRank\x08\x00\x00\x00_CIPRank\x02\x00\x00\x00\x00\x13;\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x13\x16',),
 (None,)]

I would like to be able to store the rdkit molecule including conformer, hence the desire not to generate the table entry using mol_from_smiles

Thank you!

@rvianello
Copy link
Owner

Hi @mwinokan thank you for reporting the problem, I hope I'll be able to look into this during the next few days. In the meantime, could you please share some details about your software configuration? Thanks!

@mwinokan
Copy link
Author

@rvianello thank you. My details are:

  • macOS Ventura 13.6 on Intel
  • SQLite version 3.41.2
  • conda environment: py310.txt

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

No branches or pull requests

2 participants