/** * Returns the conversionFactor of this Species as a {@link Parameter} instance. * * @return the Parameter instance which has the conversionFactor of this * Species as id, null if it doesn't exist. */ public Parameter getConversionFactorInstance() { if (getModel() == null) { return null; } return getModel().getParameter(conversionFactorID); }
/** * @return {@code true} if the {@link UnitDefinition} which has the * spatialSizeUnitsID of * this {@link Species} as id is not {@code null}. * @deprecated Only valid for SBML Level 2 Versions 1 and 2. */ @Deprecated public boolean isSetSpatialSizeUnitsInstance() { if (getModel() == null) { return false; } return getModel().getUnitDefinition(spatialSizeUnitsID) != null; }
/** * Returns the speciesType of this {@link Species} as a {@link SpeciesType}. * * @return the SpeciesType instance which has the speciesType of this * Species as id. Null if it doesn't exist. * @deprecated Only valid for SBML Level 2 Versions 2, 3, and 4. */ @Deprecated public SpeciesType getSpeciesTypeInstance() { if (getModel() == null) { return null; } return getModel().getSpeciesType(speciesTypeID); }
@Override public Compartment getCompartmentInstance() { if (isSetCompartment()) { Model model = getModel(); if (model != null) { return model.getCompartment(compartmentID); } } return null; }
@Override public boolean check(ValidationContext ctx, Species s) { return s.isSetSubstanceUnits() || s.getModel().isSetSubstanceUnits(); } };
@Override public boolean containsUndeclaredUnits() { boolean undeclared = super.containsUndeclaredUnits(); if (undeclared && (getLevel() > 2)) { Model model = getModel(); if ((model != null) && model.isSetSubstanceUnits()) { // In Level 3 a species inherits substance units from its model. // If the model declares the default substance units, the units of each // species are also declared. return false; } } return undeclared; }
/** * Returns the spatialSizeUnits {@link UnitDefinition} instance of this {@link Species}. * * <p>Determines the spatial units of this {@link Species}. If the spatial * units have been set explicitly using 'spatialSizeUnits' the * corresponding {@link UnitDefinition} from the {@link Model} to which this * {@link Species} belongs will be returned. Otherwise, the size unit from * the surrounding {@link Compartment} of this {@link Species} will be * returned. If this also fails, {@code null} will be returned.</p> * * @return The {@link UnitDefinition} instance which as the * 'spatialSizeUnits' of this {@link Species} as id or the * size unit of the surrounding {@link Compartment}. * {@code null} if it doesn't exist. * @deprecated Only valid for SBML Level 2 Versions 1 and 2. */ @Deprecated public UnitDefinition getSpatialSizeUnitsInstance() { if (isSetSpatialSizeUnits()) { Model model = getModel(); return model != null ? model .getUnitDefinition(spatialSizeUnitsID) : null; } Compartment compartment = getCompartmentInstance(); return compartment != null ? compartment.getUnitsInstance() : null; }
/** * Returns the substanceUnits of this Species. * * @return the substanceUnits of this Species. */ public String getSubstanceUnits() { String units = getUnits(); if ((units == null) && (getLevel() > 2)) { Model model = getModel(); if ((model != null) && model.isSetSubstanceUnits()) { units = model.getSubstanceUnits(); } } return units; }
/** * Returns the substanceUnits of this Species as a {@link UnitDefinition} instance. * * @return The UnitsDefinition instance which has the substanceUnist of * this Species as id. */ public UnitDefinition getSubstanceUnitsInstance() { UnitDefinition ud = getUnitsInstance(); if ((ud == null) && (getLevel() > 2)) { Model model = getModel(); if ((model != null) && model.isSetSubstanceUnits()) { ud = model.getSubstanceUnitsInstance(); } } return ud; }
@Override public boolean check(ValidationContext ctx, Species s) { /* * Invalid value found for Species 'compartment' attribute */ if (s.isSetCompartment() && s.getModel() != null && s.getCompartmentInstance() == null) { ValidationConstraint.logError(ctx, CORE_20601, s, s.getId(), s.getCompartment()); return false; } return true; } };
@Override public boolean check(ValidationContext ctx, Species s) { if (s.getModel() != null) { Compartment c = s.getCompartmentInstance(); if (c != null && c.getSpatialDimensions() == 0 && s.isSetSpatialSizeUnits()) { ValidationConstraint.logError(ctx, CORE_20603, s, s.getId(), s.getCompartment()); return false; } } return true; } };
@Override public boolean check(ValidationContext ctx, Species s) { // TODO - change the way we report the error, to report the error per compartment, only once. // And we should be able to avoid a loop over the full listofSpecies for each species Model m = s.getModel(); if (s.isSetSpeciesType() && m != null) { String st = s.getSpeciesType(); for (Species spec: m.getListOfSpecies()) { // Are species in same compartment but not the same? if (spec.isSetSpeciesType() && spec.getCompartment().equals(s.getCompartment()) && !spec.getId().equals(s.getId())) { // Must have different Types if (spec.getSpeciesType().equals(st)) { return false; } } } } return true; } };
/** * Returns the derived species substance units, never dividing by the compartment units. * * @return the derived species substance units, never dividing by the compartment units. * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getDerivedUnitDefinition() */ public UnitDefinition getDerivedSubstanceUnitDefinition() { // We cannot use 'super.getDerivedUnitDefinition()' because the method Species.getDerivedUnits() cannot be used in this case // as it return null if hasOnlySubstanceUnits is 'false' and we just want to have the species units for this method UnitDefinition specUnit = null; Model model = getModel(); if (isSetUnitsInstance()) { specUnit = getUnitsInstance(); } else { String derivedUnits = super.getDerivedUnits(); // System.out.println("Species - getDerivedUnits " + getElementName() + " = " + derivedUnits + " (unitsID = " + unitsID + ", isSetUnits = " + isSetUnits() + ")"); if ((model != null) && (derivedUnits != null) && !derivedUnits.isEmpty()) { specUnit = model.getUnitDefinition(derivedUnits); } } if ((specUnit == null) && (getLevel() > 2) && (model != null) && (model.isSetSubstanceUnits())) { // According to SBML specification of Level 3 Version 1, page 44, lines 20-22: specUnit = model.getSubstanceUnitsInstance(); } return specUnit; }
@Override public boolean check(ValidationContext ctx, Species s) { Model m = s.getModel(); if (m != null && !s.isSetInitialAmount() && !s.isSetInitialConcentration()) { boolean setByAssignment = false; if (s.isSetId()) { setByAssignment = m.getInitialAssignmentBySymbol(s.getId()) != null; if (!setByAssignment) { Rule r = m.getRuleByVariable(s.getId()); setByAssignment = r != null && r.isAssignment(); } } if (!setByAssignment) { // TODO - build a nice error message } return setByAssignment; } return true; } };
@Override public boolean check(ValidationContext ctx, Species s) { Model m = s.getModel();
Model model = getModel();