Exemple #1
0
        protected override void Context()
        {
            base.Context();
            _quantityValue1 = new QuantityValues {
                QuantityPath = "Path1"
            };
            _quantityValue2 = new QuantityValues {
                QuantityPath = "Path1"
            };
            _anotherQuantityValue = new QuantityValues {
                QuantityPath = "Path2"
            };

            var individualResults1 = new IndividualResults {
                IndividualId = 3
            };

            individualResults1.Add(_quantityValue1);
            individualResults1.Add(_anotherQuantityValue);

            var individualResults2 = new IndividualResults {
                IndividualId = 2
            };

            individualResults2.Add(_quantityValue2);

            sut.Add(individualResults1);
            sut.Add(individualResults2);

            //reorder results before accessing them
            sut.ReorderByIndividualId();
        }
Exemple #2
0
        protected override void Context()
        {
            base.Context();
            _newName = "TOTO";
            _f1      = new ExplicitFormula("A+B");
            _f2      = new ExplicitFormula("A+B");
            _f3      = new ExplicitFormula("A+B");
            _f1.AddObjectPath(new FormulaUsablePath(_initialSimulationName, "Liver", "Cell"));
            _f1.AddObjectPath(new FormulaUsablePath("Drug", "LogP"));
            _f2.AddObjectPath(new FormulaUsablePath("SU", "Liver", "Cell"));
            _f2.AddObjectPath(new FormulaUsablePath("Drug", "LogP"));
            _f3.AddObjectPath(new FormulaUsablePath(_initialSimulationName, "Liver", "Cell"));
            _f3.AddObjectPath(new FormulaUsablePath(_initialSimulationName, "LogP"));

            var p1 = new PKSimParameter().WithName("P1").WithFormula(_f1);
            var p2 = new PKSimParameter().WithName("P2").WithFormula(_f2);
            var p3 = new PKSimParameter().WithName("P3").WithFormula(_f3);
            var c1 = new Container().WithName("C1");

            c1.Add(p3);
            _root.Add(p1);
            _root.Add(p2);
            _root.Add(c1);

            var results = new SimulationResults {
                Time = new QuantityValues {
                    ColumnId = "0", QuantityPath = "baseGrid"
                }
            };

            _individualResults = new IndividualResults {
                IndividualId = 1
            };
            results.Add(_individualResults);

            var quantityCache = new PathCacheForSpecs <IQuantity>
            {
                { "Liver|Cell|Drug", new MoleculeAmount {
                      QuantityType = QuantityType.Drug
                  } },
                { "Liver|Cell|Meta", new MoleculeAmount {
                      QuantityType = QuantityType.Metabolite
                  } },
            };

            _individualResults.Add(new QuantityValues {
                PathList = new[] { "Liver", "Cell", "Drug" }.ToList()
            });
            _individualResults.Add(new QuantityValues {
                PathList = new[] { "Liver", "Cell", "Meta" }.ToList()
            });

            _individualSimulation.Results            = results;
            _individualSimulation.DataRepository     = new DataRepository();
            _individualSimulation.Reactions          = new ReactionBuildingBlock();
            _individualSimulation.SimulationSettings = new SimulationSettings();
            A.CallTo(_containerTask).WithReturnType <PathCache <IQuantity> >().Returns(quantityCache);

            A.CallTo(() => _curveNamer.RenameCurvesWithOriginalNames(_individualSimulation, A <Action> ._, true)).Invokes(x => x.Arguments[1].DowncastTo <Action>()());
        }
Exemple #3
0
        protected override void Context()
        {
            _dataFactory         = A.Fake <IDataFactory>();
            _dimensionRepository = A.Fake <IDimensionRepository>();
            sut = new DataRepositoryFromResultsCreator(_dimensionRepository, new ObjectPathFactoryForSpecs(), _dataFactory);

            _simulation       = new IndividualSimulation().WithName("S");
            _simulation.Model = new OSPSuite.Core.Domain.Model();
            var root = new Container().WithContainerType(ContainerType.Simulation).WithName(_simulation.Name);

            _simulation.Model.Root = root;
            var liver = new Container().WithName("LIVER");

            liver.Add(new Observer().WithName("C"));
            var kidney = new Container().WithName("KIDNEY");

            kidney.Add(new Observer().WithName("C"));
            root.Add(liver);
            root.Add(kidney);

            _simulationResults  = new SimulationResults();
            _simulation.Results = _simulationResults;
            _timeValues         = new QuantityValues {
                QuantityPath = "Time", Values = new[] { 1f, 2f, 3f }
            };
            _simulationResults.Time = _timeValues;

            _individualResults = new IndividualResults();
            _individualResults.Add(new QuantityValues {
                QuantityPath = "LIVER|C", Time = _timeValues, Values = new[] { 10f, 20f, 30f }
            });
            _individualResults.Add(new QuantityValues {
                QuantityPath = "KIDNEY|C", Time = _timeValues, Values = new[] { 11f, 22f, 33f }
            });
        }
        protected override void Context()
        {
            _lazyLoadTask                = A.Fake <ILazyLoadTask>();
            _pkValuesCalculator          = A.Fake <IPKValuesCalculator>();
            _pkParameterRepository       = A.Fake <IPKParameterRepository>();
            _pkCalculationOptionsFactory = A.Fake <IPKCalculationOptionsFactory>();
            _entityPathResolver          = A.Fake <IEntityPathResolver>();
            _pkMapper            = A.Fake <IPKValuesToPKAnalysisMapper>();
            _dimensionRepository = A.Fake <IDimensionRepository>();
            sut = new PKAnalysesTask(_lazyLoadTask, _pkValuesCalculator, _pkParameterRepository, _pkCalculationOptionsFactory, _entityPathResolver, _pkMapper, _dimensionRepository);

            _populationSimulation = A.Fake <PopulationSimulation>();
            _outputSelections     = new OutputSelections();
            A.CallTo(() => _populationSimulation.OutputSelections).Returns(_outputSelections);
            _allBodyWeights = new List <double>();
            _bodyWeight     = A.Fake <IParameter>();
            var bodyWeightPath = "PATH";

            A.CallTo(() => _populationSimulation.BodyWeight).Returns(_bodyWeight);
            A.CallTo(() => _entityPathResolver.PathFor(_bodyWeight)).Returns(bodyWeightPath);
            A.CallTo(() => _populationSimulation.AllValuesFor(bodyWeightPath)).Returns(_allBodyWeights);
            A.CallTo(() => _populationSimulation.NumberOfItems).Returns(2);
            _individualResult0 = new IndividualResults {
                IndividualId = 0, Time = new QuantityValues {
                    Values = new[] { 1f, 2f }
                }
            };
            _individualResult0.Add(new QuantityValues {
                QuantityPath = _quantityPath1, Values = new[] { 10f, 20f }
            });
            _individualResult0.Add(new QuantityValues {
                QuantityPath = _quantityPath2, Values = new[] { 11f, 21f }
            });
            _individualResult1 = new IndividualResults {
                IndividualId = 1, Time = new QuantityValues {
                    Values = new[] { 3f, 4f }
                }
            };
            _individualResult1.Add(new QuantityValues {
                QuantityPath = _quantityPath1, Values = new[] { 30f, 40f }
            });
            _individualResult1.Add(new QuantityValues {
                QuantityPath = _quantityPath2, Values = new[] { 31f, 41f }
            });
            _simulationResults = new SimulationResults {
                _individualResult0, _individualResult1
            };
            _populationSimulation.Results = _simulationResults;

            _pkParameter1 = new PKParameter {
                Mode = PKParameterMode.Always, Name = "Cmax"
            };
            _pkParameter2 = new PKParameter {
                Mode = PKParameterMode.Always, Name = "tMax"
            };

            A.CallTo(() => _pkParameterRepository.All()).Returns(new[] { _pkParameter1, _pkParameter2 });
        }
        protected override void Context()
        {
            base.Context();
            _newName = "TOTO";
            _f1      = new ExplicitFormula("A+B");
            _f2      = new ExplicitFormula("A+B");
            _f3      = new ExplicitFormula("A+B");
            _f1.AddObjectPath(new FormulaUsablePath(_initialSimulationName, "Liver", "Cell"));
            _f1.AddObjectPath(new FormulaUsablePath("Drug", "LogP"));
            _f2.AddObjectPath(new FormulaUsablePath("SU", "Liver", "Cell"));
            _f2.AddObjectPath(new FormulaUsablePath("Drug", "LogP"));
            _f3.AddObjectPath(new FormulaUsablePath(_initialSimulationName, "Liver", "Cell"));
            _f3.AddObjectPath(new FormulaUsablePath(_initialSimulationName, "LogP"));

            var p1 = new PKSimParameter().WithName("P1").WithFormula(_f1);
            var p2 = new PKSimParameter().WithName("P2").WithFormula(_f2);
            var p3 = new PKSimParameter().WithName("P3").WithFormula(_f3);
            var c1 = new Container().WithName("C1");

            c1.Add(p3);
            _root.Add(p1);
            _root.Add(p2);
            _root.Add(c1);

            var results = new SimulationResults {
                Time = new QuantityValues {
                    ColumnId = "0", QuantityPath = "baseGrid"
                }
            };

            _individualResults = new IndividualResults {
                IndividualId = 1
            };
            results.Add(_individualResults);

            var quantityCache = new PathCacheForSpecs <IQuantity>
            {
                { "Liver|Cell|Drug", new MoleculeAmount {
                      QuantityType = QuantityType.Drug
                  } },
                { "Liver|Cell|Meta", new MoleculeAmount {
                      QuantityType = QuantityType.Metabolite
                  } },
            };

            _individualResults.Add(new QuantityValues {
                PathList = new[] { "Liver", "Cell", "Drug" }.ToList()
            });
            _individualResults.Add(new QuantityValues {
                PathList = new[] { "Liver", "Cell", "Meta" }.ToList()
            });

            _individualSimulation.Results = results;
            A.CallTo(_containerTask).WithReturnType <PathCache <IQuantity> >().Returns(quantityCache);
        }
Exemple #6
0
        public SimulationResults CreateResultsFrom(DataRepository dataRepository)
        {
            if (dataRepository.IsNull())
            {
                return(new NullSimulationResults());
            }

            var results  = new SimulationResults();
            var baseGrid = dataRepository.BaseGrid;

            results.Time = valuesFrom(baseGrid);
            foreach (var columnsForIndividual in dataRepository.AllButBaseGrid().GroupBy(selectIndividualIndex))
            {
                var individualResults = new IndividualResults {
                    IndividualId = columnsForIndividual.Key, Time = results.Time
                };
                foreach (var dataColumn in columnsForIndividual)
                {
                    individualResults.Add(valuesFrom(dataColumn, pathWithoutIndividualIndex(dataColumn, columnsForIndividual.Key)));
                }
                individualResults.UpdateQuantityTimeReference();
                results.Add(individualResults);
            }
            return(results);
        }
Exemple #7
0
        protected override void Context()
        {
            base.Context();
            var quantityValue1 = new QuantityValues {
                QuantityPath = "Path1"
            };
            var quantityValue2 = new QuantityValues {
                QuantityPath = "Path1"
            };

            var individualResults1 = new IndividualResults {
                IndividualId = 1
            };

            individualResults1.Add(quantityValue1);

            var individualResults2 = new IndividualResults {
                IndividualId = 2
            };

            individualResults2.Add(quantityValue2);

            sut.Time = new QuantityValues {
                QuantityPath = "Time"
            };
            individualResults1.Time = sut.Time;
            individualResults2.Time = sut.Time;
            sut.AddRange(new[] { individualResults1, individualResults2 });
        }
        private SimulationResults createResultsFrom(DataRepository dataRepository, ISimModelBatch simModel, string[] parameters)
        {
            if (dataRepository.IsNull() || dataRepository.BaseGrid == null)
            {
                return(new NullSimulationResults());
            }

            var results = new SimulationResults {
                Time = valuesFrom(dataRepository.BaseGrid, null, new string[] { })
            };

            foreach (var columnsForIndividual in dataRepository.AllButBaseGrid().GroupBy(selectIndividualIndex))
            {
                var individualResults = new IndividualResults {
                    IndividualId = columnsForIndividual.Key, Time = results.Time
                };
                foreach (var dataColumn in columnsForIndividual)
                {
                    individualResults.Add(valuesFrom(dataColumn, pathWithoutIndividualIndex(dataColumn, columnsForIndividual.Key), simModel, parameters));
                }

                individualResults.UpdateQuantityTimeReference();
                results.Add(individualResults);
            }

            return(results);
        }
Exemple #9
0
        protected override void Context()
        {
            base.Context();
            _quantityValue1 = new QuantityValues {
                QuantityPath = "Path1"
            };
            _quantityValue2 = new QuantityValues {
                QuantityPath = "Path2"
            };

            var individualResults1 = new IndividualResults {
                IndividualId = 1
            };

            individualResults1.Add(_quantityValue1);
            individualResults1.Add(_quantityValue2);

            sut.Add(individualResults1);
        }
Exemple #10
0
        private static IndividualResults newIndividualResults(int indIndex, int numberOfPaths, int numberOfPoints)
        {
            var ind = new IndividualResults {
                IndividualId = indIndex
            };

            for (int i = 0; i < numberOfPaths; i++)
            {
                ind.Add(createValuesArray(i, numberOfPoints));
            }
            return(ind);
        }
        private QuantityValues quantityPathFor(IndividualResults individualResult, string path, Cache <QuantityValues, List <float> > cacheQuantitiesValues)
        {
            var quantity = individualResult.ValuesFor(path);

            if (quantity == null)
            {
                quantity = new QuantityValues {
                    QuantityPath = path
                };
                cacheQuantitiesValues.Add(quantity, new List <float>());
                individualResult.Add(quantity);
            }
            return(quantity);
        }
Exemple #12
0
        protected override void Context()
        {
            base.Context();
            var results = new SimulationResults {
                Time = new QuantityValues {
                    ColumnId = "0", QuantityPath = "baseGrid"
                }
            };

            _individualResults = new IndividualResults {
                IndividualId = 1
            };
            results.Add(_individualResults);

            _quantityCache = new PathCacheForSpecs <IQuantity>
            {
                { "C|Liver|Cell|C2", new MoleculeAmount {
                      QuantityType = QuantityType.Drug
                  } },
                { "C|Liver|Cell|Meta", new MoleculeAmount {
                      QuantityType = QuantityType.Metabolite
                  } }
            };

            _individualResults.Add(new QuantityValues {
                ColumnId = "1", PathList = new[] { "C", "Liver", "Cell", "C" }.ToList()
            });
            _individualResults.Add(new QuantityValues {
                ColumnId = "3", PathList = new[] { "C", "Liver", "Cell", "Meta" }.ToList()
            });
            _individualResults.Add(new QuantityValues {
                ColumnId = "4", PathList = new[] { "S", "Liver", "Cell" }.ToList()
            });

            A.CallTo(_containerTask).WithReturnType <PathCache <IQuantity> >().Returns(_quantityCache);
            _individualSimulation.Results = results;
        }
Exemple #13
0
        protected override void Context()
        {
            base.Context();
            _quantityValue1 = new QuantityValues {
                QuantityPath = "Path1", Values = new [] { 1f, 2f, 3f }
            };
            _quantityValue2 = new QuantityValues {
                QuantityPath = "Path1", Values = new[] { 4f, 5f, 6f }
            };
            _anotherQuantityValue = new QuantityValues {
                QuantityPath = "Path2", Values = new[] { 7f, 8f, 9f }
            };
            _timeValues = new QuantityValues {
                QuantityPath = "Time", Values = new[] { 10f, 20f, 30f }
            };

            var individualResults1 = new IndividualResults {
                IndividualId = 3
            };

            individualResults1.Add(_quantityValue1);
            individualResults1.Add(_anotherQuantityValue);

            var individualResults2 = new IndividualResults {
                IndividualId = 2
            };

            individualResults2.Add(_quantityValue2);

            sut.Add(individualResults1);
            sut.Add(individualResults2);
            sut.Time = _timeValues;

            //reorder results before accessing them
            sut.ReorderByIndividualId();
        }
Exemple #14
0
        /// <summary>
        ///    Get Results from SimModel
        /// </summary>
        /// <param name="simulation">SimModel simulation</param>
        /// <param name="individualId">Individual id</param>
        private IndividualResults individualResultsFrom(SimModelNET.ISimulation simulation, int individualId)
        {
            var results = new IndividualResults {
                IndividualId = individualId
            };
            var simulationTimes       = simulation.SimulationTimes;
            var simulationTimesLength = simulationTimes.Length;

            foreach (var result in simulation.AllValues)
            {
                //Add quantity name and remove simulation name
                var quantityPath = _objectPathFactory.CreateObjectPathFrom(result.Path.ToPathArray());
                quantityPath.Remove(_simulationName);
                results.Add(quantityValuesFor(quantityPath.ToString(), result, simulationTimesLength));
            }

            results.Time = quantityValuesFor(Constants.TIME, simulation.SimulationTimes);
            return(results);
        }
        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);
        }