private void updateMoleculeOntogeny(IndividualMolecule molecule, Ontogeny ontogeny, Population population, IReadOnlyList <double> allAges, IReadOnlyList <double> allGAs) { var ontogenyFactorPath = _entityPathResolver.PathFor(molecule.OntogenyFactorParameter); var ontogenyFactorGIPath = _entityPathResolver.PathFor(molecule.OntogenyFactorGIParameter); molecule.Ontogeny = ontogeny; clearOntogenyFor(ontogenyFactorPath, ontogenyFactorGIPath, population); if (ontogeny.IsUndefined()) { return; } var ontogenyFactors = new ParameterValues(ontogenyFactorPath); var ontogenyFactorsGI = new ParameterValues(ontogenyFactorGIPath); for (int i = 0; i < population.NumberOfItems; i++) { var age = allAges[i]; var ga = allGAs[i]; ontogenyFactors.Add(_ontogenyRepository.OntogenyFactorFor(ontogeny, CoreConstants.Groups.ONTOGENY_LIVER, age, ga, population.RandomGenerator)); ontogenyFactorsGI.Add(_ontogenyRepository.OntogenyFactorFor(ontogeny, CoreConstants.Groups.ONTOGENY_DUODENUM, age, ga, population.RandomGenerator)); } population.IndividualPropertiesCache.Add(ontogenyFactors); population.IndividualPropertiesCache.Add(ontogenyFactorsGI); }
private DistributedParameterValue distributedOntogenyFactorFor(Ontogeny ontogeny, string moleculeName, OriginData originData, string parameterName, string ontogenyLocation) { var parameterPath = new ObjectPath { moleculeName, parameterName }; var(mean, std, distributionType) = _ontogenyRepository.OntogenyParameterDistributionFor(ontogeny, originData, ontogenyLocation); return(new DistributedParameterValue(parameterPath, mean, CoreConstants.DEFAULT_PERCENTILE, mean, std, distributionType)); }
private ParameterValue ontogenyFactorFor(Ontogeny ontogeny, string moleculeName, OriginData originData, string parameterName, string ontogenyLocation) { var path = new ObjectPath { moleculeName, parameterName }; double factor = _ontogenyRepository.OntogenyFactorFor(ontogeny, ontogenyLocation, originData); return(new ParameterValue(path, factor, CoreConstants.DEFAULT_PERCENTILE)); }
protected override void Context() { base.Context(); _selectedOntogeny = new DatabaseOntogeny(); _individual = A.Fake <Individual>(); _protein = A.Fake <IndividualProtein>(); _command = A.Fake <IPKSimCommand>(); A.CallTo(() => _ontogenyTask.SetOntogenyForMolecule(_protein, _selectedOntogeny, _individual)).Returns(_command); sut.Edit(_protein, _individual); }
protected override void Context() { base.Context(); CYP3A4 = sut.All().FindByName("CYP3A4"); _originData = new OriginData { Species = new Species { Name = CoreConstants.Species.HUMAN } }; }
protected override void Context() { base.Context(); _cloneManager = A.Fake <ICloneManager>(); _sourceMolecule = new IndividualEnzyme { Ontogeny = new UserDefinedOntogeny() }; _clonedOntogeny = new UserDefinedOntogeny(); A.CallTo(() => _cloneManager.Clone(_sourceMolecule.Ontogeny)).Returns(_clonedOntogeny); }
protected override void Context() { base.Context(); CYP3A4 = sut.All().FindByName("CYP3A4"); _randomGenerator = new RandomGenerator(); _originData = new OriginData { Species = new Species { Name = CoreConstants.Species.Human } }; }
protected override void Context() { base.Context(); _individual = A.Fake <Individual>(); _onto1 = new DatabaseOntogeny(); _onto2 = new DatabaseOntogeny(); _allOntogenies.AddRange(new[] { _onto1, _onto2 }); sut.Edit(new IndividualEnzyme { Ontogeny = _onto1 }, _individual); }
public void Show(Ontogeny ontogeny) { _speciesName = ontogeny.SpeciesName; _ontogeny = ontogeny; _dto = new ShowOntogenyDataDTO { SelectedOntogeny = ontogeny }; updateAvailableContainerForOntogeny(); _view.BindTo(_dto); updateChart(); _view.Display(); }
public void ShowOntogenyData(Ontogeny ontogeny) { if (ontogeny.IsUndefined()) { return; } using (var presenter = _applicationController.Start <IShowOntogenyDataPresenter>()) { presenter.Show(ontogeny); } }
protected override void Context() { _individual = new Individual(); _individual.OriginData = new OriginData(); _individual.OriginData.Species = new Species().WithName("Human"); _ontogeny = new DatabaseOntogeny { Name = "toto" }; _molecule = new IndividualEnzyme { Name = "CYP3A4" }; _executionContext = A.Fake <IExecutionContext>(); _proteinExpressionPresenter = A.Fake <IProteinExpressionsPresenter>(); _simpleMoleculePresenter = A.Fake <ISimpleMoleculePresenter>(); _querySettingsMapper = A.Fake <IMoleculeToQueryExpressionSettingsMapper>(); _applicationController = A.Fake <IApplicationController>(); _individualMoleculeFactoryResolver = A.Fake <IIndividualMoleculeFactoryResolver>(); _transportContainerUpdater = A.Fake <ITransportContainerUpdater>(); _containerTask = A.Fake <IContainerTask>(); _moleculeParameterRepository = A.Fake <IMoleculeParameterRepository>(); _proteinExpressionDbPathManager = A.Fake <IProteinExpressionsDatabasePathManager>(); A.CallTo(() => _applicationController.Start <IProteinExpressionsPresenter>()).Returns(_proteinExpressionPresenter); A.CallTo(() => _applicationController.Start <ISimpleMoleculePresenter>()).Returns(_simpleMoleculePresenter); _ontogenyRepository = A.Fake <IOntogenyRepository>(); var proteinFactory = A.Fake <IIndividualMoleculeFactory>(); _moleculeContainer1 = new MoleculeExpressionContainer().WithName("C1"); _moleculeContainer1.Add(DomainHelperForSpecs.ConstantParameterWithValue(5).WithName(CoreConstants.Parameter.RelExp)); _moleculeContainer1.Add(DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(CoreConstants.Parameter.RelExpNorm)); _moleculeContainer2 = new MoleculeExpressionContainer().WithName("C2"); _moleculeContainer2.Add(DomainHelperForSpecs.ConstantParameterWithValue(5).WithName(CoreConstants.Parameter.RelExp)); _moleculeContainer2.Add(DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(CoreConstants.Parameter.RelExpNorm)); A.CallTo(() => _individualMoleculeFactoryResolver.FactoryFor <IndividualProtein>()).Returns(proteinFactory); A.CallTo(() => proteinFactory.CreateFor(_individual)).Returns(_molecule); _molecule.Add(_moleculeContainer1); _molecule.Add(_moleculeContainer2); _molecule.Add(DomainHelperForSpecs.ConstantParameterWithValue(10).WithName(CoreConstants.Parameter.REFERENCE_CONCENTRATION)); _molecule.Add(DomainHelperForSpecs.ConstantParameterWithValue(20).WithName(CoreConstants.Parameter.HALF_LIFE_LIVER)); _molecule.Add(DomainHelperForSpecs.ConstantParameterWithValue(30).WithName(CoreConstants.Parameter.HALF_LIFE_INTESTINE)); A.CallTo(() => _ontogenyRepository.AllFor(_individual.Species.Name)).Returns(new[] { _ontogeny, new DatabaseOntogeny { Name = "tralala" }, }); A.CallTo(() => _executionContext.Resolve <IOntogenyRepository>()).Returns(_ontogenyRepository); _subjectExpressionTask = new IndividualExpressionTask(_executionContext); _ontogenyTask = A.Fake <IOntogenyTask <Individual> >(); sut = new MoleculeExpressionTask <Individual>(_applicationController, _executionContext, _individualMoleculeFactoryResolver, _querySettingsMapper, _containerTask, _proteinExpressionDbPathManager, _ontogenyRepository, _transportContainerUpdater, _moleculeParameterRepository, _subjectExpressionTask, _ontogenyTask); }
protected override void Context() { _molecule = new IndividualEnzyme { DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.ONTOGENY_FACTOR), DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.ONTOGENY_FACTOR_GI) }; _ontogeny = new DatabaseOntogeny(); _ontogenyRepository = A.Fake <IOntogenyRepository>(); _entityPathResolver = new EntityPathResolverForSpecs(); sut = new MoleculeOntogenyVariabilityUpdater(_ontogenyRepository, _entityPathResolver); }
protected override void Context() { base.Context(); _ontogeny = new DatabaseOntogeny { SpeciesName = "Dog", Name = "UD6" }; _originData = new OriginData { Species = new Species { Name = "Dog" } }; A.CallTo(() => _ontogenyRepository.AllFor(_originData.Species.Name)).Returns(new[] { _ontogeny }); _moleculeNames.Add(new MoleculeOntogeny("CYP", "CYP3A4")); }
protected override void Context() { _view = A.Fake <IShowOntogenyDataView>(); _ontogenyRepository = A.Fake <IOntogenyRepository>(); _simpleChartPresenter = A.Fake <ISimpleChartPresenter>(); _dimensionRepository = A.Fake <IDimensionRepository>(); _groupRepository = A.Fake <IGroupRepository>(); _displayUnitRetriever = A.Fake <IDisplayUnitRetriever>(); _groupLiver = new Group { Name = "Liver" }; _groupDuodenum = new Group { Name = "Duodenum" }; _tableFormula = new TableFormula(); _ontogeny = new DatabaseOntogeny { SpeciesName = "toto" }; _anotherOntogeny = new DatabaseOntogeny { SpeciesName = "toto" }; _allOntongies = new List <Ontogeny> { _ontogeny, _anotherOntogeny }; _ontoData = new List <OntogenyMetaData>(); _ontoData.Add(new OntogenyMetaData { GroupName = "Liver" }); _ontoData.Add(new OntogenyMetaData { GroupName = "Duodenum" }); _allMetaData = new List <OntogenyMetaData>(); A.CallTo(() => _dimensionRepository.AgeInYears).Returns(A.Fake <IDimension>()); A.CallTo(() => _dimensionRepository.Fraction).Returns(DomainHelperForSpecs.FractionDimensionForSpecs()); A.CallTo(() => _simpleChartPresenter.Plot(A <TableFormula> ._)).Returns(new CurveChart().WithAxes()); A.CallTo(() => _simpleChartPresenter.Plot(A <DataRepository> ._, Scalings.Linear)).Returns(new CurveChart().WithAxes()); A.CallTo(() => _groupRepository.GroupByName("Liver")).Returns(_groupLiver); A.CallTo(() => _groupRepository.GroupByName("Duodenum")).Returns(_groupDuodenum); A.CallTo(() => _ontogenyRepository.AllValuesFor(_ontogeny)).Returns(_ontoData); A.CallTo(() => _ontogenyRepository.AllFor(_ontogeny.SpeciesName)).Returns(_allOntongies); A.CallTo(() => _ontogenyRepository.AllValuesFor(_ontogeny, _groupLiver.Name)).Returns(_allMetaData); sut = new ShowOntogenyDataPresenter(_view, _ontogenyRepository, _simpleChartPresenter, _dimensionRepository, _groupRepository, _displayUnitRetriever); A.CallTo(() => _view.BindTo(A <ShowOntogenyDataDTO> ._)) .Invokes(x => ShowOntogenyDataDTO = x.GetArgument <ShowOntogenyDataDTO>(0)); }
protected override void Context() { base.Context(); _ontogeny = new DatabaseOntogeny { SpeciesName = "Dog", Name = "CYP3A4" }; _originData = new OriginData { Species = new Species { Name = "Dog" } }; A.CallTo(() => _ontogenyRepository.AllFor(_originData.Species.Name)).Returns(new[] { _ontogeny }); A.CallTo(() => _ontogenyRepository.OntogenyFactorFor(_ontogeny, CoreConstants.Groups.ONTOGENY_LIVER, _originData, null)).Returns(0.5); _moleculeNames.Add(new MoleculeOntogeny("CYP", "CYP3A4")); }
protected SetOntogenyInMoleculeCommand(IndividualMolecule molecule, Ontogeny newOntogeny, TSimulationSubject simulationSubject, IExecutionContext context) { _molecule = molecule; _oldOntogeny = molecule.Ontogeny ?? new NullOntogeny(); _newOntogeny = newOntogeny ?? new NullOntogeny(); _moleculeId = molecule.Id; _simulationSubject = simulationSubject; BuildingBlockId = simulationSubject.Id; ObjectType = context.TypeFor(molecule); CommandType = PKSimConstants.Command.CommandTypeEdit; var subjectName = string.IsNullOrEmpty(_simulationSubject.Name) ? CoreConstants.ContainerName.NameTemplate : _simulationSubject.Name; Description = PKSimConstants.Command.SetOntogenyInProteinDescription(subjectName, molecule.Name, _oldOntogeny.Name, _newOntogeny.Name); context.UpdateBuildinBlockProperties(this, simulationSubject); }
public void UpdateMoleculeOntogeny(IndividualMolecule molecule, Ontogeny ontogeny, ISimulationSubject simulationSubject) { switch (simulationSubject) { case Individual individual: UpdateMoleculeOntogeny(molecule, ontogeny, individual); break; case Population population: UpdateMoleculeOntogeny(molecule, ontogeny, population); break; default: throw new ArgumentOutOfRangeException(nameof(simulationSubject)); } }
protected override void Context() { _individual = new Individual { OriginData = new OriginData { Species = new Species().WithName("Human") } }; _ontogeny = new DatabaseOntogeny { Name = "toto" }; _executionContext = A.Fake <IExecutionContext>(); _individualMoleculeFactoryResolver = A.Fake <IIndividualMoleculeFactoryResolver>(); _ontogenyRepository = A.Fake <IOntogenyRepository>(); var proteinFactory = A.Fake <IIndividualMoleculeFactory>(); _expressionProfileUpdater = A.Fake <IExpressionProfileUpdater>(); _moleculeContainer1 = new MoleculeExpressionContainer().WithName("C1"); _moleculeContainer1.Add(DomainHelperForSpecs.ConstantParameterWithValue(5).WithName(CoreConstants.Parameters.REL_EXP)); _moleculeContainer2 = new MoleculeExpressionContainer().WithName("C2"); _moleculeContainer2.Add(DomainHelperForSpecs.ConstantParameterWithValue(5).WithName(CoreConstants.Parameters.REL_EXP)); A.CallTo(() => _individualMoleculeFactoryResolver.FactoryFor <IndividualProtein>()).Returns(proteinFactory); _molecule = new IndividualEnzyme { Name = "CYP3A4" }; _molecule.Add(_moleculeContainer1); _molecule.Add(_moleculeContainer2); A.CallTo(() => proteinFactory.AddMoleculeTo(_individual, A <string> ._)).Returns(_molecule); A.CallTo(() => _ontogenyRepository.AllFor(_individual.Species.Name)).Returns(new[] { _ontogeny, new DatabaseOntogeny { Name = "tralala" }, }); A.CallTo(() => _executionContext.Resolve <IOntogenyRepository>()).Returns(_ontogenyRepository); _subjectExpressionTask = new IndividualExpressionTask(_executionContext); sut = new MoleculeExpressionTask <Individual>( _executionContext, _individualMoleculeFactoryResolver, _subjectExpressionTask, _expressionProfileUpdater ); }
public void SelectedOntogenyIs(Ontogeny ontogeny) { AddCommand(_ontogenyTask.SetOntogenyForMolecule(_individualMolecule, ontogeny, _simulationSubject)); updateShowOntogenyButton(); }
public abstract ICommand SetOntogenyForMolecule(IndividualMolecule molecule, Ontogeny ontogeny, TSimulationSubject simulationSubject);
public override ICommand SetOntogenyForMolecule(IndividualMolecule molecule, Ontogeny ontogeny, Population population) { return(new SetOntogenyInMoleculeForPopulationCommand(molecule, ontogeny, population, _executionContext).Run(_executionContext)); }
public void UpdateMoleculeOntogeny(IndividualMolecule molecule, Ontogeny ontogeny, Population population) { updateMoleculeOntogeny(molecule, ontogeny, population, allAgesIn(population), allGAsIn(population)); }
public void UpdateMoleculeOntogeny(IndividualMolecule molecule, Ontogeny ontogeny, Individual individual) { molecule.Ontogeny = ontogeny; molecule.OntogenyFactorGI = _ontogenyRepository.OntogenyFactorFor(ontogeny, CoreConstants.Groups.ONTOGENY_DUODENUM, individual.OriginData); molecule.OntogenyFactor = _ontogenyRepository.OntogenyFactorFor(ontogeny, CoreConstants.Groups.ONTOGENY_LIVER, individual.OriginData); }
public void ShowOntogenyData(Ontogeny ontogeny) { throw new NotSupportedException(); }
protected override void Because() { _ontogeny = new DatabaseOntogeny(); sut.ShowOntogenyData(_ontogeny); }
protected override async Task Because() { _newOntogeny = await sut.MapToModel(_snapshot, _simulationSubject); }
private TableFormula createOntogenyTableFormulaFrom(IParameter ontogenyFactor, Ontogeny ontogeny, OriginData originData, RandomGenerator randomize = null) { var containerName = containerNameForOntogenyFactor(ontogenyFactor); var allOntogenies = _ontogenyRepository.AllOntogenyFactorForStrictBiggerThanPMA(ontogeny, originData, containerName, randomize).ToList(); return(createMoleculeOntogenyTableFormula(ontogenyFactor, originData, allOntogenies)); }
public ICommand SetOntogenyForMolecule(IndividualMolecule molecule, Ontogeny ontogeny, ISimulationSubject simulationSubject) { return(new SetOntogenyInMoleculeCommand(molecule, ontogeny, simulationSubject, _executionContext).Run(_executionContext)); }
public SetOntogenyInMoleculeForPopulationCommand(IndividualMolecule molecule, Ontogeny newOntogeny, Population population, IExecutionContext context) : base(molecule, newOntogeny, population, context) { }
public override ICommand SetOntogenyForMolecule(IndividualMolecule molecule, Ontogeny ontogeny, Individual individual) { return(new SetOntogenyInMoleculeForIndividualCommand(molecule, ontogeny, individual, _executionContext).Run(_executionContext)); }