datamol
datamol copied to clipboard
Adding JSON I/O for molecules
Sometimes it is convenient to exchange molecules in JSON format rather than SMILES or .sdf
files. Fortunately, rdChem.Mol
<-> JSON is already implemented in rdkit.Chem.rdMolInterchange.MolsToJSON
and rdkit.Chem.rdMolInterchange.JSONToMols
. This can be implemented in either datamol.io
or datamol.mol
, though I'm not sure exactly where, and what the signatures should be: For example, implementing this in datamol.mol.to_mol()
with JSON string input will require another if-else, which will slow down the method slightly. Perhaps datamol.mol.to_mol(mol: str | Mol | dict)
might be better, but the JSON can contain multiple molecules so it's not a good interface in the first place.