Ejemplo n.º 1
0
        public void TestIsConnectedArtemisinin1()
        {
            var sp        = CDK.SmilesParser;
            var container = sp.ParseSmiles("C1CN2CCN(CCCN(CCN(C1)Cc1ccccn1)CC2)C");

            Assert.IsTrue(ConnectivityChecker.IsConnected(container));
        }
Ejemplo n.º 2
0
        public void TestPartitionExtendedTetrahedral()
        {
            SmilesParser smipar    = CDK.SmilesParser;
            var          container = smipar.ParseSmiles("CC=[C@]=CC.C");
            IChemObjectSet <IAtomContainer> containerSet = ConnectivityChecker.PartitionIntoMolecules(container);

            Assert.AreEqual(2, containerSet.Count);
            Assert.IsTrue(containerSet[0].StereoElements.GetEnumerator().MoveNext());
        }
Ejemplo n.º 3
0
        public void TestIsConnectedFromSDFile()
        {
            var filename = "NCDK.Data.MDL.mdeotest.sdf";
            var ins      = ResourceLoader.GetAsStream(filename);
            ISimpleChemObjectReader reader = new MDLV2000Reader(ins);
            ChemFile       content         = (ChemFile)reader.Read((ChemObject) new ChemFile());
            var            cList           = ChemFileManipulator.GetAllAtomContainers(content);
            IAtomContainer ac = cList.First();

            Assert.IsTrue(ConnectivityChecker.IsConnected(ac), "Molecule appears not to be connected");
        }
Ejemplo n.º 4
0
        public void TestIsConnectedFromHINFile()
        {
            var            filename = "NCDK.Data.HIN.connectivity1.hin";
            var            ins      = ResourceLoader.GetAsStream(filename);
            var            reader   = new HINReader(ins);
            var            content  = reader.Read(builder.NewChemFile());
            var            cList    = ChemFileManipulator.GetAllAtomContainers(content);
            IAtomContainer ac       = cList.First();

            Assert.IsTrue(ConnectivityChecker.IsConnected(ac), "Molecule appears not to be connected");
        }
Ejemplo n.º 5
0
        public void TestPartitionIntoMolecules_IAtomContainer()
        {
            //Debug.WriteLine(atomCon);
            AtomContainer atomCon = new AtomContainer();

            atomCon.Add(TestMoleculeFactory.Make4x3CondensedRings());
            atomCon.Add(TestMoleculeFactory.MakeAlphaPinene());
            atomCon.Add(TestMoleculeFactory.MakeSpiroRings());
            IChemObjectSet <IAtomContainer> moleculeSet = ConnectivityChecker.PartitionIntoMolecules(atomCon);

            Assert.IsNotNull(moleculeSet);
            Assert.AreEqual(3, moleculeSet.Count);
        }
Ejemplo n.º 6
0
        public void TestPartitionIntoMolecules_IAtomContainer()
        {
            //Debug.WriteLine(atomCon);
            var atomCon = builder.NewAtomContainer();

            atomCon.Add(TestMoleculeFactory.Make4x3CondensedRings());
            atomCon.Add(TestMoleculeFactory.MakeAlphaPinene());
            atomCon.Add(TestMoleculeFactory.MakeSpiroRings());
            var moleculeSet = ConnectivityChecker.PartitionIntoMolecules(atomCon).ToReadOnlyList();

            Assert.IsNotNull(moleculeSet);
            Assert.AreEqual(3, moleculeSet.Count);
        }
        public void Main()
        {
            var container = TestMoleculeFactory.MakeBenzene();

            #region 1
            bool isConnected = ConnectivityChecker.IsConnected(container);
            #endregion

            var disconnectedContainer = TestMoleculeFactory.MakeBenzene();
            #region 2
            var fragments     = ConnectivityChecker.PartitionIntoMolecules(disconnectedContainer);
            int fragmentCount = fragments.Count;
            #endregion
        }
Ejemplo n.º 8
0
        public void TestDontDeleteSingleElectrons()
        {
            AtomContainer atomCon = new AtomContainer();
            // make two molecules; one with an LonePair, the other with a SingleElectron
            IAtomContainer mol1  = new AtomContainer();
            Atom           atom1 = new Atom("C");

            mol1.Atoms.Add(atom1);
            LonePair lp1 = new LonePair(atom1);

            mol1.LonePairs.Add(lp1);
            // mol2
            IAtomContainer mol2  = new AtomContainer();
            Atom           atom2 = new Atom("C");

            mol2.Atoms.Add(atom2);
            SingleElectron se2 = new SingleElectron(atom2);

            mol2.SingleElectrons.Add(se2);

            atomCon.Add(mol1);
            atomCon.Add(mol2);

            // now partition
            IChemObjectSet <IAtomContainer> moleculeSet = ConnectivityChecker.PartitionIntoMolecules(atomCon);

            Assert.IsNotNull(moleculeSet);
            Assert.AreEqual(2, moleculeSet.Count);

            Assert.IsTrue(ConnectivityChecker.IsConnected(moleculeSet[0]));
            Assert.IsTrue(ConnectivityChecker.IsConnected(moleculeSet[1]));

            // make sure
            Assert.AreEqual(1, moleculeSet[0].Atoms.Count);
            Assert.AreEqual(1, moleculeSet[0].GetElectronContainers().Count());
            Assert.AreEqual(1, moleculeSet[1].Atoms.Count);
            Assert.AreEqual(1, moleculeSet[1].GetElectronContainers().Count());
            // we don't know which partition contains the LP and which the electron
            Assert.IsTrue(moleculeSet[0].GetConnectedSingleElectrons(
                              moleculeSet[0].Atoms[0]).Count() == 0 ||
                          moleculeSet[1].GetConnectedSingleElectrons(
                              moleculeSet[1].Atoms[0]).Count() == 0);
            Assert.IsTrue(moleculeSet[0].GetConnectedLonePairs(
                              moleculeSet[0].Atoms[0]).Count() == 0 ||
                          moleculeSet[1].GetConnectedLonePairs(
                              moleculeSet[1].Atoms[0]).Count() == 0);
        }
Ejemplo n.º 9
0
        public void TestPartitionIntoMoleculesKeepsAtomIDs()
        {
            AtomContainer atomCon = new AtomContainer();
            Atom          atom1   = new Atom("C");

            atom1.Id = "atom1";
            Atom atom2 = new Atom("C");

            atom2.Id = "atom2";
            atomCon.Atoms.Add(atom1);
            atomCon.Atoms.Add(atom2);
            IChemObjectSet <IAtomContainer> moleculeSet = ConnectivityChecker.PartitionIntoMolecules(atomCon);

            Assert.IsNotNull(moleculeSet);
            Assert.AreEqual(2, moleculeSet.Count);
            IAtom copy1 = moleculeSet[0].Atoms[0];
            IAtom copy2 = moleculeSet[1].Atoms[0];

            Assert.AreEqual(atom1.Id, copy1.Id);
            Assert.AreEqual(atom2.Id, copy2.Id);
        }
Ejemplo n.º 10
0
        public void TestPartitionIntoMoleculesKeepsAtomIDs()
        {
            var atomCon = builder.NewAtomContainer();
            var atom1   = builder.NewAtom("C");

            atom1.Id = "atom1";
            var atom2 = builder.NewAtom("C");

            atom2.Id = "atom2";
            atomCon.Atoms.Add(atom1);
            atomCon.Atoms.Add(atom2);
            var moleculeSet = ConnectivityChecker.PartitionIntoMolecules(atomCon).ToReadOnlyList();

            Assert.IsNotNull(moleculeSet);
            Assert.AreEqual(2, moleculeSet.Count);
            IAtom copy1 = moleculeSet[0].Atoms[0];
            IAtom copy2 = moleculeSet[1].Atoms[0];

            Assert.AreEqual(atom1.Id, copy1.Id);
            Assert.AreEqual(atom2.Id, copy2.Id);
        }
Ejemplo n.º 11
0
        public void TestNoAtomsIsConnected()
        {
            IAtomContainer container = new AtomContainer();

            Assert.IsTrue(ConnectivityChecker.IsConnected(container), "Molecule appears not to be connected");
        }
Ejemplo n.º 12
0
        public void TestIsConnected_IAtomContainer()
        {
            IAtomContainer spiro = TestMoleculeFactory.MakeSpiroRings();

            Assert.IsTrue(ConnectivityChecker.IsConnected(spiro));
        }