From 0360978d3eb5c31dd645427c93543fc14e3f47d4 Mon Sep 17 00:00:00 2001 From: John Mayfield Date: Mon, 22 Jul 2024 12:28:43 +0100 Subject: [PATCH] Allow acyclic carbon to be kekulized correctly - providing the valence is OK. --- core/src/main/java/uk/ac/ebi/beam/Localise.java | 2 +- core/src/test/java/uk/ac/ebi/beam/LocaliseTest.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/uk/ac/ebi/beam/Localise.java b/core/src/main/java/uk/ac/ebi/beam/Localise.java index 0c4297b..70a1cb6 100644 --- a/core/src/main/java/uk/ac/ebi/beam/Localise.java +++ b/core/src/main/java/uk/ac/ebi/beam/Localise.java @@ -192,7 +192,7 @@ else if (e.bond().order() > 2) { case Boron: return (q == 0) && deg == 3; case Carbon: - return (q == 1 || q == -1) && deg == 3; + return ((q == 1 || q == -1) && deg == 3) || (q == 0 && deg == 4); case Silicon: case Germanium: return q < 0; diff --git a/core/src/test/java/uk/ac/ebi/beam/LocaliseTest.java b/core/src/test/java/uk/ac/ebi/beam/LocaliseTest.java index a92e791..f09ec01 100644 --- a/core/src/test/java/uk/ac/ebi/beam/LocaliseTest.java +++ b/core/src/test/java/uk/ac/ebi/beam/LocaliseTest.java @@ -360,6 +360,14 @@ public void mixing_aromatic_and_aliphatic() throws Exception { test("c1cc(c([n+]c1)N)[N+](=O)[O-]", "C1=CC(=C([N+]=C1)N)[N+](=O)[O-]"); } + + @Test public void acyclicValence() throws Exception { + test("[cH3]cc", "[CH3]C=C"); + test("[cH2+][cH2-]", "[CH2+][CH2-]"); + test("[cH+][cH-]", "[CH+]=[CH-]"); + test("[nH2]cc", "[NH2]C=C"); + test("[oH]cc", "[OH]C=C"); + } @Test public void smallRingTest_5() throws Exception { Graph g = Graph.fromSmiles("C1CCCC1");