Package org.sbml.jsbml

Examples of org.sbml.jsbml.Model


    assertTrue(doc.findSBase("M1") == null);
    assertTrue(doc.findSBase("M2") == null);
    assertTrue(doc.findSBase("M4") == null);
   
    Model m = doc.createModel("test_model");
    m.setMetaId("M4");
    m.createParameter("LP1");
  }
View Full Code Here


  public static void main(String args[]) {
    SBMLDocument doc = new SBMLDocument(2, 4);
    doc.setNotes("<body>Senseless test commentar</body>");

    Model m = doc.createModel("model");

    CVTerm term = new CVTerm();
    term.setQualifierType(Type.MODEL_QUALIFIER);
    term.setModelQualifierType(Qualifier.BQM_IS);
    term.addResource("urn:miriam:kegg.pathway:hsa00010");
    m.addCVTerm(term);

    History history = new History();
    Creator creator = new Creator();
    creator.setFamilyName("Dr\u00e4ger");
    creator.setGivenName("Andreas");
    creator.setEmail("andreas.draeger@uni-tuebingen.de");
    creator.setOrganization("Universit\u00e4t T\u00fcbingen");
    history.addCreator(creator);
    history.setCreatedDate(Calendar.getInstance().getTime());
    history.addModifiedDate(Calendar.getInstance().getTime());
    m.setHistory(history);

    m
        .setNotes("<body>A senseless test model with a senseless notes element.</body>");

    m.getUnitDefinition("substance").getUnit(0).setScale(-3);

    try {
      new SBMLWriter().write(doc, new BufferedOutputStream(System.out),
          "SBMLWriterTest", "");
    } catch (XMLStreamException e) {
View Full Code Here

   * @throws SBMLException
   */
  @SuppressWarnings("deprecation")
  public static void main(String args[]) throws ParseException, XMLStreamException, SBMLException {
    SBMLDocument doc = new SBMLDocument(1, 2);
    Model m = doc.createModel();
    Compartment c = m.createCompartment("c1");
    Species s1 = m.createSpecies("s1", c);
    Species s2 = m.createSpecies("s2", c);
    Reaction r = m.createReaction("r1");
    r.createReactant(null, s1);
    r.createProduct(null, s2);
    KineticLaw kl = r.createKineticLaw();
    kl.setFormula("s1 * 3");
    SBMLWriter.write(doc, System.out, ' ', (short) 2);
View Full Code Here

    }   
  }
 
 
  public void addModelEdges() {
    Model model = document.getModel();
    if (model == null) {
      return;
    }
    for (ReactionGlyph rGlyph : layout.getListOfReactionGlyphs()) {
      CyNode rNode = Cytoscape.getCyNode(rGlyph.getId(), false);
      if (rGlyph.isSetListOfSpeciesReferencesGlyphs()) {
       
        // if the reaction is not set
        if (!rGlyph.isSetReaction()) {
          for (SpeciesReferenceGlyph sRefGlyph : rGlyph.getListOfSpeciesReferenceGlyphs()) {
            String sGlyphId = sRefGlyph.getSpeciesGlyph();
            CyNode sNode = Cytoscape.getCyNode(sGlyphId, false);
            CyEdge edge = Cytoscape.getCyEdge(rNode, sNode, Semantics.INTERACTION,
                              CySBMLConstants.EDGETYPE_UNDEFINED, true);
            readEdgeAttributesFromSpeciesReferenceGlyph(edge, sRefGlyph);
            edgeIds.add(edge.getRootGraphIndex());
          }
        }

        // if the reaction is set
        if (rGlyph.isSetReaction()) {
          String reactionId = rGlyph.getReaction();
          Reaction reaction = model.getReaction(reactionId);
          if (reaction == null) {
            System.err.println("reactionId in in ReactionGlyph is not in SBML model: " + reactionId);
            continue;
          }
          for (SpeciesReferenceGlyph sRefGlyph : rGlyph.getListOfSpeciesReferenceGlyphs()) {
View Full Code Here

      }
    }
  }
 
  public void addQualitativeModelEdges() {
    Model model = document.getModel();
    if (model == null) {
      return;
    }
    QualitativeModel qModel = (QualitativeModel) model.getExtension(QualConstant.namespaceURI);
    if (qModel == null){
      return;
    }
       
    for (ReactionGlyph rGlyph : layout.getListOfReactionGlyphs()) {
View Full Code Here

  }
 
  public NavigationTree(SBMLDocument document){   
    this();
   
    Model model = document.getModel();
    String modelName = getModelNameFromModel(model);
    SBMLNetwork = true;
   
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(modelName);
    treeModel = new DefaultTreeModel(top);
    addListOfCompartmentsToTreeModel(top, model.getListOfCompartments());
    addListOfSpeciesToTreeModel(top, model.getListOfSpecies());
    addListOfReactionsToTreeModel(top, model.getListOfReactions());
        QualitativeModel qModel = (QualitativeModel) model.getExtension(QualConstant.namespaceURI);
    if (qModel != null){
      addListOfQualitativeSpeciesToTreeModel(top, qModel.getListOfQualitativeSpecies());
      addListOfTransitionsToTreeModel(top, qModel.getListOfTransitions());
    }
  }
View Full Code Here

 
  /** Read the SBML model information to create the Cytoscape Graph.
   * Additional information is stored as Node and Edge Attributes.*/
  public void createCytoscapeGraphFromSBMLDocument(){
   
    Model model = document.getModel();
    networkName = getAvailableNetworkName(model.getId());
    model.setId(networkName);
   
    // Handle the node and edge information
    CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
    CyAttributes edgeAttributes = Cytoscape.getEdgeAttributes();
    CyAttributes netAttributes = Cytoscape.getNetworkAttributes();
   
    nodeIds = new ArrayList<Integer>();
    edgeIds = new ArrayList<Integer>();
   
    // Model
    String id = networkName;
    netAttributes.setAttribute(id, CySBMLConstants.ATT_ID, model.getId());
    if (model.isSetName()){
      netAttributes.setAttribute(id, CySBMLConstants.ATT_NAME, model.getName());
    } else {
      netAttributes.setAttribute(id, CySBMLConstants.ATT_NAME, model.getId());
    }
    if (model.isSetMetaId()){
      netAttributes.setAttribute(id, CySBMLConstants.ATT_METAID, model.getMetaId());
    }
    if (model.isSetSBOTerm()){
      netAttributes.setAttribute(id, CySBMLConstants.ATT_SBOTERM, model.getSBOTermID());
    }
   
    // Species
    for (Species species : model.getListOfSpecies()) {
      id = species.getId();
      CyNode node = Cytoscape.getCyNode(id, true);
     
      nodeAttributes.setAttribute(id, CySBMLConstants.ATT_ID, id);
      nodeAttributes.setAttribute(id, CySBMLConstants.ATT_TYPE, CySBMLConstants.NODETYPE_SPECIES);
      if (species.isSetName()){
        nodeAttributes.setAttribute(id, CySBMLConstants.ATT_NAME, species.getName());
      } else {
        nodeAttributes.setAttribute(id, CySBMLConstants.ATT_NAME, id);
      }
      if (species.isSetInitialConcentration()){
        nodeAttributes.setAttribute(id, CySBMLConstants.ATT_INITIAL_CONCENTRATION,
            new Double(species.getInitialConcentration()));
      }
      if (species.isSetInitialAmount()){
        nodeAttributes.setAttribute(id, CySBMLConstants.ATT_INITIAL_AMOUNT,
            new Double(species.getInitialAmount()));
      }
      if (species.isSetSBOTerm()){
          nodeAttributes.setAttribute(id, CySBMLConstants.ATT_SBOTERM,
            species.getSBOTermID());
      }
      if (species.isSetCompartment()){
        nodeAttributes.setAttribute(id,
            CySBMLConstants.ATT_COMPARTMENT, species.getCompartment());
      }
      if (species.isSetBoundaryCondition()){
        nodeAttributes.setAttribute(id, CySBMLConstants.ATT_BOUNDARY_CONDITION,
            new Boolean(species.getBoundaryCondition()));
      }
      if (species.isSetConstant()){
        nodeAttributes.setAttribute(id, CySBMLConstants.ATT_CONSTANT,
            new Boolean(species.getConstant()));
      }
      if (species.isSetMetaId()){
        nodeAttributes.setAttribute(id, CySBMLConstants.ATT_METAID, species.getMetaId());
      }
      if (species.isSetHasOnlySubstanceUnits()){
        nodeAttributes.setAttribute(id, CySBMLConstants.ATT_HAS_ONLY_SUBSTANCE_UNITS,
            new Boolean(species.getHasOnlySubstanceUnits()));
      }
      nodeIds.add(node.getRootGraphIndex());
    }

    // Reactions
    String rid;
    for (Reaction reaction : model.getListOfReactions()) {
      rid = reaction.getId();
      CyNode node = Cytoscape.getCyNode(rid, true);
      nodeAttributes.setAttribute(rid, CySBMLConstants.ATT_TYPE, CySBMLConstants.NODETYPE_REACTION);
      nodeAttributes.setAttribute(rid, CySBMLConstants.ATT_ID, reaction.getId());
     
      if (reaction.isSetSBOTerm()){
        nodeAttributes.setAttribute(rid, CySBMLConstants.ATT_SBOTERM, reaction.getSBOTermID());
      }
      if (reaction.isSetName()){
        nodeAttributes.setAttribute(rid, CySBMLConstants.ATT_NAME, reaction.getName());
      } else {
        nodeAttributes.setAttribute(rid, CySBMLConstants.ATT_NAME, rid);
      }
   
      if (reaction.isSetCompartment()){
        nodeAttributes.setAttribute(rid, CySBMLConstants.ATT_COMPARTMENT, reaction.getCompartment());
      } else {
        nodeAttributes.setAttribute(rid, CySBMLConstants.ATT_COMPARTMENT, "-");
      }
      // Reactions are reversible by default
      if (reaction.isSetReversible()){
        nodeAttributes.setAttribute(rid, CySBMLConstants.ATT_REVERSIBLE,
            new Boolean(reaction.getReversible()));
      } else {
        nodeAttributes.setAttribute(rid, CySBMLConstants.ATT_REVERSIBLE,
            new Boolean(true));
      }
      if (reaction.isSetMetaId()){
        nodeAttributes.setAttribute(rid, CySBMLConstants.ATT_METAID, reaction.getMetaId());
      }
      nodeIds.add(node.getRootGraphIndex());

      //products
      Double stoichiometry;
      for (SpeciesReference speciesRef : reaction.getListOfProducts()) {
        CyNode product = Cytoscape.getCyNode(speciesRef.getSpecies(), false);
        CyEdge edge = Cytoscape.getCyEdge(node, product, Semantics.INTERACTION,
            CySBMLConstants.EDGETYPE_REACTION_PRODUCT, true);
        if (speciesRef.isSetStoichiometry()){
          stoichiometry = speciesRef.getStoichiometry();
        } else {
          stoichiometry = 1.0;
        }
        edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_STOICHIOMETRY, stoichiometry);
        if (speciesRef.isSetSBOTerm()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_SBOTERM, speciesRef.getSBOTermID());
        }
        if (speciesRef.isSetMetaId()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_METAID, speciesRef.getMetaId());
        }
        edgeIds.add(edge.getRootGraphIndex());
      }

      //reactants
      for (SpeciesReference speciesRef : reaction.getListOfReactants()) {
        CyNode reactant = Cytoscape.getCyNode(speciesRef.getSpecies(), false);
        CyEdge edge = Cytoscape.getCyEdge(node, reactant, Semantics.INTERACTION,
            CySBMLConstants.EDGETYPE_REACTION_REACTANT, true);
        if (speciesRef.isSetStoichiometry()){
          stoichiometry = speciesRef.getStoichiometry();
        } else {
          stoichiometry = 1.0;
        }
        edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_STOICHIOMETRY, stoichiometry);
        if (speciesRef.isSetSBOTerm()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_SBOTERM, speciesRef.getSBOTermID());
        }
        if (speciesRef.isSetMetaId()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_METAID, speciesRef.getMetaId());
        }
        edgeIds.add(edge.getRootGraphIndex());
      }
     
      //modifier
      for (ModifierSpeciesReference msref : reaction.getListOfModifiers()) {
        CyNode modifier = Cytoscape.getCyNode(msref.getSpecies(), false);
        CyEdge edge = Cytoscape.getCyEdge(modifier, node, Semantics.INTERACTION,
            CySBMLConstants.EDGETYPE_REACTION_MODIFIER, true);
        stoichiometry = 1.0;
        edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_STOICHIOMETRY, stoichiometry);
        if (msref.isSetSBOTerm()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_SBOTERM, msref.getSBOTermID());
        }
        if (msref.isSetMetaId()){
          edgeAttributes.setAttribute(edge.getIdentifier(), CySBMLConstants.ATT_METAID, msref.getMetaId());
        }
        edgeIds.add(edge.getRootGraphIndex());
      }
     
      //parse the parameters from the kinetic laws
      //TODO: better handling of the kinetic information
      if (reaction.isSetKineticLaw()){
        KineticLaw law = reaction.getKineticLaw();
        if (law.isSetListOfLocalParameters()){
          for (LocalParameter parameter: law.getListOfLocalParameters()){
            String attName = "kineticLaw-" + parameter.getId();
            String attUnitsName = "kineticLaw-" + parameter.getId() + "-units";
            if (parameter.isSetValue()){
              nodeAttributes.setAttribute(rid, attName, parameter.getValue());
            }
            if (parameter.isSetUnits()){
              nodeAttributes.setAttribute(rid, attUnitsName, parameter.getValue());
            }
          }
        }
      }
    }
   
    ////////////// QUALITATIVE SBML MODEL ////////////////////////////////////////////
    //Must the network be generated again for the qual model ??
     QualitativeModel qModel = (QualitativeModel) model.getExtension(QualConstant.namespaceURI);
     if (qModel != null){
      
     //QualSpecies
     String qsid;
     for (QualitativeSpecies qSpecies : qModel.getListOfQualitativeSpecies()){ 
View Full Code Here

   */
  public static void main(String[] args) throws XMLStreamException,
      SBMLException {
    SBMLDocument doc = new SBMLDocument(2, 4);
    doc.addTreeNodeChangeListener(new SimpleTreeNodeChangeListener());
    Model model = doc.createModel("test_model");
   
    Parameter k1 = model.createParameter("k1");
    Parameter k2 = model.createParameter("k2");

    k1.addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "test"));
   
    k1.setConstant(false);
    k2.setConstant(false);
   
    Event event = model.createEvent("test_event");
   
    Trigger trigger = event.createTrigger();
    trigger.setMath(ASTNode.geq(new ASTNode(ASTNode.Type.NAME_TIME),
        new ASTNode(10)));
   
View Full Code Here

      System.out.printf("[IN]:\t%s\n", formula);
      System.out.printf("[OUT]:\t%s\n", testNode.toFormula());
      System.out.printf("[LTX]:\t%s\n", testNode.toLaTeX());

//      AssignmentRule as = new AssignmentRule(2, 4);
      Model m = new Model(2, 4);
      FunctionDefinition fd = new FunctionDefinition("f", 2, 4);
      m.addFunctionDefinition(fd);
      //as.setMath(ASTNode.parseFormula("f(a, b, c, d)"));
      //m.addRule(as);
      //System.out.println(as.getMath().toString());

    }
View Full Code Here

public class SpeciesAnnotationTest extends SimpleTreeNodeChangeListener {

  public SpeciesAnnotationTest() throws XMLStreamException, SBMLException {
    SBMLDocument doc = new SBMLDocument(2, 4);
    doc.addTreeNodeChangeListener(this);
    Model model = doc.createModel("model_test");
    Species s1 = model.createSpecies("s1", model.createCompartment("c1"));
    s1.setMetaId("meta_" + s1.getId());
    // Not necessary anymore.
    // s1.getAnnotation().addRDFAnnotationNamespace("bqbiol", "",
    // "http://biomodels.net/biology-qualifiers/");
    s1.addCVTerm(new CVTerm(CVTerm.Type.BIOLOGICAL_QUALIFIER,
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.