Example #1
0
        /// <summary>
        /// This badly named methods tries to determine which AtomContainer in the
        /// ChemModel is best suited to contain added Atom's and Bond's.
        /// </summary>
        public static IAtomContainer GetRelevantAtomContainer(IChemModel chemModel, IAtom atom)
        {
            IAtomContainer result = null;

            if (chemModel.MoleculeSet != null)
            {
                var moleculeSet = chemModel.MoleculeSet;
                result = MoleculeSetManipulator.GetRelevantAtomContainer(moleculeSet, atom);
                if (result != null)
                {
                    return(result);
                }
            }
            if (chemModel.ReactionSet != null)
            {
                var reactionSet = chemModel.ReactionSet;
                return(ReactionSetManipulator.GetRelevantAtomContainer(reactionSet, atom));
            }
            if (chemModel.Crystal != null && chemModel.Crystal.Contains(atom))
            {
                return(chemModel.Crystal);
            }
            if (chemModel.RingSet != null)
            {
                return(AtomContainerSetManipulator.GetRelevantAtomContainer(chemModel.RingSet, atom));
            }
            throw new ArgumentException("The provided atom is not part of this IChemModel.");
        }
Example #2
0
        public void TestGetRelevantAtomContainer_IAtomContainerSet_IAtom()
        {
            IAtomContainer ac1 = MoleculeSetManipulator.GetRelevantAtomContainer(som, atomInMol1);

            Assert.AreEqual(mol1, ac1);
            IAtomContainer ac2 = MoleculeSetManipulator.GetRelevantAtomContainer(som, atomInMol2);

            Assert.AreEqual(mol2, ac2);
        }
Example #3
0
        public static IAtomContainer GetRelevantAtomContainer(IReaction reaction, IBond bond)
        {
            var result = MoleculeSetManipulator.GetRelevantAtomContainer(reaction.Reactants, bond);

            if (result != null)
            {
                return(result);
            }
            return(MoleculeSetManipulator.GetRelevantAtomContainer(reaction.Products, bond));
        }
Example #4
0
        /// <summary>
        /// Retrieves the first IAtomContainer containing a given IBond from an
        /// IChemModel.
        /// </summary>
        /// <param name="chemModel">The IChemModel object.</param>
        /// <param name="bond">The IBond object to search.</param>
        /// <returns>The IAtomContainer object found, null if none is found.</returns>
        public static IAtomContainer GetRelevantAtomContainer(IChemModel chemModel, IBond bond)
        {
            IAtomContainer result = null;

            if (chemModel.MoleculeSet != null)
            {
                var moleculeSet = chemModel.MoleculeSet;
                result = MoleculeSetManipulator.GetRelevantAtomContainer(moleculeSet, bond);
                if (result != null)
                {
                    return(result);
                }
            }
            if (chemModel.ReactionSet != null)
            {
                var reactionSet = chemModel.ReactionSet;
                return(ReactionSetManipulator.GetRelevantAtomContainer(reactionSet, bond));
            }
            // This should never happen.
            return(null);
        }
Example #5
0
        public void TestGetRelevantAtomContainer_IAtomContainerSet_IBond()
        {
            IAtomContainer ac1 = MoleculeSetManipulator.GetRelevantAtomContainer(som, bondInMol1);

            Assert.AreEqual(mol1, ac1);
        }