private void updateSelectionFromTemplate(Simulation simulation, OutputSelections templateOutputSelections) { var settings = simulation.OutputSelections; settings.Clear(); //Cache all quantities by path key var quantityCache = new Cache <string, List <IQuantity> >(); foreach (var quantity in simulation.All <IQuantity>()) { var key = _keyPathMapper.MapFrom(quantity); if (!quantityCache.Contains(key)) { quantityCache[key] = new List <IQuantity>(); } quantityCache[key].Add(quantity); } //find them from the template and select them foreach (var selectedQuantity in templateOutputSelections) { var key = _keyPathMapper.MapFrom(selectedQuantity); if (!quantityCache.Contains(key)) { continue; } var selectedQuantityType = selectedQuantity.QuantityType; //we only select quantity that have the exact same type quantityCache[key].Where(q => q.QuantityType == selectedQuantityType) .Each(q => settings.AddOutput(selectionFrom(q))); } }
protected override void Context() { base.Context(); _outputSelection = new OutputSelections(); A.CallTo(() => _populationSimulation.OutputSelections).Returns(_outputSelection); A.CallTo(() => _individual.Species).Returns(_mouse); }
private void addDefaultOutputsFor(Simulation simulation, Compound compound, OutputSelections outputSelections) { var individual = simulation.Individual; if (individual == null) { return; } //Default is peripheral venous blood plasma var observer = peripheralVenousBloodObserverFor(simulation, compound); if (speciesUsesVenousBlood(individual.Species)) { observer = venousBloodObservedFor(simulation, compound); } if (observer == null) { return; } var observedPath = _entityPathResolver.PathFor(observer); outputSelections.AddOutput(new QuantitySelection(observedPath, observer.QuantityType)); }
protected override void Context() { base.Context(); _outputSelections = new OutputSelections(); A.CallTo(() => _newSimulation.OutputSelections).Returns(_outputSelections); A.CallTo(() => _parameterIdentification.AllOutputMappingsFor(_oldSimulation)).Returns(_outputMappings); }
public SimulationSettings() { Icon = IconNames.SIMULATION_SETTINGS; RandomSeed = Environment.TickCount; _chartTemplates = new Cache <string, CurveChartTemplate>(x => x.Name, x => null); OutputSelections = new OutputSelections(); }
protected override void Context() { base.Context(); _simulation = A.Fake <ISimulation>(); _runResults = A.Fake <SimulationResults>(); var outputSelections = new OutputSelections(); outputSelections.AddOutput(new QuantitySelection("Liver|Cell|Drug|Concentration", QuantityType.Drug)); A.CallTo(() => _simulation.OutputSelections).Returns(outputSelections); var pKCalculationOptions = new PKCalculationOptions(); A.CallTo(_pkCalculationOptionsFactory).WithReturnType <PKCalculationOptions>().Returns(pKCalculationOptions); _p1 = new PKParameter().WithName("AUC"); _p1.Mode = PKParameterMode.Single; _p2 = new PKParameter().WithName("AUC" + Constants.PKParameters.NormSuffix); _p2.Mode = PKParameterMode.Single; A.CallTo(() => _pkParameterRepository.All()).Returns(new[] { _p1, _p2 }); var individualResults = A.Fake <IndividualResults>(); A.CallTo(() => _runResults.AllIndividualResults).Returns(new HashSet <IndividualResults>(new [] { individualResults })); var pKValues = new PKValues(); pKValues.AddValue(_p1.Name, 10f); pKValues.AddValue(_p2.Name, 20f); A.CallTo(_pkValuesCalculator).WithReturnType <PKValues>().Returns(pKValues); }
protected override void Context() { base.Context(); _simulation = A.Fake <ISimulation>(); _runResults = A.Fake <SimulationResults>(); var outputSelections = new OutputSelections(); outputSelections.AddOutput(new QuantitySelection("Liver|Cell|Drug|Concentration", QuantityType.Drug)); A.CallTo(() => _simulation.OutputSelections).Returns(outputSelections); var pKCalculationOptions = new PKCalculationOptions(); A.CallTo(_pkCalculationOptionsFactory).WithReturnType <PKCalculationOptions>().Returns(pKCalculationOptions); _p1 = new PKParameter { Name = "AUC", Mode = PKParameterMode.Single }; _userDefinedParameter1 = new UserDefinedPKParameter { Name = "Dynamic1", Mode = PKParameterMode.Single }; A.CallTo(() => _pkParameterRepository.All()).Returns(new[] { _p1, _userDefinedParameter1 }); var individualResults = A.Fake <IndividualResults>(); A.CallTo(() => _runResults.AllIndividualResults).Returns(new HashSet <IndividualResults>(new[] { individualResults })); var pKValues = new PKValues(); pKValues.AddValue(_p1.Name, 10f); pKValues.AddValue(_userDefinedParameter1.Name, 30f); A.CallTo(_pkValuesCalculator).WithReturnType <PKValues>().Returns(pKValues); }
private bool columnIsSelected(DataColumn column, OutputSelections outputSelections) { //skip the first entry that corresponds to the simulation name var columnPath = column.QuantityInfo.Path.Skip(1).ToPathString(); return(outputSelections.Any(x => string.Equals(x.Path, columnPath))); }
protected override void Context() { base.Context(); _defaultSettings = new OutputSelections(); _project.OutputSelections = _defaultSettings; A.CallTo(() => _populationSimulationSettingsPresenter.CreateSettings(_populationSimulation)).Returns(_originalSettings); }
public UpdateOutputSelectionInBuildingBlockCommand(OutputSelections outputSelections, ISimulationSettings buildingBlock) : base(buildingBlock) { _outputSelections = outputSelections; CommandType = AppConstants.Commands.EditCommand; ObjectType = ObjectTypes.OutputSelections; Description = AppConstants.Commands.UpdateOutputSelectionInSimulationDescription(buildingBlock.Name); }
protected override async Task Context() { await base.Context(); _newPopulationSettings = new OutputSelections(); _populationSimulation = A.Fake <PopulationSimulation>(); A.CallTo(() => _simulationSettingsRetriever.SettingsFor(_populationSimulation)).Returns(_newPopulationSettings); }
protected override void Context() { base.Context(); _newPopulationSettings = new OutputSelections(); _populationSimulation = A.Fake <PopulationSimulation>(); A.CallTo(() => _entityTask.Validate(_populationSimulation)).Returns(true); A.CallTo(() => _simulationSettingsRetriever.SettingsFor(_populationSimulation)).Returns(_newPopulationSettings); }
protected override void Context() { base.Context(); _settings = A.Fake <OutputSelections>(); A.CallTo(() => _settings.HasSelection).Returns(false); _simulation = A.Fake <IMoBiSimulation>(); A.CallTo(() => _outputSelectionsRetriever.OutputSelectionsFor(_simulation)).Returns(null); }
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(); _outputSelection = new OutputSelections(); _simulation = A.Fake <IMoBiSimulation>(); _presenter = A.Fake <IOutputSelectionsPresenter>(); A.CallTo(() => _presenter.StartSelection(_simulation)).Returns(_outputSelection); A.CallTo(() => _applicationController.Start <IOutputSelectionsPresenter>()).Returns(_presenter); }
protected override void Context() { _simulationPersistableUpdater = A.Fake <ISimulationPersistableUpdater>(); sut = new OutputSelectionUpdater(_simulationPersistableUpdater); _mappedOutputs = new List <QuantitySelection>(); _simulation = A.Fake <IModelCoreSimulation>(); _outputSelection = new OutputSelections(); _simulation.SimulationSettings.OutputSelections = _outputSelection; }
private void exportOutputDefiniton(OutputSelections outputSelections, string outputDeffinitionFileFullPath) { using (var sw = new StreamWriter(outputDeffinitionFileFullPath, false)) { // Add Simulation Name to paths for sim model outputSelections.AllOutputs.Each(sq => sw.WriteLine("{0}{1}", sq.Path, ';')); sw.Close(); } }
protected override void Context() { _populationSimulationSettingsPresenter = A.Fake <IPopulationSimulationSettingsPresenter>(); _applicationController = A.Fake <IApplicationController>(); _projectRetriever = A.Fake <IPKSimProjectRetriever>(); _simulationPersistableUpdater = A.Fake <ISimulationPersistableUpdater>(); _project = A.Fake <PKSimProject>(); _compound1 = A.Fake <Compound>(); _individual = A.Fake <Individual>(); _human = new Species().WithName(CoreConstants.Species.HUMAN); _rat = new Species().WithName(CoreConstants.Species.RAT); _mouse = new Species().WithName(CoreConstants.Species.MOUSE); A.CallTo(() => _individual.Species).Returns(_human); _populationSimulation = A.Fake <PopulationSimulation>(); A.CallTo(() => _populationSimulation.Compounds).Returns(new[] { _compound1 }); A.CallTo(() => _populationSimulation.Individual).Returns(_individual); _keyPathMapper = A.Fake <IKeyPathMapper>(); _entityPathResolver = A.Fake <IEntityPathResolver>(); _userSettings = A.Fake <ICoreUserSettings>(); _originalSettings = new OutputSelections(); A.CallTo(() => _populationSimulation.OutputSelections).Returns(_originalSettings); _populationSimulation.Model = new Model(); _populationSimulation.Model.Root = new Container(); _compound1.Name = "DRUG"; var organism = new Organism(); var peripheralVenousBlood = new Container().WithName(CoreConstants.Organ.PeripheralVenousBlood); var venousBlood = new Container().WithName(CoreConstants.Organ.VenousBlood); var venousBloodPlasma = new Container().WithName(CoreConstants.Compartment.Plasma).WithParentContainer(venousBlood); var drugPeripheralBlood = new Container().WithName(_compound1.Name); var drugVenousBlood = new Container().WithName(_compound1.Name); var periperhalVenousBloodObserver = new Observer { Name = CoreConstants.Observer.PLASMA_PERIPHERAL_VENOUS_BLOOD }; drugPeripheralBlood.Add(periperhalVenousBloodObserver); var venousBloodObserver = new Observer { Name = CoreConstants.Observer.CONCENTRATION }; drugVenousBlood.Add(venousBloodObserver); peripheralVenousBlood.Add(drugPeripheralBlood); venousBloodPlasma.Add(drugVenousBlood); organism.Add(peripheralVenousBlood); organism.Add(venousBlood); _populationSimulation.Model.Root.Add(organism); A.CallTo(() => _projectRetriever.Current).Returns(_project); A.CallTo(() => _applicationController.Start <ISimulationOutputSelectionPresenter <PopulationSimulation> >()).Returns(_populationSimulationSettingsPresenter); sut = new SimulationSettingsRetriever(_applicationController, _projectRetriever, _entityPathResolver, _keyPathMapper, _userSettings, _simulationPersistableUpdater); A.CallTo(() => _entityPathResolver.PathFor(periperhalVenousBloodObserver)).Returns("PERIPHERAL_OBSERVER"); A.CallTo(() => _entityPathResolver.PathFor(venousBloodObserver)).Returns("VENOUS_BLOOD_OBSERVER"); }
private OutputSelections createOutputSelectionWithAllMoleculeAmountSelected() { var outputSelection = new OutputSelections(); foreach (var keyValue in _allMoleculeAmounts.KeyValues) { outputSelection.AddOutput(new QuantitySelection(keyValue.Key, keyValue.Value.QuantityType)); } return(outputSelection); }
private void updateOutputSelectionInSimulation(IMoBiSimulation simulation, OutputSelections outputSelections) { if (!outputSelections.DiffersFrom(simulation.OutputSelections)) { return; } //they are different. Issue an update command addCommand(new UpdateOutputSelectionsInSimulationCommand(outputSelections, simulation).Run(_context)); }
protected override void Context() { base.Context(); _project = A.Fake <IPKSimProject>(); _templateSettings = A.Fake <OutputSelections>(); A.CallTo(() => _editedSettings.Clone()).Returns(_templateSettings); sut.CreateSettings(_populationSimulation); A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project); }
protected override void Context() { base.Context(); _cloner = A.Fake <ICloneManager>(); _output1 = new QuantitySelection("A", QuantityType.Drug); _output2 = new QuantitySelection("B", QuantityType.Complex); sut.AddOutput(_output1); _newOutputSelection = new OutputSelections(); _newOutputSelection.AddOutput(_output2); }
protected override void Context() { base.Context(); _outputSelections = new OutputSelections(); _outputSelections.AddOutput(new QuantitySelection("A", QuantityType.Drug)); _newOutputSelection = new OutputSelections(); _newOutputSelection.AddOutput(new QuantitySelection("B", QuantityType.Drug)); _simulation = A.Fake <IMoBiSimulation>(); A.CallTo(() => _simulation.OutputSelections).Returns(_outputSelections); A.CallTo(() => _outputSelectionsRetriever.OutputSelectionsFor(_simulation)).Returns(_newOutputSelection); }
private void updatePersitable(PathCache <IQuantity> allQuantities, OutputSelections outputSelections) { SetPersistable(allQuantities, false); foreach (var selectedQuantity in outputSelections) { var quantity = allQuantities[selectedQuantity.Path]; if (quantity != null) { quantity.Persistable = true; } } }
protected override void Context() { base.Context(); _outputSelections = new OutputSelections(); _simulation = A.Fake <IMoBiSimulation>(); _p1 = new Parameter { Persistable = true }; A.CallTo(() => _entityPathResolver.PathFor(_p1)).Returns("PARAMETER"); _simulation.Model.Root = new Container { _p1 }; A.CallTo(() => _simulation.OutputSelections).Returns(_outputSelections); }
public OutputSelections StartSelection(IMoBiSimulation simulation) { _simulation = simulation; _editedSelection = defaultSettingsFrom(simulation); _quantitySelectionPresenter.Edit(_simulationPersistableUpdater.AllSelectableIn(_simulation), _editedSelection.AllOutputs); refreshView(); _view.Display(); if (_view.Canceled) { return(null); } updateSettingsFromSelection(); return(_editedSelection); }
public OutputSelections CreateSettings(TSimulation simulation) { _simulation = simulation; setupSelectionPresenter(); _editedOutputSelections = DefaultSettingsFrom(simulation); _simulationPersistableUpdater.ResetPersistable(_simulation); _quantitySelectionPresenter.Edit(_simulation.Model.Root, _editedOutputSelections.AllOutputs); RefreshView(); _view.Display(); if (_view.Canceled) return null; updateSettingsFromSelection(); return _editedOutputSelections; }
protected override void Context() { _dataFactory = A.Fake <IDataRepositoryTask>(); _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 } }); _outputSelection = new OutputSelections(); _outputSelection.AddOutput(new QuantitySelection(new[] { "LIVER", "C" }.ToPathString(), QuantityType.Molecule)); _simulation.SimulationSettings = new SimulationSettings(); _simulation.SimulationSettings.OutputSelections = _outputSelection; }
protected override void Context() { base.Context(); _defaultSettings = new OutputSelections(); _allQuantities = new List <IQuantity>(); var moleculeSelection1 = new QuantitySelection("PATH1", QuantityType.Drug); _defaultSettings.AddOutput(moleculeSelection1); _allQuantities.Add(q1); q1.QuantityType = QuantityType.Drug; A.CallTo(() => _keyPathMapper.MapFrom(q1)).Returns("KEY1"); A.CallTo(() => _keyPathMapper.MapFrom(moleculeSelection1)).Returns("KEY2"); _project.OutputSelections = _defaultSettings; A.CallTo(() => _populationSimulationSettingsPresenter.CreateSettings(_populationSimulation)).Returns(_originalSettings); A.CallTo(() => _populationSimulation.All <IQuantity>()).Returns(_allQuantities); }
protected override Task Context() { _entitiesInContainerRetriever = A.Fake <IEntitiesInContainerRetriever>(); _logger = A.Fake <IOSPSuiteLogger>(); sut = new OutputSelectionsMapper(_entitiesInContainerRetriever, _logger); _quantitySelection1 = new QuantitySelection("PATH1", QuantityType.Drug); _quantitySelection2 = new QuantitySelection("PATH2", QuantityType.Observer); _outputSelections = new OutputSelections(); _outputSelections.AddOutput(_quantitySelection1); _outputSelections.AddOutput(_quantitySelection2); _simulation = new IndividualSimulation(); _allQuantities = new PathCacheForSpecs <IQuantity>(); A.CallTo(() => _entitiesInContainerRetriever.QuantitiesFrom(_simulation)).Returns(_allQuantities); return(Task.FromResult(true)); }