Exemplo n.º 1
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));
                }
            }
        }
 public void should_not_crash()
 {
     _results.AllPKParametersFor(_quantityPath1).Count.ShouldBeEqualTo(2);
 }
 public void should_have_created_one_pk_analyses_for_each_output_defined_in_the_simulation()
 {
     _results.AllPKParametersFor(_quantityPath1).Count.ShouldBeEqualTo(2);
     _results.AllPKParametersFor(_quantityPath2).Count.ShouldBeEqualTo(2);
 }