Skip to content

Commit

Permalink
Additional patch that calls refine before returning the automorphism …
Browse files Browse the repository at this point in the history
…partition

Signed-off-by: John May <john.wilkinsonmay@gmail.com>
  • Loading branch information
gilleain authored and egonw committed Nov 29, 2012
1 parent cd85e29 commit 186b35b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
Expand Up @@ -293,6 +293,19 @@ public PermutationGroup getAutomorphismGroup(
super.refine(initialPartition);
return super.getAutomorphismGroup();
}

/**
* Get the automorphism partition (equivalence classes) of the atoms.
*
* @param atomContainer the molecule to calculate equivalence classes for
* @return a partition of the atoms into equivalence classes
*/
@TestMethod("getAutomorphismPartitionTest")
public Partition getAutomorphismPartition(IAtomContainer atomContainer) {
setup(atomContainer);
super.refine(getElementPartition(atomContainer));
return super.getAutomorphismPartition();
}

/**
* Makes a lookup table for the connection between atoms, to avoid looking
Expand Down
Expand Up @@ -290,6 +290,19 @@ public PermutationGroup getAutomorphismGroup(
return super.getAutomorphismGroup();
}

/**
* Get the automorphism partition (equivalence classes) of the bonds.
*
* @param atomContainer the molecule to calculate equivalence classes for
* @return a partition of the bonds into equivalence classes
*/
@TestMethod("getAutomorphismPartitionTest")
public Partition getAutomorphismPartition(IAtomContainer atomContainer) {
setup(atomContainer);
super.refine(getBondPartition(atomContainer));
return super.getAutomorphismPartition();
}

private void setup(IAtomContainer atomContainer) {
// have to setup the connection table before making the group
// otherwise the size may be wrong
Expand Down
Expand Up @@ -191,6 +191,17 @@ public void getConnectivityTest() {
Assert.assertEquals(orderN, refiner.getConnectivity(1, 2));
}

@Test
public void getAutomorphismPartitionTest() {
String acpString = "C0C1C2C3C4C5C6C7C8C9 0:1(2),1:2(1),2:3(2),3:4(1)," +
"4:5(2),5:6(1),6:7(2),7:8(1),8:9(2),5:9(1),0:9(1)";
IAtomContainer ac = AtomContainerPrinter.fromString(acpString, builder);
AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner();
Partition autP = refiner.getAutomorphismPartition(ac);
Partition expected = Partition.fromString("0|1|2|3|4|5|6|7|8|9");
Assert.assertEquals(expected, autP);
}

// NOTE : the following tests are from bug 1250 by Luis F. de Figueiredo
// and mostly test for aromatic bonds

Expand Down
Expand Up @@ -185,6 +185,17 @@ public void getConnectivityTest() {
Assert.assertEquals(1, refiner.getConnectivity(0, 1));
}

@Test
public void getAutomorphismPartitionTest() {
String acpString = "C0C1C2C3C4C5C6C7C8C9 0:1(2),1:2(1),2:3(2),3:4(1)," +
"4:5(2),5:6(1),6:7(2),7:8(1),8:9(2),5:9(1),0:9(1)";
IAtomContainer ac = AtomContainerPrinter.fromString(acpString, builder);
BondDiscretePartitionRefiner refiner = new BondDiscretePartitionRefiner();
Partition autP = refiner.getAutomorphismPartition(ac);
Partition expected = Partition.fromString("0|1|2|3|4|5|6|7|8|9|10");
Assert.assertEquals(expected, autP);
}

// NOTE : the following tests are from bug 1250 by Luis F. de Figueiredo
// and mostly test for aromatic bonds

Expand All @@ -193,6 +204,7 @@ public void testAzulene() throws Exception {

IAtomContainer mol = MoleculeFactory.makeAzulene();
Assert.assertNotNull("Created molecule was null", mol);
AtomContainerPrinter.print(mol);

AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
CDKHueckelAromaticityDetector.detectAromaticity(mol);
Expand Down

0 comments on commit 186b35b

Please sign in to comment.