/** * Adds a product to this reaction. * * @param product Molecule added as product to this reaction * @see #getProducts */ @Override public void addProduct(IAtomContainer product) { this.addProduct(product, 1.0); /* * notifyChanged() is called by addProduct(Molecule product, double * coefficient) */ }
/** * Adds a reactant to this reaction. * * @param reactant Molecule added as reactant to this reaction * @see #getReactants */ @Override public void addReactant(IAtomContainer reactant) { addReactant(reactant, 1.0); /* * notifyChanged() is called by addReactant(Molecule reactant, double * coefficient) */ }
/** * Adds a mapping between the reactant and product side to this * Reaction. * * @param mapping Mapping to add. * @see #mappings */ @Override public void addMapping(IMapping mapping) { if (mappingCount + 1 >= map.length) growMappingArray(); map[mappingCount] = mapping; mappingCount++; }
@Override public IChemObject newTestObject() { return new Reaction(); } });
/** * Constructs an empty, forward reaction. */ public Reaction() { this.reactants = getBuilder().newInstance(IAtomContainerSet.class); this.products = getBuilder().newInstance(IAtomContainerSet.class); this.agents = getBuilder().newInstance(IAtomContainerSet.class); this.map = new Mapping[growArraySize]; mappingCount = 0; reactionDirection = IReaction.Direction.FORWARD; }
@Override public void remove() { removeMapping(--pointer); }
/** * Clones this <code>ReactionSet</code> and the contained <code>Reaction</code>s * too. * * @return The cloned ReactionSet */ @Override public Object clone() throws CloneNotSupportedException { ReactionSet clone = (ReactionSet) super.clone(); // clone the reactions clone.reactionCount = this.reactionCount; clone.reactions = new Reaction[clone.reactionCount]; for (int f = 0; f < clone.reactionCount; f++) { clone.reactions[f] = (Reaction) ((Reaction) reactions[f]).clone(); } return clone; }
/** * Returns a one line string representation of this Atom. * Methods is conform RFC #9. * * @return The string representation of this Atom */ @Override public String toString() { StringBuffer description = new StringBuffer(64); description.append("Reaction("); description.append(getID()); description.append(", #M:").append(mappingCount); description.append(", reactants=").append(reactants.toString()); description.append(", products=").append(products.toString()); description.append(", agents=").append(agents.toString()); description.append(')'); return description.toString(); }
@Test public void testReaction() { IReaction polymer = new Reaction(); Assert.assertTrue(polymer instanceof Reaction); }
/** * Constructs an empty, forward reaction. */ public Reaction() { this.reactants = getBuilder().newInstance(IAtomContainerSet.class); this.products = getBuilder().newInstance(IAtomContainerSet.class); this.agents = getBuilder().newInstance(IAtomContainerSet.class); this.map = new Mapping[growArraySize]; mappingCount = 0; reactionDirection = IReaction.Direction.FORWARD; }
@Override public void remove() { removeMapping(--pointer); }
/** * Clones this <code>ReactionSet</code> and the contained <code>Reaction</code>s * too. * * @return The cloned ReactionSet */ @Override public Object clone() throws CloneNotSupportedException { ReactionSet clone = (ReactionSet) super.clone(); // clone the reactions clone.reactionCount = this.reactionCount; clone.reactions = new Reaction[clone.reactionCount]; for (int f = 0; f < clone.reactionCount; f++) { clone.reactions[f] = (Reaction) ((Reaction) reactions[f]).clone(); } return clone; }
/** * Returns a one line string representation of this Atom. * Methods is conform RFC #9. * * @return The string representation of this Atom */ @Override public String toString() { StringBuffer description = new StringBuffer(64); description.append("Reaction("); description.append(getID()); description.append(", #M:").append(mappingCount); description.append(", reactants=").append(reactants.toString()); description.append(", products=").append(products.toString()); description.append(", agents=").append(agents.toString()); description.append(')'); return description.toString(); }
@BeforeClass public static void setUp() { setTestObjectBuilder(new ITestObjectBuilder() { @Override public IChemObject newTestObject() { return new Reaction(); } }); }
/** * Adds a reactant to this reaction. * * @param reactant Molecule added as reactant to this reaction * @see #getReactants */ @Override public void addReactant(IAtomContainer reactant) { addReactant(reactant, 1.0); /* * notifyChanged() is called by addReactant(Molecule reactant, double * coefficient) */ }
/** * Adds a mapping between the reactant and product side to this * Reaction. * * @param mapping Mapping to add. * @see #mappings */ @Override public void addMapping(IMapping mapping) { if (mappingCount + 1 >= map.length) growMappingArray(); map[mappingCount] = mapping; mappingCount++; }
/** * Adds a product to this reaction. * * @param product Molecule added as product to this reaction * @see #getProducts */ @Override public void addProduct(IAtomContainer product) { this.addProduct(product, 1.0); /* * notifyChanged() is called by addProduct(Molecule product, double * coefficient) */ }
@Test public void testReactionCustomization() throws Exception { StringWriter writer = new StringWriter(); IReaction reaction = new Reaction(); reaction.setID("reaction1"); IAtomContainer reactant = reaction.getBuilder().newInstance(IAtomContainer.class); reactant.setID("react"); IAtomContainer product = reaction.getBuilder().newInstance(IAtomContainer.class); product.setID("product"); IAtomContainer agent = reaction.getBuilder().newInstance(IAtomContainer.class); agent.setID("agent"); reaction.addReactant(reactant); reaction.addProduct(product); reaction.addAgent(agent); CMLWriter cmlWriter = new CMLWriter(writer); cmlWriter.write(reaction); cmlWriter.close(); String cmlContent = writer.toString(); logger.debug("****************************** testReactionCustomization()"); logger.debug(cmlContent); logger.debug("******************************"); Assert.assertTrue(cmlContent.indexOf("<reaction id=\"reaction1") != -1); Assert.assertTrue(cmlContent.indexOf("<molecule id=\"react") != -1); Assert.assertTrue(cmlContent.indexOf("<molecule id=\"product") != -1); Assert.assertTrue(cmlContent.indexOf("<molecule id=\"agent") != -1); }