/// <summary>
        ///    Creates a MoBi Event by the given SBML Event.
        /// </summary>
        internal void CreateEvent(Event sbmlEvent)
        {
            EventBuilder = new EventBuilder()
                           .WithId(sbmlEvent.getId() + SBMLConstants.SBML_EVENTBUILDER)
                           .WithName(sbmlEvent.getId())
                           .WithDescription(sbmlEvent.getNotesString());

            if (sbmlEvent.isSetTrigger())
            {
                CreateCondition(sbmlEvent.getTrigger());
            }
            CreateEventAssignments(sbmlEvent);
            CreateWarningsForUnsupportedFeatures(sbmlEvent);

            EventGroupBuilder.Add(EventBuilder);
        }
Beispiel #2
0
        protected override void Context()
        {
            base.Context();
            _eventGroupBuildingBlock = new EventGroupBuildingBlock();
            var eventGroup = new EventGroupBuilder().WithName("EG");

            _eventGroupBuildingBlock.Add(eventGroup);
            var ehcStartEvent = new EventBuilder().WithName(Converter321To331.EHCStartEvent);

            eventGroup.Add(ehcStartEvent);
            var eabOldStart = new EventAssignmentBuilder().WithName("EAB1").WithFormula(new ExplicitFormula("ln(2) / EHC_Halftime * M * EHC_EjectionFraction"));

            eabOldStart.UseAsValue = false;
            eabOldStart.ObjectPath = new ObjectPath(new[] { "Organism", "Gallbladder", "Gallbladder emptying rate" });
            ehcStartEvent.AddAssignment(eabOldStart);
            var assignmentBuilder = new EventAssignmentBuilder().WithName("EAB2").WithFormula(new ExplicitFormula("DontChange"));

            assignmentBuilder.ObjectPath = new ObjectPath(new[] { "PATH" });
            ehcStartEvent.AddAssignment(assignmentBuilder);
            var ehcStopEvent = new EventBuilder().WithName(Converter321To331.EHCStopEvent);
            var eabOldStop   = new EventAssignmentBuilder().WithName("EAB1").WithFormula(new ConstantFormula(0));

            eabOldStop.UseAsValue = false;
            eabOldStop.ObjectPath = new ObjectPath(new[] { "Organism", "Gallbladder", "Gallbladder emptying rate" });
            ehcStopEvent.AddAssignment(eabOldStop);
            assignmentBuilder            = new EventAssignmentBuilder().WithName("EAB2").WithFormula(new ExplicitFormula("DontChange"));
            assignmentBuilder.ObjectPath = new ObjectPath(new[] { "PATH" });
            ehcStopEvent.AddAssignment(assignmentBuilder);
            eventGroup.Add(ehcStopEvent);

            var protocolSchemaItem = new Container().WithName("ProtocolSchemaItem").WithParentContainer(eventGroup);

            _drugMassParameter = new Parameter().WithName("DrugMass").WithParentContainer(protocolSchemaItem).WithValue(1);

            applications = new EventGroupBuilder().WithName("Applications");
            applications.Add(new Parameter().WithName("TotalDrugMass"));
            _eventGroupBuildingBlock.Add(applications);
        }
        public void TestSerialization()
        {
            EventGroupBuilder x1 = CreateObject <EventGroupBuilder>().WithName("Evan.Builder");

            x1.EventGroupType = "IV Bolus";
            IFormula f1 = CreateObject <ConstantFormula>().WithValue(2.3);
            IFormula f2 = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(3.4);

            IParameter p1 = CreateObject <Parameter>().WithName("Patricia").WithFormula(f1).WithValue(3.1);
            IParameter p2 = CreateObject <Parameter>().WithName("Pascal").WithFormula(f1).WithValue(3.2);

            x1.Add(p1);
            x1.Add(p2);

            EventBuilder eb1 = CreateObject <EventBuilder>().WithName("Eve.Builder").WithDimension(DimensionLength).WithFormula(f1);
            EventBuilder eb2 = CreateObject <EventBuilder>().WithName("Eva.Builder").WithDimension(DimensionLength).WithFormula(f2);

            eb2.OneTime = true;

            x1.Add(eb1);
            x1.Add(eb2);

            ApplicationBuilder a1 = CreateObject <ApplicationBuilder>().WithName("App.Builder");

            x1.Add(a1);
            var applicationMoleculeBuilder = CreateObject <ApplicationMoleculeBuilder>().WithName("AppMolecule");

            applicationMoleculeBuilder.Formula = f2;
            applicationMoleculeBuilder.RelativeContainerPath = new ObjectPath(new[] { "A", "B" });
            a1.AddMolecule(applicationMoleculeBuilder);

            a1.AddTransport(CreateObject <TransportBuilder>().WithName("PassiveTranport").WithFormula(f1));


            IEventGroupBuilder x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualEventGroupBuilder(x1, x2);
        }