/** * Returns all the AtomContainer's of a Reaction. * @param reaction The reaction being considered * @return a list of the IAtomContainer objects comprising the reaction */ public static List<IAtomContainer> getAllAtomContainers(IReaction reaction) { return MoleculeSetManipulator.getAllAtomContainers(getAllMolecules(reaction)); }
public static IAtomContainer getRelevantAtomContainer(IReaction reaction, IBond bond) { IAtomContainer result = MoleculeSetManipulator.getRelevantAtomContainer(reaction.getReactants(), bond); if (result != null) { return result; } return MoleculeSetManipulator.getRelevantAtomContainer(reaction.getProducts(), bond); }
if (moleculeSet != null) { list.add(moleculeSet); List<IChemObject> current = MoleculeSetManipulator.getAllChemObjects(moleculeSet); for (IChemObject chemObject : current) { if (!list.contains(chemObject)) list.add(chemObject);
@Test public void testRemoveAtomAndConnectedElectronContainers_IAtomContainerSet_IAtom() { IAtomContainerSet ms = new AtomContainerSet(); IAtomContainer mol = new AtomContainer(); mol.addAtom(new Atom("O")); mol.addAtom(new Atom("O")); mol.addBond(0, 1, IBond.Order.DOUBLE); IAtom atom = mol.getAtom(0); ms.addAtomContainer(mol); IAtom otherAtom = new Atom("O"); MoleculeSetManipulator.removeAtomAndConnectedElectronContainers(ms, otherAtom); Assert.assertEquals(1, MoleculeSetManipulator.getBondCount(ms)); Assert.assertEquals(2, MoleculeSetManipulator.getAtomCount(ms)); MoleculeSetManipulator.removeAtomAndConnectedElectronContainers(ms, atom); Assert.assertEquals(0, MoleculeSetManipulator.getBondCount(ms)); Assert.assertEquals(1, MoleculeSetManipulator.getAtomCount(ms)); }
@Test public void testRemoveElectronContainer_IAtomContainerSet_IElectronContainer() { IAtomContainerSet ms = new AtomContainerSet(); IAtomContainer mol = new AtomContainer(); mol.addAtom(new Atom("O")); mol.addAtom(new Atom("O")); mol.addBond(0, 1, IBond.Order.DOUBLE); IBond bond = mol.getBond(0); ms.addAtomContainer(mol); IBond otherBond = new Bond(new Atom(), new Atom()); MoleculeSetManipulator.removeElectronContainer(ms, otherBond); Assert.assertEquals(1, MoleculeSetManipulator.getBondCount(ms)); MoleculeSetManipulator.removeElectronContainer(ms, bond); Assert.assertEquals(0, MoleculeSetManipulator.getBondCount(ms)); }
public static List<String> getAllIDs(IChemModel chemModel) { ArrayList<String> list = new ArrayList<String>(); if (chemModel.getID() != null) list.add(chemModel.getID()); ICrystal crystal = chemModel.getCrystal(); if (crystal != null) { list.addAll(AtomContainerManipulator.getAllIDs(crystal)); } IAtomContainerSet moleculeSet = chemModel.getMoleculeSet(); if (moleculeSet != null) { list.addAll(MoleculeSetManipulator.getAllIDs(moleculeSet)); } IReactionSet reactionSet = chemModel.getReactionSet(); if (reactionSet != null) { list.addAll(ReactionSetManipulator.getAllIDs(reactionSet)); } return list; } }
/** * Sets the AtomProperties of all Atoms inside an IChemModel. * * @param chemModel The IChemModel object. * @param propKey The key of the property. * @param propVal The value of the property. */ public static void setAtomProperties(IChemModel chemModel, Object propKey, Object propVal) { if (chemModel.getMoleculeSet() != null) { MoleculeSetManipulator.setAtomProperties(chemModel.getMoleculeSet(), propKey, propVal); } if (chemModel.getReactionSet() != null) { ReactionSetManipulator.setAtomProperties(chemModel.getReactionSet(), propKey, propVal); } if (chemModel.getCrystal() != null) { AtomContainerManipulator.setAtomProperties(chemModel.getCrystal(), propKey, propVal); } }
@Test public void testGetAtomCount_IAtomContainerSet() { int count = MoleculeSetManipulator.getAtomCount(som); Assert.assertEquals(3, count); }
@Test public void testGetBondCount_IAtomContainerSet() { int count = MoleculeSetManipulator.getBondCount(som); Assert.assertEquals(1, count); }
/** * Remove an Atom and the connected ElectronContainers from all AtomContainers * inside an IChemModel. * * @param chemModel The IChemModel object. * @param atom The Atom object to remove. */ public static void removeAtomAndConnectedElectronContainers(IChemModel chemModel, IAtom atom) { ICrystal crystal = chemModel.getCrystal(); if (crystal != null) { if (crystal.contains(atom)) { crystal.removeAtom(atom); } return; } IAtomContainerSet moleculeSet = chemModel.getMoleculeSet(); if (moleculeSet != null) { MoleculeSetManipulator.removeAtomAndConnectedElectronContainers(moleculeSet, atom); } IReactionSet reactionSet = chemModel.getReactionSet(); if (reactionSet != null) { ReactionSetManipulator.removeAtomAndConnectedElectronContainers(reactionSet, atom); } }
/** * Remove an ElectronContainer from all AtomContainers * inside an IChemModel. * * @param chemModel The IChemModel object. * @param electrons The ElectronContainer to remove. */ public static void removeElectronContainer(IChemModel chemModel, IElectronContainer electrons) { ICrystal crystal = chemModel.getCrystal(); if (crystal != null) { if (crystal.contains(electrons)) { crystal.removeElectronContainer(electrons); } return; } IAtomContainerSet moleculeSet = chemModel.getMoleculeSet(); if (moleculeSet != null) { MoleculeSetManipulator.removeElectronContainer(moleculeSet, electrons); } IReactionSet reactionSet = chemModel.getReactionSet(); if (reactionSet != null) { ReactionSetManipulator.removeElectronContainer(reactionSet, electrons); } }
@Test public void testGetAllIDs_IAtomContainerSet() { som.setID("som"); mol2.setID("mol"); atomInMol2.setID("atom"); bondInMol1.setID("bond"); List<String> list = MoleculeSetManipulator.getAllIDs(som); Assert.assertEquals(4, list.size()); }
@Test public void testSetAtomProperties_IAtomContainerSet_Object_Object() { String key = "key"; String value = "value"; MoleculeSetManipulator.setAtomProperties(som, key, value); Assert.assertEquals(value, atomInMol1.getProperty(key)); Assert.assertEquals(value, atomInMol2.getProperty(key)); }
/** * Get the total number of atoms inside an IChemModel. * * @param chemModel The IChemModel object. * @return The number of Atom object inside. */ public static int getAtomCount(IChemModel chemModel) { int count = 0; ICrystal crystal = chemModel.getCrystal(); if (crystal != null) { count += crystal.getAtomCount(); } IAtomContainerSet moleculeSet = chemModel.getMoleculeSet(); if (moleculeSet != null) { count += MoleculeSetManipulator.getAtomCount(moleculeSet); } IReactionSet reactionSet = chemModel.getReactionSet(); if (reactionSet != null) { count += ReactionSetManipulator.getAtomCount(reactionSet); } return count; }
/** * Get the total number of bonds inside an IChemModel. * * @param chemModel The IChemModel object. * @return The number of Bond object inside. */ public static int getBondCount(IChemModel chemModel) { int count = 0; ICrystal crystal = chemModel.getCrystal(); if (crystal != null) { count += crystal.getBondCount(); } IAtomContainerSet moleculeSet = chemModel.getMoleculeSet(); if (moleculeSet != null) { count += MoleculeSetManipulator.getBondCount(moleculeSet); } IReactionSet reactionSet = chemModel.getReactionSet(); if (reactionSet != null) { count += ReactionSetManipulator.getBondCount(reactionSet); } return count; }
/** * Returns all the AtomContainer's of a Reaction. * @param set the reaction set to get the molecules from * @return a List containing the IAtomContainer objects in the IReactionSet */ public static List<IAtomContainer> getAllAtomContainers(IReactionSet set) { return MoleculeSetManipulator.getAllAtomContainers(getAllMolecules(set)); }
public static IAtomContainer getRelevantAtomContainer(IReaction reaction, IAtom atom) { IAtomContainer result = MoleculeSetManipulator.getRelevantAtomContainer(reaction.getReactants(), atom); if (result != null) { return result; } return MoleculeSetManipulator.getRelevantAtomContainer(reaction.getProducts(), atom); }
List<String> ids = MoleculeSetManipulator.getAllIDs(molSet); Assert.assertEquals(4, ids.size()); ids = MoleculeSetManipulator.getAllIDs(molSet); Assert.assertEquals(7, ids.size()); ids = MoleculeSetManipulator.getAllIDs(molSet); Assert.assertFalse(ids.contains("a1")); List<String> idsAfter = MoleculeSetManipulator.getAllIDs(molSet); Assert.assertTrue(idsAfter.contains("a1")); Assert.assertEquals(10, idsAfter.size());
@Test public void testGetAllChemObjects_IAtomContainerSet() { List<IChemObject> list = MoleculeSetManipulator.getAllChemObjects(som); Assert.assertEquals(3, list.size()); // only MoleculeSets and AtomContainers at the moment (see source code comment) } }
@Test public void testGetAllAtomContainers_IAtomContainerSet() { List<IAtomContainer> list = MoleculeSetManipulator.getAllAtomContainers(som); Assert.assertEquals(2, list.size()); }