Skip to content

Commit

Permalink
Allow acyclic carbon to be kekulized correctly - providing the valenc…
Browse files Browse the repository at this point in the history
…e is OK.
  • Loading branch information
johnmay committed Jul 22, 2024
1 parent a850353 commit 0360978
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/uk/ac/ebi/beam/Localise.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions core/src/test/java/uk/ac/ebi/beam/LocaliseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 0360978

Please sign in to comment.