protected override void Context()
        {
            _view = A.Fake <IEditTimeProfileAnalysisChartView>();
            _timeProfilerChartPresenter          = A.Fake <ITimeProfileChartPresenter>();
            _timeProfileChartDataCreator         = A.Fake <ITimeProfileChartDataCreator>();
            _populationSimulationAnalysisStarter = A.Fake <IPopulationSimulationAnalysisStarter>();
            _populationAnalysisTask = A.Fake <IPopulationAnalysisTask>();
            _colorGenerator         = A.Fake <IColorGenerator>();
            _observedDataTask       = A.Fake <IObservedDataTask>();
            _pkAnalysisPresenter    = A.Fake <IPopulationPKAnalysisPresenter>();
            _dimensionRepository    = A.Fake <IDimensionRepository>();

            _presenterSettingsTask = A.Fake <IPresentationSettingsTask>();
            sut = new EditTimeProfileAnalysisChartPresenter(_view, _timeProfilerChartPresenter, _timeProfileChartDataCreator,
                                                            _populationSimulationAnalysisStarter, _populationAnalysisTask, _colorGenerator, _observedDataTask, _pkAnalysisPresenter, _dimensionRepository, _presenterSettingsTask);

            _timeProfileAnalysisChart      = new TimeProfileAnalysisChart();
            _populationStatisticalAnalysis = new PopulationStatisticalAnalysis();
            _timeProfileAnalysisChart.PopulationAnalysis = _populationStatisticalAnalysis;
            _populationDataCollector = A.Fake <IPopulationDataCollector>();
            sut.InitializeAnalysis(_timeProfileAnalysisChart, _populationDataCollector);

            _observedDataRepository = DomainHelperForSpecs.ObservedData();
            var data = new DragDropInfo(
                new List <ITreeNode> {
                new ObservedDataNode(new ClassifiableObservedData {
                    Subject = _observedDataRepository
                })
            }
                );

            _dragEventArgs = new DragEventArgs(new DataObject(data), 0, 0, 0, DragDropEffects.All, DragDropEffects.All);

            _chartData = new ChartData <TimeProfileXValue, TimeProfileYValue>(null, null);
            var concentrationDimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs();
            var yAxis = new AxisData(concentrationDimension, concentrationDimension.DefaultUnit, Scalings.Linear);

            _paneData = new PaneData <TimeProfileXValue, TimeProfileYValue>(yAxis);
            _chartData.AddPane(_paneData);
            A.CallTo(_timeProfileChartDataCreator).WithReturnType <ChartData <TimeProfileXValue, TimeProfileYValue> >().Returns(_chartData);

            var outputField = new PopulationAnalysisOutputField {
                Dimension = DomainHelperForSpecs.MassConcentrationDimensionForSpecs()
            };

            _populationStatisticalAnalysis.Add(outputField);

            A.CallTo(() => _dimensionRepository.MergedDimensionFor(A <NumericFieldContext> ._)).Returns(concentrationDimension);
        }
Example #2
0
        public static PivotResult CreateOutputResults(PopulationPivotAnalysis analysis, PopulationAnalysisCovariateField genderField, PopulationAnalysisOutputField outputField1,
                                                      PopulationAnalysisOutputField outputField2,
                                                      ObservedDataCollection observedDataCollection = null)
        {
            var populationSimulation = A.Fake <IPopulationDataCollector>();

            var pivotResultCreator = new PivotResultCreator(new Pivoter(), new PopulationAnalysisFlatTableCreator());
            //simulation with 4 time points
            var time = new QuantityValues {
                Values = new float[] { 1, 2, 3, 4 }
            };
            var output11 = createValues(time, 10, 20, 30, 40);
            var output12 = createValues(time, 100, 200, 300, 400);
            var output13 = createValues(time, 1000, 2000, 3000, 4000);
            var output21 = createValues(time, 50, 60, 70, 80);
            var output22 = createValues(time, 500, 600, 700, 800);
            var output23 = createValues(time, 5000, 6000, 7000, 8000);

            A.CallTo(() => populationSimulation.NumberOfItems).Returns(3);
            A.CallTo(() => populationSimulation.AllCovariateValuesFor(CoreConstants.Covariates.GENDER)).Returns(new List <string> {
                "Male", "Female", "Male"
            });
            A.CallTo(() => populationSimulation.AllOutputValuesFor(outputField1.QuantityPath)).Returns(new List <QuantityValues> {
                output11, output12, output13
            });
            A.CallTo(() => populationSimulation.AllOutputValuesFor(outputField2.QuantityPath)).Returns(new List <QuantityValues> {
                output21, output22, output23
            });
            A.CallTo(() => populationSimulation.AllSimulationNames).Returns(new List <string> {
                "Sim", "Sim", "Sim"
            });


            if (observedDataCollection == null)
            {
                observedDataCollection = new ObservedDataCollection();
            }

            return(pivotResultCreator.Create(analysis, populationSimulation, observedDataCollection, AggregationFunctions.QuantityAggregation));
        }
Example #3
0
 private void mapOutputFieldToModel(PopulationAnalysisField snapshot, PopulationAnalysisOutputField field)
 {
     mapQuantityFieldToModel(snapshot, field);
     field.Color = ModelValueFor(snapshot.Color, field.Color);
 }
Example #4
0
 private void mapOutputFieldToSnapshot(PopulationAnalysisField snapshot, PopulationAnalysisOutputField field)
 {
     mapQuantityFieldToSnapshot(snapshot, field);
     snapshot.Color = field.Color;
 }
        protected override Task Context()
        {
            _groupingDefinitionMapper = A.Fake <GroupingDefinitionMapper>();
            _dimension           = DomainHelperForSpecs.ConcentrationDimensionForSpecs();
            _mergedDimension     = DomainHelperForSpecs.TimeDimensionForSpecs();
            _unit                = _mergedDimension.Unit("h"); // this unit is defined in the merged dimension but not in the field dimension
            _dimensionRepository = A.Fake <IDimensionRepository>();

            sut = new PopulationAnalysisFieldMapper(_groupingDefinitionMapper, _dimensionRepository);

            _groupingItem1 = new GroupingItem();

            _parameterField = new PopulationAnalysisParameterField
            {
                Name          = "P",
                ParameterPath = "A|B",
                Scaling       = Scalings.Linear,
                Dimension     = _dimension,
                DisplayUnit   = _unit
            };

            _pkParameterField = new PopulationAnalysisPKParameterField
            {
                Name         = "PK",
                Dimension    = _dimension,
                DisplayUnit  = _unit,
                PKParameter  = "AUC",
                QuantityPath = "A|B|C",
                QuantityType = QuantityType.Observer | QuantityType.Drug
            };

            _outputField = new PopulationAnalysisOutputField
            {
                Name         = "Output",
                Dimension    = _dimension,
                DisplayUnit  = _unit,
                QuantityType = QuantityType.BaseGrid,
                QuantityPath = "A|B|C",
                Color        = Color.AntiqueWhite
            };

            _groupingDefinition = new FixedLimitsGroupingDefinition("AA");
            _groupingField      = new PopulationAnalysisGroupingField(_groupingDefinition)
            {
                Name = "Grouping",
            };


            _covariateField = new PopulationAnalysisCovariateField
            {
                Name      = "Gender",
                Covariate = "Gender",
            };
            _covariateField.AddGroupingItem(_groupingItem1);

            _snapshotGroupingDefinition = new Snapshots.GroupingDefinition();
            A.CallTo(() => _groupingDefinitionMapper.MapToSnapshot(_groupingDefinition)).Returns(_snapshotGroupingDefinition);

            A.CallTo(() => _dimensionRepository.DimensionByName(_dimension.Name)).Returns(_dimension);
            A.CallTo(() => _dimensionRepository.MergedDimensionFor(A <INumericValueField> ._)).Returns(_mergedDimension);
            return(_completed);
        }
 protected override async Task Because()
 {
     _newOutputField = await sut.MapToModel(_snapshot, new SnapshotContext()) as PopulationAnalysisOutputField;
 }
        public override void GlobalContext()
        {
            base.GlobalContext();
            _populationAnalysis = new PopulationPivotAnalysis();

            _pkParameterField              = new PopulationAnalysisPKParameterField().WithName("PKParam");
            _pkParameterField.PKParameter  = "AUC";
            _pkParameterField.QuantityPath = "A|B|C";
            _pkParameterField.QuantityType = QuantityType.Drug;
            _pkParameterField.Dimension    = _dimensionRepository.MassConcentration;

            _parameterField = new PopulationAnalysisParameterField().WithName("Param");
            _parameterField.ParameterPath = "A|B|C|D";
            _parameterField.Dimension     = _dimensionRepository.Auc;

            _outputField = new PopulationAnalysisOutputField().WithName("Output");
            _outputField.QuantityPath = "A|B|C";
            _outputField.Dimension    = _dimensionRepository.Auc;
            _outputField.Color        = Color.Aquamarine;

            _genderField = new PopulationAnalysisCovariateField {
                Covariate = "Gender"
            }.WithName("Gender");
            var numberOfBinsGroupingDefinition = new NumberOfBinsGroupingDefinition(_parameterField.Name)
            {
                NumberOfBins = 2
            };

            numberOfBinsGroupingDefinition.NamingPattern = "AA";
            numberOfBinsGroupingDefinition.StartColor    = Color.AliceBlue;
            numberOfBinsGroupingDefinition.EndColor      = Color.RoyalBlue;
            numberOfBinsGroupingDefinition.Strategy      = LabelGenerationStrategies.Roman;
            numberOfBinsGroupingDefinition.AddItems(PopulationAnalysisHelperForSpecs.BMIGroups);
            _numberOfBinsDerivedField = new PopulationAnalysisGroupingField(numberOfBinsGroupingDefinition).WithName("NumberOfBins");

            var fixedLimitsGroupingDefinition = new FixedLimitsGroupingDefinition(_pkParameterField.Name);

            fixedLimitsGroupingDefinition.AddItems(PopulationAnalysisHelperForSpecs.AgeGroups);

            _fixedLimitsGroupingDefinitionField = new PopulationAnalysisGroupingField(fixedLimitsGroupingDefinition)
                                                  .WithName("FixedLimits");

            fixedLimitsGroupingDefinition.SetLimits(new[] { 1d, 2d }.OrderBy(x => x));

            _derivedFieldWithFixedExpression = new PopulationAnalysisExpressionField("A+B")
                                               .WithName("FixedExpression");


            var valueMappingGroupingDefinition = new ValueMappingGroupingDefinition(_genderField.Name);

            valueMappingGroupingDefinition.AddValueLabel("Male", PopulationAnalysisHelperForSpecs.GroupingItemMale);
            valueMappingGroupingDefinition.AddValueLabel("Female", PopulationAnalysisHelperForSpecs.GroupingItemFemale);
            var valueMappingGroupingDefinitionField = new PopulationAnalysisGroupingField(valueMappingGroupingDefinition).WithName("ValueMapping");

            _populationAnalysis.Add(_pkParameterField);
            _populationAnalysis.Add(_parameterField);
            _populationAnalysis.Add(_genderField);
            _populationAnalysis.Add(_numberOfBinsDerivedField);
            _populationAnalysis.Add(_fixedLimitsGroupingDefinitionField);
            _populationAnalysis.Add(_derivedFieldWithFixedExpression);
            _populationAnalysis.Add(valueMappingGroupingDefinitionField);
            _populationAnalysis.Add(_outputField);
        }
Example #8
0
        protected override void Context()
        {
            base.Context();
            _populationSimulation = new PopulationSimulation {
                SimulationSettings = new SimulationSettings {
                    OutputSelections = new OutputSelections()
                }
            };

            var liverCellsDrugConc = "Liver|Cells|Drug|Conc";

            _populationSimulation.OutputSelections.AddOutput(new QuantitySelection(liverCellsDrugConc, QuantityType.Drug));
            _populationSimulation.OutputSelections.AddOutput(new QuantitySelection("Liver|Plasma|Drug|Conc", QuantityType.Drug));

            _populationStatisticalAnalysis = new PopulationStatisticalAnalysis();
            _timeProfileAnalysis           = new TimeProfileAnalysisChart {
                PopulationAnalysis = _populationStatisticalAnalysis
            };

            _outputField1 = new PopulationAnalysisOutputField {
                QuantityPath = "Kidney|Cell|Drug|Conc", Name = "outputField1"
            };
            _derivedField1 = new PopulationAnalysisGroupingField(new NumberOfBinsGroupingDefinition(_outputField1.Name))
            {
                Name = "derivedField1"
            };

            _outputField2 = new PopulationAnalysisOutputField {
                QuantityPath = liverCellsDrugConc, Name = "outputField2"
            };
            _derivedField2 = new PopulationAnalysisGroupingField(new NumberOfBinsGroupingDefinition(_outputField2.Name))
            {
                Name = "derivedField2"
            };

            _pkField1 = new PopulationAnalysisPKParameterField {
                QuantityPath = "Kidney|Cell|Drug|Conc", Name = "pkField1"
            };
            _pkDerivedField1 = new PopulationAnalysisGroupingField(new NumberOfBinsGroupingDefinition(_pkField1.Name))
            {
                Name = "pkDerivedField1"
            };

            _pkField2 = new PopulationAnalysisPKParameterField {
                QuantityPath = liverCellsDrugConc, Name = "pkField2"
            };
            _pkDerivedField2 = new PopulationAnalysisGroupingField(new NumberOfBinsGroupingDefinition(_pkField2.Name))
            {
                Name = "pkDerivedField2"
            };

            _populationStatisticalAnalysis.Add(_outputField1);
            _populationStatisticalAnalysis.Add(_outputField2);
            _populationStatisticalAnalysis.Add(_derivedField1);
            _populationStatisticalAnalysis.Add(_derivedField2);
            _populationStatisticalAnalysis.Add(_pkField1);
            _populationStatisticalAnalysis.Add(_pkField2);
            _populationStatisticalAnalysis.Add(_pkDerivedField1);
            _populationStatisticalAnalysis.Add(_pkDerivedField2);
            _populationSimulation.AddAnalysis(_timeProfileAnalysis);
        }