if (species.isSetBoundaryCondition()) { setBoundaryCondition(species.getBoundaryCondition()); } else { boundaryCondition = species.boundaryCondition == null ? null : new Boolean(species.boundaryCondition); if (species.isSetCharge()) { setCharge(species.getCharge()); } else { charge = species.charge == null ? null : new Integer(species.charge); if (species.isSetCompartment()) { setCompartment(new String(species.getCompartment())); if (species.isSetSubstanceUnits()) { setSubstanceUnits(new String(species.getSubstanceUnits())); if (species.isSetHasOnlySubstanceUnits()) { setHasOnlySubstanceUnits(new Boolean( species.getHasOnlySubstanceUnits())); } else { hasOnlySubstanceUnits = species.hasOnlySubstanceUnits == null ? null : new Boolean(species.hasOnlySubstanceUnits); if (species.isSetInitialAmount()) { setInitialAmount(new Double(species.getInitialAmount())); } else if (species.isSetInitialConcentration()) { setInitialConcentration(new Double(species.getInitialConcentration())); if (species.isSetSpatialSizeUnits()) { setSpatialSizeUnits(new String(species.getSpatialSizeUnits()));
/** * Creates a new {@link QualitativeSpecies} instance. * * <p> * Copy constructor that clones all values from the input {@code species} that * are also available in {@link QualitativeSpecies}. * </p> * <p> * You should consider setting a new id and meta_id afterwards to avoid * duplicate identifiers. * </p> * * @param species * the species to be used to initialize the new instance */ public QualitativeSpecies(Species species) { super(species); initDefaults(); if (species.isSetCompartment()) { compartment = species.getCompartment(); } if (species.isSetConstant()) { constant = species.getConstant(); } /* * initialLevel, maxLevel and listOfSymbolicValues are only for qual species. */ }
@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 accepts(Object o) { if (o instanceof Species) { Species s = (Species) o; return s.isSetBoundaryCondition() && s.getBoundaryCondition(); } return false; }
/** * Creates a SimpleSpeciesReference instance from a given Species. * * @param species */ public SimpleSpeciesReference(Species species) { this(species.getLevel(), species.getVersion()); speciesID = species.isSetId() ? new String(species.getId()) : null; }
Map<String, String> attributes = super.writeXMLAttributes(); Locale en = Locale.ENGLISH; if (isSetCompartment()) { attributes.put(TreeNodeChangeEvent.compartment, getCompartment()); if (isSetInitialAmount()) { attributes.put(TreeNodeChangeEvent.initialAmount, StringTools.toString(en, getInitialAmount())); if (isSetBoundaryCondition()) { attributes.put(TreeNodeChangeEvent.boundaryCondition, Boolean.toString(getBoundaryCondition())); if (1 < getLevel()) { if (isSetInitialConcentration() && !isSetInitialAmount()) { attributes.put("initialConcentration", StringTools.toString(en, getInitialConcentration())); if (isSetSubstanceUnits()) { attributes.put(TreeNodeChangeEvent.substanceUnits, getSubstanceUnits()); if (isSetHasOnlySubstanceUnits()) { attributes.put(TreeNodeChangeEvent.hasOnlySubstanceUnits, Boolean.toString(getHasOnlySubstanceUnits())); if (isSetConstant()) { attributes.put(TreeNodeChangeEvent.constant, Boolean.toString(getConstant())); if (getLevel() < 3) {
ONDEXConcept speciesC = graph.getFactory().createConcept(species.getId(), dataSourceSBML, cc, etSBML); speciesById.put(species.getId(), speciesC); if (species.isSetName()) { for (String potentialYName : species.getName().split(":")) { if (potentialYName.matches("Y\\w{2}\\d{3}\\w{1,2}(\\-\\w)?")) { speciesC.createConceptAccession(potentialYName, dataSourceMips, false); if (species.isSetNotes()) { speciesC.setDescription(species.getNotesString()); if (species.isSetCompartment()) { ONDEXConcept compC = compartmentsById.get(species.getCompartment()); if (compC != null) { graph.getFactory().createRelation(speciesC, compC, locatedIn, etSBML); } else { logFail("Failed to resolve compartment concept: " + species.getCompartment()); if (species.isSetInitialAmount()) { speciesC.createAttribute(initialAmount, species.getInitialAmount(), false); if (species.isSetInitialConcentration()) { speciesC.createAttribute(initialConcentration, species.getInitialConcentration(), false); speciesC.createAttribute(constantAmount, species.getConstant(), false); speciesC.createAttribute(boundaryCondition, species.getBoundaryCondition(), false); } else { logFail("Unable to determine concept class for species " + species.getId());
if (equals) { Species s = (Species) object; equals &= s.isSetBoundaryCondition() == isSetBoundaryCondition(); if (equals && isSetBoundaryCondition()) { equals &= s.getBoundaryCondition() == getBoundaryCondition(); equals &= s.isSetHasOnlySubstanceUnits() == isSetHasOnlySubstanceUnits(); if (equals && isSetHasOnlySubstanceUnits()) { equals &= s.getHasOnlySubstanceUnits() == getHasOnlySubstanceUnits(); equals &= s.isSetCharge() == isSetCharge(); if (equals && isSetCharge()) { equals &= s.getCharge() == getCharge(); equals &= s.isSetSpeciesType() == isSetSpeciesType(); if (equals && isSetSpeciesType()) { equals &= s.getSpeciesType().equals(getSpeciesType()); equals &= s.isSetCompartment() == isSetCompartment(); if (equals && isSetCompartment()) { equals &= s.getCompartment().equals(getCompartment()); equals &= s.isSetInitialAmount() == isSetInitialAmount(); equals &= s.isSetInitialConcentration() == isSetInitialConcentration(); equals &= s.isSetSpatialSizeUnits() == isSetSpatialSizeUnits(); if (equals && isSetSpatialSizeUnits()) { equals &= s.getSpatialSizeUnits().equals(getSpatialSizeUnits());
if (species.isSetSubstanceUnits() && !species.isSetSubstanceUnitsInstance()) { logger.warn(MessageFormat.format( bundle.getString("SBMLCoreParser.unknownReferenceError1"), "UnitDefinition", "subtsanceUnitsID", species.getSubstanceUnits(), species.getElementName(), SBMLtools.getIdOrName(species))); if (species.isSetSpeciesType() && !species.isSetSpeciesTypeInstance()) { logger.warn(MessageFormat.format( bundle.getString("SBMLCoreParser.unknownReferenceError1"), "SpeciesType", "speciesTypeID", species.getSpeciesType(), species.getElementName(), SBMLtools.getIdOrName(species))); if (species.isSetConversionFactor() && !species.isSetConversionFactorInstance()) { logger.warn(MessageFormat.format( bundle.getString("SBMLCoreParser.unknownReferenceError1"), "Parameter", "conversionFactorID", species.getConversionFactor(), species.getElementName(), SBMLtools.getIdOrName(species))); if (species.isSetCompartment() && !species.isSetCompartmentInstance()) { logger.warn(MessageFormat.format( bundle.getString("SBMLCoreParser.unknownReferenceError1"), "Compartment", "compartmentID", species.getCompartment(), species.getElementName(), SBMLtools.getIdOrName(species)));
@Override public int hashCode() { final int prime = 997; int hashCode = super.hashCode(); hashCode += prime * Boolean.valueOf(amount).hashCode(); if (isSetBoundaryCondition()) { hashCode += prime * boundaryCondition.hashCode(); } if (isSetHasOnlySubstanceUnits()) { hashCode += prime * hasOnlySubstanceUnits.hashCode(); } if (isSetCharge()) { hashCode += prime * charge.hashCode(); } if (isSetSpeciesType()) { hashCode += prime * getSpeciesType().hashCode(); } if (isSetCompartment()) { hashCode += prime * getCompartment().hashCode(); } if (isSetSpatialSizeUnits()) { hashCode += prime * getSpatialSizeUnits().hashCode(); } if (isSetConversionFactor()) { hashCode += prime * getConversionFactor().hashCode(); } return hashCode; }
@Override public boolean check(ValidationContext ctx, Species s) { Compartment c = s.getCompartmentInstance(); boolean checkResult = true; if (c != null && c.getSpatialDimensions() == 3 && s.isSetSpatialSizeUnits()) { UnitDefinition def = s.getSpatialSizeUnitsInstance(); if (def == null) { checkResult = false; } boolean isVolume = checkResult && def.isVariantOfVolume(); if (checkResult && ctx.getLevel() == 2 && ctx.getLevel() == 1 && !isVolume) { checkResult = false; } if (checkResult && ctx.getLevel() >= 2 && (! (def.isVariantOfDimensionless() || isVolume))) { checkResult = false; } } if (!checkResult) { // report error ValidationConstraint.logError(ctx, CORE_20607, s, s.getId(), s.getCompartment(), s.getSpatialSizeUnits()); } return checkResult; } };
@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) { Compartment c = s.getCompartmentInstance(); if (c != null && c.getSpatialDimensions() == 0 && s.isSetInitialConcentration()) { ValidationConstraint.logError(ctx, CORE_20604, s, s.getId(), s.getCompartment()); return false; } return true; } };
@Override public boolean check(ValidationContext ctx, Species c) { // id 'compartment', 'hasOnlySubstanceUnits', 'boundaryCondition'and constant are mandatory attributes if (!c.isSetId() || !c.isSetConstant() || !c.isSetHasOnlySubstanceUnits() || !c.isSetBoundaryCondition() || !c.isSetCompartment()) { return false; } return super.check(ctx, c); } };
@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; } };
@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; } };
if (!isReadingInProgress() && (getLevel() != 2) && ((1 != getVersion()) || (2 != getVersion()))) { throw new PropertyNotAvailableException( TreeNodeChangeEvent.spatialSizeUnits, this); if (!isReadingInProgress() && hasOnlySubstanceUnits()) { throw new SBMLException(MessageFormat.format( "Cannot set spatial size units on species {0} because it has only substance units.", toString())); Compartment c = getCompartmentInstance(); if (!isReadingInProgress() && (c != null) && (c.getSpatialDimensions() == 0d)) { toString())); spatialSizeUnitsID = spatialSizeUnits; firePropertyChange(TreeNodeChangeEvent.spatialSizeUnits, oldSpatialSizeUnits, spatialSizeUnitsID);
/** * Sets the initialAmount of this {@link Species}. * * @param initialAmount the initial amount */ public void setInitialAmount(double initialAmount) { // store initialConcentration in user define object to allow validation of incorrect SBML files if (isReadingInProgress() && isSetInitialConcentration()) { // TODO - replace by processInvalidAttribute and change the corresponding rule(s) AbstractReaderWriter.processUnknownAttribute("initialConcentration", "", getInitialConcentration() + "", "", this); } if (!amount) { amount = true; firePropertyChange(TreeNodeChangeEvent.initialAmount, Boolean.FALSE, Boolean.TRUE); } setValue(initialAmount); }
/** * Sets the initialConcentration of this {@link Species}. * * @param initialConcentration the initial concentration */ public void setInitialConcentration(double initialConcentration) { // store initialAmount in user define object to allow validation of incorrect SBML files if (isReadingInProgress() && isSetInitialAmount()) { // TODO - replace by processInvalidAttribute and change the corresponding rule(s) AbstractReaderWriter.processUnknownAttribute("initialAmount", "", getInitialAmount() + "", "", this); } if (amount) { amount = false; firePropertyChange(TreeNodeChangeEvent.initialAmount, Boolean.TRUE, Boolean.FALSE); } setValue(initialConcentration); }
UnitDefinition specUnit = getDerivedSubstanceUnitDefinition(); if ((isSetHasOnlySubstanceUnits() || getLevel() < 3) && !hasOnlySubstanceUnits) { Compartment compartment = getCompartmentInstance(); if (compartment != null && (compartment.isSetSpatialDimensions() || getLevel() < 3) && (0d == compartment.getSpatialDimensions())) { return specUnit; Model model = getModel(); if ((model != null) && isSetSpatialSizeUnits()) { sizeUnit = model.getUnitDefinition(getSpatialSizeUnits()); } else { sizeUnit = compartment.getDerivedUnitDefinition();