Skip to content

Commit

Permalink
Allow aromaticity status of bonds to be preserved through kekulisatio…
Browse files Browse the repository at this point in the history
…n/localisation.
  • Loading branch information
johnmay committed Jul 20, 2024
1 parent 61c10fc commit 166f6b8
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 91 deletions.
28 changes: 28 additions & 0 deletions core/src/main/java/uk/ac/ebi/beam/Bond.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,34 @@ public enum Bond {
return UP;
}

@Override boolean directional() {
return true;
}
},
/**
* This is an internal quirk to allow the aromaticity of input to be preserved when
* we kekulize. The up/down bonds may be between aromatic atoms:
* {@code O=c1cccc\c1=C/C} Since the double bond is exo, the / \ must be aromatic.
*/
UP_AROMATIC("/", 1) {
@Override public Bond inverse() {
return DOWN_AROMATIC;
}

@Override boolean directional() {
return true;
}
},
/**
* This is an internal quirk to allow the aromaticity of input to be preserved when
* we kekulize. The up/down bonds may be between aromatic atoms:
* {@code O=c1cccc\c1=C/C} Since the double bond is exo, the / \ must be aromatic.
*/
DOWN_AROMATIC("\\", 1) {
@Override public Bond inverse() {
return UP_AROMATIC;
}

@Override boolean directional() {
return true;
}
Expand Down
14 changes: 14 additions & 0 deletions core/src/main/java/uk/ac/ebi/beam/Localise.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ private static Graph assign(Graph g, BitSet subset, BitSet aromatic, Matching m)
int v = e.other(u);
if (v < u) {
switch (e.bond()) {
case UP:
case UP_AROMATIC:
if (aromatic.get(u) && aromatic.get(v))
e.bond(Bond.UP_AROMATIC);
else
e.bond(Bond.UP);
break;
case DOWN:
case DOWN_AROMATIC:
if (aromatic.get(u) && aromatic.get(v))
e.bond(Bond.DOWN_AROMATIC);
else
e.bond(Bond.DOWN);
break;
case SINGLE:
if (aromatic.get(u) && aromatic.get(v)) {
e.bond(Bond.SINGLE);
Expand Down
Loading

0 comments on commit 166f6b8

Please sign in to comment.