Пример #1
0
        public void TestRoundtrip()
        {
            Molecule molecule = new Molecule();

            molecule.AddAtom("C");
            molecule.AddAtom("C");
            molecule.AddAtom("C");
            molecule.AddAtom("C");
            molecule.AddSingleBond(0, 1);
            molecule.AddSingleBond(0, 3);
            molecule.AddSingleBond(1, 2);
            molecule.AddSingleBond(2, 3);

            AtomSignature atomSignature   = new AtomSignature(molecule, 0);
            string        signatureString = atomSignature.ToCanonicalString();

            ColoredTree     tree          = AtomSignature.Parse(signatureString);
            MoleculeBuilder builder       = new MoleculeBuilder();
            Molecule        builtMolecule = builder.FromTree(tree);

            Assert.AreEqual(molecule.ToString(), builtMolecule.ToString());

            // test that this can be done more than once
            builtMolecule = builder.FromTree(tree);
            Assert.AreEqual(molecule.ToString(), builtMolecule.ToString());
        }
Пример #2
0
        public void TestOddCycleReadin()
        {
            string      signatureString = "[C]([C]([C,2]([C,1]))[C]([C,1]))";
            ColoredTree tree            = AtomSignature.Parse(signatureString);

            Assert.AreEqual(signatureString, tree.ToString());
            Molecule molecule = new MoleculeBuilder().FromTree(tree);

            Assert.AreEqual(5, molecule.GetAtomCount());
            Assert.AreEqual(5, molecule.GetBondCount());
        }
Пример #3
0
        public void TestCage()
        {
            string signatureString = "[C]([C]([C,2]([C]([C,3][C,4]))[C]([C,5]" +
                                     "[C,3]([C,6]([C,1]))))[C]([C]([C,7][C]" +
                                     "([C,1][C,8]))[C,5]([C,8]([C,6])))[C]([C,2]" +
                                     "[C,7]([C,4]([C,1]))))";
            ColoredTree tree = AtomSignature.Parse(signatureString);

            Assert.AreEqual(signatureString, tree.ToString());
            Molecule molecule = new MoleculeBuilder().FromTree(tree);

            Assert.AreEqual(16, molecule.GetAtomCount());
            Assert.AreEqual(24, molecule.GetBondCount());
        }