IR.setDirection(FORWARD); break; case 2: IR.setDirection(BACKWARD); break; case 3: case 0: IR.setDirection(BIDIRECTIONAL); break; default:
cleanedReaction.setDirection(BIDIRECTIONAL);
IR.setDirection(BIDIRECTIONAL);
/** * 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()); }
standardizedReaction.setDirection(reaction.getDirection()); } else { standardizedReaction.setDirection(BIDIRECTIONAL);
/** * * @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()); } }
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; }
? "MappedReaction (ecBLAST)" : reactionWithSTOICHIOMETRY.getID()); reactionWithUniqueSTOICHIOMETRY.setDirection(reactionWithSTOICHIOMETRY.getDirection() == null ? BIDIRECTIONAL : reactionWithSTOICHIOMETRY.getDirection());
copiedReaction.setDirection(orignalReaction.getDirection()); copiedReaction.notifyChanged(); return copiedReaction;