Skip to content

Commit

Permalink
For the simple cyclic pi bonds aromaticity model - don't allow atoms …
Browse files Browse the repository at this point in the history
…which are next to two cyclic pi bonds. Documentation wording also improved.

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Oct 22, 2013
1 parent 062d720 commit b193aa9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
Expand Up @@ -72,9 +72,9 @@ public static ElectronDonation cdkAtomTypes(boolean exocyclic) {
/**
* A very simple aromaticity model which only allows atoms adjacent to
* cyclic pi bonds. Lone pairs are not consider and as such molecules like
* furan and pyrrole are not considered aromatic. The model is useful for
* storing aromaticity in MDL and Mol2 file formats where aromatic systems
* involving a lone pair can not be properly stored.
* furan and pyrrole are non-aromatic. The model is useful for storing
* aromaticity in MDL and Mol2 file formats where aromatic systems involving
* a lone pair can not be properly represented.
*
* @return electron donation model to use for aromaticity perception
*/
Expand Down
20 changes: 14 additions & 6 deletions src/main/org/openscience/cdk/aromaticity/PiBondModel.java
Expand Up @@ -37,8 +37,8 @@
/**
* A simple aromatic model which only allows cyclic pi-bonds to contribute to an
* aromatic system. Lone pairs are not considered and as such molecules like
* furan and pyrrole are not considered aromatic. This model is suitable for
* storing aromaticity in the MDL/Mol2 file formats.
* furan and pyrrole are non-aromatic. This model is suitable for storing
* aromaticity in the MDL/Mol2 file formats.
*
* @author John May
* @cdk.module standard
Expand All @@ -52,17 +52,25 @@ final class PiBondModel extends ElectronDonation {

int n = container.getAtomCount();
int[] electrons = new int[n];
int[] piBonds = new int[n];

Arrays.fill(electrons, -1);

// count number of cyclic pi bonds
for (IBond bond : container.bonds()) {
int u = container.getAtomNumber(bond.getAtom(0));
int v = container.getAtomNumber(bond.getAtom(1));

if (bond.getOrder() == DOUBLE && ringSearch.cyclic(u, v))
electrons[u] = electrons[v] = 1;
if (bond.getOrder() == DOUBLE && ringSearch.cyclic(u, v)) {
piBonds[u]++;
piBonds[v]++;
}
}

// any atom which is adjacent to one (and only one) cyclic
// pi bond contributes 1 electron
for (int i = 0; i < n; i++) {
electrons[i] = piBonds[i] == 1 ? 1 : -1;
}

return electrons;
}
}
12 changes: 12 additions & 0 deletions src/test/org/openscience/cdk/aromaticity/PiBondModelTest.java
Expand Up @@ -167,6 +167,18 @@ public class PiBondModelTest {
test(smiles("O=C1NC=CC=C1"),
-1, -1, -1, 1, 1, 1, 1);
}

// ensures atoms next to 2 cyclic pi bonds aren't allowed
@Test public void cyclodecahexaene() throws Exception {
test(smiles("C1=CC=C=CC=C=CC=C1"),
1, 1, 1, -1, 1, 1, -1, 1, 1, 1);
}

// similar to cyclodecahexaene but 5 pi bonds instead of 6
@Test public void cyclodecapentaene() throws Exception {
test(smiles("C1=CC=CC=CC=CC=C1"),
1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
}

static IAtomContainer smiles(String smi) throws Exception {
return new SmilesParser(SilentChemObjectBuilder.getInstance()).parseSmiles(smi);
Expand Down

0 comments on commit b193aa9

Please sign in to comment.