Package org.sbml.jsbml

Examples of org.sbml.jsbml.Model


   * @return the {@link Transition} that has the given id or null if
   * no {@link Transition} are found that match {@code id}.
   */
  public Transition getTransition(String id) {
    if (isSetListOfTransitions()) {
      Model m = getModel();
      if (m != null) {
        return (Transition) m.findNamedSBase(id);
      }
      return listOfTransitions.firstHit(new NameFilter(id));
    }
    return null;
  }
View Full Code Here


  public Object processStartElement(String elementName, String uri,
    String prefix, boolean hasAttributes, boolean hasNamespaces,
    Object contextObject)
  {
    if (contextObject instanceof Model) {
      Model model = (Model) contextObject;
      SpatialModelPlugin spatialModel = null;

      if (model.getExtension(SpatialConstants.namespaceURI) != null) {
        spatialModel = (SpatialModelPlugin) model.getExtension(SpatialConstants.namespaceURI);
      } else {
        spatialModel = new SpatialModelPlugin(model);
        model.addExtension(SpatialConstants.namespaceURI, spatialModel);
      }
      if (elementName.equals(SpatialConstants.geometry)) {
        Geometry geometry = new Geometry();
        spatialModel.setGeometry(geometry);
        return geometry;
View Full Code Here

  public SBase getSBaseInstance() {

    SBase instance = null;

    if (isSetIdRef()) {
      Model model = getModel();

      if (model != null) {
        instance = model.findNamedSBase(idRef);
      }
    } else if (isSetMetaIdRef()) {
      SBMLDocument doc = getSBMLDocument();

      if (doc != null) {
View Full Code Here

      DATA_FOLDER = System.getProperty("user.dir") + "/extensions/layout/test/org/sbml/jsbml/xml/test/data";
    }
    String fileName = DATA_FOLDER + "/layout/GlycolysisLayout_small.xml";

    SBMLDocument doc = new SBMLReader().readSBMLFile(fileName);
    Model model = doc.getModel();

    System.out.println("Model extension objects: " + model.getExtension(LAYOUT_NAMESPACE));
    LayoutModelPlugin extendedModel = (LayoutModelPlugin) model.getExtension(LAYOUT_NAMESPACE);

    System.out.println("Nb Layouts = " + extendedModel.getListOfLayouts().size());

    Layout layout = extendedModel.getLayout(0);
View Full Code Here

   * @throws SBMLException
   */
  public static void main(String[] args) throws SBMLException, XMLStreamException {

    SBMLDocument d = new SBMLDocument(3,1);
    Model model = d.createModel("testLayoutWriting");

    LayoutModelPlugin lModel = new LayoutModelPlugin(model);
    Layout layout = lModel.createLayout("layout");

    model.addExtension(LayoutConstants.namespaceURI, lModel);

    ReactionGlyph rg = new ReactionGlyph("react_r1", model.getLevel(), model.getVersion());

    SpeciesReferenceGlyph srg1 = rg.createSpeciesReferenceGlyph("srg_r1_s1", "SPG1");
    SpeciesReferenceGlyph srg2 = rg.createSpeciesReferenceGlyph("srg_r1_s2", "SPG2");
    srg1.setRole(SpeciesReferenceRole.SUBSTRATE);
    srg2.setRole(SpeciesReferenceRole.PRODUCT);

    assert(model.findNamedSBase("srg_r1_s1") == null);

    BoundingBox bbRg = rg.createBoundingBox(10.0, 10.0, 0.0);
    bbRg.setPosition(new Point(100.0, 0.0, 0.0));

    //    Curve c = new Curve(3, 1);
    Curve c = srg1.createCurve();
    //    CurveSegmentImpl cs1 = (CurveSegmentImpl) c.createCurveSegment();
    //    CubicBezier cs1 = new CubicBezier();
    CubicBezier cs1 = c.createCubicBezier();
    cs1.setStart(new Point(35.0, 10.0, 0.0));
    cs1.setEnd(new Point(100.0, 10.0, 0.0));
    cs1.setBasePoint1(new Point(25, 35, 45));
    cs1.setBasePoint2(new Point(55, 65, 75));

    //    ListOf<CurveSegment> csList = new ListOf<CurveSegment>();
    //    csList.add(cs1);
    //    c.setListOfCurveSegments(csList);
    //    srg1.setCurve(c);

    LineSegment cs2 = new LineSegment();
    cs2.createStart(110.0, 10.0, 0.0);
    cs2.createEnd(235.0, 10.0, 0.0);
    Curve c2 = new Curve();
    ListOf<CurveSegment> csList2 = new ListOf<CurveSegment>();
    csList2.add(cs2);
    c2.setListOfCurveSegments(csList2);
    srg2.setCurve(c2);

    BoundingBox bbSrg2 = srg2.createBoundingBox();
    bbSrg2.setPosition(new Point(110.0, 10.0, 0.0));
    bbSrg2.setDimensions(new Dimensions(200.0, 10.0, 0, model.getLevel(), model.getVersion()));

    layout.addReactionGlyph(rg);

    assert(model.findNamedSBase("srg_r1_s1") != null);

    String writtenDocument = JSBML.writeSBMLToString(d);

    System.out.println(writtenDocument);

View Full Code Here

   * @throws XMLStreamException
   */
  public static void main(String[] args) throws XMLStreamException {

    SBMLDocument sbmlDoc = new SBMLDocument(3, 1);
    Model model = sbmlDoc.createModel("m_default_name");

    model.getHistory().addModifiedDate(Calendar.getInstance().getTime());
    model.getAnnotation().addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "urn:miriam:obo.go:GO%3A1234567"));

    QualitativeModel qModel = new QualitativeModel(model);

    model.addExtension(QUAL_NS_PREFIX, qModel);

    if (model.getExtension(QUAL_NS) == null) {
      System.out.println("!!!!!!! getting a plugin object using a namespace does not work");
    }
   
    // ListOfCompartments
    Compartment comp1 = model.createCompartment("comp1");
    comp1.setConstant(true);

    // ListOfQualitativeSpecies
    QualitativeSpecies g0 = qModel.createQualitativeSpecies("G0", comp1.getId(), false);
    g0.setMaxLevel(1);
View Full Code Here

  /**
   *
   * @return
   */
  public Species getSpeciesInstance() {
    Model model = getModel();
    return model != null ? model.getSpecies(getSpeciesReference()) : null;
  }
View Full Code Here

    return model != null ? model.getSpecies(getSpeciesReference()) : null;
  }

  public Geometry getGeometryInstance() {

    Model model = getModel();

    SpatialModelPlugin m = (SpatialModelPlugin) model.getExtension(SpatialConstants.packageName);
    //TODO: Get the correct element in geometry using the spid
    return m.getGeometry();
  }
View Full Code Here

   */
  public SpeciesGlyph getSpeciesGlyphInstance() {
    if (!isSetSpeciesGlyph()) {
      return null;
    }
    Model model = getModel();
    return (model != null) ? (SpeciesGlyph) model.findNamedSBase(getSpeciesGlyph()) : null;
  }
View Full Code Here

  public void processEndDocument(SBMLDocument sbmlDocument) {

    log4jLogger.debug("SBMLCoreParser : processEndDocument");
   
    if (sbmlDocument.isSetModel()) {
      Model model = sbmlDocument.getModel();

      if (model.isSetAreaUnits() && !model.isSetAreaUnitsInstance()) {
        log4jLogger.warn("No unitDefinition matches the areaUnitsID of Model.");
      }
      if (model.isSetConversionFactor()
          && !model.isSetConversionFactorInstance()) {
        log4jLogger.warn("No parameter matches the conversionFactorID of Model.");
      }
      if (model.isSetExtentUnits() && !model.isSetExtentUnitsInstance()) {
        log4jLogger.warn("No unitDefinition matches the extentUnitsID of Model.");
      }
      if (model.isSetLengthUnits() && !model.isSetLengthUnitsInstance()) {
        log4jLogger.warn("No unitDefinition matches the lengthUnitsID of Model.");
      }
      if (model.isSetSubstanceUnits()
          && !model.isSetSubstanceUnitsInstance()) {
        log4jLogger.warn("No unitDefinition matches the substanceUnitsID of Model.");
      }
      if (model.isSetTimeUnits() && !model.isSetTimeUnitsInstance()) {
        log4jLogger.warn("No unitDefinition matches the timeUnitsID of Model.");
      }
      if (model.isSetVolumeUnits() && !model.isSetVolumeUnitsInstance()) {
        log4jLogger.warn("No unitDefinition matches the volumeUnitsID of Model.");
      }

      if (model.isSetListOfRules()) {
       
        if (model.getLevel() == 1) {

          log4jLogger.debug("Transformed SBMLLevel1Rule : processEndDocument : model is level 1");

          int i = 0;
          for (Rule rule : model.getListOfRules().clone()) {
            if (rule instanceof SBMLLevel1Rule) {
              Rule realRule;
             
              if (((SBMLLevel1Rule) rule).isScalar()) {
                realRule = ((SBMLLevel1Rule) rule).cloneAsAssignmentRule();
                log4jLogger.debug("Transformed SBMLLevel1Rule : " + ((SBMLLevel1Rule) rule).getVariable() + " into AssignmentRule.");
              } else {
                realRule = ((SBMLLevel1Rule) rule).cloneAsRateRule();
                log4jLogger.debug("Transformed SBMLLevel1Rule : " + ((SBMLLevel1Rule) rule).getVariable() + " into RateRule.");
              }
             
              log4jLogger.debug("Transformed SBMLLevel1Rule : realRule = " + realRule);

              model.getListOfRules().remove(i);
              model.getListOfRules().add(i, realRule);
            }
            i++;
          }
        }
       
        for (int i = 0; i < model.getNumRules(); i++) {
          Rule rule = model.getRule(i);
          if (rule instanceof AssignmentRule) {
            AssignmentRule assignmentRule = (AssignmentRule) rule;
            if (assignmentRule.isSetVariable()
                && !assignmentRule.isSetVariableInstance()) {
              log4jLogger.warn("No Symbol matches the variableID of AssignmentRule.");
            }
            if (assignmentRule.isSetUnits()
                && !assignmentRule.isSetUnitsInstance()
                && assignmentRule.isParameter()) {
              log4jLogger.warn("No UnitDefinition matches the unitsID of AssignmentRule.");
            }
          } else if (rule instanceof RateRule) {
            RateRule rateRule = (RateRule) rule;
            if (rateRule.isSetVariable()
                && !rateRule.isSetVariableInstance()) {
              log4jLogger.warn("No Symbol matches the variableID of RateRule.");
            }
          }
        }
      }
      if (model.isSetListOfCompartments()) {
        for (int i = 0; i < model.getNumCompartments(); i++) {
          Compartment compartment = model.getCompartment(i);
          if (compartment.isSetCompartmentType()
              && !compartment.isSetCompartmentTypeInstance()) {
            log4jLogger.warn("No CompartmentType matches the compartmentTypeID of compartment.");
          }
          if (compartment.isSetOutside()
              && !compartment.isSetOutsideInstance()) {
            log4jLogger.warn("No Compartment matches the outsideID of compartment.");
          }
          if (compartment.isSetUnits()
              && !compartment.isSetUnitsInstance()) {
            log4jLogger.warn("No UnitDefinition matches the unitsID of compartment.");
          }
        }
      }
      if (model.isSetListOfEvents()) {
        for (int i = 0; i < model.getNumEvents(); i++) {
          Event event = model.getEvent(i);

          if (event.isSetTimeUnits()
              && !event.isSetTimeUnitsInstance()) {
            log4jLogger.warn("No UnitDefinition matches the timeUnitsID of event.");
          }

          if (event.isSetListOfEventAssignments()) {

            for (int j = 0; j < event.getNumEventAssignments(); j++) {
              EventAssignment eventAssignment = event
                  .getEventAssignment(j);

              if (eventAssignment.isSetVariable()
                  && !eventAssignment.isSetVariableInstance()) {
                log4jLogger.warn("No Symbol matches the variableID of eventAssignment.");
              }
            }
          }
        }
      }
      if (model.isSetListOfInitialAssignments()) {
        for (int i = 0; i < model.getNumInitialAssignments(); i++) {
          InitialAssignment initialAssignment = model
              .getInitialAssignment(i);

          if (initialAssignment.isSetVariable()
              && !initialAssignment.isSetVariableInstance()) {
            log4jLogger.warn("No Symbol matches the symbolID of initialAssignment.");
          }
        }
      }
      if (model.isSetListOfReactions()) {
        for (int i = 0; i < model.getNumReactions(); i++) {
          Reaction reaction = model.getReaction(i);
          if (reaction.isSetCompartment()
              && !reaction.isSetCompartmentInstance()) {
            log4jLogger.warn("No Compartment matches the compartmentID of reaction.");
          }

          if (reaction.isSetListOfReactants()) {
            for (int j = 0; j < reaction.getNumReactants(); j++) {
              SpeciesReference speciesReference = reaction
                  .getReactant(j);

              if (speciesReference.isSetSpecies()
                  && !speciesReference.isSetSpeciesInstance()) {
                log4jLogger.warn(String.format("No Species matches the speciesID '%s' of %s.",
                    speciesReference.getId(), speciesReference.getElementName()));
              }
            }
          }
          if (reaction.isSetListOfProducts()) {
            for (int j = 0; j < reaction.getNumProducts(); j++) {
              SpeciesReference speciesReference = reaction
                  .getProduct(j);

              if (speciesReference.isSetSpecies()
                  && !speciesReference.isSetSpeciesInstance()) {
                log4jLogger.warn(String.format("No Species matches the speciesID '%s' of %s.",
                    speciesReference.getId(), speciesReference.getElementName()));
              }
            }
          }
          if (reaction.isSetListOfModifiers()) {
            for (int j = 0; j < reaction.getNumModifiers(); j++) {
              ModifierSpeciesReference modifierSpeciesReference = reaction
                  .getModifier(j);

              if (modifierSpeciesReference.isSetSpecies()
                  && !modifierSpeciesReference
                      .isSetSpeciesInstance()) {
                log4jLogger.warn(String.format("No Species matches the speciesID '%s' of %s.",
                    modifierSpeciesReference.getId(), modifierSpeciesReference.getElementName()));
              }
            }
          }
          if (reaction.isSetKineticLaw()) {
            KineticLaw kineticLaw = reaction.getKineticLaw();
            if (kineticLaw.isSetTimeUnits()
                && !kineticLaw.isSetTimeUnitsInstance()) {
              log4jLogger.warn("No UnitDefinition matches the timeUnitsID of kineticLaw.");
            }
            if (kineticLaw.isSetSubstanceUnits()
                && !kineticLaw.isSetSubstanceUnitsInstance()) {
              log4jLogger.warn("No UnitDefinition matches the substanceUnitsID of kineticLaw.");
            }
            if (kineticLaw.isSetListOfLocalParameters()) {
              for (int j = 0; j < kineticLaw.getNumLocalParameters(); j++) {
                LocalParameter parameter = kineticLaw
                    .getLocalParameter(j);
                if (parameter.isSetUnits()
                    && !parameter.isSetUnitsInstance()) {
                  log4jLogger.warn(String.format(
                    "No UnitDefinition matches the unitsID '%s'of the parameter %s.",
                    parameter.getUnits(), parameter.getId()));
                }
              }
            }
          }
        }
      }
      if (model.isSetListOfSpecies()) {
        for (int i = 0; i < model.getNumSpecies(); i++) {
          Species species = model.getSpecies(i);

          if (species.isSetSubstanceUnits()
              && !species.isSetSubstanceUnitsInstance()) {
            log4jLogger.warn("No UnitDefinition matches the subtsanceUnitsID of species.");
          }
          if (species.isSetSpeciesType()
              && !species.isSetSpeciesTypeInstance()) {
            log4jLogger.warn("No SpeciesType matches the speciesTypeID of species.");
          }
          if (species.isSetConversionFactor()
              && !species.isSetConversionFactorInstance()) {
            log4jLogger.warn("No Parameter matches the conversionFactorID of species.");
          }
          if (species.isSetCompartment()
              && !species.isSetCompartmentInstance()) {
            log4jLogger.warn("No Compartment matches the compartmentID of species.");
          }
          if (species.isSetSpatialSizeUnits()
              && !species.isSetSpatialSizeUnitsInstance()) {
            log4jLogger.warn("No UnitDefinition matches the spatialSizeUnitsID of species.");
          }
        }
      }
      if (model.isSetListOfParameters()) {
        for (int i = 0; i < model.getNumParameters(); i++) {
          Parameter parameter = model.getParameter(i);
          if (parameter.isSetUnits()
              && !parameter.isSetUnitsInstance()) {
            log4jLogger.warn("No UnitDefinition matches the unitsID of parameter.");
          }
        }
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.Model

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.