Example #1
0
        private void setValue(ModelCompound compound, string parameterName, double value)
        {
            var parameter = compound.Parameter(parameterName);

            parameter.Value = value;
            _batchLogger.AddParameterValueToDebug(parameter);
        }
Example #2
0
        private void setPka(ModelCompound compound, PkaType pkaType, int i)
        {
            var type = EnumHelper.ParseValue <CompoundType>(pkaType.Type);

            setValue(compound, CoreConstants.Parameter.ParameterCompoundType(i), (int)type);
            setValue(compound, CoreConstants.Parameter.ParameterPKa(i), pkaType.Value);
        }
Example #3
0
        private void setValue(ModelCompound compound, string alternativeName, string parameterName, double value)
        {
            var alternative = compound.ParameterAlternativeGroup(alternativeName).DefaultAlternative;
            var parameter   = alternative.Parameter(parameterName);

            parameter.Value = value;
            _batchLogger.AddParameterValueToDebug(parameter);
        }
Example #4
0
 public ObservedDataToCompoundMappingPresenter(IObservedDataToCompoundMappingView view, ICompoundFactory compoundFactory) : base(view)
 {
     _compoundFactory       = compoundFactory;
     _undefinedCompound     = _compoundFactory.Create().WithName(PKSimConstants.UI.Undefined);
     _allAvailableCompounds = new List <PKSim.Core.Model.Compound> {
         _undefinedCompound
     };
     view.CancelVisible = false;
 }
        protected override Task Context()
        {
            sut = new ProcessMappingMapper();

            _compound = new Compound
            {
                Name = "COMP",
            };


            _enzymaticProcess          = new EnzymaticProcess().WithName("MetaProcess");
            _enzymaticProcessSelection = new EnzymaticProcessSelection
            {
                CompoundName   = _compound.Name,
                MetaboliteName = "META",
                MoleculeName   = "CYP",
                ProcessName    = _enzymaticProcess.Name
            };


            _specificBindingProcess = new SpecificBindingPartialProcess().WithName("BindingProcess");
            _specificBindingPartialProcessSelection = new ProcessSelection
            {
                CompoundName = _compound.Name,
                MoleculeName = "BINDER",
                ProcessName  = _specificBindingProcess.Name
            };

            _transportSystemicProcess = new SystemicProcess
            {
                Name = "SystemicTransport",
                SystemicProcessType = SystemicProcessTypes.GFR
            };

            _transportSystemicProcessSelection = new SystemicProcessSelection
            {
                CompoundName = _compound.Name,
                ProcessName  = _transportSystemicProcess.Name,
                ProcessType  = _transportSystemicProcess.SystemicProcessType
            };

            _interactionProcess   = new InductionProcess().WithName("InteractionProcess");
            _interactionSelection = new InteractionSelection
            {
                CompoundName = _compound.Name,
                ProcessName  = _interactionProcess.Name,
                MoleculeName = "INHIBITOR"
            };

            _compound.AddProcess(_enzymaticProcess);
            _compound.AddProcess(_transportSystemicProcess);
            _compound.AddProcess(_interactionProcess);
            _compound.AddProcess(_specificBindingProcess);

            return(_completed);
        }
Example #6
0
        public ParameterAlternative CreateCompoundAlternative(Compound compound, string group, string alternativeName, double value, string parameterName, bool setDefault = true)
        {
            var alternativeGroup = compound.ParameterAlternativeGroup(group);
            var alternative      = _parameterAlternativeFactory.CreateAlternativeFor(alternativeGroup).WithName(alternativeName);

            AddCommand(_compoundAlternativeTask.AddParameterGroupAlternativeTo(alternativeGroup, alternative));
            AddCommand(_compoundAlternativeTask.SetAlternativeParameterValue(alternative.Parameter(parameterName), value));
            if (setDefault)
            {
                AddCommand(_compoundAlternativeTask.SetDefaultAlternativeFor(alternativeGroup, alternative));
            }

            return(alternative);
        }
Example #7
0
        public static Simulation CreateSimulationWith(ISimulationSubject simulationSubject, Compound compound, Protocol protocol, string modelName, Formulation formulation = null)
        {
            var simulation = createModelLessSimulationWith(simulationSubject, compound, protocol, modelName, formulation);

            AddModelToSimulation(simulation);
            return(simulation);
        }
Example #8
0
 public static Simulation CreateModelLessSimulationWith(ISimulationSubject simulationSubject, Compound compound,
                                                        Protocol protocol, ModelProperties modelProperties,
                                                        bool allowAging = false, Formulation formulation = null)
 {
     return(CreateModelLessSimulationWith(simulationSubject, new[] { compound }, new[] { protocol }, modelProperties, allowAging, formulation));
 }
Example #9
0
 public static Simulation CreateModelLessSimulationWith(ISimulationSubject simulationSubject,
                                                        Compound compound, Protocol protocol,
                                                        bool allowAging = false, Formulation formulation = null)
 {
     return(CreateModelLessSimulationWith(simulationSubject, compound, protocol, CreateDefaultModelPropertiesFor(simulationSubject), allowAging, formulation));
 }
Example #10
0
        public static Simulation CreateSimulationWith(ISimulationSubject simulationSubject, Compound compound,
                                                      Protocol protocol, Formulation formulation, bool allowAging = false)
        {
            var simulation = CreateModelLessSimulationWith(simulationSubject, compound, protocol, allowAging, formulation);

            AddModelToSimulation(simulation);
            return(simulation);
        }
Example #11
0
 private static Simulation createModelLessSimulationWith(ISimulationSubject simulationSubject, Compound compound,
                                                         Protocol protocol, string modelName,
                                                         Formulation formulation = null)
 {
     return(CreateModelLessSimulationWith(simulationSubject, compound, protocol, CreateModelPropertiesFor(simulationSubject, modelName), false, formulation));
 }
Example #12
0
 public ParameterAlternative CreateLipophilicityAlternative(Compound compound, string alternativeName, double value, bool setDefault = true)
 {
     return(CreateCompoundAlternative(compound, CoreConstants.Groups.COMPOUND_LIPOPHILICITY, alternativeName, value, CoreConstants.Parameter.LIPOPHILICITY, setDefault));
 }
 public PartialProcessDTO MapFrom(PKSim.Core.Model.PartialProcess partialProcess, PKSim.Core.Model.Compound compound)
 {
     return(new PartialProcessDTO(partialProcess)
     {
         MoleculeName = partialProcess.MoleculeName,
         DataSource = partialProcess.DataSource,
         Compound = compound,
         Species = partialProcess.Species
     });
 }
Example #14
0
        protected override Task Context()
        {
            _classificationMapper          = A.Fake <ClassificationMapper>();
            _snapshotMapper                = A.Fake <ISnapshotMapper>();
            _executionContext              = A.Fake <IExecutionContext>();
            _lazyLoadTask                  = A.Fake <ILazyLoadTask>();
            _simulationMapper              = A.Fake <SimulationMapper>();
            _simulationComparisonMapper    = A.Fake <SimulationComparisonMapper>();
            _parameterIdentificationMapper = A.Fake <ParameterIdentificationMapper>();
            _classificationSnapshotTask    = A.Fake <IClassificationSnapshotTask>();
            _qualificationPlanMapper       = A.Fake <QualificationPlanMapper>();
            _creationMetaDataFactory       = A.Fake <ICreationMetaDataFactory>();
            _logger = A.Fake <ILogger>();

            sut = new ProjectMapper(
                _simulationMapper,
                _simulationComparisonMapper,
                _parameterIdentificationMapper,
                _qualificationPlanMapper,
                _executionContext,
                _classificationSnapshotTask,
                _lazyLoadTask,
                _creationMetaDataFactory,
                _logger);


            A.CallTo(() => _executionContext.Resolve <ISnapshotMapper>()).Returns(_snapshotMapper);
            _individual               = new Individual().WithName("IND");
            _compound                 = new Compound().WithName("COMP");
            _event                    = new PKSimEvent().WithName("EVENT");
            _formulation              = new Formulation().WithName("FORM");
            _protocol                 = new SimpleProtocol().WithName("PROTO");
            _population               = new RandomPopulation().WithName("POP");
            _observedData             = new DataRepository().WithName("OD");
            _parameterIdentification  = new OSPSuite.Core.Domain.ParameterIdentifications.ParameterIdentification().WithName("PI").WithId("PI_ID");
            _classifiableObservedData = new ClassifiableObservedData {
                Subject = _observedData
            };
            _classification = new Classification {
                ClassificationType = ClassificationType.ObservedData
            }.WithName("OD Classification");
            _simulationComparison = new IndividualSimulationComparison().WithName("COMP").WithId("SimComp");
            _simulation           = new IndividualSimulation().WithName("IND_SIM").WithId("IndSim");
            _qualificationPlan    = new QualificationPlan().WithName("QP").WithId("QP_ID");
            _project = new PKSimProject();
            _project.AddBuildingBlock(_individual);
            _project.AddBuildingBlock(_compound);
            _project.AddBuildingBlock(_event);
            _project.AddBuildingBlock(_formulation);
            _project.AddBuildingBlock(_protocol);
            _project.AddBuildingBlock(_population);
            _project.AddObservedData(_observedData);
            _project.AddBuildingBlock(_simulation);
            _project.AddClassifiable(_classifiableObservedData);
            _project.AddClassification(_classification);
            _project.AddSimulationComparison(_simulationComparison);
            _project.AddParameterIdentification(_parameterIdentification);
            _project.AddQualificationPlan(_qualificationPlan);

            _compoundSnapshot                              = new Snapshots.Compound();
            _individualSnapshot                            = new Snapshots.Individual();
            _eventSnapshot                                 = new Event();
            _formulationSnapshot                           = new Snapshots.Formulation();
            _protocolSnapshot                              = new Snapshots.Protocol();
            _populationSnapshot                            = new Snapshots.Population();
            _observedDataSnapshot                          = new Snapshots.DataRepository();
            _parameterIdentificationSnapshot               = new ParameterIdentification();
            _observedDataClassificationSnapshot            = new Snapshots.Classification();
            _simulationComparisonSnapshot                  = new SimulationComparison();
            _simulationClassificationSnapshot              = new Snapshots.Classification();
            _comparisonClassificationSnapshot              = new Snapshots.Classification();
            _parameterIdentificationClassificationSnapshot = new Snapshots.Classification();
            _qualificationPlanClassificationSnapshot       = new Snapshots.Classification();
            _qualificationPlanSnapshot                     = new Snapshots.QualificationPlan();
            _simulationSnapshot                            = new Simulation();


            A.CallTo(() => _snapshotMapper.MapToSnapshot(_compound)).Returns(_compoundSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_individual)).Returns(_individualSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_event)).Returns(_eventSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_formulation)).Returns(_formulationSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_protocol)).Returns(_protocolSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_population)).Returns(_populationSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_observedData)).Returns(_observedDataSnapshot);
            A.CallTo(() => _simulationMapper.MapToSnapshot(_simulation, _project)).Returns(_simulationSnapshot);
            A.CallTo(() => _simulationComparisonMapper.MapToSnapshot(_simulationComparison)).Returns(_simulationComparisonSnapshot);
            A.CallTo(() => _parameterIdentificationMapper.MapToSnapshot(_parameterIdentification, _project)).Returns(_parameterIdentificationSnapshot);
            A.CallTo(() => _qualificationPlanMapper.MapToSnapshot(_qualificationPlan)).Returns(_qualificationPlanSnapshot);

            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableObservedData>(_project)).Returns(new[] { _observedDataClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableSimulation>(_project)).Returns(new[] { _simulationClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableComparison>(_project)).Returns(new[] { _comparisonClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableParameterIdentification>(_project)).Returns(new[] { _parameterIdentificationClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableQualificationPlan>(_project)).Returns(new[] { _qualificationPlanClassificationSnapshot });

            return(_completed);
        }
Example #15
0
 protected abstract void EditProcess(TProcess process, PKSim.Core.Model.Compound compound);
Example #16
0
        protected override Task Context()
        {
            _calculationMethodCacheMapper = A.Fake <CalculationMethodCacheMapper>();
            _processMappingMapper         = A.Fake <ProcessMappingMapper>();
            _logger  = A.Fake <ILogger>();
            _project = new PKSimProject();
            _calculationMethodSnapshot = new CalculationMethodCache();
            sut = new CompoundPropertiesMapper(_calculationMethodCacheMapper, _processMappingMapper, _logger);

            _compoundGroupSelectionOneAlternative = new CompoundGroupSelection
            {
                AlternativeName = "ALT1",
                GroupName       = "ALTERNATIVE_GROUP_1"
            };

            _compoundGroupSelectionTwoAlternatives = new CompoundGroupSelection
            {
                AlternativeName = "ALT2",
                GroupName       = "ALTERNATIVE_GROUP_2"
            };

            _compound = new Compound
            {
                Name = "COMP",
            };

            _protocol = new SimpleProtocol
            {
                Name = "PROTOCOL"
            };

            _parameterAlternativeGroupWithOneAlternative = new ParameterAlternativeGroup {
                Name = _compoundGroupSelectionOneAlternative.GroupName
            };
            _parameterAlternativeGroupWithTwoAlternatives = new ParameterAlternativeGroup {
                Name = _compoundGroupSelectionTwoAlternatives.GroupName
            };

            _parameterAlternativeGroupWithTwoAlternatives.AddAlternative(new ParameterAlternative {
                Name = "ALT1"
            });
            _parameterAlternativeGroupWithTwoAlternatives.AddAlternative(new ParameterAlternative {
                Name = "ALT2"
            });

            _compound.AddParameterAlternativeGroup(_parameterAlternativeGroupWithOneAlternative);
            _compound.AddParameterAlternativeGroup(_parameterAlternativeGroupWithTwoAlternatives);

            _compoundProperties = new Model.CompoundProperties();

            _compoundProperties.AddCompoundGroupSelection(_compoundGroupSelectionOneAlternative);
            _compoundProperties.AddCompoundGroupSelection(_compoundGroupSelectionTwoAlternatives);
            _compoundProperties.Compound = _compound;
            _enzymaticProcess            = new EnzymaticProcess {
                Name = "EnzymaticProcess"
            };
            _anotherEnzymaticProcess = new EnzymaticProcess {
                Name = "AnotherEnzymaticProcess", MoleculeName = "CYP3A4"
            };
            _specificBindingProcess = new SpecificBindingPartialProcess {
                Name = "SpecificBinding"
            };
            _gfrTransportProcess = new SystemicProcess {
                Name = "Transport", SystemicProcessType = SystemicProcessTypes.GFR
            };
            _hepaticEnzymaticProcess = new SystemicProcess {
                Name = "Plasma Clearance", SystemicProcessType = SystemicProcessTypes.Hepatic
            };
            _compound.AddProcess(_enzymaticProcess);
            _compound.AddProcess(_specificBindingProcess);
            _compound.AddProcess(_gfrTransportProcess);
            _compound.AddProcess(_hepaticEnzymaticProcess);

            _enzymaticPartialProcessSelection = new EnzymaticProcessSelection {
                ProcessName = _enzymaticProcess.Name
            };
            _noEnzymaticSystemicProcessSelection = new SystemicProcessSelection {
                ProcessType = SystemicProcessTypes.Hepatic
            };
            _specificBindingPartialProcessSelection = new ProcessSelection {
                ProcessName = _specificBindingProcess.Name
            };
            _transportSystemicProcessSelection = new SystemicProcessSelection {
                ProcessName = _gfrTransportProcess.Name, ProcessType = _gfrTransportProcess.SystemicProcessType,
            };
            _noEnzymaticPartialProcessSelection = new EnzymaticProcessSelection {
                MoleculeName = _anotherEnzymaticProcess.MoleculeName
            };
            _compoundProperties.Processes.MetabolizationSelection.AddPartialProcessSelection(_enzymaticPartialProcessSelection);
            _compoundProperties.Processes.MetabolizationSelection.AddPartialProcessSelection(_noEnzymaticPartialProcessSelection);
            _compoundProperties.Processes.MetabolizationSelection.AddSystemicProcessSelection(_noEnzymaticSystemicProcessSelection);
            _compoundProperties.Processes.SpecificBindingSelection.AddPartialProcessSelection(_specificBindingPartialProcessSelection);
            _compoundProperties.Processes.TransportAndExcretionSelection.AddSystemicProcessSelection(_transportSystemicProcessSelection);

            _snapshotProcess1 = new CompoundProcessSelection {
                Name = _enzymaticPartialProcessSelection.ProcessName
            };
            _snapshotProcess2 = new CompoundProcessSelection {
                Name = _specificBindingPartialProcessSelection.ProcessName
            };
            _snapshotProcess3 = new CompoundProcessSelection {
                Name = _transportSystemicProcessSelection.ProcessName
            };
            _snapshotProcess4 = new CompoundProcessSelection {
                SystemicProcessType = _noEnzymaticSystemicProcessSelection.ProcessType.SystemicProcessTypeId.ToString()
            };
            _snapshotProcess5 = new CompoundProcessSelection {
                MoleculeName = _noEnzymaticPartialProcessSelection.MoleculeName
            };

            _formulation = new Formulation
            {
                Id = "123456"
            };
            _compoundProperties.ProtocolProperties.Protocol = _protocol;
            _compoundProperties.ProtocolProperties.AddFormulationMapping(new FormulationMapping
            {
                FormulationKey        = "F1",
                TemplateFormulationId = _formulation.Id
            });

            _project.AddBuildingBlock(_formulation);
            A.CallTo(() => _calculationMethodCacheMapper.MapToSnapshot(_compoundProperties.CalculationMethodCache)).Returns(_calculationMethodSnapshot);
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_enzymaticPartialProcessSelection)).Returns(_snapshotProcess1);
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_specificBindingPartialProcessSelection)).Returns(_snapshotProcess2);
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_transportSystemicProcessSelection)).Returns(_snapshotProcess3);
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_noEnzymaticSystemicProcessSelection)).Returns(_snapshotProcess4);
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_noEnzymaticPartialProcessSelection)).Returns(_snapshotProcess5);

            A.CallTo(() => _processMappingMapper.MapToModel(_snapshotProcess1, _enzymaticProcess)).Returns(_enzymaticPartialProcessSelection);
            A.CallTo(() => _processMappingMapper.MapToModel(_snapshotProcess2, _specificBindingProcess)).Returns(_specificBindingPartialProcessSelection);
            A.CallTo(() => _processMappingMapper.MapToModel(_snapshotProcess3, _gfrTransportProcess)).Returns(_transportSystemicProcessSelection);
            A.CallTo(() => _processMappingMapper.MapToModel(_snapshotProcess4, A <NotSelectedSystemicProcess> ._)).Returns(_noEnzymaticSystemicProcessSelection);
            A.CallTo(() => _processMappingMapper.MapToModel(_snapshotProcess5, A <EnzymaticProcess> ._)).Returns(_noEnzymaticPartialProcessSelection);

            return(_completed);
        }
Example #17
0
 protected abstract void Rebind(TProcess process, PKSim.Core.Model.Compound compound);
Example #18
0
        protected override Task Context()
        {
            _solverSettingsMapper               = A.Fake <SolverSettingsMapper>();
            _outputSchemaMapper                 = A.Fake <OutputSchemaMapper>();
            _outputSelectionMapper              = A.Fake <OutputSelectionsMapper>();
            _parameterMapper                    = A.Fake <ParameterMapper>();
            _compoundPropertiesMapper           = A.Fake <CompoundPropertiesMapper>();
            _advancedParameterMapper            = A.Fake <AdvancedParameterMapper>();
            _eventMappingMapper                 = A.Fake <EventMappingMapper>();
            _observerSetMappingMapper           = A.Fake <ObserverSetMappingMapper>();
            _curveChartMapper                   = A.Fake <SimulationTimeProfileChartMapper>();
            _processMappingMapper               = A.Fake <ProcessMappingMapper>();
            _simulationFactory                  = A.Fake <ISimulationFactory>();
            _executionContext                   = A.Fake <IExecutionContext>();
            _simulationModelCreator             = A.Fake <ISimulationModelCreator>();
            _simulationBuildingBlockUpdater     = A.Fake <ISimulationBuildingBlockUpdater>();
            _modelPropertiesTask                = A.Fake <IModelPropertiesTask>();
            _simulationRunner                   = A.Fake <ISimulationRunner>();
            _populationAnalysisChartMapper      = A.Fake <PopulationAnalysisChartMapper>();
            _simulationParameterOriginIdUpdater = A.Fake <ISimulationParameterOriginIdUpdater>();
            _logger             = A.Fake <ILogger>();
            _containerTask      = A.Fake <IContainerTask>();
            _entityPathResolver = A.Fake <IEntityPathResolver>();

            sut = new SimulationMapper(_solverSettingsMapper, _outputSchemaMapper,
                                       _outputSelectionMapper, _compoundPropertiesMapper, _parameterMapper,
                                       _advancedParameterMapper, _eventMappingMapper, _observerSetMappingMapper, _curveChartMapper,
                                       _populationAnalysisChartMapper, _processMappingMapper,
                                       _simulationFactory, _executionContext, _simulationModelCreator,
                                       _simulationBuildingBlockUpdater, _modelPropertiesTask,
                                       _simulationRunner, _simulationParameterOriginIdUpdater,
                                       _logger, _containerTask, _entityPathResolver
                                       );

            _project    = new PKSimProject();
            _individual = new Individual {
                Name = "IND", Id = "IND"
            };
            _compound = new Compound {
                Name = "COMP", Id = "COMP"
            };
            _observerSet = new ObserverSet {
                Name = "OBS_SET", Id = "OBS_SET"
            };
            _protocol = new SimpleProtocol {
                Name = "PROT", Id = "PROT"
            };
            _inductionProcess = new InductionProcess().WithName("Interaction process");
            _compound.AddProcess(_inductionProcess);


            _event = new PKSimEvent {
                Name = "Event"
            };
            _population = new RandomPopulation()
            {
                Name = "POP"
            };
            _observedData = new DataRepository("OBS_ID").WithName("OBS");
            _project.AddBuildingBlock(_individual);
            _project.AddBuildingBlock(_compound);
            _project.AddBuildingBlock(_event);
            _project.AddBuildingBlock(_population);
            _project.AddBuildingBlock(_observerSet);
            _project.AddObservedData(_observedData);

            _simulationProperties = new SimulationProperties
            {
                ModelProperties = new ModelProperties
                {
                    ModelConfiguration = new ModelConfiguration {
                        ModelName = "4Comp"
                    }
                }
            };
            _interactionSelection = new InteractionSelection {
                ProcessName = _inductionProcess.Name
            };
            _noInteractionSelection = new InteractionSelection {
                MoleculeName = "CYP2D6"
            };

            _simulationProperties.InteractionProperties.AddInteraction(_interactionSelection);
            _simulationProperties.InteractionProperties.AddInteraction(_noInteractionSelection);

            _settings      = new SimulationSettings();
            _rootContainer = new Container().WithName("Sim");
            _model         = new OSPSuite.Core.Domain.Model {
                Root = _rootContainer
            };

            _individualSimulation = new IndividualSimulation
            {
                Name               = "S1",
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Description        = "Simulation Description",
                Model              = _model
            };

            _simulationTimeProfile         = new SimulationTimeProfileChart();
            _snapshotSimulationTimeProfile = new CurveChart();
            _individualSimulation.AddAnalysis(_simulationTimeProfile);

            A.CallTo(() => _curveChartMapper.MapToSnapshot(_simulationTimeProfile)).Returns(_snapshotSimulationTimeProfile);


            _populationSimulation = new PopulationSimulation
            {
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Model = _model
            };

            _advancedParameterCollection       = new AdvancedParameterCollection();
            _populationSimulationAnalysisChart = new BoxWhiskerAnalysisChart();
            _populationSimulation.SetAdvancedParameters(_advancedParameterCollection);
            _populationSimulation.AddAnalysis(_populationSimulationAnalysisChart);
            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndTemplateId", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual
            });

            _snapshotPopulationAnalysisChart = new Snapshots.PopulationAnalysisChart();

            A.CallTo(() => _populationAnalysisChartMapper.MapToSnapshot(_populationSimulationAnalysisChart)).Returns(_snapshotPopulationAnalysisChart);

            _snapshotInteraction = new CompoundProcessSelection();
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_interactionSelection)).Returns(_snapshotInteraction);
            _snapshotInteraction.CompoundName = _compound.Name;
            _snapshotInteraction.Name         = _inductionProcess.Name;

            _noSelectionSnapshotInteraction = new CompoundProcessSelection();
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_noInteractionSelection)).Returns(_noSelectionSnapshotInteraction);
            _noSelectionSnapshotInteraction.MoleculeName = _noInteractionSelection.MoleculeName;

            _compoundProperties         = new CompoundProperties();
            _snapshotCompoundProperties = new Snapshots.CompoundProperties {
                Name = _compound.Name
            };
            _individualSimulation.Properties.AddCompoundProperties(_compoundProperties);

            _eventMapping = new EventMapping();
            _individualSimulation.EventProperties.AddEventMapping(_eventMapping);

            _observerSetMapping = new ObserverSetMapping();
            _individualSimulation.ObserverSetProperties.AddObserverSetMapping(_observerSetMapping);

            A.CallTo(() => _compoundPropertiesMapper.MapToSnapshot(_compoundProperties, _project)).Returns(_snapshotCompoundProperties);


            _eventSelection = new EventSelection
            {
                Name = _event.Name,
            };

            _observerSetSelection = new ObserverSetSelection
            {
                Name = _observerSet.Name,
            };

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndTemplateId", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual,

                Altered = true
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("CompTemplateId", PKSimBuildingBlockType.Compound)
            {
                BuildingBlock = _compound
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("ProtTemplateId", PKSimBuildingBlockType.Protocol)
            {
                BuildingBlock = _protocol
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("ObserveSetTemplateId", PKSimBuildingBlockType.ObserverSet)
            {
                BuildingBlock = _observerSet
            });

            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("PopTemplateId", PKSimBuildingBlockType.Population)
            {
                BuildingBlock = _population
            });


            _individualSimulation.AddUsedObservedData(_observedData);

            A.CallTo(() => _eventMappingMapper.MapToSnapshot(_eventMapping, _project)).Returns(_eventSelection);
            A.CallTo(() => _observerSetMappingMapper.MapToSnapshot(_observerSetMapping, _project)).Returns(_observerSetSelection);

            _outputSelectionSnapshot = new OutputSelections();
            A.CallTo(() => _outputSelectionMapper.MapToSnapshot(_individualSimulation.OutputSelections)).Returns(_outputSelectionSnapshot);

            A.CallTo(() => _processMappingMapper.MapToModel(_snapshotInteraction, _inductionProcess)).Returns(_interactionSelection);

            return(_completed);
        }
Example #19
0
        private IndividualSimulation createForPKCalculation(IndividualSimulation originalSimulation, Compound compound, Action <Simulation, Compound, List <Protocol> > updateUsedProtocolsForSimulation)
        {
            var pkSimulation = createModelLessSimulationBasedOn(originalSimulation);

            //a new template was created. We need to retrieve by name
            var pkCompound = pkSimulation.Compounds.FindByName(compound.Name);

            //cache all protocols currently used by simulation
            var allProtocols = pkSimulation.AllBuildingBlocks <Protocol>().ToList();

            //Remove them from the simulations
            pkSimulation.RemoveAllBuildingBlockOfType(PKSimBuildingBlockType.Protocol);

            //updates the list according to the action given
            updateUsedProtocolsForSimulation(pkSimulation, pkCompound, allProtocols);

            _simulationBuildingBlockUpdater.UpdateMultipleUsedBuildingBlockInSimulationFromTemplate(pkSimulation, allProtocols, PKSimBuildingBlockType.Protocol);
            updateCompoundProperties(pkSimulation);

            _simulationModelCreator.CreateModelFor(pkSimulation);

            //now update all parameters from the orginal simulation
            _simulationParametersUpdater.ReconciliateSimulationParametersBetween(originalSimulation, pkSimulation);
            return(pkSimulation);
        }