Package org.sbml.jsbml

Examples of org.sbml.jsbml.LocalParameter


                && !kineticLaw.isSetSubstanceUnitsInstance()) {
              log4jLogger.warn("No UnitDefinition matches the substanceUnitsID of kineticLaw.");
            }
            if (kineticLaw.isSetListOfLocalParameters()) {
              for (int j = 0; j < kineticLaw.getLocalParameterCount(); 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.getSpeciesCount(); 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.getParameterCount(); i++) {
          Parameter parameter = model.getParameter(i);
          if (parameter.isSetUnits()
              && !parameter.isSetUnitsInstance()) {
            log4jLogger.warn("No UnitDefinition matches the unitsID of parameter.");
          }
        }
      }
View Full Code Here


            // localParameter and listOfLocalParameter
            if (elementName.equals("localParameter")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfLocalParameters)
                && kineticLaw.getLevel() >= 3) {
              LocalParameter localParameter = (LocalParameter) newContextObject;
              kineticLaw.addLocalParameter(localParameter);

              return localParameter;
            } else if (elementName.equals("parameter")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfLocalParameters)
                && kineticLaw.isSetLevel()
                && kineticLaw.getLevel() < 3) {
              LocalParameter localParameter = new LocalParameter(
                  (Parameter) newContextObject);
              kineticLaw.addLocalParameter(localParameter);

              return localParameter;
            } else {
View Full Code Here

  public void test_read_l1v1_branch() throws XMLStreamException, InvalidPropertiesFormatException, IOException, ClassNotFoundException {
    SBMLDocument d;
    Model m;
    Compartment c;
    KineticLaw kl;
    LocalParameter p;
    Reaction r;
    Species s;
    SpeciesReference sr;
    UnitDefinition ud;
    String filename = DATA_FOLDER + "/libsbml-test-data/l1v1-branch.xml";
    d = new SBMLReader().readSBML(filename);
    if (d == null)
      ;
    {
    }
    assertTrue(d.getLevel() == 1);
    assertTrue(d.getVersion() == 1);
    m = d.getModel();
    assertTrue(m.getName().equals("Branch"));
    assertTrue(m.getCompartmentCount() == 1);
    c = m.getCompartment(0);
    assertTrue(c.getName().equals("compartmentOne"));
    assertTrue(c.getVolume() == 1);
    ud = c.getDerivedUnitDefinition();
    assertTrue(ud.getUnitCount() == 1);

    // assertTrue(ud.getUnit(0).getKind() == Unit.Kind.LITRE); // getDerivedUnitDefinition not working properly
    assertTrue(m.getSpeciesCount() == 4);
    s = m.getSpecies(0);
    assertTrue(s.getName().equals("S1"));
    assertTrue(s.getCompartment().equals("compartmentOne"));
    assertTrue(s.getInitialAmount() == 0);
    assertTrue(s.getBoundaryCondition() == false);

    //    ud = s.getDerivedUnitDefinition(); // getDerivedUnitDefinition not working properly
//    assertTrue(ud.getUnitCount() == 2);
//    assertTrue(ud.getUnit(0).getKind() == Unit.Kind.MOLE);
//    assertTrue(ud.getUnit(0).getExponent() == 1);
//    assertTrue(ud.getUnit(1).getKind() == Unit.Kind.LITRE);
//    assertTrue(ud.getUnit(1).getExponent() == -1);
   
    s = m.getSpecies(1);
    assertTrue(s.getName().equals("X0"));
    assertTrue(s.getCompartment().equals("compartmentOne"));
    assertTrue(s.getInitialAmount() == 0);
    assertTrue(s.getBoundaryCondition() == true);
    s = m.getSpecies(2);
    assertTrue(s.getName().equals("X1"));
    assertTrue(s.getCompartment().equals("compartmentOne"));
    assertTrue(s.getInitialAmount() == 0);
    assertTrue(s.getBoundaryCondition() == true);
    s = m.getSpecies(3);
    assertTrue(s.getName().equals("X2"));
    assertTrue(s.getCompartment().equals("compartmentOne"));
    assertTrue(s.getInitialAmount() == 0);
    assertTrue(s.getBoundaryCondition() == true);
    assertTrue(m.getReactionCount() == 3);
    r = m.getReaction(0);
    assertTrue(r.getName().equals("reaction_1"));
    assertTrue(r.getReversible() == false);
    assertTrue(r.getFast() == false);
    ud = r.getKineticLaw().getDerivedUnitDefinition();

    //    assertTrue(ud.getUnitCount() == 2);
//    assertTrue(ud.getUnit(0).getKind() == Unit.Kind.MOLE);
//    assertTrue(ud.getUnit(0).getExponent() == 1);
//    assertTrue(ud.getUnit(1).getKind() == Unit.Kind.LITRE);
//    assertTrue(ud.getUnit(1).getExponent() == -1);
   
    assertTrue(r.getKineticLaw().containsUndeclaredUnits() == true);
    r = m.getReaction(1);
    assertTrue(r.getName().equals("reaction_2"));
    assertTrue(r.getReversible() == false);
    assertTrue(r.getFast() == false);
    r = m.getReaction(2);
    assertTrue(r.getName().equals("reaction_3"));
    assertTrue(r.getReversible() == false);
    assertTrue(r.getFast() == false);
    r = m.getReaction(0);
    assertTrue(r.getReactantCount() == 1);
    assertTrue(r.getProductCount() == 1);
    sr = r.getReactant(0);
    assertTrue(sr.getSpecies().equals("X0"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    sr = r.getProduct(0);
    assertTrue(sr.getSpecies().equals("S1"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    kl = r.getKineticLaw();
    assertTrue(kl.getFormula().equals("k1*X0")); // We are not putting the same space in the formula
    assertTrue(kl.getLocalParameterCount() == 1);
    p = kl.getParameter(0);
    assertTrue(p.getName().equals("k1"));
    assertTrue(p.getValue() == 0);
    r = m.getReaction(1);
    assertTrue(r.getReactantCount() == 1);
    assertTrue(r.getProductCount() == 1);
    sr = r.getReactant(0);
    assertTrue(sr.getSpecies().equals("S1"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    sr = r.getProduct(0);
    assertTrue(sr.getSpecies().equals("X1"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    kl = r.getKineticLaw();
    assertTrue(kl.getFormula().equals("k2*S1")); // equals("k2 * S1")
    assertTrue(kl.getLocalParameterCount() == 1);
    p = kl.getParameter(0);
    assertTrue(p.getName().equals("k2"));
    assertTrue(p.getValue() == 0);
    r = m.getReaction(2);
    assertTrue(r.getReactantCount() == 1);
    assertTrue(r.getProductCount() == 1);
    sr = r.getReactant(0);
    assertTrue(sr.getSpecies().equals("S1"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    sr = r.getProduct(0);
    assertTrue(sr.getSpecies().equals("X2"));
    assertTrue(sr.getStoichiometry() == 1);
    assertTrue(sr.getDenominator() == 1);
    kl = r.getKineticLaw();
    assertTrue(kl.getFormula().equals("k3*S1")); // equals("k3 * S1")
    assertTrue(kl.getLocalParameterCount() == 1);
    p = kl.getParameter(0);
    assertTrue(p.getName().equals("k3"));
    assertTrue(p.getValue() == 0);
    d = null;
  }
View Full Code Here

    /*
     * Local Parameters
     */
    logger.debug("==== LocalParameters ====");
    KineticLaw kl = r1.createKineticLaw();
    LocalParameter parameter = kl.createLocalParameter("lp1");
    parameter.setValue(2d);
    kl.getListOfLocalParameters().add(new LocalParameter("lp2"));
    try {
      kl.createLocalParameter("lp1");
      fail();
    } catch (IllegalArgumentException exc) {
      logger.debug(exc.getLocalizedMessage());
      assertTrue(kl.getListOfLocalParameters()
                   .filterList(new NameFilter(parameter.getId())).size() == 1);
    }
    kl.removeLocalParameter(parameter);
    assertTrue(kl.getListOfLocalParameters()
               .filterList(new NameFilter(parameter.getId())).size() == 0);
    assertTrue(kl.getLocalParameter(parameter.getId()) == null);
    // remove ListOfLocalParameters
    ListOf<LocalParameter> listOfLP = kl.getListOfLocalParameters();
    kl.unsetListOfLocalParameters();
    assertTrue(!listOfLP.contains(parameter));
    assertTrue(kl.getLocalParameter("lp2") == null);
    // add ListOfLocalParameters
    listOfLP.add(parameter);
    kl.setListOfLocalParameters(listOfLP);
    assertTrue(kl.getLocalParameter(parameter.getId()) != null);
   
    /*
     * Compartments
     */
    logger.debug("==== Compartments ====");
View Full Code Here

    SBMLDocument d = null;
    Model m;
    Compartment c;
    Species s;
    Parameter gp;
    LocalParameter lp;
    AssignmentRule ar;
    Reaction r;
    SpeciesReference sr;
    KineticLaw kl;
    UnitDefinition ud;
    Reaction r1;
    ListOf<Compartment> loc;
    Compartment c1;
    ListOf<Rule> lor;
    AssignmentRule ar1;
    ListOf<Parameter> lop;
    Parameter p1;
    ListOf<Species> los;
    Species s1;
    String filename = new String( DATA_FOLDER + "/libsbml-test-data/" );
    filename += "l2v1-assignment.xml";
    try {
    d = reader.readSBML(filename);
  } catch (IOException e) {
    e.printStackTrace();
    assert(false);
  } catch (XMLStreamException e) {
    e.printStackTrace();
    assert(false);
  }

  System.out.println(" TestReadFromFile 5: reading done.");
 
  assertTrue( d.getLevel() == 2 );
    assertTrue( d.getVersion() == 1 );
    m = d.getModel();
    assertTrue( m != null );
    assertTrue( m.getCompartmentCount() == 1 );
    c = m.getCompartment(0);
    assertTrue( c != null );
    assertTrue( c.getId().equals( "cell") );
/*    ud = c.getDerivedUnitDefinition();
    assertTrue( ud.getUnitCount() == 1 );
    assertTrue( ud.getUnit(0).getKind() == Kind.LITRE );
    */
    loc = m.getListOfCompartments();
    c1 = loc.get(0);
    assertTrue( c1.equals(c) );
    c1 = loc.get("cell");
    assertTrue( c1.equals(c) );
    assertTrue( m.getSpeciesCount() == 5 );
    s = m.getSpecies(0);
    assertTrue( s != null );
    assertTrue( s.getId().equals( "X0"  ) );
    assertTrue( s.getCompartment().equals( "cell") );
    assertTrue( s.getInitialConcentration() == 1.0 );
    los = m.getListOfSpecies();
    s1 = los.get(0);
    assertTrue( s1.equals(s) );
    s1 = los.get("X0");
    assertTrue( s1.equals(s) );
    s = m.getSpecies(1);
    assertTrue( s != null );
    assertTrue( s.getId().equals( "X1"  ) );
    assertTrue( s.getCompartment().equals( "cell") );
    assertTrue( s.getInitialConcentration() == 0.0 );
    s = m.getSpecies(2);
    assertTrue( s != null );
    assertTrue( s.getId().equals( "T"   ) );
    assertTrue( s.getCompartment().equals( "cell") );
    assertTrue( s.getInitialConcentration() == 0.0 );
    s = m.getSpecies(3);
    assertTrue( s != null );
    assertTrue( s.getId().equals( "S1"  ) );
    assertTrue( s.getCompartment().equals( "cell") );
    assertTrue( s.getInitialConcentration() == 0.0 );
    s = m.getSpecies(4);
    assertTrue( s != null );
    assertTrue( s.getId().equals( "S2"  ) );
    assertTrue( s.getCompartment().equals( "cell") );
    assertTrue( s.getInitialConcentration() == 0.0 );
    assertTrue( m.getParameterCount() == 1 );
    gp = m.getParameter(0);
    assertTrue( gp != null );
    assertTrue( gp.getId().equals( "Keq") );
    assertTrue( gp.getValue() == 2.5 );
    lop = m.getListOfParameters();
    p1 = lop.get(0);
    assertTrue( p1.equals(gp) );
    p1 = lop.get("Keq");
    assertTrue( p1.equals(gp) );
    /*
    ud = gp.getDerivedUnitDefinition();
    assertTrue( ud.getUnitCount() == 0 );
    assertTrue( m.getRuleCount() == 2 );
    */
    ar = (AssignmentRulem.getRule(0);
    assertTrue( ar != null );
    assertTrue( ar.getVariable().equals( "S1"           ) );
    assertTrue( ar.getFormula().equals( "T/(1+Keq)") );
    /*
    ud = ar.getDerivedUnitDefinition();
    assertTrue( ud.getUnitCount() == 2 );
    assertTrue( ud.getUnit(0).getKind() == Kind.MOLE );
    assertTrue( ud.getUnit(0).getExponent() == 1 );
    assertTrue( ud.getUnit(1).getKind() == Kind.LITRE );
    assertTrue( ud.getUnit(1).getExponent() == -1 );
    */
    assertTrue( ar.containsUndeclaredUnits() == true );
    lor = m.getListOfRules();
    ar1 = (AssignmentRule) lor.get(0);
    assertTrue( ar1.equals(ar) );
    ar1 = (AssignmentRule) lor.get("S1");
    assertTrue( ar1.equals(ar) );
    ar = (AssignmentRulem.getRule(1);
    assertTrue( ar != null );
    assertTrue( ar.getVariable().equals( "S2"      ) );
    assertTrue( ar.getFormula().equals( "Keq*S1") );
    assertTrue( m.getReactionCount() == 2 );
    r = m.getReaction(0);
    assertTrue( r != null );
    assertTrue( r.getId().equals( "in") );
    assertTrue( r.getReactantCount() == 1 );
    assertTrue( r.getProductCount() == 1 );
    sr = r.getReactant(0);
    assertTrue( sr != null );
    assertTrue( sr.getSpecies().equals( "X0") );
    sr = r.getProduct(0);
    assertTrue( sr != null );
    assertTrue( sr.getSpecies().equals( "T" ) );
    kl = r.getKineticLaw();
    assertTrue( kl != null );
    assertTrue( kl.getFormula().equals( "k1*X0") );
    assertTrue( kl.getLocalParameterCount() == 1 );
    r1 = (Reaction) kl.getParentSBMLObject();
    assertTrue( r1 != null );
    assertTrue( r1.getId().equals( "in") );
    assertTrue( r1.getReactantCount() == 1 );
    assertTrue( r1.getProductCount() == 1 );
    lp = kl.getLocalParameter(0);
    assertTrue( lp != null );
    assertTrue( lp.getId().equals( "k1") );
    assertTrue( lp.getValue() == 0.1 );
    kl = (KineticLaw) lp.getParentSBMLObject().getParentSBMLObject();
    assertTrue( kl != null );
    assertTrue( kl.getFormula().equals( "k1*X0") );
    assertTrue( kl.getLocalParameterCount() == 1 );
    r = m.getReaction(1);
    assertTrue( r != null );
    assertTrue( r.getId().equals( "out") );
    assertTrue( r.getReactantCount() == 1 );
    assertTrue( r.getProductCount() == 1 );
    sr = r.getReactant(0);
    assertTrue( sr != null );
    assertTrue( sr.getSpecies().equals( "T" ) );
    sr = r.getProduct(0);
    assertTrue( sr != null );
    assertTrue( sr.getSpecies().equals( "X1") );
    kl = r.getKineticLaw();
    assertTrue( kl != null );
    assertTrue( kl.getFormula().equals( "k2*T") );
    assertTrue( kl.getLocalParameterCount() == 1 );
    lp = kl.getLocalParameter(0);
    assertTrue( lp != null );
    assertTrue( lp.getId().equals( "k2") );
    assertTrue( lp.getValue() == 0.15 );
    d = null;
  }
View Full Code Here

    M.addParameter(k2);
    Reaction r1 = new Reaction(2, 4);
    r1.setId("reaction_1");
    KineticLaw kl = new KineticLaw(2, 4);
    kl.setFormula("k1 * X0");
    LocalParameter k3 = new LocalParameter(2, 4);
    LocalParameter k4 = new LocalParameter(2, 4);
    k3.setId("k1");
    k4.setId("k2");
    k3.setValue(2.72);
    k4.setValue(3.14);
    kl.addParameter(k3);
    kl.addParameter(k4);
    r1.setKineticLaw(kl);
    M.addReaction(r1);
    KineticLaw kl1 = M.getReaction(0).getKineticLaw();
View Full Code Here

  @Test
  public void test_Model_createKineticLawParameter() {
    Reaction r;
    KineticLaw kl;
    LocalParameter p;
    M.createReaction();
    M.createReaction();
    M.createKineticLaw();
    p = M.createKineticLawParameter();
    assertTrue(M.getReactionCount() == 2);
View Full Code Here

   
    SpeciesReference product = model.createProduct("SP2");
    product.setMetaId("SP2");
    product.setSpecies(s2);
   
    LocalParameter lp1 = r1.createKineticLaw().createLocalParameter("LP1");
    lp1.setMetaId("LP1");
   
  }
View Full Code Here

    assertTrue(model.getReactionCount() == 2);

    KineticLaw k = r2.createKineticLaw();
   
    // Creating a new local parameter without id
    LocalParameter lp = k.createLocalParameter();
   
    lp.setMetaId("LP1_2");
    lp.setName("LP1_2");
    lp.setId("LP1");
   
    assertTrue(k.getLocalParameterCount() == 1);
   
    assertTrue(doc.findSBase("LP1_2") != null);

    assertTrue(k.getLocalParameter("LP1") != null);
    assertTrue(model.findLocalParameters("LP1").size() == 2);
    assertTrue(model.findReactionsForLocalParameter("LP1").size() == 1); // because r2 has no ID yet !!
   
    lp.setId("LP1_2"); // changing the id of the localParameter !!
   
    assertTrue(k.getLocalParameter("LP1") == null);
    assertTrue(k.getLocalParameter("LP1_2") != null);
   
    assertTrue(model.findLocalParameters("LP1_2").size() == 1);
View Full Code Here

    Reaction r2 = model.createReaction("R2");
   
    KineticLaw kl = r2.createKineticLaw();

    ListOf<LocalParameter> listOfLP = new ListOf<LocalParameter>(2, 4);
    listOfLP.add(new LocalParameter("LP1"));
    listOfLP.add(new LocalParameter("LP2"));
    listOfLP.add(new LocalParameter("LP3"));
    listOfLP.add(new LocalParameter("LP1"));
   
    try {
     
      kl.setListOfLocalParameters(listOfLP);
     
      fail("We should not be able to register twice the same local parameter id.");
    } catch(IllegalArgumentException e) {
      // success
    }
   
    assertTrue(kl.getLocalParameterCount() == 0);
    assertTrue(model.findLocalParameters("LP1").size() == 1);
    assertTrue(model.findLocalParameters("LP2").size() == 0);
       
    // listOfLP.remove(3); // TODO: at the moment the list of local parameter is emptied if there is an error !! Should we clone the listOf
    // when using the setListOf methods ??

    listOfLP.clear();
    listOfLP.add(new LocalParameter("LP1"));
    listOfLP.add(new LocalParameter("LP2"));
    listOfLP.add(new LocalParameter("LP3"));

    try {
     
      kl.setListOfLocalParameters(listOfLP);
     
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.LocalParameter

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.