/** * Returns the value of a PluginSpeciesReference object's stoichiometry * either as a double or, if the stoichiometry has an integer value, as an * int object. * * @param ref * @return */ protected static final double getStoichiometry(SpeciesReference ref) { double stoich = ref.getStoichiometry(); return stoich; }
@Override public String printSpeciesReference() { StringBuilder sb = new StringBuilder(); if (isSetStoichiometry() && (getStoichiometry() != 1d)) { sb.append(StringTools.toString(getStoichiometry())); sb.append(' '); } else if (isSetStoichiometryMath()) { sb.append(getStoichiometryMath().getMath().toFormula()); sb.append(' '); } sb.append(super.printSpeciesReference()); return sb.toString(); }
reactionEqn.append(reactant.getStoichiometryMath().getMath() .compile(this)); } else if (reactant.getStoichiometry() != 1d) { reactionEqn.append(reactant.getStoichiometry()); reactionEqn.append(product.getStoichiometryMath().getMath() .compile(this)); } else if (product.getStoichiometry() != 1d) { reactionEqn.append(product.getStoichiometry());
@Override public double getValue() { return getStoichiometry(); }
reactionEqn.append(reactant.getStoichiometryMath().getMath().toASTNode2() .compile((ASTNode2Compiler) this)); } else if (reactant.getStoichiometry() != 1d) { reactionEqn.append(reactant.getStoichiometry()); reactionEqn.append(product.getStoichiometryMath().getMath().toASTNode2() .compile((ASTNode2Compiler) this)); } else if (product.getStoichiometry() != 1d) { reactionEqn.append(product.getStoichiometry());
/** * This method computes the fraction of the stoichiometry and the * denominator. Actually, the denominator is only defined in SBML Level 1. * For convenience, this method might be usefull. * * @return The fraction between {@link #stoichiometry} and * {@link #denominator}. */ public double getCalculatedStoichiometry() { int denominator = getDenominator(); return (denominator != 1) ? getStoichiometry() / denominator : getStoichiometry(); }
/** * Creates a SpeciesReference instance from a given SpeciesReference. * * @param speciesReference */ @SuppressWarnings("deprecation") public SpeciesReference(SpeciesReference speciesReference) { super(speciesReference); if (speciesReference.isSetStoichiometryMath()) { setStoichiometryMath(speciesReference.getStoichiometryMath() .clone()); } if (speciesReference.isSetStoichiometry()) { setStoichiometry(new Double(speciesReference.getStoichiometry())); } else { stoichiometry = speciesReference.stoichiometry == null ? null : new Double(speciesReference.stoichiometry); } if (speciesReference.isSetConstant()) { setConstant(new Boolean(speciesReference.isConstant())); } else { constant = speciesReference.constant == null ? null : new Boolean(speciesReference.constant); } if (speciesReference.isSetDenominator) { setDenominator(new Integer(speciesReference.getDenominator())); } else { denominator = speciesReference.denominator == null ? null : new Integer(speciesReference.denominator); } }
@Override public Map<String, String> writeXMLAttributes() { Map<String, String> attributes = super.writeXMLAttributes(); if (isSetStoichiometry()) { attributes.put("stoichiometry", StringTools.toString( Locale.ENGLISH, getStoichiometry())); } if (isSetConstant()) { attributes.put("constant", Boolean.toString(isConstant())); } if (isSetDenominator() && (getLevel() == 1)) { int denominator = getDenominator(); if (denominator != 1) { attributes.put("denominator", Integer.toString(denominator)); } } return attributes; }
private void processSpeciesReferences(ONDEXConcept reactionC, ListOf<? extends SimpleSpeciesReference> references, RelationType rt) { if (references == null) { return; } for (int j = 0; j < references.size(); j++) { SimpleSpeciesReference reactantRef = references.get(j); ONDEXConcept speciesC = speciesById.get(reactantRef.getSpecies()); if (speciesC != null) { ONDEXRelation reactantRel = graph.getFactory().createRelation(speciesC, reactionC, rt, etSBML); if (reactantRel != null) { if (reactantRef instanceof SpeciesReference) { reactantRel.createAttribute(anStoch, ((SpeciesReference) reactantRef).getStoichiometry(), false); // TODO: handle stoich math } } else { logFail("Failed to create relation!"); } } else { logFail("Unable to resolve species reference: " + reactantRef.getSpecies()); } } }
private void processSpeciesReferences(ONDEXConcept reactionC, ListOf<? extends SimpleSpeciesReference> references, RelationType rt) { if (references == null) { return; } for (int j = 0; j < references.size(); j++) { SimpleSpeciesReference reactantRef = references.get(j); ONDEXConcept speciesC = speciesById.get(reactantRef.getSpecies()); if (speciesC != null) { ONDEXRelation reactantRel = graph.getFactory().createRelation(speciesC, reactionC, rt, etSBML); if (reactantRel != null) { if (reactantRef instanceof SpeciesReference) { reactantRel.createAttribute(anStoch, ((SpeciesReference) reactantRef).getStoichiometry(), false); // TODO: handle stoich math } } else { logFail("Failed to create relation!"); } } else { logFail("Unable to resolve species reference: " + reactantRef.getSpecies()); } } }
@Override public boolean equals(Object object) { boolean equals = super.equals(object); if (equals) { SpeciesReference sr = (SpeciesReference) object; equals &= sr.isSetStoichiometry() == isSetStoichiometry(); if (equals && isSetStoichiometry()) { equals &= sr.getStoichiometry() == getStoichiometry(); } equals &= sr.isSetConstant() == isSetConstant(); if (equals && isSetConstant()) { equals &= sr.isConstant() == isConstant(); } equals &= sr.isSetDenominator() == isSetDenominator(); if (equals && isSetDenominator()) { equals &= sr.getDenominator() == getDenominator(); } } return equals; }