コード例 #1
0
        public void TestRemoveAtomAndConnectedElectronContainers_IAtomContainerSet_IAtom()
        {
            IChemObjectSet <IAtomContainer> ms = new ChemObjectSet <IAtomContainer>();
            var mol = new AtomContainer();

            mol.Atoms.Add(new Atom("O"));
            mol.Atoms.Add(new Atom("O"));
            mol.AddBond(mol.Atoms[0], mol.Atoms[1], BondOrder.Double);
            IAtom atom = mol.Atoms[0];

            ms.Add(mol);
            IAtom otherAtom = new Atom("O");

            MoleculeSetManipulator.RemoveAtomAndConnectedElectronContainers(ms, otherAtom);
            Assert.AreEqual(1, MoleculeSetManipulator.GetBondCount(ms));
            Assert.AreEqual(2, MoleculeSetManipulator.GetAtomCount(ms));
            MoleculeSetManipulator.RemoveAtomAndConnectedElectronContainers(ms, atom);
            Assert.AreEqual(0, MoleculeSetManipulator.GetBondCount(ms));
            Assert.AreEqual(1, MoleculeSetManipulator.GetAtomCount(ms));
        }
コード例 #2
0
        /// <summary>
        /// Get the total number of atoms inside an IChemModel.
        /// </summary>
        /// <param name="chemModel">The IChemModel object.</param>
        /// <returns>The number of Atom object inside.</returns>
        public static int GetAtomCount(IChemModel chemModel)
        {
            int count   = 0;
            var crystal = chemModel.Crystal;

            if (crystal != null)
            {
                count += crystal.Atoms.Count;
            }
            var moleculeSet = chemModel.MoleculeSet;

            if (moleculeSet != null)
            {
                count += MoleculeSetManipulator.GetAtomCount(moleculeSet);
            }
            var reactionSet = chemModel.ReactionSet;

            if (reactionSet != null)
            {
                count += ReactionSetManipulator.GetAtomCount(reactionSet);
            }
            return(count);
        }
コード例 #3
0
        /// <summary>
        /// Get the total number of atoms inside an IChemModel.
        /// </summary>
        /// <param name="chemModel">The IChemModel object.</param>
        /// <returns>The number of Atom object inside.</returns>
        public static int GetAtomCount(IChemModel chemModel)
        {
            int      count   = 0;
            ICrystal crystal = chemModel.Crystal;

            if (crystal != null)
            {
                count += crystal.Atoms.Count;
            }
            IChemObjectSet <IAtomContainer> moleculeSet = chemModel.MoleculeSet;

            if (moleculeSet != null)
            {
                count += MoleculeSetManipulator.GetAtomCount(moleculeSet);
            }
            IReactionSet reactionSet = chemModel.ReactionSet;

            if (reactionSet != null)
            {
                count += ReactionSetManipulator.GetAtomCount(reactionSet);
            }
            return(count);
        }
コード例 #4
0
        public void TestGetAtomCount_IAtomContainerSet()
        {
            int count = MoleculeSetManipulator.GetAtomCount(som);

            Assert.AreEqual(3, count);
        }