Exemple #1
0
 protected override void Context()
 {
     sut = new Converter531To541();
     _eventGroubBuildingBlock = new EventGroupBuildingBlock();
     _eventGroup      = new EventGroupBuilder().WithName("EG");
     _rootApplication = new ApplicationBuilder().WithName("App").WithContainerType(ContainerType.Other);
     _eventGroubBuildingBlock.Add(_eventGroup);
     _eventGroubBuildingBlock.Add(_rootApplication);
     _container   = new Container().WithName("PSI").WithParentContainer(_eventGroup);
     _application = new ApplicationBuilder().WithName("App").WithContainerType(ContainerType.Other).WithParentContainer(_eventGroup);
 }
        private void createNonApplicationEvents()
        {
            // group events by the event-building block they are using
            var eventBuildingBlockInfos = (from eventMapping in _simulation.EventProperties.EventMappings
                                           let usedBuildingBlock = _simulation.UsedBuildingBlockByTemplateId(eventMapping.TemplateEventId)
                                                                   let eventBuildingBlock = usedBuildingBlock.BuildingBlock.DowncastTo <PKSimEvent>()
                                                                                            select new { eventBuildingBlock.Id, eventBuildingBlock.TemplateName, eventBuildingBlock.Name })
                                          .Distinct();

            // create event groups for each used event-building block
            foreach (var eventBuildingBlockInfo in eventBuildingBlockInfos)
            {
                // get event group template
                var templateEventGroup = _eventGroupRepository.FindByName(eventBuildingBlockInfo.TemplateName);

                // create new event group
                var eventGroup = _cloneManagerForBuildingBlock.Clone(templateEventGroup);
                eventGroup.Name = eventBuildingBlockInfo.Name;
                eventGroup.RemoveChild(eventGroup.MainSubContainer());

                // get building block and eventgroup-template to be used
                var eventBuildingBlock = _simulation.UsedBuildingBlockById(eventBuildingBlockInfo.Id);
                var eventTemplate      = eventBuildingBlock.BuildingBlock.DowncastTo <PKSimEvent>();

                // set event group parameter
                _parameterSetUpdater.UpdateValuesByName(eventTemplate, eventGroup);

                // create subcontainers (event groups) for all events of the same type
                int eventIndex = 0; //used for naming of event subcontainers only

                foreach (var eventMapping in _simulation.EventProperties.EventMappings.OrderBy(em => em.StartTime.Value))
                {
                    if (!eventMapping.TemplateEventId.Equals(eventBuildingBlock.TemplateId))
                    {
                        continue; //event from different template
                    }
                    // clone main event subcontainer and set its start time
                    var mainSubContainer = _cloneManagerForBuildingBlock.Clone(templateEventGroup.MainSubContainer());

                    eventIndex           += 1;
                    mainSubContainer.Name = $"{eventBuildingBlockInfo.Name}_{eventIndex}";

                    _parameterSetUpdater.UpdateValue(eventMapping.StartTime, mainSubContainer.StartTime());

                    eventGroup.Add(mainSubContainer);
                }

                // update building block ids
                _parameterIdUpdater.UpdateBuildingBlockId(eventGroup, eventTemplate);

                _eventGroupBuildingBlock.Add(eventGroup);
            }
        }
Exemple #3
0
 protected override void Context()
 {
     base.Context();
     _eventGroupBuildingBlock = new EventGroupBuildingBlock();
     _eventGroup = new EventGroupBuilder().WithName("EG");
     _eventGroupBuildingBlock.Add(_eventGroup);
     var parameter = new Parameter().WithName("P1").WithParentContainer(_eventGroup);
 }
Exemple #4
0
        protected override void Context()
        {
            base.Context();
            _eventBuildingBlock = new EventGroupBuildingBlock();
            var applicationBuilder = new ApplicationBuilder().WithName("App1");

            _moleculeBuilder = new ApplicationMoleculeBuilder();
            applicationBuilder.AddMolecule(_moleculeBuilder);
            _eventBuildingBlock.Add(applicationBuilder);
        }
        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);
        }
Exemple #6
0
 protected override void Context()
 {
     base.Context();
     _eventBuildingBlock = new EventGroupBuildingBlock().WithName("Events");
     _applicationBuilder = new ApplicationBuilder().WithName("Tada");
     _applicationBuilder.MoleculeName = "B";
     _eventBuildingBlock.Add(_applicationBuilder);
     _molceuleBuidingBlock = new MoleculeBuildingBlock().WithName("Molecules");
     _molceuleBuidingBlock.Add(new MoleculeBuilder().WithName("A"));
     _buildConfiguration                      = new BuildConfiguration();
     _buildConfiguration.Molecules            = _molceuleBuidingBlock;
     _buildConfiguration.MoleculeStartValues  = new MoleculeStartValuesBuildingBlock();
     _buildConfiguration.Observers            = new ObserverBuildingBlock();
     _buildConfiguration.ParameterStartValues = new ParameterStartValuesBuildingBlock();
     _buildConfiguration.PassiveTransports    = new PassiveTransportBuildingBlock();
     _buildConfiguration.Reactions            = new ReactionBuildingBlock();
     _buildConfiguration.SpatialStructure     = new SpatialStructure();
     _buildConfiguration.EventGroups          = _eventBuildingBlock;
 }