예제 #1
0
 public void AddDataRepository(ModelDataRepository dataRepository)
 {
     if (dataRepository != null)
     {
         _dataRepositories.Add(dataRepository);
     }
 }
예제 #2
0
        protected override async Task Context()
        {
            await base.Context();

            _runOptions.Validate = true;

            _expectedOutputPath             = Path.Combine(_qualificationConfiguration.OutputFolder, PROJECT_NAME);
            _expectedObsDataPath            = _qualificationConfiguration.ObservedDataFolder;
            DirectoryHelper.DirectoryExists = s => string.Equals(s, _expectedOutputPath);
            DirectoryHelper.DeleteDirectory = (s, b) => _deletedDirectory = s;


            _observedData = DomainHelperForSpecs.ObservedData().WithName("OBS");
            _project.AddObservedData(_observedData);
        }
예제 #3
0
        protected override async Task Context()
        {
            await base.Context();

            _snapshot = await sut.MapToSnapshot(_individualSimulation, _project);

            var individualSimulation = new IndividualSimulation
            {
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Model = _model
            };

            individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndTemplateId", PKSimBuildingBlockType.Individual)
            {
                Name          = _individual.Name,
                BuildingBlock = _individual
            });

            _modelProperties = new ModelProperties();
            A.CallTo(() => _modelPropertiesTask.DefaultFor(_individual.OriginData, _snapshot.Model)).Returns(_modelProperties);
            A.CallTo(() => _simulationFactory.CreateFrom(_individual, A <IReadOnlyList <Compound> > ._, _modelProperties, null)).Returns(individualSimulation);

            _outputSelection = new OSPSuite.Core.Domain.OutputSelections();
            _outputSelection.AddOutput(new QuantitySelection("PATH", QuantityType.BaseGrid));
            A.CallTo(() => _outputSelectionMapper.MapToModel(_snapshot.OutputSelections, individualSimulation)).Returns(_outputSelection);

            _solver = new SolverSettings();
            A.CallTo(() => _solverSettingsMapper.MapToModel(_snapshot.Solver)).Returns(_solver);

            _outputSchema = new OutputSchema();
            A.CallTo(() => _outputSchemaMapper.MapToModel(_snapshot.OutputSchema)).Returns(_outputSchema);

            A.CallTo(() => _curveChartMapper.MapToModel(_snapshotSimulationTimeProfile, A <SimulationAnalysisContext> ._))
            .Invokes(x => _context = x.GetArgument <SimulationAnalysisContext>(1))
            .Returns(_simulationTimeProfile);


            //ensure that run will be performed
            _snapshot.HasResults      = true;
            _calculatedDataRepository = DomainHelperForSpecs.ObservedData("Calculated");

            A.CallTo(() => _simulationRunner.RunSimulation(individualSimulation, A <SimulationRunOptions> ._))
            .Invokes(x => { individualSimulation.DataRepository = _calculatedDataRepository; });

            A.CallTo(() => _eventMappingMapper.MapToModel(_eventSelection, _project)).Returns(_eventMapping);
            A.CallTo(() => _observerSetMappingMapper.MapToModel(_observerSetSelection, _project)).Returns(_observerSetMapping);
        }
        protected override Task Context()
        {
            _parameterIdentificationAnalysisChartMapper = A.Fake <ParameterIdentificationAnalysisChartMapper>();
            _dataRepositoryMapper = A.Fake <DataRepositoryMapper>();
            _idGenerator          = A.Fake <IIdGenerator>();
            sut = new ParameterIdentificationAnalysisMapper(_parameterIdentificationAnalysisChartMapper, _dataRepositoryMapper, _idGenerator);

            _parameterIdentificationAnalysis = new T().WithName("Chart");
            _chartSnapshot           = new CurveChart();
            _localRepository         = DomainHelperForSpecs.ObservedData();
            _snapshotLocalRepository = new Snapshots.DataRepository();
            A.CallTo(() => _dataRepositoryMapper.MapToSnapshot(_localRepository)).Returns(_snapshotLocalRepository);

            _parameterIdentification = new ParameterIdentification();
            _project = new PKSimProject();
            _parameterIdentificationContext = new ParameterIdentificationContext(_parameterIdentification, _project);
            return(_completed);
        }
        protected override async Task Context()
        {
            await base.Context();

            _expectedOutputPath             = Path.Combine(_qualificationConfiguration.OutputFolder, PROJECT_NAME);
            DirectoryHelper.DirectoryExists = s => string.Equals(s, _expectedOutputPath);
            DirectoryHelper.DeleteDirectory = (s, b) => _deletedDirectory = s;

            _simulationName = "S1";
            _simulation     = new Simulation {
                Name = _simulationName
            };
            _individualSimulation = new IndividualSimulation {
                Name = _simulationName
            };
            _input = new Input {
                Project = PROJECT_NAME, Name = _simulationName, SectionId = 2, Type = PKSimBuildingBlockType.Simulation, SectionLevel = 5
            };

            _expectedSimulationPath = Path.Combine(_expectedOutputPath, _simulationName);
            _simulationExport       = new SimulationMapping {
                Project = PROJECT_NAME, Simulation = _simulationName, Path = _expectedSimulationPath
            };
            _simulationExports = new[] { _simulationExport };
            A.CallTo(() => _exportSimulationRunner.ExportSimulationsIn(_project, A <ExportRunOptions> ._))
            .Invokes(x => _exportOptions = x.GetArgument <ExportRunOptions>(1))
            .Returns(_simulationExports);

            _observedData = DomainHelperForSpecs.ObservedData().WithName("OBS");
            _project.AddObservedData(_observedData);
            _projectSnapshot.Simulations     = new[] { _simulation };
            _expectedObservedDataXlsFullPath = Path.Combine(_qualificationConfiguration.ObservedDataFolder, $"{_observedData.Name}{Constants.Filter.XLSX_EXTENSION}");
            _expectedObservedDataCsvFullPath = Path.Combine(_qualificationConfiguration.ObservedDataFolder, $"{_observedData.Name}{Constants.Filter.CSV_EXTENSION}");

            _expectedInputFullPath = Path.Combine(_qualificationConfiguration.InputsFolder, PROJECT_NAME, PKSimBuildingBlockType.Simulation.ToString(), $"{_simulationName}{CoreConstants.Filter.MARKDOWN_EXTENSION}");

            A.CallTo(() => _jsonSerializer.Serialize(A <QualificationMapping> ._, _qualificationConfiguration.MappingFile))
            .Invokes(x => _mapping = x.GetArgument <QualificationMapping>(0));

            _project.AddBuildingBlock(_individualSimulation);
            _qualificationConfiguration.Inputs      = new[] { _input };
            _qualificationConfiguration.Simulations = new[] { _simulationName, };
            _runOptions.Run = true;
        }
예제 #6
0
        protected override Task Context()
        {
            _curveOptionsMapper = A.Fake <CurveOptionsMapper>();
            sut = new ObservedDataCollectionMappper(_curveOptionsMapper);

            _observedDataRepository = DomainHelperForSpecs.ObservedData("ID").WithName("ObsData");
            _observedDataCollection = new Model.PopulationAnalyses.ObservedDataCollection();
            _observedDataCollection.ApplyGroupingToObservedData = true;
            _observedDataCollection.AddObservedData(_observedDataRepository);
            _firstObservedDataColumn  = _observedDataRepository.ObservationColumns().First();
            _observedDataCurveOptions = new ObservedDataCurveOptions
            {
                Caption  = "Obs Data Caption",
                ColumnId = _firstObservedDataColumn.Id
            };

            _observedDataCollection.AddCurveOptions(_observedDataCurveOptions);
            _snapshotCurveOptions = new CurveOptions();
            A.CallTo(() => _curveOptionsMapper.MapToSnapshot(_observedDataCurveOptions.CurveOptions)).Returns(_snapshotCurveOptions);
            return(_completed);
        }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
0
 private void addObservedDataToProject(ModelProject project, ModelDataRepository repository)
 {
     addClassifiableToProject <ClassifiableObservedData, ModelDataRepository>(project, repository, project.AddObservedData);
 }