/** * * @param i Index at I th position * @return Stoichiometry weight of the product molecule at i th Position * */ @Override public synchronized Double getExpandedProductStoichiometry(int i) { IAtomContainer Mol = reactionWithUniqueSTOICHIOMETRY.getProducts().getAtomContainer(i); return reactionWithUniqueSTOICHIOMETRY.getProductCoefficient(Mol); }
@Test public void testGetProductCoefficients() { IReaction reaction = (IReaction) newChemObject(); IAtomContainer pr1 = reaction.getBuilder().newInstance(IAtomContainer.class); IAtomContainer pr2 = reaction.getBuilder().newInstance(IAtomContainer.class); reaction.addProduct(pr1, 1d); reaction.addProduct(pr2, 2d); Double[] pc = reaction.getProductCoefficients(); Assert.assertEquals(2.0, pc.length, 0.00001); Assert.assertEquals(reaction.getProductCoefficient(pr1), pc[0], 0.00001); Assert.assertEquals(2.0, pc[1], 0.00001); }
private static void printReaction(IReaction reaction) { IAtomContainerSet Educt = reaction.getReactants(); IAtomContainerSet Product = reaction.getProducts(); out.println("*******************************"); out.println("Educt Mol Count: " + Educt.getAtomContainerCount()); out.println("*******************************"); for (int j = 0; j < Educt.getAtomContainerCount(); j++) { IAtomContainer M = Educt.getAtomContainer(j); out.println("Mol ID: " + M.getID()); out.println("Stoic: " + reaction.getReactantCoefficient(M)); out.println("Split Mol Atom Count: " + M.getAtomCount()); printAtoms(M); } out.println("*******************************"); out.println("Product Mol Count: " + Product.getAtomContainerCount()); out.println("*******************************"); for (int j = 0; j < Product.getAtomContainerCount(); j++) { IAtomContainer M = Product.getAtomContainer(j); out.println("Mol ID: " + M.getID()); out.println("Stoic: " + reaction.getProductCoefficient(M)); out.println("Split Mol Atom Count: " + M.getAtomCount()); printAtoms(M); } out.println(NEW_LINE + "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + NEW_LINE + NEW_LINE); }
out.println("Mol ID: " + M.getID()); out.println("SingleElectron: " + M.getSingleElectronCount()); out.println("Stoic: " + reaction.getProductCoefficient(M)); out.println("Split Mol Atom Count: " + M.getAtomCount()); printAtoms(M);
productCount += reaction.getProductCoefficient(p).intValue();
@Test public void testGetProductCoefficient_IAtomContainer() { IReaction reaction = (IReaction) newChemObject(); IAtomContainer proton = reaction.getBuilder().newInstance(IAtomContainer.class); reaction.addProduct(proton, 2.0); Assert.assertEquals(2.0, reaction.getProductCoefficient(proton), 0.00001); Assert.assertEquals(-1.0, reaction.getProductCoefficient(reaction.getBuilder().newInstance(IAtomContainer.class)), 0.00001); }
@Test public void testAddProduct_IAtomContainer_Double() { IReaction reaction = (IReaction) newChemObject(); IAtomContainer proton = reaction.getBuilder().newInstance(IAtomContainer.class); IAtomContainer sulfate = reaction.getBuilder().newInstance(IAtomContainer.class); reaction.addProduct(proton, 2.0); reaction.addProduct(sulfate, 1.0); Assert.assertEquals(2.0, reaction.getProductCoefficient(proton), 0.00001); Assert.assertEquals(1.0, reaction.getProductCoefficient(sulfate), 0.00001); }
IAtomContainer ac1 = ac.getBuilder().newInstance(IAtomContainer.class, ac); String id = ac.getID() == null ? toHexString(currentTimeMillis()).toUpperCase() : ac.getID(); Double productCoefficient = reaction.getProductCoefficient(ac);
String id = mol.getID() == null || mol.getID().trim().isEmpty() ? null : mol.getID(); tempStoic = 1.0; if (reaction.getProductCoefficient(mol) > 0) { tempStoic = reaction.getProductCoefficient(mol);
@Test public void testSetProductCoefficient_IAtomContainer_Double() { IReaction reaction = (IReaction) newChemObject(); IAtomContainer proton = reaction.getBuilder().newInstance(IAtomContainer.class); reaction.addProduct(proton, 2.0); reaction.setProductCoefficient(proton, 1.0); Assert.assertEquals(1.0, reaction.getProductCoefficient(proton), 0.00001); }
/** * * @param reaction * @return a new mol with explicit Hydrogens * @throws CloneNotSupportedException */ public static IReaction addExplicitH(IReaction reaction) throws CloneNotSupportedException { IReaction r = reaction.getBuilder().newInstance(IReaction.class); for (IAtomContainer ac : reaction.getReactants().atomContainers()) { IAtomContainer addExplicitH = ExtAtomContainerManipulator.addExplicitH(ac); r.addReactant(addExplicitH, reaction.getReactantCoefficient(ac)); } for (IAtomContainer ac : reaction.getProducts().atomContainers()) { IAtomContainer addExplicitH = ExtAtomContainerManipulator.addExplicitH(ac); r.addProduct(addExplicitH, reaction.getProductCoefficient(ac)); } r.setDirection(reaction.getDirection()); r.setID(reaction.getID() == null ? "" : reaction.getID()); return r; } }
@Test public void testSetProductCoefficients_arrayDouble() { IReaction reaction = (IReaction) newChemObject(); IAtomContainer pr1 = reaction.getBuilder().newInstance(IAtomContainer.class); reaction.addProduct(pr1, 1d); Double[] pc = {2.0}; boolean coeffSet = reaction.setProductCoefficients(pc); Assert.assertTrue(coeffSet); Assert.assertEquals(2.0, reaction.getProductCoefficient(pr1), 0.00001); Double[] pcFalse = {1.0, 2.0}; Assert.assertFalse(reaction.setProductCoefficients(pcFalse)); }
System.out.println("p " + ac.getTitle() + ":" + reaction.getProductCoefficient(ac));
/** * Returns a new Reaction object which is the reverse of the given * Reaction. * @param reaction the reaction being considered * @return the reverse reaction */ public static IReaction reverse(IReaction reaction) { IReaction reversedReaction = reaction.getBuilder().newInstance(IReaction.class); if (reaction.getDirection() == IReaction.Direction.BIDIRECTIONAL) { reversedReaction.setDirection(IReaction.Direction.BIDIRECTIONAL); } else if (reaction.getDirection() == IReaction.Direction.FORWARD) { reversedReaction.setDirection(IReaction.Direction.BACKWARD); } else if (reaction.getDirection() == IReaction.Direction.BACKWARD) { reversedReaction.setDirection(IReaction.Direction.FORWARD); } IAtomContainerSet reactants = reaction.getReactants(); for (int i = 0; i < reactants.getAtomContainerCount(); i++) { double coefficient = reaction.getReactantCoefficient(reactants.getAtomContainer(i)); reversedReaction.addProduct(reactants.getAtomContainer(i), coefficient); } IAtomContainerSet products = reaction.getProducts(); for (int i = 0; i < products.getAtomContainerCount(); i++) { double coefficient = reaction.getProductCoefficient(products.getAtomContainer(i)); reversedReaction.addReactant(products.getAtomContainer(i), coefficient); } return reversedReaction; }
private synchronized void copyReferenceReaction(IReaction referenceReaction) throws CDKException, IOException, Exception { try { for (int i = 0; i < referenceReaction.getReactantCount(); i++) { IAtomContainer refMol = referenceReaction.getReactants().getAtomContainer(i); IAtomContainer mol = cloneWithIDs(refMol); mol = canonicalLabelling(mol); mol.setID(referenceReaction.getReactants().getAtomContainer(i).getID()); Double st = referenceReaction.getReactantCoefficient(refMol); aromatizeMolecule(mol); reactionWithSTOICHIOMETRY.addReactant(mol, st); } } catch (CloneNotSupportedException | CDKException e) { LOGGER.error(SEVERE, null, e); } try { for (int i = 0; i < referenceReaction.getProductCount(); i++) { IAtomContainer refMol = referenceReaction.getProducts().getAtomContainer(i); IAtomContainer mol = cloneWithIDs(refMol);//refMol.clone(); mol = canonicalLabelling(mol); mol.setID(referenceReaction.getProducts().getAtomContainer(i).getID()); Double st = referenceReaction.getProductCoefficient(refMol); aromatizeMolecule(mol); reactionWithSTOICHIOMETRY.addProduct(mol, st); } reactionWithSTOICHIOMETRY.setID(referenceReaction.getID()); reactionWithSTOICHIOMETRY.setDirection(referenceReaction.getDirection()); } catch (Exception e) { LOGGER.error(SEVERE, "Error in Reactor class", e.getMessage()); } }
private IReaction layoutReaction( IReaction mappedReaction, String reactionID) { IReaction reactionWithLayout = new Reaction(); reactionWithLayout.setDirection(FORWARD); reactionWithLayout.setID(reactionID); for (IAtomContainer ac : mappedReaction.getReactants().atomContainers()) { IAtomContainer moleculeWithLayoutCheck = getMoleculeWithLayoutCheck(ac); moleculeWithLayoutCheck.setID(ac.getID()); reactionWithLayout.addReactant(ac, mappedReaction.getReactantCoefficient(ac)); } for (IAtomContainer ac : mappedReaction.getProducts().atomContainers()) { IAtomContainer moleculeWithLayoutCheck = getMoleculeWithLayoutCheck(ac); moleculeWithLayoutCheck.setID(ac.getID()); reactionWithLayout.addProduct(ac, mappedReaction.getProductCoefficient(ac)); } for (IMapping m : mappedReaction.mappings()) { reactionWithLayout.addMapping(m); } reactionWithLayout.setFlags(mappedReaction.getFlags()); reactionWithLayout.setProperties(mappedReaction.getProperties()); return reactionWithLayout; }
@Test public void testSetProducts_IAtomContainerSet() { IReaction reaction = (IReaction) newChemObject(); IAtomContainer sodiumhydroxide = reaction.getBuilder().newInstance(IAtomContainer.class); IAtomContainer aceticAcid = reaction.getBuilder().newInstance(IAtomContainer.class); IAtomContainer water = reaction.getBuilder().newInstance(IAtomContainer.class); IAtomContainerSet products = reaction.getBuilder().newInstance(IAtomContainerSet.class); products.addAtomContainer(sodiumhydroxide); products.addAtomContainer(aceticAcid); products.addAtomContainer(water); reaction.setProducts(products); Assert.assertEquals(3, reaction.getProductCount()); Assert.assertEquals(1.0, reaction.getProductCoefficient(aceticAcid), 0.00001); }
Double stoichiometry = reactionWithSTOICHIOMETRY.getProductCoefficient(_prod); while (stoichiometry > 0.0) { stoichiometry -= 1;
@Test public void testAddProduct_IAtomContainer() { IReaction reaction = (IReaction) newChemObject(); IAtomContainer sodiumhydroxide = reaction.getBuilder().newInstance(IAtomContainer.class); IAtomContainer aceticAcid = reaction.getBuilder().newInstance(IAtomContainer.class); IAtomContainer water = reaction.getBuilder().newInstance(IAtomContainer.class); IAtomContainer acetate = reaction.getBuilder().newInstance(IAtomContainer.class); reaction.addProduct(sodiumhydroxide); reaction.addProduct(aceticAcid); reaction.addProduct(water); Assert.assertEquals(3, reaction.getProductCount()); // next one should trigger a growArray, if the grow // size is still 3. reaction.addProduct(acetate); Assert.assertEquals(4, reaction.getProductCount()); Assert.assertEquals(1.0, reaction.getProductCoefficient(aceticAcid), 0.00001); }
Double st = orignalReaction.getProductCoefficient(mol); IAtomContainer newMol = cloneWithIDs(mol); for (int index = 0; index < mol.getAtomCount(); index++) {