Beispiel #1
0
 public SpanningTreeTest()
 {
     if (azulene == null)
     {
         // load azulene
         var            filename        = "NCDK.Data.MDL.azulene.mol";
         var            ins             = ResourceLoader.GetAsStream(filename);
         var            reader          = new MDLV2000Reader(ins, ChemObjectReaderMode.Strict);
         var            chemFile        = reader.Read(builder.NewChemFile());
         var            seq             = chemFile[0];
         var            model           = seq[0];
         IAtomContainer azuleneMolecule = model.MoleculeSet[0];
         Assert.AreEqual(10, azuleneMolecule.Atoms.Count);
         Assert.AreEqual(11, azuleneMolecule.Bonds.Count);
         azulene = new SpanningTree(azuleneMolecule);
     }
     if (ethane == null)
     {
         // create ethane
         IAtomContainer ethaneMolecule = builder.NewAtomContainer();
         ethaneMolecule.Atoms.Add(builder.NewAtom("C"));
         ethaneMolecule.Atoms.Add(builder.NewAtom("C"));
         ethaneMolecule.AddBond(ethaneMolecule.Atoms[0], ethaneMolecule.Atoms[1], BondOrder.Single);
         ethane = new SpanningTree(ethaneMolecule);
     }
 }
Beispiel #2
0
        public virtual void TestGetSpanningTreeForPyridine()
        {
            IAtomContainer mol          = TestMoleculeFactory.MakePyridine();
            SpanningTree   spanningTree = new SpanningTree(mol);

            Assert.AreEqual(6, spanningTree.GetBondsCyclicCount());
            Assert.AreEqual(6, spanningTree.GetCyclicFragmentsContainer().Atoms.Count);
            Assert.AreEqual(0, spanningTree.GetBondsAcyclicCount());
        }
Beispiel #3
0
        public virtual void TestIsDisconnected()
        {
            Assert.IsFalse(azulene.IsDisconnected);

            IChemObjectBuilder builder = azulene.GetSpanningTree().Builder;
            IAtomContainer     disconnectedStructure = builder.NewAtomContainer();

            disconnectedStructure.Atoms.Add(builder.NewAtom("Na"));
            disconnectedStructure.Atoms[0].FormalCharge = +1;
            disconnectedStructure.Atoms.Add(builder.NewAtom("Cl"));
            disconnectedStructure.Atoms[1].FormalCharge = -1;
            SpanningTree stree = new SpanningTree(disconnectedStructure);

            Assert.IsTrue(stree.IsDisconnected);
        }
Beispiel #4
0
        public virtual void TestGetPath_IAtomContainer_IAtom_IAtom()
        {
            IAtomContainer ethaneMol = ethane.GetSpanningTree();
            IAtomContainer path      = SpanningTree.GetPath(ethaneMol, ethaneMol.Atoms[0], ethaneMol.Atoms[1]);

            Assert.AreEqual(2, path.Atoms.Count);
            Assert.AreEqual(1, path.Bonds.Count);

            IAtomContainer disconnectedStructure = builder.NewAtomContainer();

            disconnectedStructure.Atoms.Add(builder.NewAtom("Na"));
            disconnectedStructure.Atoms[0].FormalCharge = +1;
            disconnectedStructure.Atoms.Add(builder.NewAtom("Cl"));
            disconnectedStructure.Atoms[1].FormalCharge = -1;
            path = SpanningTree.GetPath(disconnectedStructure, disconnectedStructure.Atoms[0], disconnectedStructure.Atoms[1]);
            Assert.IsNotNull(path);
            Assert.AreEqual(0, path.Atoms.Count);
            Assert.AreEqual(0, path.Bonds.Count);
        }
Beispiel #5
0
        public virtual void TestSpanningTree_IAtomContainer()
        {
            SpanningTree sTree = new SpanningTree(builder.NewAtomContainer());

            Assert.IsNotNull(sTree);
        }