Package org.sbml.jsbml

Examples of org.sbml.jsbml.SpeciesReference


    assertTrue(sr2.getSpecies().equals( "P2"));
  }

  @Test public void test_Reaction_getProductById()
  {
    SpeciesReference sr1 = new  SpeciesReference(2,4);
    sr1.setSpecies( "P1");
    SpeciesReference sr2 = new  SpeciesReference(2,4);
    sr2.setSpecies( "P1");
    R.addProduct(sr1);
    R.addProduct(sr2);
    assertTrue( R.getNumReactants() == 0 );
    assertTrue( R.getNumProducts() == 2 );
    assertTrue( R.getNumModifiers() == 0 );
View Full Code Here


    sr2 = null;
  }

  @Test public void test_Reaction_getReactant()
  {
    SpeciesReference sr1 = new  SpeciesReference(2,4);
    SpeciesReference sr2 = new  SpeciesReference(2,4);
    sr1.setSpecies( "R1");
    sr2.setSpecies( "R2");
    R.addReactant(sr1);
    R.addReactant(sr2);
    sr1 = null;
    sr2 = null;
    assertTrue( R.getNumReactants() == 2 );
    assertTrue( R.getNumProducts() == 0 );
    assertTrue( R.getNumModifiers() == 0 );
    sr1 = R.getReactant(0);
    sr2 = R.getReactant(1);
    assertTrue(sr1.getSpecies().equals( "R1"));
    assertTrue(sr2.getSpecies().equals( "R2"));
  }
View Full Code Here

    assertTrue(sr2.getSpecies().equals( "R2"));
  }

  @Test public void test_Reaction_getReactantById()
  {
    SpeciesReference sr1 = new  SpeciesReference(2,4);
    sr1.setSpecies( "R1");
    SpeciesReference sr2 = new  SpeciesReference(2,4);
    sr2.setSpecies( "R2");
    R.addReactant(sr1);
    R.addReactant(sr2);
    assertTrue( R.getNumReactants() == 2 );
    assertTrue( R.getNumProducts() == 0 );
    assertTrue( R.getNumModifiers() == 0 );
View Full Code Here

    o3 = null;
  }

  @Test public void test_Reaction_removeProduct()
  {
    SpeciesReference o1,o2,o3;
    o1 = R.createProduct();
    o2 = R.createProduct();
    o3 = R.createProduct();
    o3.setSpecies("test");
    assertTrue( R.removeProduct(0).equals(o1) );
View Full Code Here

    o3 = null;
  }

  @Test public void test_Reaction_removeReactant()
  {
    SpeciesReference o1,o2,o3;
    o1 = R.createReactant();
    o2 = R.createReactant();
    o3 = R.createReactant();
    o3.setSpecies("test");
    assertTrue( R.removeReactant(0).equals(o1) );
View Full Code Here

    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.getNumCompartments() == 1 );
    c = m.getCompartment(0);
    assertTrue( c != null );
    assertTrue( c.getId().equals( "cell") );
/*    ud = c.getDerivedUnitDefinition();
    assertTrue( ud.getNumUnits() == 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.getNumSpecies() == 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.getNumParameters() == 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.getNumUnits() == 0 );
    assertTrue( m.getNumRules() == 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.getNumUnits() == 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.getNumReactions() == 2 );
    r = m.getReaction(0);
    assertTrue( r != null );
    assertTrue( r.getId().equals( "in") );
    assertTrue( r.getNumReactants() == 1 );
    assertTrue( r.getNumProducts() == 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.getNumReactants() == 1 );
    assertTrue( r1.getNumProducts() == 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.getNumReactants() == 1 );
    assertTrue( r.getNumProducts() == 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);
View Full Code Here

    s2.setMetaId("S2");
   
    Reaction r1 = model.createReaction("R1");
    r1.setMetaId("R1");
   
    SpeciesReference reactant = model.createReactant("SP1");
    reactant.setMetaId("SP1");
    reactant.setSpecies(s1);
   
    SpeciesReference product = model.createProduct("SP2");
    product.setMetaId("SP2");
    product.setSpecies(s2);
   
    LocalParameter lp1 = r1.createKineticLaw().createLocalParameter("LP1");
    lp1.setMetaId("LP1");
   
  }
View Full Code Here

      fail("We should be able to register an id or metaid from a removed element.");
      // success
    }
   
    try {
      SpeciesReference reactant = r1.createReactant("S1");
      reactant.setMetaId("S1");
    } catch (IllegalArgumentException e) {
      fail("We should be able to put any id to an element removed from a model.");
    } catch (IdentifierException e) {
      fail("We should be able to put any id to an element removed from a model.");
    }
View Full Code Here

        if (kineticLaw.isSetListOfLocalParameters()) {
          listOfElementsToWrite = new ArrayList<Object>();
          listOfElementsToWrite.add(kineticLaw.getListOfLocalParameters());
        }
      } else if (sbase instanceof SpeciesReference) {
        SpeciesReference speciesReference = (SpeciesReference) sbase;

        if (speciesReference.isSetStoichiometryMath()) {
          listOfElementsToWrite = new ArrayList<Object>();
          listOfElementsToWrite.add(speciesReference.getStoichiometryMath());
        }
      } else if (sbase instanceof Event) {
        Event event = (Event) sbase;
        listOfElementsToWrite = new ArrayList<Object>();
View Full Code Here

            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++) {
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.SpeciesReference

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.