/** * Returns the id of a PluginSpeciesReference object's belonging species as * an object of type StringBuffer. * * @param ref * @return */ protected static final StringBuffer getSpecies(SpeciesReference ref) { return new StringBuffer(ref.getSpecies()); }
/** * 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 SpeciesReference clone() { return new SpeciesReference(this); }
/** * Initializes the default values using the current Level/Version configuration. */ public void initDefaults() { initDefaults(getLevel(), getVersion()); }
/** * 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(); }
/** * * @return the stoichiometry value of this {@link SpeciesReference} if it is * set, otherwise, depending on the Level attribute, 1 for Level < 3 * or {@link Double#NaN}. */ public double getStoichiometry() { if (isSetStoichiometry()) { return stoichiometry.doubleValue(); } return (getLevel() < 3) ? 1d : Double.NaN; }
@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; }
reactionEqn.append(" + "); if (reactant.isSetStoichiometryMath()) { reactionEqn.append(reactant.getStoichiometryMath().getMath() .compile(this)); } else if (reactant.getStoichiometry() != 1d) { reactionEqn.append(reactant.getStoichiometry()); .append(StringTools.encodeForHTML(reactant.getSpecies())); count++; reactionEqn.append(" + "); if (product.isSetStoichiometryMath()) { reactionEqn.append(product.getStoichiometryMath().getMath() .compile(this)); } else if (product.getStoichiometry() != 1d) { reactionEqn.append(product.getStoichiometry()); reactionEqn.append(StringTools.encodeForHTML(product.getSpecies())); count++;
@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(); }
SpeciesReference speciesReference = reaction.getReactant(j); if (speciesReference.isSetSpecies() && !speciesReference.isSetSpeciesInstance()) { logger.warn(MessageFormat.format( bundle.getString("SBMLCoreParser.unknownReferenceError1"), "Species", "speciesID", speciesReference.getSpecies(), speciesReference.getElementName(), SBMLtools.getIdOrName(speciesReference))); SpeciesReference speciesReference = reaction.getProduct(j); if (speciesReference.isSetSpecies() && !speciesReference.isSetSpeciesInstance()) { logger.warn(MessageFormat.format( bundle.getString("SBMLCoreParser.unknownReferenceError1"), "Species", "speciesID", speciesReference.getSpecies(), speciesReference.getElementName(), SBMLtools.getIdOrName(speciesReference)));
/** * Sets the stoichiometry of this {@link SpeciesReference}. * * @param stoichiometry */ public void setStoichiometry(double stoichiometry) { if ((getLevel() == 1) && (getVersion() == 2)) { int stoch = (int) stoichiometry; if ((stoch < 0) || (stoch - stoichiometry != 0d)) { throw new IllegalArgumentException(MessageFormat.format( ILLEGAL_STOCHIOMETRY_VALUE, "stoichiometry", stoichiometry)); } } Double oldStoichiometry = this.stoichiometry; this.stoichiometry = Double.valueOf(stoichiometry); if (isSetStoichiometryMath()) { stoichiometryMath = null; } if (Double.isNaN(stoichiometry)) { isSetStoichiometry = false; } else { isSetStoichiometry = true; } firePropertyChange(TreeNodeChangeEvent.stoichiometry, oldStoichiometry, this.stoichiometry); }
/** * This builds multiple reaction participants in one step and adds them to * the given list of {@link SpeciesReference}s. * * @param listOf * where to add new {@link SpeciesReference} * @param participants * the definition of stoichiometry and {@link Species} for which a * reaction participant is to be created. */ private static void buildParticipants(ListOf<SpeciesReference> listOf, Pair<Double, Species>... participants) { for (Pair<Double, Species> participant : participants) { SpeciesReference sr = new SpeciesReference(listOf.getLevel(), listOf.getVersion()); if (participant.isSetKey()) { sr.setStoichiometry(participant.getKey().doubleValue()); } if (participant.isSetValue()) { sr.setSpecies(participant.getValue()); } if (listOf.getLevel() > 2) { sr.setConstant(true); } listOf.add(sr); } }
/** * 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; }
/** * Sets the denominator of this {@link SpeciesReference}. * * @param denominator * @deprecated */ @Deprecated public void setDenominator(int denominator) { if ((getLevel() == 1) && (getVersion() == 2)) { if (denominator < 0) { throw new IllegalArgumentException(MessageFormat.format( ILLEGAL_STOCHIOMETRY_VALUE, "denominator", stoichiometry)); } } Integer oldDenominator = this.denominator; this.denominator = denominator; isSetDenominator = true; firePropertyChange(TreeNodeChangeEvent.denominator, oldDenominator, this.denominator); }
/** * * @param math * @return * @deprecated since SBML Level 3 this should not be used anymore. */ @Deprecated public StoichiometryMath createStoichiometryMath(ASTNode math) { StoichiometryMath sm = new StoichiometryMath(getLevel(), getVersion()); sm.setMath(math); setStoichiometryMath(sm); return sm; }
@Override public UnitDefinition getDerivedUnitDefinition() { if (isSetStoichiometryMath()) { return stoichiometryMath.getDerivedUnitDefinition(); } UnitDefinition ud = new UnitDefinition(getLevel(), getVersion()); ud.addUnit(Unit.Kind.DIMENSIONLESS); return ud; }
((reaction.getLevel() == 1) && (reaction.getVersion() == 2)))) { SpeciesReference speciesReference = (SpeciesReference) newContextObject; speciesReference.initDefaults(); && reaction.getLevel() == 1) { SpeciesReference speciesReference = (SpeciesReference) newContextObject; speciesReference.initDefaults(); if (elementName.equals("stoichiometryMath") && speciesReference.getLevel() == 2) { StoichiometryMath stoichiometryMath = (StoichiometryMath) newContextObject; speciesReference.setStoichiometryMath(stoichiometryMath);
@Override public String getElementName() { if ((getLevel() == 1) && (getVersion() == 1)) { return "specieReference"; } return super.getElementName(); }
@Override public void setConstant(boolean constant) { if (getLevel() < 3) { throw new PropertyNotAvailableException(TreeNodeChangeEvent.constant, this); } Boolean oldConstant = this.constant; this.constant = Boolean.valueOf(constant); isSetConstant = true; firePropertyChange(TreeNodeChangeEvent.constant, oldConstant, this.constant); }
SBase parent = sbase.getParentSBMLObject(); if (parent != null) { parent = parent.getParentSBMLObject(); String id = sbase.getId(); Dimension dim = arraysParentPlugin.getDimensionByArrayDimension(0); double size = ArraysMath.getSize(model, dim);