Esempio n. 1
0
        protected override void Context()
        {
            sut = new PopulationAnalysisFlatTableCreator();
            _populationDataCollector = A.Fake <PopulationSimulationComparison>();
            _populationAnalysis      = new PopulationPivotAnalysis();

            _ageField = new PopulationAnalysisParameterField {
                ParameterPath = "Path", Name = "Age"
            };
            _populationAnalysis.Add(_ageField);

            //add derived field age class
            var groupingDefinition = new FixedLimitsGroupingDefinition("Age");

            groupingDefinition.SetLimits(new[] { 14d }.OrderBy(x => x));
            groupingDefinition.AddItems(new[]
            {
                new GroupingItem {
                    Label = "Children", Color = Color.Blue
                },
                new GroupingItem {
                    Label = "Adults", Color = Color.Red
                }
            });
            _ageClassField = new PopulationAnalysisGroupingField(groupingDefinition)
            {
                Name = "AgeClass"
            };
            _populationAnalysis.Add(_ageClassField);

            _ageValues = new List <double> {
                8d, 14d, 21d
            };
            _ageClassValues = new[] { "Children", "Adults", "Adults" };
        }
 protected override void Context()
 {
     _populationAnalysis = new PopulationPivotAnalysis();
     _anotherField       = new PopulationAnalysisParameterField().WithName("NAME");
     sut = new PopulationAnalysisParameterField();
     _populationAnalysis.Add(_anotherField);
 }
Esempio n. 3
0
        protected override void Context()
        {
            base.Context();
            _populationDataCollector    = A.Fake <IPopulationDataCollector>();
            _templatePopulationAnalysis = new PopulationPivotAnalysis();

            _parameterFound = new PopulationAnalysisParameterField {
                ParameterPath = "P1"
            };
            _parameterNotFound = new PopulationAnalysisParameterField {
                ParameterPath = "P2"
            };

            _templatePopulationAnalysis.Add(_parameterFound);
            _templatePopulationAnalysis.Add(_parameterNotFound);

            _cache = new PathCacheForSpecs <IParameter> {
                { "P1", new PKSimParameter() }
            };

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

            A.CallTo(() => _entitiesInContainerRetriever.ParametersFrom(_populationDataCollector)).Returns(_cache);
            A.CallTo(_dialogCreator).WithReturnType <ViewResult>().Returns(ViewResult.Yes);
        }
Esempio n. 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();
     _parameter = A.Fake <IParameter>();
     _field     = A.Fake <PopulationAnalysisParameterField>();
     sut.StartAnalysis(_populationDataCollector, _populationPivotAnalysis);
 }
        protected override void Context()
        {
            _view = A.Fake <IPopulationAnalysisFieldsView>();
            _quantitiesRetriever            = A.Fake <IEntitiesInContainerRetriever>();
            _contextMenuFactory             = A.Fake <IPopulationAnalysesContextMenuFactory>();
            _populationAnalysisFieldFactory = A.Fake <IPopulationAnalysisFieldFactory>();
            _populationAnalysisTemplateTask = A.Fake <IPopulationAnalysisTemplateTask>();
            _dialogCreator  = A.Fake <IDialogCreator>();
            _fieldDTOMapper = A.Fake <IPopulationAnalysisFieldToPopulationAnalysisFieldDTOMapper>();
            _parameterCache = new PathCacheForSpecs <IParameter>();
            _eventPublisher = A.Fake <IEventPublisher>();
            _populationAnalysisGroupingFieldCreator = A.Fake <IPopulationAnalysisGroupingFieldCreator>();
            sut = new PopulationAnalysisParameterFieldsPresenter(_view, _contextMenuFactory, _quantitiesRetriever, _populationAnalysisFieldFactory,
                                                                 _eventPublisher, _populationAnalysisGroupingFieldCreator, _populationAnalysisTemplateTask, _dialogCreator, _fieldDTOMapper);

            A.CallTo(_quantitiesRetriever).WithReturnType <PathCache <IParameter> >().Returns(_parameterCache);
            _populationPivotAnalysis = new PopulationPivotAnalysis();
            _populationDataCollector = A.Fake <IPopulationDataCollector>();
            sut.StartAnalysis(_populationDataCollector, _populationPivotAnalysis);

            _parameter      = A.Fake <IParameter>();
            _parameterField = new PopulationAnalysisParameterField {
                ParameterPath = _parameterPath, Name = "ParameterField"
            };
            A.CallTo(() => _populationAnalysisFieldFactory.CreateFor(_parameter)).Returns(_parameterField);

            _derivedField = A.Fake <PopulationAnalysisDerivedField>();
            A.CallTo(() => _derivedField.ReferencedFieldNames).Returns(new[] { _parameterField.Name });

            _parameterCache.Add(_parameterPath, _parameter);
        }
 private void drawDistributionFor(IParameter parameter, PopulationAnalysisParameterField parameterField = null)
 {
     if (parameter == null)
     {
         return;
     }
     _populationAnalysisFieldDistributionPresenter.Plot(_populationDataCollector, parameter, parameterField);
 }
 protected override void Context()
 {
     base.Context();
     _parameterField = A.Fake <PopulationAnalysisParameterField>();
     _parameter      = A.Fake <IParameter>();
     A.CallTo(() => _selectedParametersPresenter.SelectedParameter).Returns(_parameter);
     sut.StartAnalysis(_populationDataCollector, _populationPivotAnalysis);
 }
 protected override void Context()
 {
     base.Context();
     _field.Name    = "NEW NAME";
     _existingField = new PopulationAnalysisParameterField {
         Name = "Existing Field"
     };
     _existingFields.Add(_existingField);
 }
Esempio n. 10
0
        private IParameter parameterFromField(PopulationAnalysisParameterField field)
        {
            if (field == null)
            {
                return(null);
            }

            return(_allParameterCache[field.ParameterPath]);
        }
 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()
 {
     _dimension             = A.Fake <IDimension>();
     _displayUnit           = A.Fake <Unit>();
     _dimension.DefaultUnit = _displayUnit;
     _displayValue          = 0.1;
     _baseValue             = 1;
     sut = new PopulationAnalysisParameterField {
         Dimension = _dimension, DisplayUnit = _displayUnit, ParameterPath = _parameterPath
     };
 }
 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;
 }
        public override void GlobalContext()
        {
            base.GlobalContext();
            _populationPivotAnalysis       = new PopulationPivotAnalysis();
            _pkParameterField              = new PopulationAnalysisPKParameterField().WithName("PKParam");
            _pkParameterField.PKParameter  = "AUC";
            _pkParameterField.QuantityPath = "A|B|C";

            _parameterField = new PopulationAnalysisParameterField().WithName("Param");
            _parameterField.ParameterPath = "A|B|C|D";
            _populationPivotAnalysis.Add(_pkParameterField);
            _populationPivotAnalysis.Add(_parameterField);
            _populationPivotAnalysis.SetPosition(_parameterField, PivotArea.DataArea, 1);
            _populationPivotAnalysis.SetPosition(_pkParameterField, PivotArea.RowArea, 2);
        }
        protected override void Context()
        {
            _view = A.Fake <IFixedLimitsGroupingView>();
            _populationDataCollector = A.Fake <IPopulationDataCollector>();
            _field           = A.Fake <PopulationAnalysisParameterField>();
            _colorGenerator  = A.Fake <IColorGenerator>();
            _symbolGenerator = A.Fake <ISymbolGenerator>();
            sut = new FixedLimitsGroupingPresenter(_view, _colorGenerator, _symbolGenerator);

            //standard action for all tests
            _dimension         = A.Fake <IDimension>();
            _unit              = A.Fake <Unit>();
            _field.Dimension   = _dimension;
            _field.DisplayUnit = _unit;
            A.CallTo(() => _view.BindTo(A <IEnumerable <FixedLimitGroupingDTO> > ._, A <Unit> ._))
            .Invokes(x => _allDTOs = x.GetArgument <NotifyList <FixedLimitGroupingDTO> >(0).DowncastTo <IEnumerable <FixedLimitGroupingDTO> >());

            A.CallTo(() => _field.CanBeUsedForGroupingIn(_populationDataCollector)).Returns(true);
            A.CallTo(() => _field.GetValues(_populationDataCollector)).Returns(_values);
        }
Esempio n. 16
0
        protected override void Context()
        {
            _view = A.Fake <INumberOfBinsGroupingView>();
            _populationDataCollector = A.Fake <IPopulationDataCollector>();
            _populationAnalysis      = new PopulationPivotAnalysis();
            _field = A.Fake <PopulationAnalysisParameterField>().WithName("Field");
            A.CallTo(() => _field.CanBeUsedForGroupingIn(_populationDataCollector)).Returns(true);
            A.CallTo(() => _field.GetValues(_populationDataCollector)).Returns(_values);
            _populationAnalysis.Add(_field);
            _groupingLabelGenerator = A.Fake <IGroupingLabelGenerator>();
            _colorGradientGenerator = A.Fake <IColorGradientGenerator>();
            sut = new NumberOfBinsGroupingPresenter(_view, _groupingLabelGenerator, _colorGradientGenerator);

            //standard action for all tests
            _dimension         = A.Fake <IDimension>();
            _unit              = A.Fake <Unit>();
            _field.Dimension   = _dimension;
            _field.DisplayUnit = _unit;

            A.CallTo(() => _view.BindTo(A <BinSizeGroupingDTO> ._))
            .Invokes(x => _dto = x.GetArgument <BinSizeGroupingDTO>(0));
        }
Esempio n. 17
0
 protected override void Context()
 {
     sut       = new PopulationPivotAnalysis();
     _pkField1 = new PopulationAnalysisPKParameterField {
         PKParameter = "P1"
     }.WithName("Field1");
     _pkField2 = new PopulationAnalysisPKParameterField {
         PKParameter = "P2"
     }.WithName("Field2");
     _paraField1 = new PopulationAnalysisParameterField {
         ParameterPath = "Path3"
     }.WithName("Field3");
     _paraField2 = new PopulationAnalysisParameterField {
         ParameterPath = "Path4"
     }.WithName("Field4");
     _derivedField1 = A.Fake <PopulationAnalysisDerivedField>().WithName("Field5");
     sut.Add(_paraField1);
     sut.Add(_paraField2);
     sut.Add(_pkField1);
     sut.Add(_pkField2);
     sut.Add(_derivedField1);
 }
Esempio n. 18
0
 private void mapParameterFieldToModel(PopulationAnalysisField snapshot, PopulationAnalysisParameterField field)
 {
     mapNumericFieldToModel(snapshot, field);
     field.ParameterPath = snapshot.ParameterPath;
 }
Esempio n. 19
0
 public void Plot(IPopulationDataCollector populationDataCollector, IParameter parameter, PopulationAnalysisParameterField parameterField)
 {
     plotContinousData(populationDataCollector, parameter, parameterField, x => x.Plot);
 }
        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()
 {
     _newParameterField = await sut.MapToModel(_snapshot, new SnapshotContext()) as PopulationAnalysisParameterField;
 }
 protected override void Because()
 {
     _result = sut.CreateFor(_parameter);
 }
        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);
        }
Esempio n. 24
0
 public ParameterFieldSelectedEventArgs(IParameter parameter, PopulationAnalysisParameterField parameterField)
 {
     Parameter      = parameter;
     ParameterField = parameterField;
 }