getEvent() public method

public getEvent ( long n ) : Event
n long
return Event
Esempio n. 1
0
        /// <summary>
        ///    Imports all Events of the SBML Model.
        /// </summary>
        protected override void Import(Model model)
        {
            _astHandler.NeedAbsolutePath = true;
            CreateEGBandEGBB();

            for (long i = 0; i < model.getNumEvents(); i++)
            {
                CreateEvent(model.getEvent(i));
            }
            _astHandler.NeedAbsolutePath = false;
            AddToProject();
        }
        /// <summary>
        ///    Imports all Events of the SBML Model.
        /// </summary>
        protected override void Import(Model model)
        {
            _astHandler.NeedAbsolutePath = true;
            CreateEGBandEGBB();
            var numEvents = model.getNumEvents();

            if (numEvents == 0)
            {
                CreateEmptyEvent();
            }
            else
            {
                for (var i = 0; i < numEvents; i++)
                {
                    CreateEvent(model.getEvent(i));
                }
            }

            _astHandler.NeedAbsolutePath = false;
            AddToProject();
        }
Esempio n. 3
0
    private static void printMath(Model m)
    {
        int n;

        for (n = 0; n < m.getNumFunctionDefinitions(); ++n)
        {
            printFunctionDefinition(n + 1, m.getFunctionDefinition(n));
        }

        for (n = 0; n < m.getNumRules(); ++n)
        {
            printRuleMath(n + 1, m.getRule(n));
        }

        Console.WriteLine();

        for (n = 0; n < m.getNumReactions(); ++n)
        {
            printReactionMath(n + 1, m.getReaction(n));
        }

        Console.WriteLine();

        for (n = 0; n < m.getNumEvents(); ++n)
        {
            printEventMath(n + 1, m.getEvent(n));
        }
    }
 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() );
 }
 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() );
 }
 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_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 );
 }
Esempio n. 8
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() ));
 }
Esempio n. 9
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() ));
 }
Esempio n. 10
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 ));
 }
Esempio n. 11
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 ));
 }
Esempio n. 12
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 ));
 }
Esempio n. 13
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() ));
 }