protected override void Context()
 {
     base.Context();
     _populationSimulationComparison = new PopulationSimulationComparison();
     _simulationNameField            = new PopulationAnalysisCovariateField();
     A.CallTo(() => _populationAnalysisFieldFactory.CreateFor(CoreConstants.Covariates.SIMULATION_NAME, _populationSimulationComparison)).Returns(_simulationNameField);
 }
Exemple #2
0
 protected override void Context()
 {
     _dimensionRepository          = A.Fake <IDimensionRepository>();
     _representationInfoRepository = A.Fake <IRepresentationInfoRepository>();
     _lazyLoadTask            = A.Fake <ILazyLoadTask>();
     _observedcurveDataMapper = A.Fake <IDataRepositoryToObservedCurveDataMapper>();
     _statisticalAnalysis     = new PopulationStatisticalAnalysis();
     _genderField             = ChartDataHelperForSpecs.CreateGenderField();
     _statisticalAnalysis.Add(_genderField);
     _statisticalAnalysis.Add(_outputFieldVenousBloodPlasma);
     _statisticalAnalysis.Add(_outputFieldLiverCell);
     _predefinedStatisticalAggregation = new PredefinedStatisticalAggregation {
         Selected = true
     };
     _percentileStatisticalAggregation = new PercentileStatisticalAggregation {
         Selected = false, Percentile = 50
     };
     _statisticalAnalysis.AddStatistic(_predefinedStatisticalAggregation);
     _statisticalAnalysis.AddStatistic(_percentileStatisticalAggregation);
     A.CallTo(() => _representationInfoRepository.DisplayNameFor(_predefinedStatisticalAggregation)).Returns(_singlecurveId);
     A.CallTo(() => _representationInfoRepository.DisplayNameFor(_percentileStatisticalAggregation)).Returns(_percentileId);
     _statisticalDataCalculator = new StatisticalDataCalculator();
     _pivotResultCreator        = A.Fake <IPivotResultCreator>();
     sut = new TimeProfileChartDataCreator(_dimensionRepository, _pivotResultCreator, _representationInfoRepository,
                                           _statisticalDataCalculator, _lazyLoadTask, _observedcurveDataMapper);
 }
Exemple #3
0
        protected override void Context()
        {
            base.Context();

            var populationFieldFactory = A.Fake <PopulationAnalysisFieldFactory>();

            _covariateField = populationFieldFactory.CreateFor("Gender", _populationDataCollector);
            _populationAnalysis.Add(_covariateField);
            _genderValues = new string[] { "Male", "Female" };
            _covariateField.AddGroupingItem(new GroupingItem {
                Label = "Male", Color = PKSimColors.Male, Symbol = Symbols.Circle
            });
            _covariateField.AddGroupingItem(new GroupingItem {
                Label = "Female", Color = PKSimColors.Female, Symbol = Symbols.Diamond
            });

            var referenceSimulation = A.Fake <PopulationSimulation>().WithName("Sim");

            _referenceGroupingItem = new GroupingItem {
                Label = "Reference", Color = Color.Black, Symbol = Symbols.Circle
            };

            _populationDataCollector.ReferenceSimulation   = referenceSimulation;
            _populationDataCollector.ReferenceGroupingItem = _referenceGroupingItem;

            A.CallTo(() => _populationDataCollector.NumberOfItems).Returns(_ageValues.Count * 2);
            A.CallTo(() => _populationDataCollector.AllSimulationNames()).Returns(
                Enumerable.Repeat(referenceSimulation.Name, _ageValues.Count).Concat(
                    Enumerable.Repeat("Sim2", _ageValues.Count)).ToArray());
            A.CallTo(() => _populationDataCollector.AllValuesFor(_ageField.ParameterPath)).Returns(_ageValues.Concat(_ageValues).ToArray());
            A.CallTo(() => _populationDataCollector.AllCovariateValuesFor(_covariateField.Covariate)).Returns(_genderValues.Concat(_genderValues).Concat(_genderValues).ToArray());
        }
Exemple #4
0
        public static PivotResult CreatePivotResult(PopulationPivotAnalysis pivotAnalysis, Aggregate aggregate,
                                                    PopulationAnalysisCovariateField genderFielder,
                                                    PopulationAnalysisCovariateField raceField,
                                                    PopulationAnalysisParameterField bmiField,
                                                    PopulationAnalysisPKParameterField cmaxField)
        {
            var pivotResultCreator = new PivotResultCreator(new Pivoter(), new PopulationAnalysisFlatTableCreator());

            var populationSimulation = A.Fake <IPopulationDataCollector>();

            A.CallTo(() => populationSimulation.NumberOfItems).Returns(3);

            //thin, thin,  big
            A.CallTo(() => populationSimulation.AllValuesFor(bmiField.ParameterPath)).Returns(new List <double> {
                10, 20, 30
            });
            A.CallTo(() => populationSimulation.AllCovariateValuesFor(genderFielder.Covariate)).Returns(new List <string> {
                "Male", "Female", "Male"
            });
            A.CallTo(() => populationSimulation.AllCovariateValuesFor(raceField.Covariate)).Returns(new List <string> {
                "US", "EU", "EU"
            });
            A.CallTo(() => populationSimulation.AllPKParameterValuesFor(cmaxField.QuantityPath, cmaxField.PKParameter)).Returns(new List <double> {
                900, 600, 1000
            });
            A.CallTo(() => populationSimulation.AllSimulationNames).Returns(new List <string> {
                "Sim", "Sim", "Sim"
            });

            return(pivotResultCreator.Create(pivotAnalysis, populationSimulation, new ObservedDataCollection(), aggregate));
        }
 protected override void Context()
 {
     base.Context();
     _pivotAnalysis = new PopulationPivotAnalysis();
     _field         = new PopulationAnalysisCovariateField().WithName("Param");
     _pivotAnalysis.Add(_field);
 }
 protected override void Because()
 {
     _covariate = sut.CreateFor(_covariateName, _populationDataCollector);
     _covariate.ReferenceGroupingItem = new GroupingItem()
     {
         Color = Color.Black, Label = _referenceLabel, Symbol = Symbols.Circle
     };
 }
Exemple #7
0
        public void Plot(IPopulationDataCollector populationDataCollector, PopulationAnalysisCovariateField covariateField)
        {
            var fields = new List <IPopulationAnalysisField> {
                covariateField
            };

            plotDiscreteData(populationDataCollector, fields, covariateField);
        }
 protected override void Context()
 {
     base.Context();
     _pivotAnalysis  = new PopulationPivotAnalysis();
     _parameterField = new PopulationAnalysisCovariateField().WithName("Param");
     _dataArea       = new PopulationAnalysisParameterField().WithName("OnFilter");
     _pivotAnalysis.Add(_parameterField);
     _pivotAnalysis.Add(_dataArea);
     _pivotAnalysis.SetPosition(_dataArea, PivotArea.DataArea, 0);
 }
 protected override void Context()
 {
     base.Context();
     _covriateName   = "Gender";
     _covariateField = new PopulationAnalysisCovariateField().WithName(_covriateName);
     A.CallTo(() => _populationAnalysisFieldFactory.CreateFor(_covriateName, _populationDataCollector)).Returns(_covariateField);
     _dataTable = new DataTable();
     _dataTable.AddColumn <string>(_covriateName);
     A.CallTo(_flatTableCreator).WithReturnType <DataTable>().Returns(_dataTable);
 }
 protected override void Context()
 {
     base.Context();
     _pivotAnalysis      = new PopulationPivotAnalysis();
     _parameterField     = new PopulationAnalysisCovariateField().WithName("Param");
     _existingColorField = new PopulationAnalysisCovariateField().WithName("ColorField");
     _filterArea         = new PopulationAnalysisParameterField().WithName("OnFilter");
     _pivotAnalysis.Add(_parameterField);
     _pivotAnalysis.Add(_existingColorField);
     _pivotAnalysis.Add(_filterArea);
     _pivotAnalysis.SetPosition(_filterArea, PivotArea.FilterArea, 0);
     _pivotAnalysis.ColorField = _existingColorField;
 }
 private void addCovariateField(PopulationAnalysisCovariateField covariateField)
 {
     if (!hasReferenceSimulation)
     {
         addDataField(covariateField);
     }
     else
     {
         var covariateFieldInternalName = ShortGuid.NewGuid().ToString();
         _allCovariateFields.Add(covariateField.Name, covariateFieldInternalName);
         addDataField(covariateField, covariateFieldInternalName);
     }
 }
Exemple #12
0
        protected override void Context()
        {
            _view            = A.Fake <IValueMappingGroupingView>();
            _colorGenerator  = A.Fake <IColorGenerator>();
            _symbolGenerator = A.Fake <ISymbolGenerator>();
            sut = new ValueMappingGroupingPresenter(_view, _colorGenerator, _symbolGenerator);
            _populationDataCollector = A.Fake <IPopulationDataCollector>();

            _covariateField = A.Fake <PopulationAnalysisCovariateField>();
            A.CallTo(() => _covariateField.GetValues(_populationDataCollector)).Returns(new[] { "Male", "Male", "Female", "Female" });

            A.CallTo(() => _view.BindTo(A <IEnumerable <GroupingLabelDTO> > ._))
            .Invokes(x => _allLabels = x.GetArgument <IEnumerable <GroupingLabelDTO> >(0).ToList());
        }
Exemple #13
0
        protected override void Context()
        {
            _dimensionRepository          = A.Fake <IDimensionRepository>();
            _representationInfoRepository = A.Fake <IRepresentationInfoRepository>();
            _lazyLoadTask            = A.Fake <ILazyLoadTask>();
            _observedCurveDataMapper = A.Fake <IDataRepositoryToObservedCurveDataMapper>();
            _statisticalAnalysis     = new PopulationStatisticalAnalysis();
            _genderField             = ChartDataHelperForSpecs.CreateGenderField();
            _statisticalAnalysis.Add(_genderField);
            _statisticalAnalysis.Add(_outputFieldVenousBloodPlasma);
            _statisticalAnalysis.Add(_outputFieldLiverCell);
            _predefinedStatisticalAggregation = new PredefinedStatisticalAggregation {
                Selected = true
            };
            _percentileStatisticalAggregation = new PercentileStatisticalAggregation {
                Selected = false, Percentile = 50
            };
            _statisticalAnalysis.AddStatistic(_predefinedStatisticalAggregation);
            _statisticalAnalysis.AddStatistic(_percentileStatisticalAggregation);
            A.CallTo(() => _representationInfoRepository.DisplayNameFor(_predefinedStatisticalAggregation)).Returns(_singleCurveId);
            A.CallTo(() => _representationInfoRepository.DisplayNameFor(_percentileStatisticalAggregation)).Returns(_percentileId);
            _statisticalDataCalculator = new StatisticalDataCalculator();
            _pivotResultCreator        = A.Fake <IPivotResultCreator>();

            _mergedDimensionVenousBloodPlasma = DomainHelperForSpecs.ConcentrationDimensionForSpecs();
            _mergedDimensionLiverCell         = DomainHelperForSpecs.FractionDimensionForSpecs();

            A.CallTo(() => _dimensionRepository.MergedDimensionFor(A <IWithDimension> ._))
            .WhenArgumentsMatch((IWithDimension context) => Equals((context as NumericFieldContext)?.NumericValueField, _outputFieldVenousBloodPlasma))
            .Returns(_mergedDimensionVenousBloodPlasma);

            A.CallTo(() => _dimensionRepository.MergedDimensionFor(A <IWithDimension> ._))
            .WhenArgumentsMatch((IWithDimension context) => Equals((context as NumericFieldContext)?.NumericValueField, _outputFieldLiverCell))
            .Returns(_mergedDimensionLiverCell);

            sut = new TimeProfileChartDataCreator(_dimensionRepository, _pivotResultCreator, _representationInfoRepository,
                                                  _statisticalDataCalculator, _lazyLoadTask, _observedCurveDataMapper);
        }
Exemple #14
0
        protected override void Context()
        {
            base.Context();
            _populationDataCollector    = A.Fake <IPopulationDataCollector>();
            _templatePopulationAnalysis = new PopulationPivotAnalysis();

            _covariateFound = new PopulationAnalysisCovariateField {
                Covariate = "Covariate1"
            };
            _covariateNotFound = new PopulationAnalysisCovariateField {
                Covariate = "Covariate2"
            };

            _templatePopulationAnalysis.Add(_covariateFound);
            _templatePopulationAnalysis.Add(_covariateNotFound);

            A.CallTo(_templateTask).WithReturnType <PopulationAnalysis>().Returns(_templatePopulationAnalysis);

            A.CallTo(() => _populationDataCollector.AllCovariateNames).Returns(new List <string> {
                _covariateFound.Covariate
            });
            A.CallTo(_dialogCreator).WithReturnType <ViewResult>().Returns(ViewResult.Yes);
        }
        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);
        }
 protected override void Context()
 {
     base.Context();
     _covariateField = A.Fake <PopulationAnalysisCovariateField>();
     sut.StartAnalysis(_populationDataCollector, _populationPivotAnalysis);
 }
 public CovariateFieldSelectedEventArgs(string covariate, PopulationAnalysisCovariateField covariateField)
 {
     Covariate      = covariate;
     CovariateField = covariateField;
 }
Exemple #18
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));
        }
Exemple #19
0
 private void mapCovariateField(PopulationAnalysisField snapshot, PopulationAnalysisCovariateField field)
 {
     snapshot.Covariate     = field.Covariate;
     snapshot.GroupingItems = field.GroupingItems.ToArray();
 }
Exemple #20
0
 private void mapCovariateFieldToModel(PopulationAnalysisField snapshot, PopulationAnalysisCovariateField field)
 {
     field.Covariate = snapshot.Covariate;
     snapshot.GroupingItems?.Each(field.AddGroupingItem);
 }
 private void drawDistributionFor(PopulationAnalysisCovariateField covariateField)
 {
     _populationAnalysisFieldDistributionPresenter.Plot(_populationDataCollector, covariateField);
 }
        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()
 {
     _newCovariateField = await sut.MapToModel(_snapshot, new SnapshotContext()) as PopulationAnalysisCovariateField;
 }
 protected override void Because()
 {
     _covariate = sut.CreateFor(_covariateName, _populationDataCollector);
 }
 protected override void Because()
 {
     _populationAnalysisCovariateField = new PopulationAnalysisCovariateField();
     _selectedParametersPresenter.CovariateFieldSelected += Raise.With(new CovariateFieldSelectedEventArgs(_covariate, _populationAnalysisCovariateField));
 }