Package org.sbml.jsbml

Examples of org.sbml.jsbml.Compartment


    private Compartment C;
    private Event E;

    @Before public void setUp() throws Exception
    {
      C = new  Compartment(2,4);
      E = new  Event(2,4);
    }
View Full Code Here


      XMLNamespaces xmlns = new  XMLNamespaces();
      xmlns.add( "http://www.sbml.org", "testsbml");
      SBMLNamespaces sbmlns = new  SBMLNamespaces(2,1);
      sbmlns.addNamespaces(xmlns); */
     
       Compartment c = new  Compartment(2,1); // new  Compartment(sbmlns);
//      assertTrue( c.getTypeCode() == libsbml.SBML_COMPARTMENT );
      assertTrue( c.getMetaId().equals("") == true );
//      assertTrue( c.getNotes() == null );
      assertTrue( c.getAnnotation() == null );
      assertTrue( c.getLevel() == 2 );
      assertTrue( c.getVersion() == 1 );
      assertTrue( c.getNamespaces() != null );
//      assertTrue( c.getNamespaces().getLength() == 2 );
      assertTrue( c.getName().equals("") == true );
      assertTrue( c.getSpatialDimensions() == 3d );
      assertTrue( c.getConstant() == true );
      c = null;
    }
View Full Code Here

  }

  @SuppressWarnings("deprecation")
@Test public void test_Compartment_initDefaults()
  {
    Compartment c = new  Compartment(2,4);
    c.setId( "A");
    c.initDefaults();
    assertTrue(c.getId().equals( "A"));
    assertTrue( c.getName().equals("") == true );
    assertTrue( c.getUnits().equals("") == true );
    assertTrue( c.getOutside().equals("") == true );
    assertTrue( c.getSpatialDimensions() == 3d );
    // assertTrue( c.getVolume() == 1.0 ); // There is no default for the volume/size in L2 !!
    assertTrue( Double.isNaN(c.getVolume()));
    assertTrue( c.getConstant() == true );
    assertEquals( true, c.isSetId() );
    assertEquals( false, c.isSetName() );
    assertEquals( false, c.isSetSize() );
    assertEquals( false, c.isSetVolume() );
    assertEquals( false, c.isSetUnits() );
    assertEquals( false, c.isSetOutside() );
    c = null;
  }
View Full Code Here

@Test public void test_read_l2v1_assignment()
  {
    SBMLReader reader = new SBMLReader();
    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.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") );
View Full Code Here

   * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml.CallableSBase)
   */
  public ASTNodeValue compile(CallableSBase variable) {
    if (variable instanceof Species) {
      Species species = (Species) variable;
      Compartment c = species.getCompartmentInstance();
      boolean concentration = !species.getHasOnlySubstanceUnits()
          && (0 < c.getSpatialDimensions());
      StringBuffer value = new StringBuffer();
      if (concentration) {
        value.append('[');
      }
      value.append(getNameOrID(species));
      if (concentration) {
        value.append(']');
      }
      return new ASTNodeValue(value.toString(), this);

    } else if (variable instanceof Compartment) {
      Compartment c = (Compartment) variable;
      return compile(c);
    }
    // TODO: more special cases of names!!! PARAMETER, FUNCTION DEF,
    // REACTION.
    return new ASTNodeValue(mathtt(maskSpecialChars(variable.getId()))
View Full Code Here

  public void setSpatial(boolean isSpatial) {
    spatial = Boolean.valueOf(isSpatial);

    // Check if the compartment of the Species has a child of CompartmentMapping
    Species species = getExtendedSBase();
    Compartment compartment = species.getCompartmentInstance();

    if (compartment != null) {
      SpatialCompartmentPlugin spatialCompartment = (SpatialCompartmentPlugin) compartment.getExtension(SpatialConstants.namespaceURI);

      boolean cmSet = spatialCompartment.isSetCompartmentMapping();

      if (!cmSet) {
        throw new SBMLException(bundle.getString("COMPARTMENT_MAPPING_NOT_SET"));
View Full Code Here

        Geometry geometry = new Geometry();
        spatialModel.setGeometry(geometry);
        return geometry;
      }
    } else if (contextObject instanceof Compartment) {
      Compartment compartment = (Compartment) contextObject;
      SpatialCompartmentPlugin spatialCompartment = null;
      if (compartment.getExtension(SpatialConstants.namespaceURI) != null) {
        spatialCompartment = (SpatialCompartmentPlugin) compartment.getExtension(SpatialConstants.namespaceURI);
      } else {
        spatialCompartment = new SpatialCompartmentPlugin(compartment);
        compartment.addExtension(SpatialConstants.namespaceURI, spatialCompartment);
      }

      if (elementName.equals(SpatialConstants.compartmentMapping)) {
        CompartmentMapping compartmentMapping = new CompartmentMapping();
        spatialCompartment.setCompartmentMapping(compartmentMapping);
View Full Code Here

    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);
    g0.setInitialLevel(0);

    g0.getAnnotation().addCVTerm(new CVTerm(CVTerm.Qualifier.BQB_IS, "urn:miriam:obo.go:GO%3A1234567"));
    g0.setNotes("<notes>\n\t<body xmlns=\"http://www.w3.org/1999/xhtml\">\n\t\t<p>TestNotes parsing &#285; &#65;</p>\n\t</body>\n</notes>");

    QualitativeSpecies g1 = qModel.createQualitativeSpecies("G1", comp1.getId(), false);
    g1.setName("G1 name");
    g1.setMaxLevel(3);
    g1.setInitialLevel(1);


    QualitativeSpecies g2 = qModel.createQualitativeSpecies("G2", comp1.getId(), false);
    g2.setMaxLevel(2);
    g2.setInitialLevel(2);

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

    QualitativeSpecies g3 = qModel.createQualitativeSpecies("G3", comp1.getId(), true);
    g3.setMaxLevel(1);
    g3.setInitialLevel(1);

    // ListOfTransitions
    Transition tr_g1 = qModel.createTransition("tr_G1");
View Full Code Here

          }
        }
      }
      if (model.isSetListOfCompartments()) {
        for (int i = 0; i < model.getNumCompartments(); i++) {
          Compartment compartment = model.getCompartment(i);

          setCompartmentCompartmentType(compartment, model);
          setCompartmentOutside(compartment, model);
          setCompartmentUnits(compartment, model);
        }
View Full Code Here

              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(
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.Compartment

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.