Exemple #1
0
        public virtual void TestChemModel()
        {
            IChemModel chemModel = new ChemModel();

            Assert.IsNotNull(chemModel);
            Assert.IsTrue(chemModel.IsEmpty());

            IAtom atom = new Atom("N");
            IRing mol  = new Ring();  // NCDK does not allow to add AtomContainer to RingSet
            IChemObjectSet <IAtomContainer> mset = new ChemObjectSet <IAtomContainer>();

            mol.Atoms.Add(atom);
            mset.Add(mol);
            chemModel.MoleculeSet = mset;
            Assert.IsFalse(chemModel.IsEmpty());
            mol.Atoms.Remove(atom);
            Assert.IsFalse(chemModel.IsEmpty());
            chemModel.MoleculeSet = null;
            Assert.IsTrue(chemModel.IsEmpty());

            IChemModel model1 = new ChemModel();

            mol.Atoms.Add(atom);
            IReaction react = new Reaction();

            react.Reactants.Add(mol);
            IReactionSet rset = new ReactionSet {
                react
            };

            model1.ReactionSet = rset;
            Assert.IsFalse(model1.IsEmpty());
            mol.Atoms.Remove(atom);
            Assert.IsFalse(model1.IsEmpty());
            model1.ReactionSet = null;
            Assert.IsTrue(model1.IsEmpty());

            IChemModel model2 = new ChemModel();

            mol.Atoms.Add(atom);
            IRingSet ringset = new RingSet();

            ringset.AddRange(mset.Cast <IRing>());  // NCDK does not allow to add AtomContainer to RingSet directly
            model2.RingSet = ringset;
            Assert.IsFalse(model2.IsEmpty());
            mol.Atoms.Remove(atom);
            Assert.IsFalse(model2.IsEmpty());
            model2.RingSet = null;
            Assert.IsTrue(model2.IsEmpty());

            IChemModel model3 = new ChemModel();

            mol.Atoms.Add(atom);
            ICrystal cry = new Crystal(mol);

            model3.Crystal = cry;
            Assert.IsFalse(model3.IsEmpty());
            mol.Atoms.Remove(atom);
            Assert.IsFalse(model3.IsEmpty());
            model3.Crystal = null;
            Assert.IsTrue(model3.IsEmpty());
        }
Exemple #2
0
        public void TestRingSet()
        {
            IRingSet rs = new RingSet();

            Assert.IsNotNull(rs);
        }