Example #1
0
        public void MethyleneCyclopropeneTest()
        {
            IAtomContainer mol = builder.NewAtomContainer();

            AbstractSignatureTest.AddCarbons(mol, 4);
            AbstractSignatureTest.AddHydrogens(mol, 1, 2);
            AbstractSignatureTest.AddHydrogens(mol, 2, 1);
            AbstractSignatureTest.AddHydrogens(mol, 3, 1);
            mol.AddBond(mol.Atoms[0], mol.Atoms[1], BondOrder.Double);
            mol.AddBond(mol.Atoms[0], mol.Atoms[2], BondOrder.Single);
            mol.AddBond(mol.Atoms[0], mol.Atoms[3], BondOrder.Single);
            mol.AddBond(mol.Atoms[2], mol.Atoms[3], BondOrder.Double);
            MoleculeSignature molSig = new MoleculeSignature(mol);

            string sigFor2Height1 = molSig.SignatureStringForVertex(2, 1);
            string sigFor3Height1 = molSig.SignatureStringForVertex(3, 1);

            Assert.IsTrue(
                sigFor2Height1.Equals(sigFor3Height1),
                "Height 1 signatures for atoms 2 and 3" + " should be the same");

            string sigFor2Height2 = molSig.SignatureStringForVertex(2, 1);
            string sigFor3Height2 = molSig.SignatureStringForVertex(3, 1);

            Assert.IsTrue(
                sigFor2Height2.Equals(sigFor3Height2),
                "Height 2 signatures for atoms 2 and 3" + " should be the same");
        }
Example #2
0
        public void TestBenzeneWithDoubleBonds()
        {
            IAtomContainer benzene = builder.NewAtomContainer();

            AbstractSignatureTest.AddCarbons(benzene, 6);
            for (int i = 0; i < 6; i++)
            {
                AbstractSignatureTest.AddHydrogens(benzene, i, 1);
            }
            benzene.AddBond(benzene.Atoms[0], benzene.Atoms[1], BondOrder.Single);
            benzene.AddBond(benzene.Atoms[1], benzene.Atoms[2], BondOrder.Double);
            benzene.AddBond(benzene.Atoms[2], benzene.Atoms[3], BondOrder.Single);
            benzene.AddBond(benzene.Atoms[3], benzene.Atoms[4], BondOrder.Double);
            benzene.AddBond(benzene.Atoms[4], benzene.Atoms[5], BondOrder.Single);
            benzene.AddBond(benzene.Atoms[5], benzene.Atoms[0], BondOrder.Double);

            MoleculeSignature signature       = new MoleculeSignature(benzene);
            string            carbonSignature = signature.SignatureStringForVertex(0);

            for (int i = 1; i < 6; i++)
            {
                string carbonSignatureI = signature.SignatureStringForVertex(i);
                Assert.AreEqual(carbonSignature, carbonSignatureI);
            }
        }
        public static IAtomContainer MakeSandwich(int ringSize, bool hasMethyl)
        {
            IAtomContainer mol = builder.NewAtomContainer();

            AbstractSignatureTest.AddCarbons(mol, (ringSize * 2));
            mol.Atoms.Add(builder.NewAtom("Fe"));
            int center = ringSize * 2;

            // face A
            for (int i = 0; i < ringSize - 1; i++)
            {
                mol.AddBond(mol.Atoms[i], mol.Atoms[i + 1], BondOrder.Single);
                mol.AddBond(mol.Atoms[i], mol.Atoms[center], BondOrder.Single);
            }
            mol.AddBond(mol.Atoms[ringSize - 1], mol.Atoms[0], BondOrder.Single);
            mol.AddBond(mol.Atoms[ringSize - 1], mol.Atoms[center], BondOrder.Single);

            //        // face B
            for (int i = 0; i < ringSize - 1; i++)
            {
                mol.AddBond(mol.Atoms[ringSize + 1], mol.Atoms[i + ringSize + 1], BondOrder.Single);
                mol.AddBond(mol.Atoms[ringSize + 1], mol.Atoms[center], BondOrder.Single);
            }
            mol.AddBond(mol.Atoms[(2 * ringSize) - 1], mol.Atoms[ringSize], BondOrder.Single);
            mol.AddBond(mol.Atoms[(2 * ringSize) - 1], mol.Atoms[center], BondOrder.Single);

            if (hasMethyl)
            {
                mol.Atoms.Add(builder.NewAtom("C"));
                mol.AddBond(mol.Atoms[0], mol.Atoms.Last(), BondOrder.Single);
            }

            return(mol);
        }
Example #4
0
        public void CyclobuteneTest()
        {
            string         expectedA   = "[C]([C]([C,0])=[C]([C,0]))";
            string         expectedB   = "[C]([C]([C,0])[C](=[C,0]))";
            IAtomContainer cyclobutene = builder.NewAtomContainer();

            AbstractSignatureTest.AddCarbons(cyclobutene, 4);
            cyclobutene.AddBond(cyclobutene.Atoms[0], cyclobutene.Atoms[1], BondOrder.Single);
            cyclobutene.AddBond(cyclobutene.Atoms[0], cyclobutene.Atoms[2], BondOrder.Single);
            cyclobutene.AddBond(cyclobutene.Atoms[1], cyclobutene.Atoms[3], BondOrder.Double);
            cyclobutene.AddBond(cyclobutene.Atoms[2], cyclobutene.Atoms[3], BondOrder.Single);
            Assert.AreEqual(expectedA, CanonicalStringFromMolecule(cyclobutene));

            string expectedFullString = "2" + expectedA + " + 2" + expectedB;
            string actualFullString   = FullStringFromMolecule(cyclobutene);

            Assert.AreEqual(expectedFullString, actualFullString);
        }
Example #5
0
        public void FusedSquareMultipleBondTest()
        {
            IAtomContainer mol      = builder.NewAtomContainer();
            string         expected = "[C]([C]([C,1])[C]([C,0])[C](=[C,1])[C](=[C,0]))";

            AbstractSignatureTest.AddCarbons(mol, 7);
            mol.AddBond(mol.Atoms[0], mol.Atoms[1], BondOrder.Single);
            mol.AddBond(mol.Atoms[0], mol.Atoms[2], BondOrder.Single);
            mol.AddBond(mol.Atoms[0], mol.Atoms[3], BondOrder.Single);
            mol.AddBond(mol.Atoms[0], mol.Atoms[4], BondOrder.Single);
            mol.AddBond(mol.Atoms[1], mol.Atoms[5], BondOrder.Double);
            mol.AddBond(mol.Atoms[2], mol.Atoms[5], BondOrder.Single);
            mol.AddBond(mol.Atoms[3], mol.Atoms[6], BondOrder.Single);
            mol.AddBond(mol.Atoms[4], mol.Atoms[6], BondOrder.Double);
            MoleculeSignature molSig  = new MoleculeSignature(mol);
            string            sigFor0 = molSig.SignatureStringForVertex(0);

            Assert.AreEqual(expected, sigFor0);
        }
        public static IAtomContainer MakeC7H16C()
        {
            IAtomContainer mol = builder.NewAtomContainer();

            AbstractSignatureTest.AddCarbons(mol, 7);
            mol.AddBond(mol.Atoms[0], mol.Atoms[2], BondOrder.Single);
            mol.AddBond(mol.Atoms[1], mol.Atoms[2], BondOrder.Single);
            mol.AddBond(mol.Atoms[2], mol.Atoms[3], BondOrder.Single);
            mol.AddBond(mol.Atoms[3], mol.Atoms[4], BondOrder.Single);
            mol.AddBond(mol.Atoms[4], mol.Atoms[5], BondOrder.Single);
            mol.AddBond(mol.Atoms[5], mol.Atoms[6], BondOrder.Single);
            AbstractSignatureTest.AddHydrogens(mol, 0, 3);
            AbstractSignatureTest.AddHydrogens(mol, 1, 3);
            AbstractSignatureTest.AddHydrogens(mol, 2, 1);
            AbstractSignatureTest.AddHydrogens(mol, 3, 2);
            AbstractSignatureTest.AddHydrogens(mol, 4, 2);
            AbstractSignatureTest.AddHydrogens(mol, 5, 2);
            AbstractSignatureTest.AddHydrogens(mol, 6, 3);
            return(mol);
        }