/** * * @param reaction * @param labeller * @return */ public IReaction labelReaction( IReaction reaction, ICanonicalMoleculeLabeller labeller) { out.println("labelling " + reaction.getID()); IReaction canonReaction = new Reaction(); Map<IAtomContainer, int[]> permutationMap = new HashMap<>(); canonReaction.setProducts( canoniseAtomContainerSet( reaction.getProducts(), labeller, permutationMap)); canonReaction.setReactants( canoniseAtomContainerSet( reaction.getReactants(), labeller, permutationMap)); cloneAndSortMappings(reaction, canonReaction, permutationMap); canonReaction.setID(reaction.getID()); return canonReaction; } }
@Override public IReaction getCanonicalReaction(IReaction reaction) { BlockMapping blockMapping = new BlockMapping(reaction); // printReaction(reaction); builder = reaction.getBuilder(); IReaction permutedReaction = builder.newInstance(IReaction.class); IAtomContainerSet reactants = reaction.getReactants(); IAtomContainerSet permutedReactants = permuteR(reactants, blockMapping); permutedReaction.setReactants(permutedReactants); IAtomContainerSet products = reaction.getProducts(); IAtomContainerSet permutedProducts = permuteP(products, blockMapping); permutedReaction.setProducts(permutedProducts); replaceMappings(reaction, permutedReaction); permutedReaction.setID(reaction.getID()); return permutedReaction; }
canonReaction.setReactants(canonicalReactants); cloneAndSortMappings(reaction, canonReaction, permutationMap); return canonReaction;
hydrogenFreeReactants.addAtomContainer(acMinusH); hydrogenFreeReaction.setReactants(hydrogenFreeReactants); IAtomContainerSet hydrogenFreeProducts = new AtomContainerSet(); for (IAtomContainer atomContainer : reaction.getProducts().atomContainers()) {
@Test public void testSetReactants_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 reactants = reaction.getBuilder().newInstance(IAtomContainerSet.class); reactants.addAtomContainer(sodiumhydroxide); reactants.addAtomContainer(aceticAcid); reactants.addAtomContainer(water); reaction.setReactants(reactants); Assert.assertEquals(3, reaction.getReactantCount()); Assert.assertEquals(1.0, reaction.getReactantCoefficient(aceticAcid), 0.00001); }