Skip to content

Commit df62635

Browse files
committed
Minor update to InChI generator now this propery is set (SAChem patch)
1 parent fc938d2 commit df62635

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

storage/inchi/src/main/java/org/openscience/cdk/inchi/InChIGenerator.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,20 @@ private void generateInchiFromCDKAtomContainer(IAtomContainer atomContainer, boo
258258

259259
// Check if radical
260260
int count = atomContainer.getConnectedSingleElectronsCount(atom);
261-
if (count == 0) {
262-
// TODO - how to check whether singlet or undefined multiplicity
263-
} else if (count == 1) {
261+
if (count == 1) {
264262
iatom.setRadical(INCHI_RADICAL.DOUBLET);
265263
} else if (count == 2) {
266-
iatom.setRadical(INCHI_RADICAL.TRIPLET);
264+
Enum spin = atom.getProperty(CDKConstants.SPIN_MULTIPLICITY);
265+
if (spin != null) {
266+
// cdk-ctab:SPIN_MULTIPLICITY not accessible by can access via Enum API although
267+
// a little brittle
268+
if (spin.name().equals("DivalentSinglet"))
269+
iatom.setRadical(INCHI_RADICAL.SINGLET);
270+
else
271+
iatom.setRadical(INCHI_RADICAL.TRIPLET);
272+
} else {
273+
iatom.setRadical(INCHI_RADICAL.TRIPLET);
274+
}
267275
} else {
268276
throw new CDKException("Unrecognised radical type");
269277
}

0 commit comments

Comments
 (0)