Skip to content

Commit 31d19d3

Browse files
committed
Allow wildcards when perceiving aromaticity.
1 parent 93cad42 commit 31d19d3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

base/standard/src/main/java/org/openscience/cdk/aromaticity/DaylightModel.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
*/
6868
final class DaylightModel extends ElectronDonation {
6969

70+
private static final int WILDCARD = 0;
7071
private static final int CARBON = 6;
7172
private static final int NITROGEN = 7;
7273
private static final int OXYGEN = 8;
@@ -172,7 +173,9 @@ else if (nCyclicPiBonds[i] == 1) {
172173
// here is we count the number free valence electrons but also
173174
// check if the bonded valence is okay (i.e. not a radical)
174175
else if (charge <= 0 && charge > -3) {
175-
if (valence(element, charge) - valence[i] >= 2)
176+
if (element == WILDCARD)
177+
electrons[i] = 2;
178+
else if (valence(element, charge) - valence[i] >= 2)
176179
electrons[i] = 2;
177180
else
178181
electrons[i] = -1;
@@ -216,6 +219,7 @@ else if (charge <= 0 && charge > -3) {
216219
*/
217220
private static int exocyclicContribution(int element, int otherElement, int charge, int nCyclic) {
218221
switch (element) {
222+
case WILDCARD:
219223
case CARBON:
220224
return otherElement != CARBON ? 0 : 1;
221225
case NITROGEN:
@@ -241,6 +245,7 @@ private static int exocyclicContribution(int element, int otherElement, int char
241245
*/
242246
private static boolean aromaticElement(int element) {
243247
switch (element) {
248+
case WILDCARD:
244249
case CARBON:
245250
case NITROGEN:
246251
case OXYGEN:
@@ -263,6 +268,8 @@ private static boolean aromaticElement(int element) {
263268
*/
264269
private static boolean normal(int element, int charge, int valence) {
265270
switch (element) {
271+
case WILDCARD:
272+
return true;
266273
case CARBON:
267274
if (charge == -1 || charge == +1) return valence == 3;
268275
return charge == 0 && valence == 4;

base/test-standard/src/test/java/org/openscience/cdk/aromaticity/DaylightModelTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@ public void abnormalValence_phosphorus() throws Exception {
197197
test(smiles("[P]1[P][P][P][P]1"), -1, -1, -1, -1, -1);
198198
}
199199

200+
@Test
201+
public void wildcardIndoleLike() throws Exception {
202+
test(smiles("*1C=CC=C1"), 2, 1, 1, 1, 1);
203+
}
204+
205+
@Test
206+
public void wildcardBenzeneLike() throws Exception {
207+
test(smiles("*1=CC=CC=C1"), 1, 1, 1, 1, 1, 1);
208+
}
209+
200210
/**
201211
* A 3 valent nitrogen cation should be aromatic, otherwise when we make it
202212
* lower case we can not convert it back.

0 commit comments

Comments
 (0)