private double caclModelScale(IReaction rxn) { List<IAtomContainer> mols = new ArrayList<>(); for (IAtomContainer mol : rxn.getReactants().atomContainers()) mols.add(mol); for (IAtomContainer mol : rxn.getProducts().atomContainers()) mols.add(mol); for (IAtomContainer mol : rxn.getAgents().atomContainers()) mols.add(mol); return caclModelScale(mols); }
private double caclModelScale(IReaction rxn) { List<IAtomContainer> mols = new ArrayList<>(); for (IAtomContainer mol : rxn.getReactants().atomContainers()) mols.add(mol); for (IAtomContainer mol : rxn.getProducts().atomContainers()) mols.add(mol); for (IAtomContainer mol : rxn.getAgents().atomContainers()) mols.add(mol); return caclModelScale(mols); }
public static IAtomContainerSet getAllAgents(IReaction reaction) { IAtomContainerSet moleculeSet = reaction.getBuilder().newInstance(IAtomContainerSet.class); IAtomContainerSet agents = reaction.getAgents(); for (int i = 0; i < agents.getAtomContainerCount(); i++) { moleculeSet.addAtomContainer(agents.getAtomContainer(i)); } return moleculeSet; }
IAtomContainerSet agents = reaction.getAgents(); for (int i = 0; i < agents.getAtomContainerCount(); i++) { reactionSMILES.append(createSMILES(agents.getAtomContainer(i)));
@Test public void testAgentParts() throws Exception { try (InputStream in = this.getClass().getResourceAsStream("ethylesterification.mol"); MDLRXNV2000Reader rdr = new MDLRXNV2000Reader(in);) { IReaction reaction = rdr.read(new Reaction()); assertThat(reaction.getAgents().getAtomContainerCount(), is(1)); } } }
/** * Labels the reactants and products in the Reaction m1, m2, etc, and the atoms * accordingly, when no ID is given. */ private static void createIDsForReaction(IReaction reaction, List<String> tabuList) { if (tabuList == null) tabuList = ReactionManipulator.getAllIDs(reaction); if (null == reaction.getID()) { // generate new ID reactionCount = setID(REACTION_PREFIX, reactionCount , reaction, tabuList); } if (policy == OBJECT_UNIQUE_POLICY) { // start atom and bond indices within a reaction set always from 1 atomCount = 0; bondCount = 0; } for (IAtomContainer reactant : reaction.getReactants().atomContainers()) { createIDsForAtomContainer(reactant, tabuList); } for (IAtomContainer product : reaction.getReactants().atomContainers()) { createIDsForAtomContainer(product, tabuList); } Iterator<IAtomContainer> agents = reaction.getAgents().atomContainers().iterator(); while (agents.hasNext()) { createIDsForAtomContainer((IAtomContainer) agents.next(), tabuList); } }
@Test public void fragmentGroupingInvalid() throws InvalidSmilesException { IReaction reaction = smipar.parseReactionSmiles("CC1=NC2=C(O)C=CC=C2C=C1.CC(Cl)=O.[Al+3].[Cl-].[Cl-].[Cl-]>[O-][N+](=O)C1=CC=CC=C1>CC(=O)C1=C2C=CC(C)=NC2=C(O)C=C1 |f:2.3.4.5,4.6|"); assertThat(reaction.getReactantCount(), is(6)); assertThat(reaction.getAgents().getAtomContainerCount(), is(1)); assertThat(reaction.getProductCount(), is(1)); assertThat(reaction.getProperty(CDKConstants.TITLE, String.class), is("")); }
@Test public void fragmentGroupingProducts() throws InvalidSmilesException { IReaction reaction = smipar.parseReactionSmiles("CC1=NC2=C(O)C=CC=C2C=C1.CC(Cl)=O>[O-][N+](=O)C1=CC=CC=C1>CC(=O)C1=C2C=CC(C)=NC2=C(O)C=C1.[Al+3].[Cl-].[Cl-].[Cl-] |f:3.4.5.6|"); assertThat(reaction.getReactantCount(), is(2)); assertThat(reaction.getAgents().getAtomContainerCount(), is(1)); assertThat(reaction.getProductCount(), is(2)); assertThat(reaction.getProperty(CDKConstants.TITLE, String.class), is("")); }
@Test public void fragmentGroupingReactants() throws InvalidSmilesException { IReaction reaction = smipar.parseReactionSmiles("CC1=NC2=C(O)C=CC=C2C=C1.CC(Cl)=O.[Al+3].[Cl-].[Cl-].[Cl-]>[O-][N+](=O)C1=CC=CC=C1>CC(=O)C1=C2C=CC(C)=NC2=C(O)C=C1 |f:2.3.4.5|"); assertThat(reaction.getReactantCount(), is(3)); assertThat(reaction.getAgents().getAtomContainerCount(), is(1)); assertThat(reaction.getProductCount(), is(1)); assertThat(reaction.getProperty(CDKConstants.TITLE, String.class), is("")); }
@Test public void fragmentGroupingAgents() throws InvalidSmilesException { IReaction reaction = smipar.parseReactionSmiles("CC1=NC2=C(O)C=CC=C2C=C1.CC(Cl)=O>[Al+3].[Cl-].[Cl-].[Cl-].[O-][N+](=O)C1=CC=CC=C1>CC(=O)C1=C2C=CC(C)=NC2=C(O)C=C1 |f:2.3.4.5|"); assertThat(reaction.getReactantCount(), is(2)); assertThat(reaction.getAgents().getAtomContainerCount(), is(2)); assertThat(reaction.getProductCount(), is(1)); assertThat(reaction.getProperty(CDKConstants.TITLE, String.class), is("")); }
/** * Determine if all parts of a reaction have coodinates * * @param reaction a reaction * @return the reaction has coordinates */ public static boolean has2DCoordinates(IReaction reaction) { for (IAtomContainer mol : reaction.getReactants().atomContainers()) if (!has2DCoordinates(mol)) return false; for (IAtomContainer mol : reaction.getProducts().atomContainers()) if (!has2DCoordinates(mol)) return false; for (IAtomContainer mol : reaction.getAgents().atomContainers()) if (!has2DCoordinates(mol)) return false; return true; }
/** * Example taken from 'Handbook of Chemoinformatics', Gasteiger, 2003, page 90 * (Part I). */ @org.junit.Test(timeout = 1000) public void testReactionWithAgents() throws Exception { String reactionSmiles = "CCO.CC(=O)O>[H+]>CC(=O)OCC.O"; IReaction reaction = sp.parseReactionSmiles(reactionSmiles); Assert.assertEquals(2, reaction.getReactantCount()); Assert.assertEquals(2, reaction.getProductCount()); Assert.assertEquals(1, reaction.getAgents().getAtomContainerCount()); Assert.assertEquals(1, reaction.getAgents().getAtomContainer(0).getAtomCount()); }
public static int getAtomCount(IReaction reaction) { int count = 0; IAtomContainerSet reactants = reaction.getReactants(); for (int i = 0; i < reactants.getAtomContainerCount(); i++) { count += reactants.getAtomContainer(i).getAtomCount(); } IAtomContainerSet agents = reaction.getAgents(); for (int i = 0; i < agents.getAtomContainerCount(); i++) { count += agents.getAtomContainer(i).getAtomCount(); } IAtomContainerSet products = reaction.getProducts(); for (int i = 0; i < products.getAtomContainerCount(); i++) { count += products.getAtomContainer(i).getAtomCount(); } return count; }
public static int getBondCount(IReaction reaction) { int count = 0; IAtomContainerSet reactants = reaction.getReactants(); for (int i = 0; i < reactants.getAtomContainerCount(); i++) { count += reactants.getAtomContainer(i).getBondCount(); } IAtomContainerSet agents = reaction.getAgents(); for (int i = 0; i < agents.getAtomContainerCount(); i++) { count += agents.getAtomContainer(i).getBondCount(); } IAtomContainerSet products = reaction.getProducts(); for (int i = 0; i < products.getAtomContainerCount(); i++) { count += products.getAtomContainer(i).getBondCount(); } return count; }
@Test public void testGetAgents() { IReaction reaction = (IReaction) newChemObject(); IAtomContainer water = reaction.getBuilder().newInstance(IAtomContainer.class); reaction.addAgent(water); Assert.assertEquals(1, reaction.getAgents().getAtomContainerCount()); }
@Test public void testAddAgent_IAtomContainer() { IReaction reaction = (IReaction) newChemObject(); IAtomContainer proton = reaction.getBuilder().newInstance(IAtomContainer.class); reaction.addAgent(proton); Assert.assertEquals(1, reaction.getAgents().getAtomContainerCount()); }
@Test public void onlyAgents() throws Exception { IReaction reaction = sp.parseReactionSmiles(">C>"); Assert.assertEquals(0, reaction.getReactantCount()); Assert.assertEquals(1, reaction.getAgents().getAtomContainerCount()); Assert.assertEquals(0, reaction.getProductCount()); }
@Test public void testReaction() throws Exception { String cmlString = "<reaction>" + "<reactantList><reactant><molecule id='react'/></reactant></reactantList>" + "<productList><product><molecule id='product'/></product></productList>" + "<substanceList><substance><molecule id='water'/></substance></substanceList>" + "</reaction>"; IChemFile chemFile = parseCMLString(cmlString); IReaction reaction = checkForSingleReactionFile(chemFile); Assert.assertEquals(1, reaction.getReactantCount()); Assert.assertEquals(1, reaction.getProductCount()); Assert.assertEquals(1, reaction.getAgents().getAtomContainerCount()); Assert.assertEquals("react", reaction.getReactants().getAtomContainer(0).getID()); Assert.assertEquals("product", reaction.getProducts().getAtomContainer(0).getID()); Assert.assertEquals("water", reaction.getAgents().getAtomContainer(0).getID()); }
protected static String cansmi(IReaction rxn) throws CDKException { IReaction copy = rxn.getBuilder().newInstance(IReaction.class); for (IAtomContainer mol : rxn.getReactants().atomContainers()) copy.addReactant(AtomContainerManipulator.copyAndSuppressedHydrogens(mol)); for (IAtomContainer mol : rxn.getProducts().atomContainers()) copy.addProduct(AtomContainerManipulator.copyAndSuppressedHydrogens(mol)); for (IAtomContainer mol : rxn.getAgents().atomContainers()) copy.addAgent(AtomContainerManipulator.copyAndSuppressedHydrogens(mol)); return smigen.create(copy); }
Assert.assertEquals("react", reaction.getReactants().getAtomContainer(0).getID()); Assert.assertEquals("product", reaction.getProducts().getAtomContainer(0).getID()); Assert.assertEquals("water", reaction.getAgents().getAtomContainer(0).getID()); Assert.assertEquals("H+", reaction.getAgents().getAtomContainer(1).getID()); Assert.assertEquals(6, reaction.getProducts().getAtomContainer(0).getAtomCount()); Assert.assertEquals(6, reaction.getReactants().getAtomContainer(0).getAtomCount());