public void should_return_the_expected_path_values() { var sut = new PopulationSimulationPKAnalyses(); sut.AddPKAnalysis(createPKAnalyses("Path1")); sut.AddPKAnalysis(createPKAnalyses("Path2")); sut.AllQuantityPaths.ShouldOnlyContain("Path1", "Path2"); }
protected override void Context() { base.Context(); _quantityPKParameter1 = new QuantityPKParameter { QuantityPath = "Path1", Name = "AUC" }; _quantityPKParameter2 = new QuantityPKParameter { QuantityPath = "Path1", Name = "C_max" }; _pop_pk = new PopulationSimulationPKAnalyses(); _pop_pk.AddPKAnalysis(_quantityPKParameter1); _pop_pk.AddPKAnalysis(_quantityPKParameter2); }
private void addPKParametersForOutput(ISimulation simulation, int numberOfIndividuals, SimulationResults runResults, Action <int> performIndividualScalingAction, QuantitySelection selectedQuantity, PopulationSimulationPKAnalyses popAnalyses, string moleculeName, PKCalculationOptions pkCalculationOptions, IReadOnlyList <PKCalculationOptionsFactory.ApplicationParameters> allApplicationParameters) { var availablePKParameters = _pkParameterRepository.All().Where(p => PKParameterCanBeUsed(p, pkCalculationOptions)).ToList(); //create pk parameter for each quantities foreach (var pkParameter in availablePKParameters) { var quantityPKParameter = new QuantityPKParameter { Name = pkParameter.Name, QuantityPath = selectedQuantity.Path, Dimension = pkParameter.Dimension }; quantityPKParameter.SetNumberOfIndividuals(numberOfIndividuals); popAnalyses.AddPKAnalysis(quantityPKParameter); } //add the values for each individual foreach (var individualResult in runResults.AllIndividualResults) { performIndividualScalingAction(individualResult.IndividualId); _pkCalculationOptionsFactory.UpdateAppliedDose(simulation, moleculeName, pkCalculationOptions, allApplicationParameters); var values = individualResult.ValuesFor(selectedQuantity.Path); var pkValues = _pkValuesCalculator.CalculatePK(individualResult.Time.Values, values.Values, pkCalculationOptions); foreach (var pkParameter in availablePKParameters) { var quantityPKParameter = popAnalyses.PKParameterFor(selectedQuantity.Path, pkParameter.Name); quantityPKParameter.SetValue(individualResult.IndividualId, pkValues.ValueOrDefaultFor(pkParameter.Name)); } } }
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); }
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); }
public void TestSerializationPopulationSimulationPKAnalyses() { var x1 = new PopulationSimulationPKAnalyses(); x1.AddPKAnalysis(createPKAnalyses("Path1")); x1.AddPKAnalysis(createPKAnalyses("Path2")); x1.AddPKAnalysis(createPKAnalyses("Path3")); x1.AddPKAnalysis(createPKAnalyses("Path4")); x1.AddPKAnalysis(createPKAnalyses("Path5")); var x2 = SerializeAndDeserialize(x1); x2.ShouldNotBeNull(); x2.All().Count().ShouldBeEqualTo(5); x2.PKParameterFor("Path1", "AUC").Count.ShouldBeEqualTo(_numberOfIndividuals); }
public PopulationSimulationPKAnalyses ImportPKAnalysesFromCSV(string fileName, IModelCoreSimulation simulation) { var pkSimulationImport = _simulationPKParametersImportTask.ImportPKParameters(fileName, simulation, CancellationToken.None).Result; pkSimulationImport.ThrowOnError(); _logger.Log(pkSimulationImport); var simulationPKAnalyses = new PopulationSimulationPKAnalyses(); pkSimulationImport.PKParameters.Each(x => simulationPKAnalyses.AddPKAnalysis(x)); return(simulationPKAnalyses); }
public void Visit(PopulationSimulationPKAnalyses populationSimulationPKAnalyses) { var allQuantityPKAnalysis = populationSimulationPKAnalyses.All().ToList(); populationSimulationPKAnalyses.Clear(); allQuantityPKAnalysis.Each(x => { x.Name = ConvertPKParameterName(x.Name); populationSimulationPKAnalyses.AddPKAnalysis(x); }); _converted = true; }
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)); } } }