Skip to content

Commit 8c9e995

Browse files
johnmayegonw
authored andcommitted
Fix Test - ignore longer extended tetrahedral - could be a warning.
1 parent 074afb4 commit 8c9e995

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

base/core/src/main/java/org/openscience/cdk/stereo/ExtendedTetrahedral.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,28 @@ public IAtom[] findTerminalAtoms(IAtomContainer container) {
192192
return atoms;
193193
}
194194

195+
public static int getLength(IAtomContainer container, IAtom focus) {
196+
int length = 0;
197+
List<IBond> focusBonds = container.getConnectedBondsList(focus);
198+
if (focusBonds.size() != 2)
199+
throw new IllegalArgumentException("focus must have exactly 2 neighbors");
200+
IAtom leftPrev = focus;
201+
IAtom rightPrev = focus;
202+
IAtom left = focusBonds.get(0).getOther(focus);
203+
IAtom right = focusBonds.get(1).getOther(focus);
204+
IAtom tmp;
205+
while (left != null && right != null) {
206+
tmp = getOtherNbr(container, left, leftPrev);
207+
leftPrev = left;
208+
left = tmp;
209+
tmp = getOtherNbr(container, right, rightPrev);
210+
rightPrev = right;
211+
right = tmp;
212+
length++;
213+
}
214+
return 2*length;
215+
}
216+
195217
@Override
196218
protected IStereoElement<IAtom, IAtom> create(IAtom focus, List<IAtom> carriers,
197219
int cfg) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,10 @@ private void generateInchiFromCDKAtomContainer(IAtomContainer atomContainer, boo
419419
IAtom[] terminals = extendedTetrahedral.findTerminalAtoms(atomContainer);
420420
IAtom[] peripherals = extendedTetrahedral.peripherals();
421421

422+
// InChI only supports length 2
423+
if (ExtendedTetrahedral.getLength(atomContainer, focus) > 2)
424+
continue;
425+
422426
// InChI API is particualar about the input, each terminal atom
423427
// needs to be present in the list of neighbors and they must
424428
// be at index 1 and 2 (i.e. in the middle). This is true even

storage/inchi/src/test/java/org/openscience/cdk/inchi/InChIGeneratorFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public void dontIgnoreMajorIsotopes() throws CDKException {
185185
}
186186

187187
// InChI only supports cumulenes of length 2 (CC=[C@]=CC) and 3
188-
// (C/C=C=C=C=C/C) longer ones should be ignored
188+
// (C/C=C=C=C/C) - longer ones should be ignored
189189
@Test
190190
public void longerExtendedTetrahedralsIgnored() throws Exception {
191191
SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());

0 commit comments

Comments
 (0)