protected override void Context() { base.Context(); _pkValues = new PKValues(); _pkValues.AddValue("P1", 10f); _pkValues.AddValue("P2", 10f); _mode = PKParameterMode.Single; _drugName = "TOTO"; _pk1 = new PKParameter { Mode = _mode, Name = "P1", Dimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs() }; _pk2 = new PKParameter { Mode = _mode, Name = "P2", Dimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs() }; _pk3 = new PKParameter { Mode = PKParameterMode.Multi, Name = "P3" }; var baseGrid = new BaseGrid("Time", DomainHelperForSpecs.TimeDimensionForSpecs()); _col = new DataColumn("COL", DomainHelperForSpecs.ConcentrationDimensionForSpecs(), baseGrid) { DataInfo = { MolWeight = 150 } }; A.CallTo(() => _pkParameterRepository.All()).Returns(new [] { _pk1, _pk2, _pk3 }); A.CallTo(() => _parameterFactory.CreateFor(A <string> ._, A <double> ._, A <string> ._, PKSimBuildingBlockType.Simulation)) .ReturnsLazily(x => DomainHelperForSpecs.ConstantParameterWithValue(x.GetArgument <double>(1)).WithName(x.GetArgument <string>(0))); }
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); }
public PKAnalysis MapFrom(DataColumn dataColumn, PKValues pkValues, PKParameterMode mode, string moleculeName) { var pk = new PKAnalysis().WithName(moleculeName); _pkParameterRepository.All().Where(parameter => parameter.Mode.Is(mode)).Each(parameter => pk.Add(createPKParameter(parameter, pkValues))); pk.MolWeight = dataColumn.DataInfo.MolWeight; return(pk); }
private PKValues pkValuesFrom(ICache <string, double> pk) { var pkValues = new PKValues(); foreach (var pkValue in pk.KeyValues) { pkValues.AddValue(pkValue.Key, pkValue.Value.ConvertedTo <float>()); } return(pkValues); }
protected override void Context() { _vssCalculator = A.Fake <IVSSCalculator>(); _parameterFactory = A.Fake <IParameterFactory>(); _protocolMapper = A.Fake <IProtocolToSchemaItemsMapper>(); _protocolFactory = A.Fake <IProtocolFactory>(); _globalPKAnalysisRunner = A.Fake <IGlobalPKAnalysisRunner>(); _pkCalculationOptionsFactory = A.Fake <IPKCalculationOptionsFactory>(); _pkAnalysisTask = A.Fake <IPKAnalysesTask>(); _interactionTask = A.Fake <IInteractionTask>(); _cloner = A.Fake <ICloner>(); sut = new GlobalPKAnalysisTask(_parameterFactory, _protocolMapper, _protocolFactory, _globalPKAnalysisRunner, _pkAnalysisTask, _pkCalculationOptionsFactory, _vssCalculator, _interactionTask, _cloner); var baseGrid = new BaseGrid("time", A.Fake <IDimension>()); _peripheralVenousBloodPlasma = CalculationColumnFor(baseGrid, CoreConstants.Organ.PeripheralVenousBlood, CoreConstants.Observer.PLASMA_PERIPHERAL_VENOUS_BLOOD, CoreConstants.Observer.PLASMA_PERIPHERAL_VENOUS_BLOOD, _compoundName); _venousBloodPlasma = CalculationColumnFor(baseGrid, CoreConstants.Organ.VenousBlood, CoreConstants.Compartment.Plasma, CoreConstants.Observer.CONCENTRATION_IN_CONTAINER, _compoundName); _individual = A.Fake <Individual>(); _species = new Species(); A.CallTo(() => _individual.Species).Returns(_species); _compound = new Compound().WithName(_compoundName); _compoundProperties = new CompoundProperties { Compound = _compound }; _simulationSchemaItems = new List <SchemaItem>(); _protocol = new SimpleProtocol(); _compoundProperties.ProtocolProperties.Protocol = _protocol; A.CallTo(() => _protocolMapper.MapFrom(_protocol)).Returns(_simulationSchemaItems); _simulation = new IndividualSimulation { Properties = new SimulationProperties() }; _simulation.Properties.AddCompoundProperties(_compoundProperties); _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("CompId", PKSimBuildingBlockType.Compound) { BuildingBlock = _compound }); _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndividualId", PKSimBuildingBlockType.Individual) { BuildingBlock = _individual }); _simulation.DataRepository = new DataRepository { _venousBloodPlasma, _peripheralVenousBloodPlasma }; _venousBloodPK = new PKValues(); _venousBloodPK.AddValue(Constants.PKParameters.Vss, 10); _venousBloodPK.AddValue(Constants.PKParameters.Vd, 11); _venousBloodPK.AddValue(Constants.PKParameters.CL, 12); _venousBloodPK.AddValue(Constants.PKParameters.AUC_inf, 13); _venousBloodPK.AddValue(Constants.PKParameters.AUC_inf_tD1_norm, 14); _peripheralVenousBloodPK = new PKValues(); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.Vss, 21); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.Vd, 22); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.CL, 23); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.AUC_inf, 24); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.AUC_inf_tD1_norm, 25); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.C_max, 26); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.C_max_tDLast_tDEnd, 27); A.CallTo(() => _pkAnalysisTask.CalculatePK(_venousBloodPlasma, A <PKCalculationOptions> ._)).Returns(_venousBloodPK); A.CallTo(() => _pkAnalysisTask.CalculatePK(_peripheralVenousBloodPlasma, A <PKCalculationOptions> ._)).Returns(_peripheralVenousBloodPK); A.CallTo(() => _parameterFactory.CreateFor(A <string> ._, A <double> ._, A <string> ._, PKSimBuildingBlockType.Simulation)) .ReturnsLazily(s => new PKSimParameter().WithName((string)s.Arguments[0]) .WithDimension(A.Fake <IDimension>()) .WithFormula(new ConstantFormula((double)s.Arguments[1]))); }
private IParameter createPKParameter(PKParameter pkParameter, PKValues pkValues) { return(createPKParameter(pkParameter.Name, pkValues.ValueOrDefaultFor(pkParameter.Name), pkParameter.Dimension.Name)); }
protected override void Because() { _pk = sut.CalculatePK(_multipleDosingColumn, _pkOptions); }
protected override void Because() { _pk = sut.CalculatePK(_emptyColums, _pkOptions); }
protected override void Because() { _pk = sut.CalculatePK(_singleDosing, _pkOptions); }
protected override void Because() { _pk = sut.CalculatePK(_multipleDosingColumn, _pkOptions, _allDynamicPkParameters); }
protected override void Context() { _vssCalculator = A.Fake <IVSSCalculator>(); _parameterFactory = A.Fake <IParameterFactory>(); _protocolMapper = A.Fake <IProtocolToSchemaItemsMapper>(); _protocolFactory = A.Fake <IProtocolFactory>(); _globalPKAnalysisRunner = A.Fake <IGlobalPKAnalysisRunner>(); _pkCalculationOptionsFactory = A.Fake <IPKCalculationOptionsFactory>(); _pkAnalysisTask = A.Fake <IPKAnalysesTask>(); _interactionTask = A.Fake <IInteractionTask>(); _cloner = A.Fake <ICloner>(); sut = new GlobalPKAnalysisTask(_parameterFactory, _protocolMapper, _protocolFactory, _globalPKAnalysisRunner, _pkAnalysisTask, _pkCalculationOptionsFactory, _vssCalculator, _interactionTask, _cloner); var baseGrid = new BaseGrid("time", A.Fake <IDimension>()); _peripheralVenousBloodPlasma = CalculationColumnFor(baseGrid, CoreConstants.Organ.PERIPHERAL_VENOUS_BLOOD, CoreConstants.Observer.PLASMA_PERIPHERAL_VENOUS_BLOOD, CoreConstants.Observer.PLASMA_PERIPHERAL_VENOUS_BLOOD, _compoundName); _venousBloodPlasma = CalculationColumnFor(baseGrid, CoreConstants.Organ.VENOUS_BLOOD, CoreConstants.Compartment.PLASMA, CoreConstants.Observer.CONCENTRATION_IN_CONTAINER, _compoundName); _individual = A.Fake <Individual>(); _species = new Species(); A.CallTo(() => _individual.Species).Returns(_species); _compound = new Compound().WithName(_compoundName); _compoundProperties = new CompoundProperties { Compound = _compound }; _protocol = new SimpleProtocol(); _compoundProperties.ProtocolProperties.Protocol = _protocol; _simulation = new IndividualSimulation { Properties = new SimulationProperties() }; _simulation.Properties.AddCompoundProperties(_compoundProperties); _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("CompId", PKSimBuildingBlockType.Compound) { BuildingBlock = _compound }); _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndividualId", PKSimBuildingBlockType.Individual) { BuildingBlock = _individual }); _simulation.DataRepository = new DataRepository { _venousBloodPlasma, _peripheralVenousBloodPlasma }; _simulation.SimulationSettings = new SimulationSettings(); _simulation.OutputSchema = new OutputSchema(); _simulation.OutputSchema.AddInterval(new OutputInterval { DomainHelperForSpecs.ConstantParameterWithValue(100).WithName(Constants.Parameters.END_TIME) }); _simulation.Model = new OSPSuite.Core.Domain.Model { Root = new Container() }; _eventGroup = new EventGroup(); _application1 = new Container().WithName("App1").WithContainerType(ContainerType.Application); _application1.Add(new MoleculeAmount().WithName(_compoundName)); _application1.Add(DomainHelperForSpecs.ConstantParameterWithValue(10).WithName(Constants.Parameters.START_TIME)); _application2 = new Container().WithName("App2").WithContainerType(ContainerType.Application); _application2.Add(DomainHelperForSpecs.ConstantParameterWithValue(10).WithName(Constants.Parameters.START_TIME)); _application2.Add(new MoleculeAmount().WithName(_compoundName)); _simulation.Model.Root.Add(_eventGroup); _eventGroup.Add(_application1); _venousBloodPK = new PKValues(); _venousBloodPK.AddValue(Constants.PKParameters.Vss, 10); _venousBloodPK.AddValue(Constants.PKParameters.Vd, 11); _venousBloodPK.AddValue(Constants.PKParameters.CL, 12); _venousBloodPK.AddValue(Constants.PKParameters.AUC_inf, 13); _venousBloodPK.AddValue(Constants.PKParameters.AUC_inf_tD1_norm, 14); _peripheralVenousBloodPK = new PKValues(); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.Vss, 21); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.Vd, 22); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.CL, 23); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.AUC_inf, 24); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.AUC_inf_tD1_norm, 25); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.C_max, 26); _peripheralVenousBloodPK.AddValue(Constants.PKParameters.C_max_tDLast_tDEnd, 27); A.CallTo(() => _pkAnalysisTask.CalculatePK(_venousBloodPlasma, A <PKCalculationOptions> ._)).Returns(_venousBloodPK); A.CallTo(() => _pkAnalysisTask.CalculatePK(_peripheralVenousBloodPlasma, A <PKCalculationOptions> ._)).Returns(_peripheralVenousBloodPK); A.CallTo(() => _parameterFactory.CreateFor(A <string> ._, A <double> ._, A <string> ._, PKSimBuildingBlockType.Simulation)) .ReturnsLazily(s => new PKSimParameter().WithName((string)s.Arguments[0]) .WithDimension(A.Fake <IDimension>()) .WithFormula(new ConstantFormula((double)s.Arguments[1]))); }