getEvent() public method

public getEvent ( long n ) : Event
n long
return Event
 public void test_Event_parent_create()
 {
     Model m = new Model(2,4);
       Event e = m.createEvent();
       ListOf lo = m.getListOfEvents();
       assertTrue( lo == m.getEvent(0).getParentSBMLObject() );
       assertTrue( lo == e.getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
Beispiel #2
0
        /// <summary>
        /// [ EventStruct ]
        ///  [[ Id , Name , StringTrigger , StringDelay , TimeUnit , [[ VariableAssignment , StringAssignment ]] ]] 
        /// </summary>
        /// <param name="aSBMLmodel"></param>
        /// <returns></returns>
        public static List<EventStruct> getEvent(Model aSBMLmodel)
        {
            List<EventStruct> list = new List<EventStruct>();
            ListOfEvents events = aSBMLmodel.getListOfEvents();
            for (int i = 0; i < events.size(); i++ )
            {
                Event anEvent = aSBMLmodel.getEvent(i);
                string anId_Ev = anEvent.getId();
                string aName_Ev = anEvent.getName();
                Trigger anASTNode_Ev_Tr = anEvent.getTrigger();
                string aString_Ev_Tr = libsbml.libsbml.formulaToString(anASTNode_Ev_Tr.getMath());
                Delay anASTNode_Ev_De = anEvent.getDelay();
                string aString_Ev_De = libsbml.libsbml.formulaToString(anASTNode_Ev_Tr.getMath());

                string aTimeUnit_Ev = anEvent.getTimeUnits();

                List<EventAssignmentStruct> listOfEventAssignments = new List<EventAssignmentStruct>();

                ListOfEventAssignments assignments = anEvent.getListOfEventAssignments();
                for (int j = 0; j < assignments.size(); j++ )
                {
                    EventAssignment anEventAssignment = anEvent.getEventAssignment(j);

                    string aVariable_Ev_As = anEventAssignment.getVariable();
                    ASTNode anASTNode_Ev_As = anEventAssignment.getMath();
                    string aString_Ev_As = libsbml.libsbml.formulaToString(anASTNode_Ev_As);

                    EventAssignmentStruct listOfEventAssignment = new EventAssignmentStruct(
                        aVariable_Ev_As,
                        aString_Ev_As);

                    listOfEventAssignments.Add(listOfEventAssignment);
                }
                EventStruct eventStruct = new EventStruct(
                    anId_Ev,
                    aName_Ev,
                    aString_Ev_Tr,
                    aString_Ev_De,
                    aTimeUnit_Ev,
                    listOfEventAssignments);

                list.Add(eventStruct);
            }
            return list;
        }
Beispiel #3
0
 public void test_Event_ancestor_create()
 {
     Model m = new Model(2,4);
       Event e = m.createEvent();
       ListOf lo = m.getListOfEvents();
       assertTrue( e.getAncestorOfType(libsbml.SBML_MODEL) == m );
       assertTrue( e.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( e.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( e.getAncestorOfType(libsbml.SBML_PARAMETER) == null );
       Event obj = m.getEvent(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_MODEL) == m );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_EVENT) == null );
 }
 public void test_Event_parent_add()
 {
     Event e = new Event(2,4);
       Trigger t = new Trigger(2,4);
       e.setTrigger(t);
       e.createEventAssignment();
       Model m = new Model(2,4);
       m.addEvent(e);
       e = null;
       ListOf lo = m.getListOfEvents();
       assertTrue( lo == m.getEvent(0).getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
Beispiel #5
0
 public void test_ReadSBML_metaid_Event()
 {
     SBase sb;
       Event e;
       string s = wrapSBML_L2v1("<listOfEvents>" +
     "  <event metaid='e'>" +
     "    <listOfEventAssignments metaid='loea'>" +
     "      <eventAssignment metaid='ea'/>" +
     "    </listOfEventAssignments>" +
     "  </event>" +
     "</listOfEvents>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M != null );
       e = M.getEvent(0);
       sb = e;
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "e" == sb.getMetaId() ));
       sb = e.getListOfEventAssignments();
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "loea" == sb.getMetaId() ));
       sb = e.getEventAssignment(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "ea" == sb.getMetaId() ));
 }
Beispiel #6
0
 public void test_Event_ancestor_add()
 {
     Event e = new Event(2,4);
       Model m = new Model(2,4);
       Trigger t = new Trigger(2,4);
       e.setTrigger(t);
       e.createEventAssignment();
       m.addEvent(e);
       e = null;
       ListOf lo = m.getListOfEvents();
       Event obj = m.getEvent(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_MODEL) == m );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null );
 }
Beispiel #7
0
 public void test_ReadSBML_metaid()
 {
     SBase sb;
       string s = wrapSBML_L2v1("<listOfFunctionDefinitions>" +
     "  <functionDefinition metaid='fd'/>" +
     "</listOfFunctionDefinitions>" +
     "<listOfUnitDefinitions>" +
     "  <unitDefinition metaid='ud'/>" +
     "</listOfUnitDefinitions>" +
     "<listOfCompartments>" +
     "  <compartment metaid='c'/>" +
     "</listOfCompartments>" +
     "<listOfSpecies>" +
     "  <species metaid='s'/>" +
     "</listOfSpecies>" +
     "<listOfParameters>" +
     "  <parameter metaid='p'/>" +
     "</listOfParameters>" +
     "<listOfRules>" +
     "  <rateRule metaid='rr'/>" +
     "</listOfRules>" +
     "<listOfReactions>" +
     "  <reaction metaid='rx'/>" +
     "</listOfReactions>" +
     "<listOfEvents>" +
     " <event metaid='e'/>" +
     "</listOfEvents>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M != null );
       sb = M.getFunctionDefinition(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "fd" == sb.getMetaId() ));
       sb = M.getUnitDefinition(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "ud" == sb.getMetaId() ));
       sb = M.getCompartment(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "c" == sb.getMetaId() ));
       sb = M.getSpecies(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "s" == sb.getMetaId() ));
       sb = M.getParameter(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "p" == sb.getMetaId() ));
       sb = M.getRule(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "rr" == sb.getMetaId() ));
       sb = M.getReaction(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "rx" == sb.getMetaId() ));
       sb = M.getEvent(0);
       assertEquals( true, sb.isSetMetaId() );
       assertTrue((  "e" == sb.getMetaId() ));
 }
Beispiel #8
0
 public void test_ReadSBML_Event_trigger()
 {
     Event e;
       Trigger trigger;
       string formula;
       string s = wrapSBML_L2v1("<listOfEvents>" +
     "  <event>" +
     "    <trigger>" +
     "      <math>" +
     "        <apply>" +
     "          <leq/>" +
     "          <ci> P1 </ci>" +
     "          <ci> t  </ci>" +
     "        </apply>" +
     "      </math>" +
     "   </trigger>" +
     "  </event>" +
     "</listOfEvents>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumEvents() == 1 );
       e = M.getEvent(0);
       assertTrue( e != null );
       assertEquals( false, e.isSetDelay() );
       assertEquals( true, e.isSetTrigger() );
       trigger = e.getTrigger();
       formula = libsbml.formulaToString(trigger.getMath());
       assertTrue( formula != null );
       assertTrue((  "leq(P1, t)" == formula ));
 }
Beispiel #9
0
 public void test_ReadSBML_Event_delay()
 {
     Event e;
       Delay delay;
       string formula;
       string s = wrapSBML_L2v1("<listOfEvents>" +
     "  <event> <delay> <math> <cn> 5 </cn> </math> </delay> </event>" +
     "</listOfEvents>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumEvents() == 1 );
       e = M.getEvent(0);
       assertTrue( e != null );
       assertEquals( true, e.isSetDelay() );
       assertEquals( false, e.isSetTrigger() );
       delay = e.getDelay();
       formula = libsbml.formulaToString(delay.getMath());
       assertTrue( formula != null );
       assertTrue((  "5" == formula ));
 }
Beispiel #10
0
 public void test_ReadSBML_EventAssignment()
 {
     Event e;
       EventAssignment ea;
       ASTNode math;
       string formula;
       string s = wrapSBML_L2v1("<listOfEvents>" +
     "  <event>" +
     "    <listOfEventAssignments>" +
     "      <eventAssignment variable='k2'>" +
     "        <math> <cn> 0 </cn> </math>" +
     "      </eventAssignment>" +
     "    </listOfEventAssignments>" +
     "  </event>" +
     "</listOfEvents>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumEvents() == 1 );
       e = M.getEvent(0);
       assertTrue( e != null );
       assertTrue( e.getNumEventAssignments() == 1 );
       ea = e.getEventAssignment(0);
       assertTrue( ea != null );
       assertEquals( true, ea.isSetVariable() );
       assertTrue((  "k2" == ea.getVariable() ));
       assertEquals( true, ea.isSetMath() );
       math = ea.getMath();
       formula = libsbml.formulaToString(math);
       assertTrue( formula != null );
       assertTrue((  "0" == formula ));
 }
Beispiel #11
0
 public void test_ReadSBML_Event()
 {
     Event e;
       string s = wrapSBML_L2v2("<listOfEvents>" +
     "  <event id='e1' name='MyEvent' timeUnits='time'/>" +
     "</listOfEvents>");
       D = libsbml.readSBMLFromString(s);
       M = D.getModel();
       assertTrue( M.getNumEvents() == 1 );
       e = M.getEvent(0);
       assertTrue( e != null );
       assertEquals( true, e.isSetId() );
       assertEquals( true, e.isSetName() );
       assertEquals( true, e.isSetTimeUnits() );
       assertEquals( false, e.isSetTrigger() );
       assertEquals( false, e.isSetDelay() );
       assertTrue((  "e1"       == e.getId() ));
       assertTrue((  "MyEvent"  == e.getName() ));
       assertTrue((  "time"     == e.getTimeUnits() ));
 }