public void TestSerialization()
        {
            EventBuilder x1 = CreateObject <EventBuilder>().WithName("Eve.Builder").WithDimension(DimensionLength);

            x1.Formula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);
            x1.OneTime = true;

            IFormula           f1  = CreateObject <ExplicitFormula>().WithDimension(DimensionLength).WithFormulaString("3*Patty");
            IFormulaUsablePath fup = new FormulaUsablePath(new string[] { "Patricia" }).WithAlias("Patty").WithDimension(DimensionLength);

            f1.AddObjectPath(fup);
            IFormula f2 = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);

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

            x1.AddParameter(p1);
            x1.AddParameter(p2);

            IEventAssignmentBuilder eab1 = CreateObject <EventAssignmentBuilder>().WithDimension(DimensionLength).WithFormula(f1).WithName("eab1");
            IEventAssignmentBuilder eab2 = CreateObject <EventAssignmentBuilder>().WithFormula(f2).WithName("eab2");

            x1.AddAssignment(eab1);
            x1.AddAssignment(eab2);

            var x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualEventBuilder(x1, x2);
        }
예제 #2
0
        /// <summary>
        ///    Creates the Mobi Event Assignment for one SBML Event Assignment.
        /// </summary>
        internal void CreateEventAssignment(EventAssignment eventAssignment)
        {
            _counter++;
            var assignmentVar = eventAssignment.getVariable();
            var alias         = _sbmlInformation.AliasCreator.CreateAliasFrom(assignmentVar) + _counter;

            var description = String.Empty;

            if (eventAssignment.isSetNotes())
            {
                description += eventAssignment.getNotesString();
            }
            if (eventAssignment.isSetSBOTerm())
            {
                description += (SBMLConstants.SPACE + eventAssignment.getSBOTerm());
            }

            IEventAssignmentBuilder eab = new EventAssignmentBuilder()
                                          .WithId(eventAssignment.getId() + SBMLConstants.SPACE + eventAssignment.getName() + SBMLConstants.SPACE + alias)
                                          .WithName(SBMLConstants.SBML_EVENT_ASSIGNMENT + eventAssignment.getId())
                                          .WithDescription(description);

            var formula = _astHandler.Parse(eventAssignment.getMath(), eab, assignmentVar, _sbmlProject, _sbmlInformation) ??
                          ObjectBaseFactory.Create <ExplicitFormula>().WithFormulaString(String.Empty).WithName(SBMLConstants.DEFAULT_FORMULA_NAME);

            eab.Formula = formula;
            EventGroupBuildingBlock.FormulaCache.Add(formula);
            EventBuilder.AddAssignment(eab);
        }
        protected override void Context()
        {
            base.Context();
            var e1 = new EventBuilder().WithName("Event");

            e1.OneTime = true;
            var eventAssignmentBuilder1 = new EventAssignmentBuilder();

            eventAssignmentBuilder1.ObjectPath = new ObjectPath("Sim|A|B|C");
            eventAssignmentBuilder1.Name       = "EAB";

            eventAssignmentBuilder1.Formula = new ExplicitFormula("a+b");
            e1.AddAssignment(eventAssignmentBuilder1);
            e1.AddParameter(new Parameter().WithName("P1"));

            var e2 = new EventBuilder().WithName("Event");

            e2.OneTime = true;
            var eventAssignmentBuilder2 = new EventAssignmentBuilder();

            eventAssignmentBuilder2.ObjectPath = new ObjectPath("Sim|A|B|C");
            eventAssignmentBuilder2.Name       = "EAB";

            eventAssignmentBuilder2.Formula = new ExplicitFormula("a+b");
            e2.AddAssignment(eventAssignmentBuilder2);

            _object1 = e1;
            _object2 = e2;
        }
        protected override void Context()
        {
            base.Context();
            var e1 = new EventBuilder().WithName("Event");

            e1.OneTime = true;
            var eventAssignmentBuilder1 = new EventAssignmentBuilder();

            eventAssignmentBuilder1.ObjectPath = new ObjectPath("Sim|A|B|C");
            eventAssignmentBuilder1.Name       = "EAB1";
            e1.AddAssignment(eventAssignmentBuilder1);

            var e2 = new EventBuilder().WithName("Event");

            e2.OneTime = true;
            var eventAssignmentBuilder2 = new EventAssignmentBuilder();

            eventAssignmentBuilder2.ObjectPath = new ObjectPath("Sim|A|B|C");
            eventAssignmentBuilder2.Name       = "EAB2";
            e2.AddAssignment(eventAssignmentBuilder2);


            _object1 = e1;
            _object2 = e2;
            _comparerSettings.OnlyComputingRelevant = false;
        }
        protected override void Context()
        {
            base.Context();
            var e1 = new EventBuilder().WithName("Event");

            e1.OneTime = true;
            var eventAssignmentBuilder1 = new EventAssignmentBuilder();

            eventAssignmentBuilder1.ObjectPath = new ObjectPath("Sim|A|B|C");
            eventAssignmentBuilder1.Name       = "EAB";
            e1.AddAssignment(eventAssignmentBuilder1);

            var e2 = new EventBuilder().WithName("Event");

            e2.OneTime = true;
            var eventAssignmentBuilder2 = new EventAssignmentBuilder();

            eventAssignmentBuilder2.ObjectPath = new ObjectPath("Sim|A|B|D");
            eventAssignmentBuilder2.Name       = "EAB";
            e2.AddAssignment(eventAssignmentBuilder2);


            _object1 = e1;
            _object2 = e2;
        }
예제 #6
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);
        }
예제 #7
0
        protected override void Context()
        {
            base.Context();
            var eg1  = new EventGroupBuilder().WithName("Events");
            var app1 = new ApplicationBuilder().WithName("App").WithParentContainer(eg1);

            app1.MoleculeName = "Drug";
            var c1 = new Container().WithName("ProtocolSchemaItem").WithParentContainer(app1);

            _e1 = new EventBuilder().WithName("Event").WithParentContainer(app1);
            _eventAssignmentBuilder1            = new EventAssignmentBuilder();
            _eventAssignmentBuilder1.ObjectPath = new ObjectPath("Sim|A|B|C");
            _eventAssignmentBuilder1.Name       = "EAB";
            _eventAssignmentBuilder1.UseAsValue = true;
            _eventAssignmentBuilder1.Formula    = new ExplicitFormula("a+b");
            _e1.AddAssignment(_eventAssignmentBuilder1);
            _explicitFormula1 = new ExplicitFormula("1+2");
            _p1 = new Parameter().WithName("P").WithFormula(_explicitFormula1).WithParentContainer(c1);

            var eg2  = new EventGroupBuilder().WithName("Events");
            var app2 = new ApplicationBuilder().WithName("App").WithParentContainer(eg2);

            app2.MoleculeName = "Drug";
            var c2 = new Container().WithName("ProtocolSchemaItem").WithParentContainer(app2);
            var e2 = new EventBuilder().WithName("Event").WithParentContainer(app2);
            var eventAssignmentBuilder2 = new EventAssignmentBuilder();

            eventAssignmentBuilder2.ObjectPath = new ObjectPath("Sim|A|B|C");
            eventAssignmentBuilder2.Name       = "EAB";
            eventAssignmentBuilder2.UseAsValue = false;
            eventAssignmentBuilder2.Formula    = new ExplicitFormula("a+b");
            e2.AddAssignment(eventAssignmentBuilder2);
            var p2 = new Parameter().WithName("P").WithFormula(new ExplicitFormula("2+1")).WithParentContainer(c2);

            _object1 = eg1;
            _object2 = eg2;
        }