girke-lab / ChemmineOB

OpenBabel wrapper package for R
Other
9 stars 5 forks source link

fatal error in convertFormat (SDF to SMI) #29

Closed ethanbass closed 1 year ago

ethanbass commented 1 year ago

Hi,

I am trying to convert an SDF file to smiles strings and it is mostly working great, but one of my SDF structures is throwing a fatal error and causing R to crash. The structure in question: sdf_fatal_error.txt

sdf <- ChemmineR::read.SDFset("sdf_fatal_error.txt")
defs = ChemmineR:::sdfSet2definition(sdf)
ChemmineOB::convertFormat("SDF", "SMI", defs)

If I run open babel from the command line it gives a warning, but does return a smiles string:

obabel -i sdf /Users/ethanbass/Library/CloudStorage/Box-Box/kessler-data/retention_indices/sdf_fatal_error.txt -o smi /Users/ethanbass/Downloads

returns:

==============================
*** Open Babel Warning  in ReadMolecule
  WARNING: Problem interpreting the valence field of an atom
The valence field specifies a valence 7 that is
less than the observed explicit valence 17.

N#CS[Cr]123456789%10(C%11(N)C1C%10C9C8C2%11)(SC#N)(SC#N)(C(C)(C)C)(C1(C3C4C5C6C71)N)SC#N    t-Butyl rhodanilate
1 molecule converted

I'd very much appreciate any insights you might have as to what the issue might be! I am running ChemmineOB 1.38 with open babel 3.1.1_2 on mac OS 12.5.1.

Thanks, Ethan

khoran commented 1 year ago

That function includes a default option to generate 2D coordinates. If you remove that option then it seems to work: convertFormat("SDF", "SMI", defs,options=data.frame())