示例#1
0
        protected override void Context()
        {
            base.Context();
            var pKAnalyses = new PopulationSimulationPKAnalyses();

            _populationSimulation = new PopulationSimulation {
                PKAnalyses = pKAnalyses
            };
            var pkParameter = new QuantityPKParameter {
                QuantityPath = "Liver", Name = "P"
            };
            var dimension = A.Fake <IDimension>();
            var unit      = A.Fake <Unit>();

            A.CallTo(() => unit.Name).Returns("UNIT");
            A.CallTo(() => _displayUnitRetriever.PreferredUnitFor(pkParameter, null)).Returns(unit);

            pkParameter.Dimension = dimension;
            pkParameter.SetNumberOfIndividuals(2);
            pkParameter.SetValue(0, 10);
            pkParameter.SetValue(1, 11);

            A.CallTo(() => dimension.BaseUnitValueToUnitValue(unit, 10)).Returns(100.10);
            A.CallTo(() => dimension.BaseUnitValueToUnitValue(unit, 11)).Returns(110.20);

            pKAnalyses.AddPKAnalysis(pkParameter);
        }
示例#2
0
        protected override void Context()
        {
            base.Context();
            _pkAnalysis           = new PopulationSimulationPKAnalyses();
            _populationSimulation = A.Fake <IModelCoreSimulation>();
            var quantityPKParameter = new QuantityPKParameter {
                QuantityPath = "Liver", Name = "P"
            };
            var pkParameter = new PKParameter {
                DisplayUnit = "UNIT", Name = "P"
            };

            A.CallTo(() => _pkParameterRepository.FindByName(quantityPKParameter.Name)).Returns(pkParameter);
            var mergedDimension = A.Fake <IDimension>();

            quantityPKParameter.SetValue(0, 10);
            quantityPKParameter.SetValue(1, 11);

            A.CallTo(() => _dimensionFactory.MergedDimensionFor(A <QuantityPKParameterContext> ._))
            .WhenArgumentsMatch(x => x.Get <QuantityPKParameterContext>(0).QuantityPKParameter == quantityPKParameter)
            .Returns(mergedDimension);

            var unit = A.Fake <Unit>();

            A.CallTo(() => unit.Name).Returns(pkParameter.DisplayUnit);
            A.CallTo(() => mergedDimension.UnitOrDefault(pkParameter.DisplayUnit)).Returns(unit);
            A.CallTo(() => mergedDimension.BaseUnitValueToUnitValue(unit, 10)).Returns(100.10f);
            A.CallTo(() => mergedDimension.BaseUnitValueToUnitValue(unit, 11)).Returns(110.20f);

            _pkAnalysis.AddPKAnalysis(quantityPKParameter);
        }
        protected override void Context()
        {
            base.Context();
            _numberOfVariations = 5;
            _pkParameter1       = new QuantityPKParameter {
                QuantityPath = "Output1", Name = "AUC"
            };
            _pkParameter1.SetNumberOfIndividuals(_numberOfVariations);
            _pkParameter1.SetValue(0, 10);
            _pkParameter1.SetValue(1, 11);
            _pkParameter1.SetValue(2, 12);
            _pkParameter1.SetValue(4, _defaultPK1Value);

            _pkParameter2 = new QuantityPKParameter {
                QuantityPath = "Output2", Name = "Cmax"
            };
            _pkParameter2.SetNumberOfIndividuals(_numberOfVariations);
            _pkParameter2.SetValue(0, 20);
            _pkParameter2.SetValue(1, 21);
            _pkParameter2.SetValue(2, 22);
            _pkParameter2.SetValue(3, 23);
            _pkParameter2.SetValue(4, _defaultPK2Value);

            _sensitivityParameter1 = A.Fake <SensitivityParameter>().WithName("SP1");
            A.CallTo(() => _sensitivityParameter1.DefaultValue).Returns(10);

            _sensitivityParameter2 = A.Fake <SensitivityParameter>().WithName("SP2");
            A.CallTo(() => _sensitivityParameter2.DefaultValue).Returns(20);

            _sensitivityParameter3 = A.Fake <SensitivityParameter>().WithName("SP3");
            A.CallTo(() => _sensitivityParameter3.DefaultValue).Returns(0);
            A.CallTo(() => _sensitivityParameter3.VariationRangeValue).Returns(0.8);

            _pkAnalyses.AddPKAnalysis(_pkParameter1);
            _pkAnalyses.AddPKAnalysis(_pkParameter2);

            _sensitivityAnalysis.AddSensitivityParameter(_sensitivityParameter1);
            _sensitivityAnalysis.AddSensitivityParameter(_sensitivityParameter2);
            _sensitivityAnalysis.AddSensitivityParameter(_sensitivityParameter3);

            var pv11 = new ParameterVariation {
                ParameterName = _sensitivityParameter1.Name, VariationId = 0, Variation = new[] { 15d, 200d, 300d }
            };
            var pv12 = new ParameterVariation {
                ParameterName = _sensitivityParameter1.Name, VariationId = 1, Variation = new[] { 20d, 200d, 300d }
            };
            var pv21 = new ParameterVariation {
                ParameterName = _sensitivityParameter2.Name, VariationId = 2, Variation = new[] { 100d, 21d, 300d }
            };
            var pv22 = new ParameterVariation {
                ParameterName = _sensitivityParameter2.Name, VariationId = 3, Variation = new[] { 100d, 31d, 300d }
            };

            _variationData.DefaultValues = new[] { 100d, 200d, 300d };
            _variationData.AddVariation(pv11);
            _variationData.AddVariation(pv12);
            _variationData.AddVariation(pv21);
            _variationData.AddVariation(pv22);
        }
        public void TestSerialization()
        {
            var x1 = new QuantityPKParameter
            {
                Name         = "C_max",
                Dimension    = DimensionMassConcentration,
                QuantityPath = "A|B|C"
            };

            x1.SetValue(1, 5.0f);
            x1.SetValue(2, 4.0f);
            x1.SetValue(8, 2.0f);
            var x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualQuantity(x2, x1);
        }
示例#5
0
        private QuantityPKParameter createPKAnalyses(string path)
        {
            var pk = new QuantityPKParameter {
                QuantityPath = path
            };

            pk.Name = "AUC";

            for (int i = 0; i < _numberOfIndividuals; i++)
            {
                pk.SetValue(i, (float)_random.NextDouble() * 100);
            }

            return(pk);
        }
示例#6
0
        private void addPKParametersForOutput(
            IModelCoreSimulation simulation,
            SimulationResults simulationResults,
            Action <int> performIndividualScalingAction,
            QuantitySelection selectedQuantity,
            PopulationSimulationPKAnalyses popAnalyses,
            string moleculeName,
            PKCalculationOptions pkCalculationOptions,
            IReadOnlyList <ApplicationParameters> allApplicationParameters)
        {
            var allPKParameters            = _pkParameterRepository.All().Where(p => PKParameterCanBeUsed(p, pkCalculationOptions)).ToList();
            var allUserDefinedPKParameters = allPKParameters.OfType <UserDefinedPKParameter>().ToList();

            //create pk parameter for each  pk parameters (predefined and dynamic)
            foreach (var pkParameter in allPKParameters)
            {
                var quantityPKParameter = new QuantityPKParameter {
                    Name = pkParameter.Name, QuantityPath = selectedQuantity.Path, Dimension = pkParameter.Dimension
                };
                popAnalyses.AddPKAnalysis(quantityPKParameter);
            }

            //add the values for each individual
            foreach (var individualResult in simulationResults.AllIndividualResults)
            {
                performIndividualScalingAction(individualResult.IndividualId);
                _pkCalculationOptionsFactory.UpdateTotalDrugMassPerBodyWeight(simulation, moleculeName, pkCalculationOptions, allApplicationParameters);

                var values = individualResult.QuantityValuesFor(selectedQuantity.Path);
                //This can happen is the results do not match the simulation
                if (values == null)
                {
                    continue;
                }

                var pkValues = _pkValuesCalculator.CalculatePK(individualResult.Time.Values, values.Values, pkCalculationOptions, allUserDefinedPKParameters);

                foreach (var quantityPKParameter in popAnalyses.AllPKParametersFor(selectedQuantity.Path))
                {
                    quantityPKParameter.SetValue(individualResult.IndividualId, pkValues.ValueOrDefaultFor(quantityPKParameter.Name));
                }
            }
        }
        protected override void Context()
        {
            base.Context();
            _pkParameter1 = new QuantityPKParameter {
                QuantityPath = "Output1", Name = "AUC"
            };
            _pkParameter1.SetValue(0, 10);
            _pkParameter1.SetValue(1, 11);
            _pkParameter1.SetValue(2, 12);
            _pkParameter1.SetValue(4, _defaultPK1Value);

            _pkParameter2 = new QuantityPKParameter {
                QuantityPath = "Output2", Name = "Cmax"
            };
            _pkParameter2.SetValue(0, 20);
            _pkParameter2.SetValue(1, 21);
            _pkParameter2.SetValue(2, 22);
            _pkParameter2.SetValue(3, 23);
            _pkParameter2.SetValue(4, _defaultPK2Value);

            _pkAnalyses.AddPKAnalysis(_pkParameter1);
            _pkAnalyses.AddPKAnalysis(_pkParameter2);

            _sensitivityParameter1 = A.Fake <SensitivityParameter>().WithName("SP1");
            A.CallTo(() => _sensitivityParameter1.DefaultValue).Returns(10);
            A.CallTo(() => _sensitivityParameter1.ParameterSelection.Path).Returns("SP1-PATH");

            _sensitivityParameter2 = A.Fake <SensitivityParameter>().WithName("SP2");
            A.CallTo(() => _sensitivityParameter2.DefaultValue).Returns(20);
            A.CallTo(() => _sensitivityParameter2.ParameterSelection.Path).Returns("SP2-PATH");

            _sensitivityAnalysis.AddSensitivityParameter(_sensitivityParameter1);
            _sensitivityAnalysis.AddSensitivityParameter(_sensitivityParameter2);

            var pv11 = new ParameterVariation(parameterName: _sensitivityParameter1.Name, parameterIndex: 0, variationId: 0, variation: new[] { 15d, 200d, 300d });
            var pv12 = new ParameterVariation(parameterName: _sensitivityParameter1.Name, parameterIndex: 0, variationId: 1, variation: new[] { 20d, 200d, 300d });
            var pv21 = new ParameterVariation(parameterName: _sensitivityParameter2.Name, parameterIndex: 1, variationId: 2, variation: new[] { 100d, 21d, 300d });
            var pv22 = new ParameterVariation(parameterName: _sensitivityParameter2.Name, parameterIndex: 1, variationId: 3, variation: new[] { 100d, 31d, 300d });

            _variationData.DefaultValues = new[] { 100d, 200d, 300d };
            _variationData.AddVariation(pv11);
            _variationData.AddVariation(pv12);
            _variationData.AddVariation(pv21);
            _variationData.AddVariation(pv22);

            _timeValues = new QuantityValues {
                QuantityPath = "Time", Values = new[] { 1, 2, 3, 4, 5f }
            };

            _resV11 = new IndividualResults {
                IndividualId = 0, Time = _timeValues
            };
            _resV11.Add(new QuantityValues {
                QuantityPath = "Output1", Values = new[] { 111.1f, 211.1f, 311.1f, 411.1f, 511.1f }
            });
            _resV11.Add(new QuantityValues {
                QuantityPath = "Output2", Values = new[] { 111.2f, 211.2f, 311.2f, 411.2f, 511.2f }
            });
            _resV11.UpdateQuantityTimeReference();

            _resV12 = new IndividualResults {
                IndividualId = 1, Time = _timeValues
            };
            _resV12.Add(new QuantityValues {
                QuantityPath = "Output1", Values = new[] { 112.1f, 212.1f, 312.1f, 412.1f, 512.1f }
            });
            _resV12.Add(new QuantityValues {
                QuantityPath = "Output2", Values = new[] { 112.2f, 212.2f, 312.2f, 412.2f, 512.2f }
            });
            _resV12.UpdateQuantityTimeReference();

            _resV21 = new IndividualResults {
                IndividualId = 2, Time = _timeValues
            };
            _resV21.Add(new QuantityValues {
                QuantityPath = "Output1", Values = new[] { 121.1f, 221.1f, 321.1f, 421.1f, 521.1f }
            });
            _resV21.Add(new QuantityValues {
                QuantityPath = "Output2", Values = new[] { 121.2f, 221.2f, 321.2f, 421.2f, 521.2f }
            });
            _resV21.UpdateQuantityTimeReference();

            _resV22 = new IndividualResults {
                IndividualId = 3, Time = _timeValues
            };
            _resV22.Add(new QuantityValues {
                QuantityPath = "Output1", Values = new[] { 122.1f, 222.1f, 322.1f, 422.1f, 522.1f }
            });
            _resV22.Add(new QuantityValues {
                QuantityPath = "Output2", Values = new[] { 122.2f, 222.2f, 322.2f, 422.2f, 522.2f }
            });
            _resV22.UpdateQuantityTimeReference();


            _simulationResults.Add(_resV11);
            _simulationResults.Add(_resV12);
            _simulationResults.Add(_resV21);
            _simulationResults.Add(_resV22);
        }