public void TestRemoveElectronContainer_IAtomContainerSet_IElectronContainer() { 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); IBond bond = mol.Bonds[0]; ms.Add(mol); IBond otherBond = new Bond(new Atom(), new Atom()); MoleculeSetManipulator.RemoveElectronContainer(ms, otherBond); Assert.AreEqual(1, MoleculeSetManipulator.GetBondCount(ms)); MoleculeSetManipulator.RemoveElectronContainer(ms, bond); Assert.AreEqual(0, MoleculeSetManipulator.GetBondCount(ms)); }
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)); }
/// <summary> /// Get the total number of bonds inside an IChemModel. /// </summary> /// <param name="chemModel">The IChemModel object.</param> /// <returns>The number of Bond object inside.</returns> public static int GetBondCount(IChemModel chemModel) { int count = 0; var crystal = chemModel.Crystal; if (crystal != null) { count += crystal.Bonds.Count; } var moleculeSet = chemModel.MoleculeSet; if (moleculeSet != null) { count += MoleculeSetManipulator.GetBondCount(moleculeSet); } var reactionSet = chemModel.ReactionSet; if (reactionSet != null) { count += ReactionSetManipulator.GetBondCount(reactionSet); } return(count); }
/// <summary> /// Get the total number of bonds inside an IChemModel. /// </summary> /// <param name="chemModel">The IChemModel object.</param> /// <returns>The number of Bond object inside.</returns> public static int GetBondCount(IChemModel chemModel) { int count = 0; ICrystal crystal = chemModel.Crystal; if (crystal != null) { count += crystal.Bonds.Count; } IChemObjectSet <IAtomContainer> moleculeSet = chemModel.MoleculeSet; if (moleculeSet != null) { count += MoleculeSetManipulator.GetBondCount(moleculeSet); } IReactionSet reactionSet = chemModel.ReactionSet; if (reactionSet != null) { count += ReactionSetManipulator.GetBondCount(reactionSet); } return(count); }
public void TestGetBondCount_IAtomContainerSet() { int count = MoleculeSetManipulator.GetBondCount(som); Assert.AreEqual(1, count); }