Skip to content

Commit 2591f99

Browse files
committed
Fail fast on extended tetrahedral perception, there were some other changes here that I've just removed since they don't make sense.
1 parent 3d502b1 commit 2591f99

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

base/standard/src/main/java/org/openscience/cdk/stereo/StereoElementFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ ExtendedTetrahedral createExtendedTetrahedral(int v, Stereocenters stereocenters
795795
if (w == v) continue;
796796
if (bond.getOrder() != IBond.Order.SINGLE) continue;
797797
if (isUnspecified(bond)) return null;
798+
if (n == 2) return null;
798799
neighbors[n] = container.getAtom(w);
799800
elevation[n] = elevationOf(terminals[0], bond);
800801
n++;
@@ -806,6 +807,7 @@ ExtendedTetrahedral createExtendedTetrahedral(int v, Stereocenters stereocenters
806807
IBond bond = bondMap.get(t1, w);
807808
if (bond.getOrder() != IBond.Order.SINGLE) continue;
808809
if (isUnspecified(bond)) return null;
810+
if (n == 4) return null;
809811
neighbors[n] = container.getAtom(w);
810812
elevation[n] = elevationOf(terminals[1], bond);
811813
n++;
@@ -1208,6 +1210,9 @@ ExtendedTetrahedral createExtendedTetrahedral(int v, Stereocenters stereocenters
12081210
IAtom focus = container.getAtom(v);
12091211

12101212
if (hasUnspecifiedParity(focus)) return null;
1213+
1214+
if (container.getConnectedBondsCount(focus) != 2)
1215+
return null;
12111216

12121217
IAtom[] terminals = ExtendedTetrahedral.findTerminalAtoms(container, focus);
12131218
IAtom[] neighbors = new IAtom[4];

0 commit comments

Comments
 (0)