protected override async Task Context() { await base.Context(); _snapshot = await sut.MapToSnapshot(_expressionProfileEnzyme); _newExpressionProfile = DomainHelperForSpecs.CreateExpressionProfile <IndividualEnzyme>(); A.CallTo(() => _expressionProfileFactory.Create(_snapshot.Type, _snapshot.Species, _snapshot.Molecule)) .Returns(_newExpressionProfile); _snapshot.Localization = null; _snapshot.IntracellularVascularEndoLocation = IntracellularVascularEndoLocation.Interstitial; _snapshot.MembraneLocation = MembraneLocation.BloodBrainBarrier; _snapshot.TissueLocation = TissueLocation.Interstitial; //Add expression container to simulate v9 format _snapshot.Expression = new[] { _relativeExpressionContainerSnapshot1, _relativeExpressionContainerSnapshot2, }; _relativeExpressionParameter1.Value = 0; _relativeExpressionContainerSnapshot1.Value = 1000; A.CallTo(() => _expressionContainerMapper.MapToModel(_relativeExpressionContainerSnapshot1, A <ExpressionContainerMapperContext> ._)) .Invokes(x => _relativeExpressionParameter1.Value = _relativeExpressionContainerSnapshot1.Value.Value); _newExpressionProfile.Molecule.Ontogeny = null; A.CallTo(() => _ontogenyMapper.MapToModel(_snapshot.Ontogeny, A <SnapshotContextWithSubject> .That.Matches(x => x.SimulationSubject == _newExpressionProfile.Individual))).Returns(_ontogeny); var enzyme = _newExpressionProfile.Molecule.DowncastTo <IndividualEnzyme>(); //Localization is now set in task. We override behavior here and pretend that command was executed A.CallTo(() => _moleculeExpressionTask.SetExpressionLocalizationFor(enzyme, A <Localization> ._, _newExpressionProfile.Individual)) .Invokes(x => enzyme.Localization = x.GetArgument <Localization>(1)); //Ensure that the parameter is at the right location so that it will be normalized enzyme.Add(_relativeExpressionParameter1); }
protected override async Task Context() { await base.Context(); _snapshot = await sut.MapToSnapshot(_expressionProfileOtherProtein); _newOtherProteinExpressionProfile = DomainHelperForSpecs.CreateExpressionProfile <IndividualOtherProtein>(); A.CallTo(() => _expressionProfileFactory.Create(_snapshot.Type, _snapshot.Species, _snapshot.Molecule)) .Returns(_newOtherProteinExpressionProfile); }
protected override async Task Context() { await base.Context(); _snapshot = await sut.MapToSnapshot(_expressionProfileTransporter); _newTransporterExpressionProfile = DomainHelperForSpecs.CreateExpressionProfile <IndividualTransporter>(); A.CallTo(() => _expressionProfileFactory.Create(_snapshot.Type, _snapshot.Species, _snapshot.Molecule)) .Returns(_newTransporterExpressionProfile); _snapshot.TransportType = TransportType.PgpLike; }
protected override Task Context() { _parameterMapper = A.Fake <ParameterMapper>(); _expressionProfileMapper = A.Fake <ExpressionProfileMapper>(); _dimensionRepository = A.Fake <IDimensionRepository>(); _individualFactory = A.Fake <IIndividualFactory>(); _originDataMapper = A.Fake <OriginDataMapper>(); _moleculeExpressionTask = A.Fake <IMoleculeExpressionTask <ModelIndividual> >(); sut = new IndividualMapper(_parameterMapper, _expressionProfileMapper, _originDataMapper, _individualFactory, _moleculeExpressionTask); _individual = DomainHelperForSpecs.CreateIndividual(); _individual.Name = "Ind"; _individual.Description = "Model Description"; var kidney = _individual.EntityAt <IContainer>(Constants.ORGANISM, CoreConstants.Organ.KIDNEY); _parameterLiver = _individual.EntityAt <IParameter>(Constants.ORGANISM, CoreConstants.Organ.LIVER, "PLiver"); _parameterKidney = _individual.EntityAt <IParameter>(Constants.ORGANISM, CoreConstants.Organ.KIDNEY, "PKidney"); _parameterKidneyRelExp = DomainHelperForSpecs.ConstantParameterWithValue().WithName(CoreConstants.Parameters.REL_EXP); _parameterKidneyRelExp.DefaultValue = 10; kidney.Add(_parameterKidneyRelExp); _parameterLiver.ValueDiffersFromDefault().ShouldBeFalse(); _parameterKidney.ValueDiffersFromDefault().ShouldBeFalse(); _parameterKidney.Value = 40; _parameterKidney.ValueDiffersFromDefault().ShouldBeTrue(); _parameterKidneyRelExp.Value = 50; _parameterKidneyRelExp.ValueDiffersFromDefault().ShouldBeTrue(); _expressionProfile1 = DomainHelperForSpecs.CreateExpressionProfile <IndividualEnzyme>(moleculeName: "Enz"); _expressionProfile2 = DomainHelperForSpecs.CreateExpressionProfile <IndividualTransporter>(moleculeName: "Trans"); _individual.AddExpressionProfile(_expressionProfile1); _individual.AddExpressionProfile(_expressionProfile2); _originDataSnapshot = new OriginData(); A.CallTo(() => _originDataMapper.MapToSnapshot(_individual.OriginData)).Returns(_originDataSnapshot); _localizedParameterKidney = new LocalizedParameter { Path = "Organism|Kidney|PKidney" }; A.CallTo(() => _parameterMapper.LocalizedParametersFrom(A <IEnumerable <IParameter> > ._)) .Invokes(x => _mappedParameters = x.GetArgument <IEnumerable <IParameter> >(0).ToList()) .Returns(new[] { _localizedParameterKidney }); return(_completed); }
protected override Task Context() { _parameterMapper = A.Fake <ParameterMapper>(); _expressionContainerMapper = A.Fake <ExpressionContainerMapper>(); _expressionProfileFactory = A.Fake <IExpressionProfileFactory>(); _ontogenyMapper = A.Fake <OntogenyMapper>(); _ontogenyTask = A.Fake <IOntogenyTask>(); _moleculeExpressionTask = A.Fake <IMoleculeExpressionTask <Individual> >(); _moleculeParameterTask = A.Fake <IMoleculeParameterTask>(); sut = new ExpressionProfileMapper( _parameterMapper, _expressionContainerMapper, _ontogenyMapper, _ontogenyTask, _moleculeExpressionTask, _expressionProfileFactory, _moleculeParameterTask); _ontogeny = new DatabaseOntogeny { Name = "Ontogeny" }; _expressionProfileEnzyme = DomainHelperForSpecs.CreateExpressionProfile <IndividualEnzyme>("Enzyme"); _expressionProfileEnzyme.Molecule.Ontogeny = _ontogeny; _expressionProfileEnzyme.Description = "Help"; _expressionProfileTransporter = DomainHelperForSpecs.CreateExpressionProfile <IndividualTransporter>("Transporter"); _expressionProfileTransporter.Description = "Help"; _expressionProfileOtherProtein = DomainHelperForSpecs.CreateExpressionProfile <IndividualOtherProtein>("OtherProtein"); _enzymeGlobalParameter = DomainHelperForSpecs.ConstantParameterWithValue(5, isDefault: true) .WithName(CoreConstants.Parameters.HALF_LIFE_LIVER); _enzymeGlobalParameterSnapshot = new Parameter(); A.CallTo(() => _parameterMapper.MapToSnapshot(_enzymeGlobalParameter)).Returns(_enzymeGlobalParameterSnapshot); _expressionContainer1 = new MoleculeExpressionContainer { Name = "Exp Container1" }; _expressionContainer2 = new MoleculeExpressionContainer { Name = "Exp Container2" }; _expressionProfileEnzyme.Individual.AddChildren(_expressionContainer1, _expressionContainer2, _enzymeGlobalParameter); _expressionProfileEnzyme.Molecule.DowncastTo <IndividualEnzyme>().Localization = Localization.Intracellular | Localization.BloodCellsMembrane; _relativeExpressionParameter1 = DomainHelperForSpecs.ConstantParameterWithValue(0.5).WithName(CoreConstants.Parameters.REL_EXP); _expressionContainer1.Add(_relativeExpressionParameter1); _relativeExpressionParameterNotSet = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.REL_EXP); _expressionContainer2.Add(_relativeExpressionParameterNotSet); _relativeExpressionContainerSnapshot1 = new ExpressionContainer(); _relativeExpressionContainerSnapshot2 = new ExpressionContainer(); A.CallTo(() => _expressionContainerMapper.MapToSnapshot(_expressionContainer1)).Returns(_relativeExpressionContainerSnapshot1); A.CallTo(() => _expressionContainerMapper.MapToSnapshot(_expressionContainer2)).Returns(_relativeExpressionContainerSnapshot2); _snapshotOntogeny = new Snapshots.Ontogeny(); A.CallTo(() => _ontogenyMapper.MapToSnapshot(_ontogeny)).Returns(_snapshotOntogeny); _individual = new Individual(); return(_completed); }
protected override async Task Because() { _newOtherProteinExpressionProfile = await sut.MapToModel(_snapshot, new SnapshotContext()); }
protected override async Task Because() { _newExpressionProfile = await sut.MapToModel(_snapshot, new SnapshotContext(new PKSimProject(), ProjectVersions.V9)); }