Package org.sbml.jsbml

Examples of org.sbml.jsbml.Model


    SBMLDocument doc = NavigationPanel.getInstance().getSBMLDocumentForCyNetwork(network);
    if (doc != null){
      int level = 3;
      int version = 1;
      doc.setLevelAndVersion(level, version);
      Model model = doc.getModel();
      model.setLevel(level);
      model.setVersion(version);
     
      // Get LayoutModel
      LayoutModelPlugin layoutModel = LayoutExtension.getOrCreateLayoutModel(doc);
      // Add the layout
      Layout layout = createSBMLLayoutForView(view, model);
View Full Code Here


  }
  private void setMissingQSpeciesBoundingBoxes(){
    Map<String, BoundingBox> boxes = speciesBoundingBoxes;
    BoundingBox genericBox = createGenericBoundingBox();
    String key;
    Model model = document.getModel();
    QualitativeModel qModel = (QualitativeModel) model.getExtension(QualConstant.namespaceURI);
    if (qModel != null){
      for (QualitativeSpecies qspecies : qModel.getListOfQualitativeSpecies()){
        key = qspecies.getId();
        if (!boxes.containsKey(key)){
          boxes.put(key, genericBox);
View Full Code Here

  }
  private void setMissingQTransitionBoundingBoxes(){
    Map<String, BoundingBox> boxes = reactionBoundingBoxes;
    BoundingBox genericBox = createGenericBoundingBox();
    String key;
    Model model = document.getModel();
    QualitativeModel qModel = (QualitativeModel) model.getExtension(QualConstant.namespaceURI);
    if (qModel != null){
      for (Transition qtransition : qModel.getListOfTransitions()){
        key = qtransition.getId();
        if (!boxes.containsKey(key)){
          boxes.put(key, genericBox);
View Full Code Here

    if (doc == null){
      text = "No SBML document available for current network";
    }
    else {
      // Access to the SBMLDocument
      Model model = doc.getModel();
      text = String.format("Current SBML document: id=%s", model.getId());
    }
    JOptionPane.showMessageDialog(
        Cytoscape.getDesktop(),
        text,
        "CySBML Current SBMLDocument",
View Full Code Here

   * to the model in the document.
   */
  public static LayoutModelPlugin getOrCreateLayoutModel(SBMLDocument doc){
    LayoutModelPlugin layoutModel = (LayoutModelPlugin) doc.getModel().getExtension(LAYOUT_NS);
    if (layoutModel == null){
      Model model = doc.getModel();
      // model should exist in the document now
      if (model == null){
        System.err.println("Model missing in SBMLDocument.");
        return null;
      }
      layoutModel = new LayoutModelPlugin(model);
      model.addExtension(LAYOUT_NS, layoutModel);
    }
    return layoutModel;
  }
View Full Code Here

   * @throws ParseException
   *
   */
  @Test public void checkHashCode() throws ParseException {
    SBMLDocument doc1 = new SBMLDocument(3, 1);
    Model model = doc1.createModel("test_model");
    Compartment c = model.createCompartment("c1");
    Species s = model.createSpecies("s1", c);
    s.addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "urn:miriam:kegg.compound:C00001"));
    Rule r = model.createAlgebraicRule();
    r.setMath(ASTNode.parseFormula("sin(3) + 1"));
   
    SBMLDocument doc2 = doc1.clone();
    try {
      (new SBMLWriter()).write(doc1, System.out);
      System.out.println("\n==================");
      (new SBMLWriter()).write(doc2, System.out);
    } catch (SBMLException e) {
      e.printStackTrace();
    } catch (XMLStreamException e) {
      e.printStackTrace();
    }
    assertTrue(doc1.hashCode() == doc2.hashCode());
    assertTrue(model.hashCode() != doc2.hashCode());
    assertTrue(s.getCVTerm(0).equals(new CVTerm(CVTerm.Qualifier.BQB_IS, "urn:miriam:kegg.compound:C00001")));
    assertTrue(s.getCVTerm(0).hashCode() == (new CVTerm(CVTerm.Qualifier.BQB_IS, "urn:miriam:kegg.compound:C00001")).hashCode());
    assertTrue(doc1.equals(doc2));
    assertTrue(doc2.equals(doc1));
  }
View Full Code Here

  public static void main(String[] args) throws XMLStreamException,
      SBMLException, ParseException {
       
    SBMLDocument doc = new SBMLDocument(2, 4);
    doc.addTreeNodeChangeListener(new SimpleTreeNodeChangeListener());
    Model model = doc.createModel("test_model");
   
    Creator c = new Creator("Hans", "Wurst",
      "Institute for Interesting Biology", "ovidiu.radulescu@univ-rennes1.fr");
    History h = new History();
    h.addCreator(c);
    model.setHistory(h);
//    model.appendNotes("This is a very interesting model.");
    model.appendNotes("<body xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Model of &#8220;Apoptosis&#8221; in &#8220;Homo sapiens (human)&#8221;</h1>Apoptosis is a genetically controlled mechanisms of cell death involved in the regulation of tissue homeostasis. The 2 major pathways of apoptosis are the extrinsic (Fas and other TNFR superfamily members and ligands) and the intrinsic (mitochondria-associated) pathways, both of which are found in the cytoplasm. The extrinsic pathway is triggered by death receptor engagement, which initiates a signaling cascade mediated by caspase-8 activation. Caspase-8 both feeds directly into caspase-3 activation and stimulates the release of cytochrome c by the mitochondria. Caspase-3 activation leads to the degradation of cellular proteins necessary to maintain cell survival and integrity. The intrinsic pathway occurs when various apoptotic stimuli trigger the release of cytochrome c from the mitochondria (independently of caspase-8 activation). Cytochrome c interacts with Apaf-1 and caspase-9 to promote the activation of caspase-3. Recent studies point to the ER as a third subcellular compartment implicated in apoptotic execution. Alterations in Ca2+ homeostasis and accumulation of misfolded proteins in the ER cause ER stress. Prolonged ER stress can result in the activation of BAD and/or caspase-12, and execute apoptosis.<br/><a href=\"http://www.genome.jp/kegg/pathway/hsa/hsa04210.png\"><img src=\"http://www.genome.jp/kegg/pathway/hsa/hsa04210.png\" alt=\"http://www.genome.jp/kegg-bin/show_pathway?hsa04210\"/></a><br/><a href=\"http://www.genome.jp/kegg-bin/show_pathway?hsa04210\">Original Entry</a><br/><div align=\"right\"></div><br/></body>");
   
    Parameter k1 = model.createParameter("k1");
    Parameter k2 = model.createParameter("k2");
   
    k1.setConstant(false);
    k2.setConstant(false);
   
    k1.addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "test"));
   
    Event event = model.createEvent("test_event");
   
    Trigger trigger = event.createTrigger();
//    trigger.setMath(ASTNode.geq(new ASTNode(ASTNode.Type.NAME_TIME),
//        new ASTNode(10)));
    trigger.setMath(ASTNode.parseFormula("time >= 10"));
View Full Code Here

          listOfElementsToWrite = new ArrayList<Object>();
          listOfElementsToWrite.add(sbmlDocument.getModel());
        }
      } else if (sbase instanceof Model) {

        Model model = (Model) sbase;
        listOfElementsToWrite = new ArrayList<Object>();
        if (model.isSetListOfUnitDefinitions()) {
          listOfElementsToWrite.add(model.getListOfUnitDefinitions());
        }
        if (model.isSetListOfCompartments()) {
          listOfElementsToWrite.add(model.getListOfCompartments());
        }
        if (model.isSetListOfSpecies()) {
          listOfElementsToWrite.add(model.getListOfSpecies());
        }
        if (model.isSetListOfParameters()) {
          listOfElementsToWrite.add(model.getListOfParameters());
        }
        if (model.isSetListOfRules()) {
          listOfElementsToWrite.add(model.getListOfRules());
        }
        if (model.isSetListOfReactions()) {
          listOfElementsToWrite.add(model.getListOfReactions());
        }

        if (listOfElementsToWrite.isEmpty()) {
          listOfElementsToWrite = null;
        }
View Full Code Here

   * org.sbml.jsbml.xml.stax.ReadingParser#processEndDocument(org.sbml.jsbml
   * .SBMLDocument)
   */
  public void processEndDocument(SBMLDocument sbmlDocument) {
    if (sbmlDocument.isSetModel()) {
      Model model = sbmlDocument.getModel();

      if (model.isSetListOfRules()) {
        for (int i = 0; i < model.getRuleCount(); i++) {
          Rule rule = model.getRule(i);
          if (rule instanceof AssignmentRule) {
            AssignmentRule assignmentRule = (AssignmentRule) rule;
            setAssignmentRuleVariable(assignmentRule, model);
          } else if (rule instanceof RateRule) {
            RateRule rateRule = (RateRule) rule;
            setRateRuleVariable(rateRule, model);
          }
        }
      }
      if (model.isSetListOfCompartments()) {
        for (int i = 0; i < model.getCompartmentCount(); i++) {
          Compartment compartment = model.getCompartment(i);

          setCompartmentCompartmentType(compartment, model);
          setCompartmentOutside(compartment, model);
          setCompartmentUnits(compartment, model);
        }
      }
      if (model.isSetListOfEvents()) {
        for (int i = 0; i < model.getEventCount(); i++) {
          Event event = model.getEvent(i);

          setEventTimeUnits(event, model);

          if (event.isSetListOfEventAssignments()) {

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

              setEventAssignmentVariable(eventAssignment, model);
            }
          }
        }
      }
      if (model.isSetListOfInitialAssignments()) {
        for (int i = 0; i < model.getInitialAssignmentCount(); i++) {
          InitialAssignment initialAssignment = model
              .getInitialAssignment(i);

          setInitialAssignmentSymbol(initialAssignment, model);
        }
      }
      if (model.isSetListOfReactions()) {
        for (int i = 0; i < model.getReactionCount(); i++) {
          Reaction reaction = model.getReaction(i);

          setReactionCompartment(reaction, model);

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

              setSpeciesReferenceSpecies(speciesReference, model);
            }
          }
          if (reaction.isSetListOfProducts()) {
            for (int j = 0; j < reaction.getProductCount(); j++) {
              SpeciesReference speciesReference = reaction
                  .getProduct(j);

              setSpeciesReferenceSpecies(speciesReference, model);
            }
          }
          if (reaction.isSetListOfModifiers()) {
            for (int j = 0; j < reaction.getModifierCount(); j++) {
              ModifierSpeciesReference modifierSpeciesReference = reaction
                  .getModifier(j);

              setSpeciesReferenceSpecies(
                  modifierSpeciesReference, model);
            }
          }
          if (reaction.isSetKineticLaw()) {
            KineticLaw kineticLaw = reaction.getKineticLaw();
            if (kineticLaw.isSetListOfLocalParameters()) {
              for (int j = 0; j < kineticLaw.getLocalParameterCount(); j++) {
                LocalParameter parameter = kineticLaw
                    .getLocalParameter(j);
                setParameterUnits(parameter, model);
              }
            }
          }
        }
      }
      if (model.isSetListOfSpecies()) {
        for (int i = 0; i < model.getSpeciesCount(); i++) {
          Species species = model.getSpecies(i);
          setSpeciesSubstanceUnits(species, model);
          setSpeciesSpeciesType(species, model);
          setSpeciesConversionFactor(species, model);
          setSpeciesCompartment(species, model);
        }
      }
      if (model.isSetListOfParameters()) {
        for (int i = 0; i < model.getParameterCount(); i++) {
          Parameter parameter = model.getParameter(i);
          setParameterUnits(parameter, model);
        }
      }

    } else {
View Full Code Here

          return annotation;
        } else if (contextObject instanceof SBMLDocument) {
          SBMLDocument sbmlDocument = (SBMLDocument) contextObject;
          if (elementName.equals("model")) {
            Model model = (Model) newContextObject;
            sbmlDocument.setModel(model);

            return model;
          }
        } else if (contextObject instanceof Model) {

          Model model = (Model) contextObject;
          if (newContextObject instanceof ListOf<?>) {
            if (elementName.equals("listOfUnitDefinitions")) {
              ListOf<UnitDefinition> listOfUnitDefinitions = (ListOf<UnitDefinition>) newContextObject;
              model.setListOfUnitDefinitions(listOfUnitDefinitions);

              return listOfUnitDefinitions;
            } else if (elementName.equals("listOfCompartments")) {
              ListOf<Compartment> listofCompartments = (ListOf<Compartment>) newContextObject;
              model.setListOfCompartments(listofCompartments);

              return listofCompartments;
            } else if (elementName.equals("listOfSpecies")) {
              ListOf<Species> listOfSpecies = (ListOf<Species>) newContextObject;
              model.setListOfSpecies(listOfSpecies);

              return listOfSpecies;
            } else if (elementName.equals("listOfParameters")) {
              ListOf<Parameter> listOfParameters = (ListOf<Parameter>) newContextObject;
              model.setListOfParameters(listOfParameters);

              return listOfParameters;
            } else if (elementName.equals("listOfRules")) {
              ListOf<Rule> listOfRules = (ListOf<Rule>) newContextObject;
              model.setListOfRules(listOfRules);

              return listOfRules;
            } else if (elementName.equals("listOfReactions")) {
              ListOf<Reaction> listOfReactions = (ListOf<Reaction>) newContextObject;
              model.setListOfReactions(listOfReactions);

              return listOfReactions;
            } else {
              // TODO: SBML syntax error, throw an exception?
            }
          } else {
            // TODO: SBML syntax error, throw an exception?
          }
        } else if (contextObject instanceof ListOf<?>) {
          ListOf<?> list = (ListOf<?>) contextObject;
          if (list.getParentSBMLObject() instanceof Model) {

            Model model = (Model) list.getParentSBMLObject();
            if (elementName.equals("unitDefinition")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfUnitDefinitions)) {
              UnitDefinition unitDefinition = (UnitDefinition) newContextObject;
              model.addUnitDefinition(unitDefinition);

              return unitDefinition;
            } else if (elementName.equals("compartment")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfCompartments)) {
              Compartment compartment = (Compartment) newContextObject;
              model.addCompartment(compartment);

              return compartment;
            } else if (elementName.equals("specie")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfSpecies)) {
              Species species = (Species) newContextObject;
              model.addSpecies(species);

              return species;
            } else if (elementName.equals("parameter")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfParameters)) {
              Parameter parameter = (Parameter) newContextObject;
              model.addParameter(parameter);

              return parameter;
            } else if (elementName.equals("algebraicRule")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfRules)) {
              AlgebraicRule rule = (AlgebraicRule) newContextObject;
              model.addRule(rule);

              return rule;
            } else if (elementName.equals("assignmentRule") // TODO: wrong, there are no assignmentRule element, only more specialize rule
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfRules)) {
              AssignmentRule rule = (AssignmentRule) newContextObject;
              model.addRule(rule);

              return rule;
            } else if (elementName.equals("reaction")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfReactions)) {
              Reaction reaction = (Reaction) newContextObject;
              model.addReaction(reaction);

              return reaction;
            } else {
              // TODO: SBML syntax error, throw an exception?
            }
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.