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"); }
protected override void Context() { base.Context(); _individual = A.Fake<Individual>(); var originData = new OriginData(); originData.Population = new SpeciesPopulation(); A.CallTo(() => _individual.OriginData).Returns(originData); var organism = new Organism(); var ga = DomainHelperForSpecs.ConstantParameterWithValue(5).WithName(Constants.Parameters.GESTATIONAL_AGE); ga.Info.MinValue = 24; ga.Info.MaxValue = 25; organism.Add(ga); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(5).WithName(CoreConstants.Parameters.MEAN_WEIGHT)); A.CallTo(() => _individual.IsPreterm).Returns(true); A.CallTo(() => _individual.Organism).Returns(organism); }
protected override void Context() { sut = new ExpressionContainersRetriever(); var objectPathFactory = new ObjectPathFactoryForSpecs(); var entityPathResolver = new EntityPathResolverForSpecs(); _liver.Add(_intLiver); _liver.Add(_cellLiver); _liver.Add(_plsLiver); _liver.Add(_bcLiver); _liver.Add(_endoLiver); _kidney.Add(_intKidney); _kidney.Add(_cellKidney); _kidney.Add(_plsKidney); _kidney.Add(_bcKidney); _kidney.Add(_endoKidney); _lumen.Add(_duodenum); _organism.Add(_liver); _organism.Add(_kidney); _organism.Add(_lumen); _protein = new IndividualEnzyme(); _protein.Add(new MoleculeExpressionContainer { OrganPath = objectPathFactory.CreateObjectPathFrom(CoreConstants.Compartment.BloodCells) }.WithName(CoreConstants.Compartment.BloodCells)); _protein.Add(new MoleculeExpressionContainer { OrganPath = objectPathFactory.CreateObjectPathFrom(CoreConstants.Compartment.Plasma) }.WithName(CoreConstants.Compartment.Plasma)); _protein.Add(new MoleculeExpressionContainer { OrganPath = objectPathFactory.CreateObjectPathFrom(CoreConstants.Compartment.VascularEndothelium) }.WithName(CoreConstants.Compartment.VascularEndothelium)); _protein.Add(new MoleculeExpressionContainer { OrganPath = entityPathResolver.ObjectPathFor(_liver) }.WithName(CoreConstants.Organ.Liver)); _protein.Add(new MoleculeExpressionContainer { OrganPath = entityPathResolver.ObjectPathFor(_kidney) }.WithName(CoreConstants.Organ.Kidney)); _protein.Add(new MoleculeExpressionContainer { OrganPath = entityPathResolver.ObjectPathFor(_lumen), GroupName = CoreConstants.Groups.GI_LUMEN, ContainerName = _duodenum.Name }.WithName(CoreConstants.ContainerName.LumenSegmentNameFor("Duodenum"))); }
protected override void Context() { base.Context(); _originData = new OriginData { Species = new Species { Name = "A", Icon = "B" }, SpeciesPopulation = A.Fake <SpeciesPopulation>() }; _individual = new Individual(); _organism = new Organism(); _neighborhoods = A.Fake <IContainer>(); _rootContainer = new RootContainer(); A.CallTo(() => _entityBaseFactory.Create <IRootContainer>()).Returns(_rootContainer); A.CallTo(() => _entityBaseFactory.Create <Individual>()).Returns(_individual); A.CallTo(() => _entityBaseFactory.Create <Organism>()).Returns(_organism); A.CallTo(() => _entityBaseFactory.Create <IContainer>()).Returns(_neighborhoods); _valueOrigin = new ValueOrigin { Method = ValueOriginDeterminationMethods.InVitro, Source = ValueOriginSources.Database }; _originData.UpdateValueOriginFrom(_valueOrigin); _originData.Age = 10; _originData.AgeUnit = _age.DisplayUnit.Name; _organism.Add(_age); _originData.GestationalAge = 40; _originData.GestationalAgeUnit = _gestationalAge.DisplayUnit.Name; _organism.Add(_gestationalAge); _originData.Height = 170; _originData.HeightUnit = _height.DisplayUnit.Name; _organism.Add(_height); _originData.Weight = 170; _originData.WeightUnit = _weight.DisplayUnit.Name; _organism.Add(_weight); _originData.BMI = 170; _originData.BMIUnit = _bmi.DisplayUnit.Name; _organism.Add(_bmi); }
protected override void Context() { base.Context(); _individual = new Individual { Root = new RootContainer() }; var organism = new Organism(); _individual.Add(organism); var ageParameter = DomainHelperForSpecs.ConstantParameterWithValue(10).WithName(CoreConstants.Parameters.AGE); organism.Add(ageParameter); var gaParameter = DomainHelperForSpecs.ConstantParameterWithValue(10).WithName(Constants.Parameters.GESTATIONAL_AGE); organism.Add(gaParameter); var ageValues = new ParameterValues(_entityPathResolver.PathFor(ageParameter)); ageValues.Add(1); ageValues.Add(2); var gaValues = new ParameterValues(_entityPathResolver.PathFor(gaParameter)); gaValues.Add(30); gaValues.Add(40); _population = new RandomPopulation { Settings = new RandomPopulationSettings { BaseIndividual = _individual, NumberOfIndividuals = 2 } }; _population.IndividualValuesCache.Add(ageValues); _population.IndividualValuesCache.Add(gaValues); _population.IndividualValuesCache.IndividualIds.AddRange(new [] { 1, 2 }); A.CallTo(() => _ontogenyRepository.OntogenyFactorFor(_ontogeny, CoreConstants.Groups.ONTOGENY_LIVER, 1, 30, _population.RandomGenerator)).Returns(10); A.CallTo(() => _ontogenyRepository.OntogenyFactorFor(_ontogeny, CoreConstants.Groups.ONTOGENY_LIVER, 2, 40, _population.RandomGenerator)).Returns(11); A.CallTo(() => _ontogenyRepository.OntogenyFactorFor(_ontogeny, CoreConstants.Groups.ONTOGENY_DUODENUM, 1, 30, _population.RandomGenerator)).Returns(20); A.CallTo(() => _ontogenyRepository.OntogenyFactorFor(_ontogeny, CoreConstants.Groups.ONTOGENY_DUODENUM, 2, 40, _population.RandomGenerator)).Returns(21); }
protected override void Because() { _sim = new IndividualSimulation().WithName("Tralala"); _organism = new Organism().WithName(Constants.ORGANISM); _sim.Add(_organism); _organ = new Organ().WithName("Liver"); _organism.Add(_organ); _entityPathResolver = new EntityPathResolverForSpecs(); }
protected override void Context() { _defaultIndividualRetriever = A.Fake <IDefaultIndividualRetriever>(); _speciesRepository = A.Fake <ISpeciesRepository>(); _simulationFactory = A.Fake <ISimulationFactory>(); _parameterFactory = A.Fake <IParameterFactory>(); _protocolFactory = A.Fake <IProtocolFactory>(); sut = new VSSCalculator(_defaultIndividualRetriever, _speciesRepository, _simulationFactory, _parameterFactory, _protocolFactory); _species1 = new Species().WithId("Human"); _species2 = new Species().WithId("Dog"); A.CallTo(() => _speciesRepository.All()).Returns(new[] { _species1, _species2 }); _simulation = A.Fake <Simulation>(); var organism = new Organism(); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(0.5).WithName(CoreConstants.Parameter.HCT)); A.CallTo(() => _simulation.Individual.Organism).Returns(organism); }
protected override void Context() { base.Context(); _population = A.Fake <RandomPopulation>().WithName("POP"); A.CallTo(() => _population.NumberOfItems).Returns(7); _baseIndividual = A.Fake <Individual>(); _cloneIndividual = A.Fake <Individual>(); var organism = new Organism(); A.CallTo(() => _cloneIndividual.Organism).Returns(organism); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(40).WithName(CoreConstants.Parameters.WEIGHT)); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(50).WithName(CoreConstants.Parameters.HEIGHT)); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(60).WithName(CoreConstants.Parameters.BMI)); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(70).WithName(CoreConstants.Parameters.AGE)); organism.Add(DomainHelperForSpecs.ConstantParameterWithValue(80).WithName(Constants.Parameters.GESTATIONAL_AGE)); _constParam1 = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName("P1"); _constParam2 = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName("P2"); //create a reference to another parameter to ensure that formula parameter are not overwritten if nothing has changed _formulaParameter = new PKSimParameter().WithName("P3").WithFormula(new ExplicitFormula("P2*2")); _formulaParameter.Formula.AddObjectPath(new FormulaUsablePath("..", "P2").WithAlias("P2")); var container1 = new Container { _constParam1, _constParam2, _formulaParameter }; _indParam1 = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName("P1"); _indParam2 = DomainHelperForSpecs.ConstantParameterWithValue(2).WithName("P2"); _indParam3 = new PKSimParameter().WithName("P3").WithFormula(new ExplicitFormula("P2*2")); _indParam3.Formula.AddObjectPath(new FormulaUsablePath("..", "P2").WithAlias("P2")); _indParam4 = DomainHelperForSpecs.ConstantParameterWithValue(4).WithName("P4"); var container2 = new Container { _indParam1, _indParam2, _indParam3, _indParam4 }; A.CallTo(() => _executionContext.Clone(_baseIndividual)).Returns(_cloneIndividual); A.CallTo(() => _population.FirstIndividual).Returns(_baseIndividual); //put explicit formula first A.CallTo(() => _population.AllVectorialParameters(_entityPathResolver)).Returns(new[] { _formulaParameter, _constParam1, _constParam2 }); A.CallTo(() => _cloneIndividual.GetAllChildren <IParameter>()).Returns(new[] { _indParam1, _indParam2, _indParam3, _indParam4 }); A.CallTo(() => _entityPathResolver.PathFor(_constParam1)).Returns("PATH1"); A.CallTo(() => _entityPathResolver.PathFor(_constParam2)).Returns("PATH2"); A.CallTo(() => _entityPathResolver.PathFor(_formulaParameter)).Returns("PATH3"); A.CallTo(() => _entityPathResolver.PathFor(_indParam1)).Returns("PATH1"); A.CallTo(() => _entityPathResolver.PathFor(_indParam2)).Returns("PATH2"); A.CallTo(() => _entityPathResolver.PathFor(_indParam3)).Returns("PATH3"); A.CallTo(() => _entityPathResolver.PathFor(_indParam4)).Returns("PATH4"); A.CallTo(() => _population.AllValuesFor("PATH1")).Returns(new[] { 10d, 11, 12, 13, 14, 15, 16 }); A.CallTo(() => _population.AllValuesFor("PATH2")).Returns(new[] { 20d, 21, 22, 23, 24, 25, 26 }); A.CallTo(() => _population.AllValuesFor("PATH3")).Returns(new[] { 40d, 42, 44, 46, 48, 50, 52 }); _templateIndividual1.Name = "POP-3"; _addIndividualCommand = A.Fake <IPKSimCommand>(); A.CallTo(() => _individualTask.AddToProject(_cloneIndividual, false, false)).Returns(_addIndividualCommand); A.CallTo(() => _executionContext.AddToHistory(A <ICommand> ._)) .Invokes(x => _overallCommand = x.GetArgument <ICommand>(0)); }
public static Individual CreateIndividual() { var originData = new OriginData(); originData.SubPopulation = new SubPopulation(); originData.Species = new Species().WithName("Species"); originData.Gender = new Gender().WithName("Gender"); originData.SpeciesPopulation = new SpeciesPopulation().WithName("Population"); var pvv = new ParameterValueVersion().WithName("PVVName"); var category = new ParameterValueVersionCategory().WithName("CategoryName"); category.Add(pvv); originData.SubPopulation.AddParameterValueVersion(pvv); var organism = new Organism().WithName("Organism").WithId("OrganismId"); var organLiver = new Organ().WithName(CoreConstants.Organ.Liver).WithId("LiverId"); organLiver.OrganType = OrganType.Liver; var periportal = new Compartment().WithName(CoreConstants.Compartment.Periportal).WithId("PeriportalId"); periportal.Add(new Container().WithName(CoreConstants.Compartment.Intracellular).WithId("PeriportalIntracellular")); var pericentral = new Compartment().WithName(CoreConstants.Compartment.Pericentral).WithId("PericentralId"); pericentral.Add(new Container().WithName(CoreConstants.Compartment.Intracellular).WithId("PericentralIntracellular")); organLiver.Add(periportal); organLiver.Add(pericentral); var organKidney = new Organ().WithName(CoreConstants.Organ.Kidney).WithId("KidneyId"); organKidney.OrganType = OrganType.Kidney; organKidney.Add(new Compartment { Visible = true }.WithName(CoreConstants.Compartment.Plasma).WithId("KidneyPlasma")); var lumen = new Organ().WithName("GiTract").WithId("GiTract"); lumen.OrganType = OrganType.Lumen; var duodenum = new Compartment().WithName("Duodenum").WithId("Duodenum"); var caecum = new Compartment().WithName("Caecum").WithId("Caecum"); var dimension = Constants.Dimension.NO_DIMENSION; var parameterLiver = new PKSimParameter().WithName("PLiver").WithId("PLiverId").WithFormula(new ExplicitFormula("1").WithId("1")).WithDimension(dimension); parameterLiver.Info = new ParameterValueMetaData { DefaultValue = 1 }; var parameterKidney = new PKSimParameter().WithName("PKidney").WithId("PKidneyId").WithFormula(new ExplicitFormula("2").WithId("2")).WithDimension(dimension); parameterKidney.Info = new ParameterValueMetaData { DefaultValue = 2 }; var parameterOrganism = new PKSimParameter().WithName(ParameterInOrganism).WithId("POrganismId").WithFormula(new ExplicitFormula("3").WithId("3")).WithDimension(dimension); parameterOrganism.Info = new ParameterValueMetaData { DefaultValue = 3 }; organLiver.Add(parameterLiver); organKidney.Add(parameterKidney); organism.Add(organLiver); organism.Add(organKidney); organism.Add(lumen); organism.Add(parameterOrganism); lumen.Add(duodenum); lumen.Add(caecum); var individual = new Individual { OriginData = originData }.WithName("Individual").WithId("IndividualId"); individual.Add(organism); return(individual); }
public static Individual CreateIndividual(string speciesName = "Species") { var originData = new OriginData { SubPopulation = new SubPopulation(), Species = new Species { DisplayName = speciesName, Id = speciesName }.WithName(speciesName), Gender = new Gender().WithName("Gender"), Population = new SpeciesPopulation().WithName("Population"), }; var pvv = new ParameterValueVersion().WithName("PVVName"); var category = new ParameterValueVersionCategory().WithName("CategoryName"); category.Add(pvv); originData.SubPopulation.AddParameterValueVersion(pvv); var organism = new Organism().WithName(Constants.ORGANISM).WithId("OrganismId"); var organLiver = new Organ().WithName(CoreConstants.Organ.LIVER).WithId("LiverId"); organLiver.OrganType = OrganType.TissueOrgansNotInGiTract; var periportal = new Compartment().WithName(CoreConstants.Compartment.PERIPORTAL).WithId("PeriportalId"); periportal.Add(new Container().WithName(CoreConstants.Compartment.INTRACELLULAR).WithId("PeriportalIntracellular")); var pericentral = new Compartment().WithName(CoreConstants.Compartment.PERICENTRAL).WithId("PericentralId"); pericentral.Add(new Container().WithName(CoreConstants.Compartment.INTRACELLULAR).WithId("PericentralIntracellular")); organLiver.Add(periportal); organLiver.Add(pericentral); var organKidney = new Organ().WithName(CoreConstants.Organ.KIDNEY).WithId("KidneyId"); organKidney.OrganType = OrganType.TissueOrgansNotInGiTract; organKidney.Add(new Compartment { Visible = true }.WithName(CoreConstants.Compartment.PLASMA).WithId("KidneyPlasma")); var lumen = new Organ().WithName("GiTract").WithId("GiTract"); lumen.OrganType = OrganType.Lumen; var duodenum = new Compartment().WithName("Duodenum").WithId("Duodenum"); var caecum = new Compartment().WithName("Caecum").WithId("Caecum"); var dimension = Constants.Dimension.NO_DIMENSION; var parameterLiver = new PKSimParameter().WithName("PLiver").WithId("PLiverId").WithFormula(new ExplicitFormula("1").WithId("1")).WithDimension(dimension); parameterLiver.Info = new ParameterValueMetaData { DefaultValue = 1 }; var parameterKidney = new PKSimParameter().WithName("PKidney").WithId("PKidneyId").WithFormula(new ExplicitFormula("2").WithId("2")).WithDimension(dimension); parameterKidney.Info = new ParameterValueMetaData { DefaultValue = 2 }; var parameterOrganism = new PKSimParameter().WithName(ParameterInOrganism).WithId("POrganismId").WithFormula(new ExplicitFormula("3").WithId("3")).WithDimension(dimension); parameterOrganism.Info = new ParameterValueMetaData { DefaultValue = 3 }; organLiver.Add(parameterLiver); organKidney.Add(parameterKidney); organism.Add(organLiver); organism.Add(organKidney); organism.Add(lumen); organism.Add(parameterOrganism); lumen.Add(duodenum); lumen.Add(caecum); var individual = new Individual { OriginData = originData }.WithName("Individual").WithId("IndividualId"); individual.Add(organism); return(individual); }