@Test public void testGetDirection() { IReaction reaction = (IReaction) newChemObject(); Assert.assertEquals(IReaction.Direction.FORWARD, reaction.getDirection()); }
/** * 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; }
@Test public void testSetDirection_IReaction_Direction() { IReaction reaction = (IReaction) newChemObject(); IReaction.Direction direction = IReaction.Direction.BIDIRECTIONAL; reaction.setDirection(direction); Assert.assertEquals(direction, reaction.getDirection()); }
if (reaction.getDirection() != null) { standardizedReaction.setDirection(reaction.getDirection()); } else { standardizedReaction.setDirection(BIDIRECTIONAL);
plus, rxn.getDirection(), dimensions, reactantTitles, productTitles,
plus, rxn.getDirection(), dimensions, reactantTitles, productTitles,
@Test public void testReaction() { IReaction reaction = new Reaction(); Assert.assertNotNull(reaction); Assert.assertEquals(0, reaction.getReactantCount()); Assert.assertEquals(0, reaction.getProductCount()); Assert.assertEquals(IReaction.Direction.FORWARD, reaction.getDirection()); }
? "MappedReaction (ecBLAST)" : reactionWithSTOICHIOMETRY.getID()); reactionWithUniqueSTOICHIOMETRY.setDirection(reactionWithSTOICHIOMETRY.getDirection() == null ? BIDIRECTIONAL : reactionWithSTOICHIOMETRY.getDirection());
/** * * @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; } }
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()); } }
copiedReaction.setDirection(orignalReaction.getDirection()); copiedReaction.notifyChanged(); return copiedReaction;