/** * * @return */ @Override public synchronized int getMappingCount() { return reactionWithUniqueSTOICHIOMETRY.getMappingCount(); }
/** * * @param reaction * @param atomAtomMap * @return */ protected List<IMapping> cloneMappings( IReaction reaction, Map<IAtom, IAtom> atomAtomMap) { // clone the mappings int numberOfMappings = reaction.getMappingCount(); List<IMapping> map = new ArrayList<>(); for (int mappingIndex = 0; mappingIndex < numberOfMappings; mappingIndex++) { IMapping mapping = reaction.getMapping(mappingIndex); map.add(cloneMapping(mapping, atomAtomMap)); } return map; }
private List<IMapping> cloneMappings(IReaction reaction, Map<IAtom, IAtom> atomAtomMap) { // clone the mappings int numberOfMappings = reaction.getMappingCount(); List<IMapping> map = new ArrayList<IMapping>(); for (int mappingIndex = 0; mappingIndex < numberOfMappings; mappingIndex++) { IMapping mapping = reaction.getMapping(mappingIndex); IChemObject keyChemObj0 = mapping.getChemObject(0); IChemObject keyChemObj1 = mapping.getChemObject(1); IChemObject co0 = (IChemObject) atomAtomMap.get(keyChemObj0); IChemObject co1 = (IChemObject) atomAtomMap.get(keyChemObj1); map.add(new Mapping(co0, co1)); } return map; }
/** * * @param cdkReaction * @param reMap remap the reaction * @param complexMappingFlag complex mapping ..ring system etc. * @return * @throws Exception */ protected ReactionMechanismTool getReactionMechanismTool(IReaction cdkReaction, boolean reMap, boolean complexMappingFlag) throws Exception { ReactionMechanismTool rmt; /* Check if the reaction is already mapped */ if (getAtomCount(cdkReaction.getReactants()) == cdkReaction.getMappingCount()) { cdkReaction.setFlag(MAPPED, true); } else { cdkReaction.setFlag(MAPPED, false); } rmt = new ReactionMechanismTool(cdkReaction, reMap, true, false, complexMappingFlag, new StandardizeReaction()); // IPatternFingerprinter formedCleavedWFingerprint = rmt // .getSelectedSolution() // .getBondChangeCalculator() // .getFormedCleavedWFingerprint(); // System.out.println("formedCleavedWFingerprint " + formedCleavedWFingerprint); return rmt; }
@Test public void testRemoveMapping_int() { IReaction reaction = (IReaction) newChemObject(); IMapping mapping = reaction.getBuilder().newInstance(IMapping.class, reaction.getBuilder().newInstance(IAtom.class, "C"), reaction.getBuilder().newInstance(IAtom.class, "C")); reaction.addMapping(mapping); Assert.assertEquals(1, reaction.getMappingCount()); reaction.removeMapping(0); Assert.assertEquals(0, reaction.getMappingCount()); }
/** * This test checks of different numbering for the same mapping gives the same result. */ @Test public void testAsadExamples() throws Exception { String filename = "data/mdl/output.rxn"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLRXNReader reader = new MDLRXNReader(ins); IReactionSet reactionSet = (IReactionSet) reader.read(new ReactionSet()); reader.close(); filename = "data/mdl/output_Cleaned.rxn"; logger.info("Testing: " + filename); ins = this.getClass().getClassLoader().getResourceAsStream(filename); reader = new MDLRXNReader(ins); IReactionSet reactionSet2 = (IReactionSet) reader.read(new ReactionSet()); reader.close(); Assert.assertEquals(reactionSet.getReaction(0).getMappingCount(), reactionSet2.getReaction(0).getMappingCount()); for (int i = 0; i < reactionSet.getReaction(0).getMappingCount(); i++) { Assert.assertEquals(getAtomNumber(reactionSet, reactionSet.getReaction(0).getMapping(i).getChemObject(0)), getAtomNumber(reactionSet2, reactionSet2.getReaction(0).getMapping(i).getChemObject(0))); Assert.assertEquals(getAtomNumber(reactionSet, reactionSet.getReaction(0).getMapping(i).getChemObject(1)), getAtomNumber(reactionSet2, reactionSet2.getReaction(0).getMapping(i).getChemObject(1))); } }
@Test public void testGetMappingCount() { IReaction reaction = (IReaction) newChemObject(); IMapping mapping = reaction.getBuilder().newInstance(IMapping.class, reaction.getBuilder().newInstance(IAtom.class, "C"), reaction.getBuilder().newInstance(IAtom.class, "C")); reaction.addMapping(mapping); Assert.assertEquals(1, reaction.getMappingCount()); }
@Test public void testMappings() { IReaction reaction = (IReaction) newChemObject(); IMapping mapping = reaction.getBuilder().newInstance(IMapping.class, reaction.getBuilder().newInstance(IAtom.class, "C"), reaction.getBuilder().newInstance(IAtom.class, "C")); reaction.addMapping(mapping); Assert.assertEquals(1, reaction.getMappingCount()); } }
/** * * @param reaction */ private synchronized void cleanMapping(IReaction reaction) { int count = reaction.getMappingCount(); for (int i = count; i > 0; i--) { reaction.removeMapping(i); } for (int eMol = 0; eMol < reaction.getReactantCount(); eMol++) { IAtomContainer eMolecule = reaction.getReactants().getAtomContainer(eMol); for (int eAtom = 0; eAtom < eMolecule.getAtomCount(); eAtom++) { IAtom atomEMap = reaction.getReactants().getAtomContainer(eMol).getAtom(eAtom); atomEMap.setFlag(MAPPED, false); } } for (int pMol = 0; pMol < reaction.getProductCount(); pMol++) { IAtomContainer pMolecule = reaction.getProducts().getAtomContainer(pMol); for (int pAtom = 0; pAtom < pMolecule.getAtomCount(); pAtom++) { IAtom atomPMap = reaction.getProducts().getAtomContainer(pMol).getAtom(pAtom); atomPMap.setFlag(MAPPED, false); } } }
/** * A unit test suite for JUnit. * * @cdk.inchi InChI=1/C2H4O/c1-2-3/h2H,1H3 * * @return The test suite */ @Test public void testMapping() throws Exception { IReactionProcess type = new AdductionSodiumLPReaction(); IAtomContainerSet setOfReactants = getExampleReactants(); IAtomContainer molecule = setOfReactants.getAtomContainer(0); /* automatic looking for active center */ List<IParameterReact> paramList = new ArrayList<IParameterReact>(); IParameterReact param = new SetReactionCenter(); param.setParameter(Boolean.FALSE); paramList.add(param); type.setParameterList(paramList); /* initiate */ IReactionSet setOfReactions = type.initiate(setOfReactants, null); IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0); Assert.assertEquals(8, setOfReactions.getReaction(0).getMappingCount()); IAtom mappedProductA0 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(0)); Assert.assertEquals(mappedProductA0, product.getAtom(0)); }
/** * A unit test suite for JUnit. * * @cdk.inchi InChI=1/C2H4O/c1-2-3/h2H,1H3 * * @return The test suite */ @Test public void testMapping() throws Exception { IReactionProcess type = new AdductionProtonLPReaction(); /* automatic looking for active center */ List<IParameterReact> paramList = new ArrayList<IParameterReact>(); IParameterReact param = new SetReactionCenter(); param.setParameter(Boolean.FALSE); paramList.add(param); type.setParameterList(paramList); /* initiate */ IAtomContainerSet setOfReactants = getExampleReactants(); IAtomContainer molecule = setOfReactants.getAtomContainer(0); IReactionSet setOfReactions = type.initiate(setOfReactants, null); IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0); Assert.assertEquals(8, setOfReactions.getReaction(0).getMappingCount()); IAtom mappedProductA0 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(0)); Assert.assertEquals(mappedProductA0, product.getAtom(0)); }
/** * A unit test suite for JUnit. Reaction: C=O => C=[O*+] * Manually put of the reactive center. * * @cdk.inchi InChI=1/CH2O/c1-2/h1H2 * * @return The test suite */ @Test public void testMapping() throws Exception { IReactionProcess type = new ElectronImpactNBEReaction(); IAtomContainerSet setOfReactants = getExampleReactants(); IAtomContainer molecule = setOfReactants.getAtomContainer(0); /* automatic search of the center active */ List<IParameterReact> paramList = new ArrayList<IParameterReact>(); IParameterReact param = new SetReactionCenter(); param.setParameter(Boolean.FALSE); paramList.add(param); type.setParameterList(paramList); IReactionSet setOfReactions = type.initiate(setOfReactants, null); IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0); Assert.assertEquals(4, setOfReactions.getReaction(0).getMappingCount()); IAtom mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(1)); Assert.assertEquals(mappedProductA1, product.getAtom(1)); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testMapping() throws Exception { IReactionProcess type = new SharingChargeDBReaction(); IAtomContainerSet setOfReactants = getExampleReactants(); IAtomContainer molecule = setOfReactants.getAtomContainer(0); /* automatic search of the center active */ List<IParameterReact> paramList = new ArrayList<IParameterReact>(); IParameterReact param = new SetReactionCenter(); param.setParameter(Boolean.FALSE); paramList.add(param); type.setParameterList(paramList); /* initiate */ IReactionSet setOfReactions = type.initiate(setOfReactants, null); IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0); Assert.assertEquals(8, setOfReactions.getReaction(0).getMappingCount()); IAtom mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(1)); Assert.assertEquals(mappedProductA1, product.getAtom(1)); mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(2)); Assert.assertEquals(mappedProductA1, product.getAtom(2)); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testMapping() throws Exception { IReactionProcess type = new SharingLonePairReaction(); IAtomContainerSet setOfReactants = getExampleReactants(); IAtomContainer molecule = setOfReactants.getAtomContainer(0); /* automatic search of the center active */ List<IParameterReact> paramList = new ArrayList<IParameterReact>(); IParameterReact param = new SetReactionCenter(); param.setParameter(Boolean.FALSE); paramList.add(param); type.setParameterList(paramList); /* initiate */ IReactionSet setOfReactions = type.initiate(setOfReactants, null); IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0); Assert.assertEquals(5, setOfReactions.getReaction(0).getMappingCount()); IAtom mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(0)); Assert.assertEquals(mappedProductA1, product.getAtom(0)); IAtom mappedProductA2 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(1)); Assert.assertEquals(mappedProductA2, product.getAtom(1)); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testMapping() throws Exception { IReactionProcess type = new SharingAnionReaction(); IAtomContainerSet setOfReactants = getExampleReactants(); IAtomContainer molecule = setOfReactants.getAtomContainer(0); /* automatic search of the center active */ List<IParameterReact> paramList = new ArrayList<IParameterReact>(); IParameterReact param = new SetReactionCenter(); param.setParameter(Boolean.FALSE); paramList.add(param); type.setParameterList(paramList); /* initiate */ IReactionSet setOfReactions = type.initiate(setOfReactants, null); IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0); Assert.assertEquals(4, setOfReactions.getReaction(0).getMappingCount()); IAtom mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(0)); Assert.assertEquals(mappedProductA1, product.getAtom(0)); IAtom mappedProductA2 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(1)); Assert.assertEquals(mappedProductA2, product.getAtom(1)); }
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testMapping() throws Exception { IReactionProcess type = new HomolyticCleavageReaction(); IAtomContainerSet setOfReactants = getExampleReactants(); IAtomContainer molecule = setOfReactants.getAtomContainer(0); /* automatic search of the center active */ List<IParameterReact> paramList = new ArrayList<IParameterReact>(); IParameterReact param = new SetReactionCenter(); param.setParameter(Boolean.FALSE); paramList.add(param); type.setParameterList(paramList); /* initiate */ makeSureAtomTypesAreRecognized(molecule); IReactionSet setOfReactions = type.initiate(setOfReactants, null); IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0); Assert.assertEquals(4, setOfReactions.getReaction(0).getMappingCount()); IAtom mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(0)); Assert.assertEquals(mappedProductA1, product.getAtom(0)); IAtom mappedProductA2 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(1)); Assert.assertEquals(mappedProductA2, product.getAtom(1)); }
/** * A unit test suite for JUnit. Reaction: C-C#[O+] => [C+] + [|C-]#[O+] * Automatically looks for active centre. * * @return The test suite */ @Test public void testMappingExample1() throws Exception { IReactionProcess type = new CarbonylEliminationReaction(); IAtomContainerSet setOfReactants = getExampleReactants(); IAtomContainer molecule = setOfReactants.getAtomContainer(0); /* initiate */ List<IParameterReact> paramList = new ArrayList<IParameterReact>(); IParameterReact param = new SetReactionCenter(); param.setParameter(Boolean.FALSE); paramList.add(param); type.setParameterList(paramList); IReactionSet setOfReactions = type.initiate(setOfReactants, null); IAtomContainer product1 = setOfReactions.getReaction(0).getProducts().getAtomContainer(0); IAtomContainer product2 = setOfReactions.getReaction(0).getProducts().getAtomContainer(1); Assert.assertEquals(6, setOfReactions.getReaction(0).getMappingCount()); IAtom mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(0)); Assert.assertEquals(mappedProductA1, product1.getAtom(0)); IAtom mappedProductA2 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(4)); Assert.assertEquals(mappedProductA2, product2.getAtom(0)); }
IAtomContainer product2 = setOfReactions.getReaction(0).getProducts().getAtomContainer(1); Assert.assertEquals(6, setOfReactions.getReaction(0).getMappingCount()); IAtom mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(0));
/** * A unit test suite for JUnit. * * @return The test suite */ @Test public void testMapping() throws Exception { IReactionProcess type = new RadicalSiteHrDeltaReaction(); IAtomContainerSet setOfReactants = getExampleReactants(); IAtomContainer molecule = setOfReactants.getAtomContainer(0); /* automatic search of the center active */ List<IParameterReact> paramList = new ArrayList<IParameterReact>(); IParameterReact param = new SetReactionCenter(); param.setParameter(Boolean.FALSE); paramList.add(param); type.setParameterList(paramList); /* initiate */ IReactionSet setOfReactions = type.initiate(setOfReactants, null); IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0); Assert.assertEquals(18, setOfReactions.getReaction(0).getMappingCount()); IAtom mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(0)); Assert.assertEquals(mappedProductA1, product.getAtom(0)); IAtom mappedProductA2 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(6)); Assert.assertEquals(mappedProductA2, product.getAtom(6)); IAtom mappedProductA3 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(7)); Assert.assertEquals(mappedProductA3, product.getAtom(7)); }
IAtomContainer product2 = setOfReactions.getReaction(0).getProducts().getAtomContainer(1); Assert.assertEquals(10, setOfReactions.getReaction(0).getMappingCount());