I'm converting InChI-Strings to MDL using the following lines of code:
public static String generateMolStringFromInChI(String inchi) throws CDKException, IOException {
InChIGeneratorFactory factory = InChIGeneratorFactory.getInstance();
InChIToStructure intostruct = factory.getInChIToStructure(inchi, DefaultChemObjectBuilder.getInstance());
new StructureDiagramGenerator().generateCoordinates(intostruct.getAtomContainer());
StringWriter molStringWriter = new StringWriter();
MDLV2000Writer writer = new MDLV2000Writer(molStringWriter);
writer.write(intostruct.getAtomContainer());
writer.close();
String molString = molStringWriter.toString();
molStringWriter.close();
return molString;
}
It works fine, but the output seems to be wrong in case the input has a radical.
Example input:
InChI=1S/C2H5/c1-2/h1H2,2H3
Output:
CDK 11242310542D
2 1 0 0 0 0 0 0 0 0999 V2000
0.0000 0.0000 0.0000 C 0 0 0 0 0 3 0 0 0 0 0 0
1.5000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
M END
Instead, the output should be (note the extra line M RAD ...) if I'm correct:
CDK 11242310542D
2 1 0 0 0 0 0 0 0 0999 V2000
0.0000 0.0000 0.0000 C 0 0 0 0 0 3 0 0 0 0 0 0
1.5000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
M RAD 1 1 2
M END
I'm converting InChI-Strings to MDL using the following lines of code:
It works fine, but the output seems to be wrong in case the input has a radical.
Example input:
Output:
Instead, the output should be (note the extra line
M RAD ...) if I'm correct: