Package org.sbml.jsbml

Examples of org.sbml.jsbml.Event


    assertEquals(M.getEvent(0), e);
  }

  @Test
  public void test_Model_createEventAssignment() {
    Event e;
    EventAssignment ea;
    M.createEvent();
    M.createEvent();
    ea = M.createEventAssignment();
    assertTrue(ea != null);
    assertTrue(M.getNumEvents() == 2);
    e = M.getEvent(1);
    assertTrue(e.getNumEventAssignments() == 1);
    assertEquals(e.getEventAssignment(0), ea);
  }
View Full Code Here


    assertTrue(M.getCompartment("C") == null);
  }

  @Test
  public void test_Model_getEventById() {
    Event e1 = new Event(2, 4);
    Event e2 = new Event(2, 4);
    Trigger t = new Trigger(2, 4);
    e1.setTrigger(t);
    e2.setTrigger(t);
    e1.createEventAssignment();
    e2.createEventAssignment();
    e1.setId("e1");
    e2.setId("e2");
    M.addEvent(e1);
    M.addEvent(e2);
    assertTrue(M.getNumEvents() == 2);
    // assertTrue(!M.getEvent("e1").equals(e1));
    // assertTrue(!M.getEvent("e2").equals(e2));
View Full Code Here

    o3 = null;
  }

  @Test
  public void test_Model_removeEvent() {
    Event o1, o2, o3;
    o1 = M.createEvent();
    o2 = M.createEvent();
    o3 = M.createEvent();
    o3.setId("test");
    assertTrue(M.removeEvent(0).equals(o1));
View Full Code Here

      XMLStreamException, SBMLException {
    SBMLDocument doc = new SBMLDocument(3, 1);
    Model model = doc.createModel("test_model");
    Parameter p = model.createParameter("p1");
    p.setValue(1d);
    Event e = model.createEvent("e1");
    Priority prior = e.createPriority();
    prior.setMath(new ASTNode(1));
    Trigger t = e.createTrigger();
    t.setFormula("time == 1");
    EventAssignment ea = e.createEventAssignment(p, ASTNode
        .parseFormula("3"));
    e.addEventAssignment(ea);
    System.out.println((new SBMLWriter()).writeSBMLToString(doc));
  }
View Full Code Here

    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)));
   
    EventAssignment assignment1 = event.createEventAssignment();
    assignment1.setVariable(k1);
    assignment1.setMath(new ASTNode(34));
   
    EventAssignment assignment2 = event.createEventAssignment();
    assignment2.setVariable(k2);
    assignment2.setMath(new ASTNode(k1));
   
    new SBMLWriter().write(doc, System.out);
  }
View Full Code Here

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

        if (event.isSetTrigger()) {
          listOfElementsToWrite.add(event.getTrigger());
        }
        if (event.isSetPriority()) {
          listOfElementsToWrite.add(event.getPriority());
        }
        if (event.isSetDelay()) {
          listOfElementsToWrite.add(event.getDelay());
        }
        if (event.isSetListOfEventAssignments()) {
          listOfElementsToWrite.add(event.getListOfEventAssignments());
        }

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

          }
        }
      }
      if (model.isSetListOfEvents()) {
        for (int i = 0; i < model.getNumEvents(); i++) {
          Event event = model.getEvent(i);

          if (event.isSetTimeUnits()
              && !event.isSetTimeUnitsInstance()) {
            log4jLogger.warn("No UnitDefinition matches the timeUnitsID of event.");
          }

          if (event.isSetListOfEventAssignments()) {

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

              if (eventAssignment.isSetVariable()
                  && !eventAssignment.isSetVariableInstance()) {
                log4jLogger.warn("No Symbol matches the variableID of eventAssignment.");
View Full Code Here

              return reaction;
            } else if (elementName.equals("event")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfEvents)
                && model.getLevel() > 1) {
              Event event = (Event) newContextObject;
              model.addEvent(event);
              event.initDefaults();

              return event;
            } else if (elementName.equals("compartmentType")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfCompartmentTypes)
                && (model.getLevel() == 2 && model.getVersion() > 1)) {
              CompartmentType compartmentType = (CompartmentType) newContextObject;
              model.addCompartmentType(compartmentType);

              return compartmentType;
            } else if (elementName.equals("speciesType")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfSpeciesTypes)
                && (model.getLevel() == 2 && model.getVersion() > 1)) {
              SpeciesType speciesType = (SpeciesType) newContextObject;
              model.addSpeciesType(speciesType);

              return speciesType;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else if (list.getParentSBMLObject() instanceof UnitDefinition) {
            UnitDefinition unitDefinition = (UnitDefinition) list
                .getParentSBMLObject();

            if (elementName.equals("unit")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfUnits)) {
              Unit unit = (Unit) newContextObject;
              unit.initDefaults();
              unitDefinition.addUnit(unit);

              return unit;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else if (list.getParentSBMLObject() instanceof Reaction) {
            Reaction reaction = (Reaction) list
                .getParentSBMLObject();

            if (elementName.equals("speciesReference")
                && (reaction.getLevel() > 1 || (reaction
                    .getLevel() == 1 && reaction
                    .getVersion() == 2))) {
              SpeciesReference speciesReference = (SpeciesReference) newContextObject;
              speciesReference.initDefaults();

              if (list.getSBaseListType().equals(
                  ListOf.Type.listOfReactants)) {
                reaction.addReactant(speciesReference);

                return speciesReference;
              } else if (list.getSBaseListType().equals(
                  ListOf.Type.listOfProducts)) {
                reaction.addProduct(speciesReference);

                return speciesReference;
              } else {
                log4jLogger.warn("The element " + elementName + " is not recognized");
              }
            } else if (elementName.equals("specieReference")
                && reaction.getLevel() == 1) {
              SpeciesReference speciesReference = (SpeciesReference) newContextObject;
              speciesReference.initDefaults();

              if (list.getSBaseListType().equals(
                  ListOf.Type.listOfReactants)) {
                reaction.addReactant(speciesReference);

                return speciesReference;
              } else if (list.getSBaseListType().equals(
                  ListOf.Type.listOfProducts)) {
                reaction.addProduct(speciesReference);

                return speciesReference;
              } else {
                log4jLogger.warn("The element " + elementName + " is not recognized");
              }
            } else if (elementName
                .equals("modifierSpeciesReference")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfModifiers)
                && reaction.getLevel() > 1) {
              ModifierSpeciesReference modifierSpeciesReference = (ModifierSpeciesReference) newContextObject;
              reaction.addModifier(modifierSpeciesReference);

              return modifierSpeciesReference;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else if (list.getParentSBMLObject() instanceof KineticLaw) {
            KineticLaw kineticLaw = (KineticLaw) list
                .getParentSBMLObject();
            // Level 3 : parameter and listOfParameters =>
            // localParameter and listOfLocalParameter
            if (elementName.equals("localParameter")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfLocalParameters)
                && kineticLaw.getLevel() >= 3) {
              LocalParameter localParameter = (LocalParameter) newContextObject;
              kineticLaw.addParameter(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.addParameter(localParameter);

              return localParameter;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else if (list.getParentSBMLObject() instanceof Event) {
            Event event = (Event) list.getParentSBMLObject();

            if (elementName.equals("eventAssignment")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfEventAssignments)
                && event.getLevel() > 1) {
              EventAssignment eventAssignment = (EventAssignment) newContextObject;
              event.addEventAssignment(eventAssignment);

              return eventAssignment;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
        } else if (contextObject instanceof UnitDefinition) {
          UnitDefinition unitDefinition = (UnitDefinition) contextObject;

          if (elementName.equals("listOfUnits")) {
            ListOf<Unit> listOfUnits = (ListOf<Unit>) newContextObject;
            unitDefinition.setListOfUnits(listOfUnits);

            return listOfUnits;
          }
        } else if (contextObject instanceof Event) {
          Event event = (Event) contextObject;

          if (elementName.equals("listOfEventAssignments")) {
            ListOf<EventAssignment> listOfEventAssignments = (ListOf<EventAssignment>) newContextObject;
            event.setListOfEventAssignments(listOfEventAssignments);

            return listOfEventAssignments;
          } else if (elementName.equals("trigger")) {
            Trigger trigger = (Trigger) newContextObject;
            event.setTrigger(trigger);

            return trigger;
          } else if (elementName.equals("delay")) {
            Delay delay = (Delay) newContextObject;
            event.setDelay(delay);

            return delay;
          } else if (elementName.equals("priority")) {
            Priority priority = (Priority) newContextObject;
            event.setPriority(priority);

            return priority;
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
View Full Code Here

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

          setEventTimeUnits(event, model);

          if (event.isSetListOfEventAssignments()) {

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

              setEventAssignmentVariable(eventAssignment, model);
            }
          }
View Full Code Here

    assertTrue(rdClkKL.getListOfParameters().size() == 3);
    assertTrue(rdClkKL.getListOfParameters().get(2).getId().equals("parameter_0000009"));
    assertTrue(rdClkKL.getListOfParameters().get(2).getName().equals("tau2"));
    assertTrue(rdClkKL.getListOfParameters().get(2).getValue() == 10);
   
    Event event = model.getEvent(0);
   
    assertTrue(event.getMetaId().equals("metaid_0000015"));
    assertTrue(event.getNumEventAssignments() == 1);
    assertTrue(event.getEventAssignment(0).getVariable().equals("dClkF"));
   
    System.out.println("First Trigger = " + event.getTrigger().getFormula());
   
    assertTrue(event.getTrigger().getMathMLString().contains("<math"));
    assertTrue(!event.getTrigger().getMathMLString().contains("athML<apply"));
   
  }
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.Event

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.