void Main() { IAtomContainer someMolecule = null; { #region 1 IAtomContainer ac = someMolecule; // get an atom container somehow AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner(); PermutationGroup autG = refiner.GetAutomorphismGroup(ac); foreach (var automorphism in autG.GenerateAll()) { // do something with the permutation } #endregion } { #region 2 IAtomContainer ac = someMolecule; // get an atom container somehow AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner(); if (refiner.IsCanonical(ac)) { // do something with the atom container } #endregion } { IAtomContainer ac = someMolecule; #region 3 AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner(); refiner.Refine(ac); bool isCanon = refiner.IsCanonical(); PermutationGroup autG = refiner.GetAutomorphismGroup(); #endregion } }
public void ReSetTest() { string acpString1 = "C0C1 0:1(1)"; IAtomContainer ac1 = AtomContainerPrinter.FromString(acpString1, builder); AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner(); refiner.Refine(ac1); Assert.AreEqual(refiner.GetConnectivity(0, 1), 1); Assert.AreEqual(refiner.GetVertexCount(), 2); string acpString2 = "C0C1C2 0:1(2),1:2(1)"; IAtomContainer ac2 = AtomContainerPrinter.FromString(acpString2, builder); refiner.Refine(ac2); Assert.AreEqual(refiner.GetConnectivity(0, 1), 2); Assert.AreEqual(refiner.GetVertexCount(), 3); }
/// <summary> /// This test is checking all permutations of an atom container to see /// if the refiner gives the canonical labelling map (effectively). /// </summary> /// <param name="atomContainer"></param> public void CheckForCanonicalForm(IAtomContainer atomContainer) { AtomContainerAtomPermutor permutor = new AtomContainerAtomPermutor(atomContainer); AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner(); refiner.Refine(atomContainer); Permutation best = refiner.GetBest().Invert(); string cert = AtomContainerPrinter.ToString(atomContainer, best, true); while (permutor.MoveNext()) { IAtomContainer permutedContainer = permutor.Current; refiner.Refine(permutedContainer); best = refiner.GetBest().Invert(); string permCert = AtomContainerPrinter.ToString(permutedContainer, best, true); Assert.AreEqual(cert, permCert); } }
public void GetVertexCountTest() { string acpString = "C0C1C2C3 0:1(1),0:3(1),1:2(1),2:3(1)"; IAtomContainer ac = AtomContainerPrinter.FromString(acpString, builder); AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner(); refiner.Refine(ac); Assert.AreEqual(ac.Atoms.Count, refiner.GetVertexCount()); }
public void RefineTest() { string acpString = "C0C1O2O3 0:1(1),0:3(1),1:2(1),2:3(1)"; IAtomContainer ac = AtomContainerPrinter.FromString(acpString, builder); AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner(); refiner.Refine(ac); PermutationGroup autG = refiner.GetAutomorphismGroup(); Assert.AreEqual(2, autG.Order()); }
public void Refine_StartingPartitionTest() { Partition partition = Partition.FromString("0,1|2,3"); string acpString = "C0C1C2C3 0:1(1),0:3(1),1:2(1),2:3(1)"; IAtomContainer ac = AtomContainerPrinter.FromString(acpString, builder); AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner(); refiner.Refine(ac, partition); PermutationGroup autG = refiner.GetAutomorphismGroup(); Assert.AreEqual(2, autG.Order()); }
public void GetConnectivityTest() { string acpString = "C0C1C2C3 0:1(1),0:3(1),1:2(2),2:3(1)"; IAtomContainer ac = AtomContainerPrinter.FromString(acpString, builder); AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner(); refiner.Refine(ac); IBond bond = ac.GetBond(ac.Atoms[1], ac.Atoms[2]); int orderN = bond.Order.Numeric(); Assert.AreEqual(orderN, refiner.GetConnectivity(1, 2)); }
public void Refine_IgnoreElementsTest() { string acpString = "C0C1O2O3 0:1(1),0:3(1),1:2(1),2:3(1)"; IAtomContainer ac = AtomContainerPrinter.FromString(acpString, builder); bool ignoreElements = true; bool ignoreBondOrder = false; AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner(ignoreElements, ignoreBondOrder); refiner.Refine(ac); PermutationGroup autG = refiner.GetAutomorphismGroup(); Assert.AreEqual(8, autG.Order()); }
public void TestBiphenyl() { IAtomContainer mol = TestMoleculeFactory.MakeBiphenyl(); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol); Aromaticity.CDKLegacy.Apply(mol); Assert.IsNotNull(mol, "Created molecule was null"); AtomDiscretePartitionRefiner refiner = new AtomDiscretePartitionRefiner(); refiner.Refine(mol); Partition autP = refiner.GetAutomorphismPartition(); Assert.AreEqual(4, autP.Count, "Wrong number of equivalent classes"); Partition expected = Partition.FromString("0,6|1,5,7,11|2,4,8,10|3,9"); Assert.AreEqual(expected, autP, "Wrong class assignment"); }