Example #1
0
 protected override void Context()
 {
     base.Context();
     _targetIndividual     = A.Fake <PKSim.Core.Model.Individual>();
     _sourceIndividual     = A.Fake <PKSim.Core.Model.Individual>();
     _parameterScaling1    = A.Fake <ParameterScaling>();
     _parameterScaling2    = A.Fake <ParameterScaling>();
     _parameterScalingDTO1 = new ParameterScalingDTO(_parameterScaling1);
     _parameterScalingDTO2 = new ParameterScalingDTO(_parameterScaling2);
     A.CallTo(() => _individualScalingTask.AllParameterScalingsFrom(_sourceIndividual, _targetIndividual)).Returns(new[] { _parameterScaling1, _parameterScaling2 });
     A.CallTo(() => _mapper.MapFrom(_parameterScaling1)).Returns(_parameterScalingDTO1);
     A.CallTo(() => _mapper.MapFrom(_parameterScaling2)).Returns(_parameterScalingDTO2);
 }
Example #2
0
        protected override void Context()
        {
            base.Context();
            _targetIndividual  = A.Fake <PKSim.Core.Model.Individual>();
            _sourceIndividual  = A.Fake <PKSim.Core.Model.Individual>();
            _parameterScaling1 = A.Fake <ParameterScaling>();
            _parameterScaling2 = A.Fake <ParameterScaling>();
            var volume = new PKSimParameter().WithName(CoreConstants.Parameter.VOLUME).WithParentContainer(new Organ());
            var p2     = new PKSimParameter().WithName("P2").WithParentContainer(new Container());

            A.CallTo(() => _individualScalingTask.AllParameterScalingsFrom(_sourceIndividual, _targetIndividual)).Returns(new[] { _parameterScaling1, _parameterScaling2 });
            A.CallTo(() => _parameterScaling1.SourceParameter).Returns(volume);
            A.CallTo(() => _parameterScaling2.SourceParameter).Returns(p2);
        }
Example #3
0
 protected override void Context()
 {
     base.Context();
     _targetIndividual = A.Fake <PKSim.Core.Model.Individual>();
     _sourceIndividual = A.Fake <PKSim.Core.Model.Individual>();
     _subCommand       = A.Fake <IPKSimCommand>();
     _scalingCommand   = new List <IPKSimCommand> {
         _subCommand
     };
     A.CallTo(() => _individualScalingTask.AllParameterScalingsFrom(_sourceIndividual, _targetIndividual)).Returns(new List <ParameterScaling>());
     A.CallTo(() => _view.HasError).Returns(false);
     A.CallTo(() => _individualScalingTask.PerformScaling(A <IEnumerable <ParameterScaling> > ._)).Returns(_scalingCommand);
     sut.ConfigureScaling(_sourceIndividual, _targetIndividual);
 }
Example #4
0
        protected override void Context()
        {
            base.Context();
            _targetIndividual  = A.Fake <PKSim.Core.Model.Individual>();
            _sourceIndividual  = A.Fake <PKSim.Core.Model.Individual>();
            _parameterScaling1 = A.Fake <ParameterScaling>();
            _parameterScaling2 = A.Fake <ParameterScaling>();
            var p1 = A.Fake <IParameter>().WithName("P1").WithParentContainer(A.Fake <IContainer>());
            var p2 = A.Fake <IParameter>().WithName("P2").WithParentContainer(A.Fake <IContainer>());

            A.CallTo(() => _individualScalingTask.AllParameterScalingsFrom(_sourceIndividual, _targetIndividual)).Returns(new[] { _parameterScaling1, _parameterScaling2 });
            A.CallTo(() => _parameterScaling1.SourceParameter).Returns(p1);
            A.CallTo(() => _parameterScaling2.SourceParameter).Returns(p2);
        }
Example #5
0
        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 void Context()
      {
         base.Context();
         _individual = new Individual().WithName("Individual");
         _container = new Container().WithName("TOTO");
         _parameter = new Parameter().WithName("Pa1");
         _parameter.Formula = new ExplicitFormula();
         _oneRelativeObjectPath = new FormulaUsablePath(new[] {"A", "B", "C"});
         _oneRelativeObjectPathAsString = _oneRelativeObjectPath.ToString();
         _parameter.Formula.AddObjectPath(_oneRelativeObjectPath);
         _oneOrganismAbsoluteObjectPath = new FormulaUsablePath(new[] { Constants.ORGANISM, "B", "C" });
         _oneOrganismAbsoluteObjectPathAsString = _oneOrganismAbsoluteObjectPath.ToString();
         _parameter.Formula.AddObjectPath(_oneOrganismAbsoluteObjectPath);

         _container.Add(_parameter);
         _individual.Add(_container);
      }
Example #7
0
        public static Population CreateDefaultPopulation(Individual individual)
        {
            var populationFactory  = IoC.Resolve <IRandomPopulationFactory>();
            var populationSettings = IoC.Resolve <IIndividualToPopulationSettingsMapper>().MapFrom(individual);

            //Non Age dependent species. We have to make sure that we set correct weight so that the algorithm can randomize target weight
            if (!individual.IsAgeDependent)
            {
                var weightValue = individual.MeanWeight;
                var weightRange = populationSettings.ParameterRange(CoreConstants.Parameters.MEAN_WEIGHT);
                weightRange.MinValue = weightValue / 10;
                weightRange.MaxValue = weightValue * 10;
            }
            populationSettings.NumberOfIndividuals = 3;
            var population = populationFactory.CreateFor(populationSettings, new CancellationToken()).Result;

            return(population.WithName("POP"));
        }
        protected override Task Context()
        {
            _individualMapper         = A.Fake <IndividualMapper>();
            _parameterRangeMapper     = A.Fake <ParameterRangeMapper>();
            _genderRepository         = A.Fake <IGenderRepository>();
            _populationSettingsMapper = A.Fake <IIndividualToPopulationSettingsMapper>();
            sut = new RandomPopulationSettingsMapper(_parameterRangeMapper, _individualMapper, _populationSettingsMapper, _genderRepository);

            _ageParameterRange = new ConstrainedParameterRange {
                ParameterName = CoreConstants.Parameters.AGE
            };
            _weightParameterRange = new ParameterRange {
                ParameterName = CoreConstants.Parameters.MEAN_WEIGHT
            };

            A.CallTo(() => _parameterRangeMapper.MapToSnapshot(null)).Returns((Snapshots.ParameterRange)null);
            _ageRangeSnapshot = new Snapshots.ParameterRange();
            A.CallTo(() => _parameterRangeMapper.MapToSnapshot(_ageParameterRange)).Returns(_ageRangeSnapshot);

            _weightRangeSnapshot = new Snapshots.ParameterRange();
            A.CallTo(() => _parameterRangeMapper.MapToSnapshot(_weightParameterRange)).Returns(_weightRangeSnapshot);


            _baseIndividual     = new Individual();
            _snapshotIndividual = new Snapshots.Individual();
            A.CallTo(() => _individualMapper.MapToSnapshot(_baseIndividual)).Returns(_snapshotIndividual);

            _randomPopulationSettings = new RandomPopulationSettings
            {
                NumberOfIndividuals = 10,
                BaseIndividual      = _baseIndividual
            };

            _randomPopulationSettings.AddParameterRange(_weightParameterRange);
            _randomPopulationSettings.AddParameterRange(_ageParameterRange);

            A.CallTo(() => _genderRepository.Female).Returns(new Gender {
                Id = "Female", Name = "Female"
            });
            A.CallTo(() => _genderRepository.Male).Returns(new Gender {
                Id = "Male", Name = "Male"
            });
            return(Task.FromResult(true));
        }
Example #9
0
        protected override async Task Context()
        {
            await base.Context();

            _newIndividual = new Individual();
            _newAgeRange   = new ParameterRange {
                ParameterName = CoreConstants.Parameters.AGE
            };
            _newWeightRange = new ParameterRange {
                ParameterName = CoreConstants.Parameters.MEAN_WEIGHT
            };

            _snapshot = await sut.MapToSnapshot(_randomPopulationSettings);

            _snapshot.ProportionOfFemales = _proportionOfFemale;

            A.CallTo(() => _parameterRangeMapper.MapToModel(_snapshot.Age, A <ParameterRangeSnapshotContext> .That.Matches(x => x.ParameterRange == _newAgeRange))).Returns(_newAgeRange);
            A.CallTo(() => _parameterRangeMapper.MapToModel(_snapshot.Weight, A <ParameterRangeSnapshotContext> .That.Matches(x => x.ParameterRange == _newWeightRange))).Returns(_newWeightRange);
            A.CallTo(() => _individualMapper.MapToModel(_snapshotIndividual, _snapshotContext)).Returns(_newIndividual);

            _mappedSettings = new RandomPopulationSettings();
            A.CallTo(() => _populationSettingsMapper.MapFrom(_newIndividual)).Returns(_mappedSettings);
            _mappedSettings.AddParameterRange(_newAgeRange);
            _mappedSettings.AddParameterRange(_newWeightRange);

            _maleRatio = new GenderRatio
            {
                Gender = _genderRepository.Male,
                Ratio  = 50
            };

            _femaleRatio = new GenderRatio
            {
                Gender = _genderRepository.Female,
                Ratio  = 50
            };

            _mappedSettings.AddGenderRatio(_maleRatio);
            _mappedSettings.AddGenderRatio(_femaleRatio);

            _snapshot.DiseaseStateParameters = null;
        }
        protected override async Task Context()
        {
            await base.Context();

            _newIndividual = new Individual();

            _snapshot = await sut.MapToSnapshot(_randomPopulationSettings);

            _snapshot.ProportionOfFemales = null;
            A.CallTo(() => _individualMapper.MapToModel(_snapshotIndividual)).Returns(_newIndividual);

            _mappedSettings = new RandomPopulationSettings();
            A.CallTo(() => _populationSettingsMapper.MapFrom(_newIndividual)).Returns(_mappedSettings);
            _unknownGender = new GenderRatio
            {
                Gender = new Gender {
                    Id = "Gender"
                },
                Ratio = 100
            };
            _mappedSettings.AddGenderRatio(_unknownGender);
        }
Example #11
0
        protected override Task Context()
        {
            _parameterMapper = A.Fake <ParameterMapper>();
            _logger          = A.Fake <IOSPSuiteLogger>();

            sut = new ExpressionContainerMapper(_parameterMapper, _logger);

            _relativeExpressionParameter =
                DomainHelperForSpecs.ConstantParameterWithValue(0, isDefault: true).WithName(CoreConstants.Parameters.REL_EXP);
            _moleculeExpressionContainer = new MoleculeExpressionContainer().WithName("EXP");
            _moleculeExpressionContainer.Add(_relativeExpressionParameter);

            _transporterRelativeExpressionParameter =
                DomainHelperForSpecs.ConstantParameterWithValue(0, isDefault: true).WithName(CoreConstants.Parameters.REL_EXP);
            _transporterExpressionContainer = new TransporterExpressionContainer().WithName("TRANS");
            _transporterExpressionContainer.TransportDirection = TransportDirectionId.InfluxInterstitialToIntracellular;

            _bloodCellsExpressionContainer = new TransporterExpressionContainer().WithName(CoreConstants.Compartment.BLOOD_CELLS);
            _bloodCellsExpressionContainer.TransportDirection = TransportDirectionId.BiDirectionalBloodCellsPlasma;

            _transporterExpressionContainer.Add(_transporterRelativeExpressionParameter);

            _individual = new Individual {
                OriginData = new OriginData {
                    Species = new Species().WithName("Human")
                }
            };
            _expressionContainerMapperContext = new ExpressionContainerMapperContext(new SnapshotContext())
            {
            };

            _enzyme = new IndividualEnzyme {
                _moleculeExpressionContainer
            };
            _transporter = new IndividualTransporter {
                _transporterExpressionContainer, _bloodCellsExpressionContainer
            };
            return(_completed);
        }
        protected override Task Context()
        {
            _parameterMapper           = A.Fake <ParameterMapper>();
            _transportContainerUpdater = A.Fake <ITransportContainerUpdater>();
            _logger = A.Fake <ILogger>();

            sut = new ExpressionContainerMapper(_parameterMapper, _transportContainerUpdater, _logger);

            _relativeExpressionParameter = DomainHelperForSpecs.ConstantParameterWithValue(0, isDefault: true).WithName(CoreConstants.Parameters.REL_EXP);
            _moleculeExpressionContainer = new MoleculeExpressionContainer().WithName("EXP");
            _moleculeExpressionContainer.Add(_relativeExpressionParameter);

            _transporterRelativeExpressionParameter          = DomainHelperForSpecs.ConstantParameterWithValue(0, isDefault: true).WithName(CoreConstants.Parameters.REL_EXP);
            _transporterExpressionContainer                  = new TransporterExpressionContainer().WithName("TRANS");
            _transporterExpressionContainer.MembraneLocation = MembraneLocation.Apical;

            _transporterExpressionContainer.Add(_transporterRelativeExpressionParameter);

            _individual = new Individual {
                OriginData = new  Model.OriginData {
                    Species = new Species().WithName("Human")
                }
            };

            _expressionContainerMapperContext = new ExpressionContainerMapperContext
            {
                SimulationSubject = _individual
            };

            _enzyme = new IndividualEnzyme {
                _moleculeExpressionContainer
            };
            _transporter = new IndividualTransporter {
                _transporterExpressionContainer
            };
            return(_completed);
        }
Example #13
0
        protected override Task Context()
        {
            _classificationMapper          = A.Fake <ClassificationMapper>();
            _snapshotMapper                = A.Fake <ISnapshotMapper>();
            _executionContext              = A.Fake <IExecutionContext>();
            _lazyLoadTask                  = A.Fake <ILazyLoadTask>();
            _simulationMapper              = A.Fake <SimulationMapper>();
            _simulationComparisonMapper    = A.Fake <SimulationComparisonMapper>();
            _parameterIdentificationMapper = A.Fake <ParameterIdentificationMapper>();
            _classificationSnapshotTask    = A.Fake <IClassificationSnapshotTask>();
            _qualificationPlanMapper       = A.Fake <QualificationPlanMapper>();
            _creationMetaDataFactory       = A.Fake <ICreationMetaDataFactory>();
            _logger = A.Fake <ILogger>();

            sut = new ProjectMapper(
                _simulationMapper,
                _simulationComparisonMapper,
                _parameterIdentificationMapper,
                _qualificationPlanMapper,
                _executionContext,
                _classificationSnapshotTask,
                _lazyLoadTask,
                _creationMetaDataFactory,
                _logger);


            A.CallTo(() => _executionContext.Resolve <ISnapshotMapper>()).Returns(_snapshotMapper);
            _individual               = new Individual().WithName("IND");
            _compound                 = new Compound().WithName("COMP");
            _event                    = new PKSimEvent().WithName("EVENT");
            _formulation              = new Formulation().WithName("FORM");
            _protocol                 = new SimpleProtocol().WithName("PROTO");
            _population               = new RandomPopulation().WithName("POP");
            _observedData             = new DataRepository().WithName("OD");
            _parameterIdentification  = new OSPSuite.Core.Domain.ParameterIdentifications.ParameterIdentification().WithName("PI").WithId("PI_ID");
            _classifiableObservedData = new ClassifiableObservedData {
                Subject = _observedData
            };
            _classification = new Classification {
                ClassificationType = ClassificationType.ObservedData
            }.WithName("OD Classification");
            _simulationComparison = new IndividualSimulationComparison().WithName("COMP").WithId("SimComp");
            _simulation           = new IndividualSimulation().WithName("IND_SIM").WithId("IndSim");
            _qualificationPlan    = new QualificationPlan().WithName("QP").WithId("QP_ID");
            _project = new PKSimProject();
            _project.AddBuildingBlock(_individual);
            _project.AddBuildingBlock(_compound);
            _project.AddBuildingBlock(_event);
            _project.AddBuildingBlock(_formulation);
            _project.AddBuildingBlock(_protocol);
            _project.AddBuildingBlock(_population);
            _project.AddObservedData(_observedData);
            _project.AddBuildingBlock(_simulation);
            _project.AddClassifiable(_classifiableObservedData);
            _project.AddClassification(_classification);
            _project.AddSimulationComparison(_simulationComparison);
            _project.AddParameterIdentification(_parameterIdentification);
            _project.AddQualificationPlan(_qualificationPlan);

            _compoundSnapshot                              = new Snapshots.Compound();
            _individualSnapshot                            = new Snapshots.Individual();
            _eventSnapshot                                 = new Event();
            _formulationSnapshot                           = new Snapshots.Formulation();
            _protocolSnapshot                              = new Snapshots.Protocol();
            _populationSnapshot                            = new Snapshots.Population();
            _observedDataSnapshot                          = new Snapshots.DataRepository();
            _parameterIdentificationSnapshot               = new ParameterIdentification();
            _observedDataClassificationSnapshot            = new Snapshots.Classification();
            _simulationComparisonSnapshot                  = new SimulationComparison();
            _simulationClassificationSnapshot              = new Snapshots.Classification();
            _comparisonClassificationSnapshot              = new Snapshots.Classification();
            _parameterIdentificationClassificationSnapshot = new Snapshots.Classification();
            _qualificationPlanClassificationSnapshot       = new Snapshots.Classification();
            _qualificationPlanSnapshot                     = new Snapshots.QualificationPlan();
            _simulationSnapshot                            = new Simulation();


            A.CallTo(() => _snapshotMapper.MapToSnapshot(_compound)).Returns(_compoundSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_individual)).Returns(_individualSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_event)).Returns(_eventSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_formulation)).Returns(_formulationSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_protocol)).Returns(_protocolSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_population)).Returns(_populationSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_observedData)).Returns(_observedDataSnapshot);
            A.CallTo(() => _simulationMapper.MapToSnapshot(_simulation, _project)).Returns(_simulationSnapshot);
            A.CallTo(() => _simulationComparisonMapper.MapToSnapshot(_simulationComparison)).Returns(_simulationComparisonSnapshot);
            A.CallTo(() => _parameterIdentificationMapper.MapToSnapshot(_parameterIdentification, _project)).Returns(_parameterIdentificationSnapshot);
            A.CallTo(() => _qualificationPlanMapper.MapToSnapshot(_qualificationPlan)).Returns(_qualificationPlanSnapshot);

            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableObservedData>(_project)).Returns(new[] { _observedDataClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableSimulation>(_project)).Returns(new[] { _simulationClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableComparison>(_project)).Returns(new[] { _comparisonClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableParameterIdentification>(_project)).Returns(new[] { _parameterIdentificationClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableQualificationPlan>(_project)).Returns(new[] { _qualificationPlanClassificationSnapshot });

            return(_completed);
        }
Example #14
0
        protected override Task Context()
        {
            _solverSettingsMapper               = A.Fake <SolverSettingsMapper>();
            _outputSchemaMapper                 = A.Fake <OutputSchemaMapper>();
            _outputSelectionMapper              = A.Fake <OutputSelectionsMapper>();
            _parameterMapper                    = A.Fake <ParameterMapper>();
            _compoundPropertiesMapper           = A.Fake <CompoundPropertiesMapper>();
            _advancedParameterMapper            = A.Fake <AdvancedParameterMapper>();
            _eventMappingMapper                 = A.Fake <EventMappingMapper>();
            _observerSetMappingMapper           = A.Fake <ObserverSetMappingMapper>();
            _curveChartMapper                   = A.Fake <SimulationTimeProfileChartMapper>();
            _processMappingMapper               = A.Fake <ProcessMappingMapper>();
            _simulationFactory                  = A.Fake <ISimulationFactory>();
            _executionContext                   = A.Fake <IExecutionContext>();
            _simulationModelCreator             = A.Fake <ISimulationModelCreator>();
            _simulationBuildingBlockUpdater     = A.Fake <ISimulationBuildingBlockUpdater>();
            _modelPropertiesTask                = A.Fake <IModelPropertiesTask>();
            _simulationRunner                   = A.Fake <ISimulationRunner>();
            _populationAnalysisChartMapper      = A.Fake <PopulationAnalysisChartMapper>();
            _simulationParameterOriginIdUpdater = A.Fake <ISimulationParameterOriginIdUpdater>();
            _logger             = A.Fake <ILogger>();
            _containerTask      = A.Fake <IContainerTask>();
            _entityPathResolver = A.Fake <IEntityPathResolver>();

            sut = new SimulationMapper(_solverSettingsMapper, _outputSchemaMapper,
                                       _outputSelectionMapper, _compoundPropertiesMapper, _parameterMapper,
                                       _advancedParameterMapper, _eventMappingMapper, _observerSetMappingMapper, _curveChartMapper,
                                       _populationAnalysisChartMapper, _processMappingMapper,
                                       _simulationFactory, _executionContext, _simulationModelCreator,
                                       _simulationBuildingBlockUpdater, _modelPropertiesTask,
                                       _simulationRunner, _simulationParameterOriginIdUpdater,
                                       _logger, _containerTask, _entityPathResolver
                                       );

            _project    = new PKSimProject();
            _individual = new Individual {
                Name = "IND", Id = "IND"
            };
            _compound = new Compound {
                Name = "COMP", Id = "COMP"
            };
            _observerSet = new ObserverSet {
                Name = "OBS_SET", Id = "OBS_SET"
            };
            _protocol = new SimpleProtocol {
                Name = "PROT", Id = "PROT"
            };
            _inductionProcess = new InductionProcess().WithName("Interaction process");
            _compound.AddProcess(_inductionProcess);


            _event = new PKSimEvent {
                Name = "Event"
            };
            _population = new RandomPopulation()
            {
                Name = "POP"
            };
            _observedData = new DataRepository("OBS_ID").WithName("OBS");
            _project.AddBuildingBlock(_individual);
            _project.AddBuildingBlock(_compound);
            _project.AddBuildingBlock(_event);
            _project.AddBuildingBlock(_population);
            _project.AddBuildingBlock(_observerSet);
            _project.AddObservedData(_observedData);

            _simulationProperties = new SimulationProperties
            {
                ModelProperties = new ModelProperties
                {
                    ModelConfiguration = new ModelConfiguration {
                        ModelName = "4Comp"
                    }
                }
            };
            _interactionSelection = new InteractionSelection {
                ProcessName = _inductionProcess.Name
            };
            _noInteractionSelection = new InteractionSelection {
                MoleculeName = "CYP2D6"
            };

            _simulationProperties.InteractionProperties.AddInteraction(_interactionSelection);
            _simulationProperties.InteractionProperties.AddInteraction(_noInteractionSelection);

            _settings      = new SimulationSettings();
            _rootContainer = new Container().WithName("Sim");
            _model         = new OSPSuite.Core.Domain.Model {
                Root = _rootContainer
            };

            _individualSimulation = new IndividualSimulation
            {
                Name               = "S1",
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Description        = "Simulation Description",
                Model              = _model
            };

            _simulationTimeProfile         = new SimulationTimeProfileChart();
            _snapshotSimulationTimeProfile = new CurveChart();
            _individualSimulation.AddAnalysis(_simulationTimeProfile);

            A.CallTo(() => _curveChartMapper.MapToSnapshot(_simulationTimeProfile)).Returns(_snapshotSimulationTimeProfile);


            _populationSimulation = new PopulationSimulation
            {
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Model = _model
            };

            _advancedParameterCollection       = new AdvancedParameterCollection();
            _populationSimulationAnalysisChart = new BoxWhiskerAnalysisChart();
            _populationSimulation.SetAdvancedParameters(_advancedParameterCollection);
            _populationSimulation.AddAnalysis(_populationSimulationAnalysisChart);
            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndTemplateId", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual
            });

            _snapshotPopulationAnalysisChart = new Snapshots.PopulationAnalysisChart();

            A.CallTo(() => _populationAnalysisChartMapper.MapToSnapshot(_populationSimulationAnalysisChart)).Returns(_snapshotPopulationAnalysisChart);

            _snapshotInteraction = new CompoundProcessSelection();
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_interactionSelection)).Returns(_snapshotInteraction);
            _snapshotInteraction.CompoundName = _compound.Name;
            _snapshotInteraction.Name         = _inductionProcess.Name;

            _noSelectionSnapshotInteraction = new CompoundProcessSelection();
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_noInteractionSelection)).Returns(_noSelectionSnapshotInteraction);
            _noSelectionSnapshotInteraction.MoleculeName = _noInteractionSelection.MoleculeName;

            _compoundProperties         = new CompoundProperties();
            _snapshotCompoundProperties = new Snapshots.CompoundProperties {
                Name = _compound.Name
            };
            _individualSimulation.Properties.AddCompoundProperties(_compoundProperties);

            _eventMapping = new EventMapping();
            _individualSimulation.EventProperties.AddEventMapping(_eventMapping);

            _observerSetMapping = new ObserverSetMapping();
            _individualSimulation.ObserverSetProperties.AddObserverSetMapping(_observerSetMapping);

            A.CallTo(() => _compoundPropertiesMapper.MapToSnapshot(_compoundProperties, _project)).Returns(_snapshotCompoundProperties);


            _eventSelection = new EventSelection
            {
                Name = _event.Name,
            };

            _observerSetSelection = new ObserverSetSelection
            {
                Name = _observerSet.Name,
            };

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndTemplateId", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual,

                Altered = true
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("CompTemplateId", PKSimBuildingBlockType.Compound)
            {
                BuildingBlock = _compound
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("ProtTemplateId", PKSimBuildingBlockType.Protocol)
            {
                BuildingBlock = _protocol
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("ObserveSetTemplateId", PKSimBuildingBlockType.ObserverSet)
            {
                BuildingBlock = _observerSet
            });

            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("PopTemplateId", PKSimBuildingBlockType.Population)
            {
                BuildingBlock = _population
            });


            _individualSimulation.AddUsedObservedData(_observedData);

            A.CallTo(() => _eventMappingMapper.MapToSnapshot(_eventMapping, _project)).Returns(_eventSelection);
            A.CallTo(() => _observerSetMappingMapper.MapToSnapshot(_observerSetMapping, _project)).Returns(_observerSetSelection);

            _outputSelectionSnapshot = new OutputSelections();
            A.CallTo(() => _outputSelectionMapper.MapToSnapshot(_individualSimulation.OutputSelections)).Returns(_outputSelectionSnapshot);

            A.CallTo(() => _processMappingMapper.MapToModel(_snapshotInteraction, _inductionProcess)).Returns(_interactionSelection);

            return(_completed);
        }
Example #15
0
        protected override Task Context()
        {
            _parameterMapper                   = A.Fake <ParameterMapper>();
            _expressionContainerMapper         = A.Fake <ExpressionContainerMapper>();
            _executionContext                  = A.Fake <IExecutionContext>();
            _individualMoleculeFactoryResolver = A.Fake <IIndividualMoleculeFactoryResolver>();
            _ontogenyMapper = A.Fake <OntogenyMapper>();
            _ontogenyTask   = A.Fake <IOntogenyTask <Individual> >();
            _individualMoleculeParametersTask = A.Fake <IMoleculeParameterTask>();

            sut = new MoleculeMapper(_parameterMapper, _expressionContainerMapper,
                                     _ontogenyMapper, _individualMoleculeFactoryResolver, _executionContext, _ontogenyTask, _individualMoleculeParametersTask);

            _ontogeny = new DatabaseOntogeny
            {
                Name = "Ontogeny"
            };

            _enzyme = new IndividualEnzyme
            {
                Name        = "Enzyme",
                Description = "Help",
                Ontogeny    = _ontogeny,
            };

            _transporter = new IndividualTransporter
            {
                Name        = "Transporter",
                Description = "Help"
            };

            _otherProtein = new IndividualOtherProtein
            {
                Name        = "OtherProtein",
                Description = "Help"
            };

            _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"
            };
            _enzyme.AddChildren(_expressionContainer1, _expressionContainer2, _enzymeGlobalParameter);

            _relativeExpressionParameter1     = DomainHelperForSpecs.ConstantParameterWithValue(0.5).WithName(CoreConstants.Parameters.REL_EXP);
            _relativeExpressionParameterNorm1 = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(CoreConstants.Parameters.REL_EXP_NORM);
            _expressionContainer1.Add(_relativeExpressionParameter1);
            _expressionContainer1.Add(_relativeExpressionParameterNorm1);

            _relativeExpressionParameterNotSet     = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.REL_EXP);
            _relativeExpressionParameterNotSetNorm = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.REL_EXP_NORM);
            _expressionContainer2.Add(_relativeExpressionParameterNotSet);
            _expressionContainer2.Add(_relativeExpressionParameterNotSetNorm);

            _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);
        }
Example #16
0
        private void updateParameterFromIndividual(ISpatialStructure spatialStructure, Individual individual)
        {
            //Update parameter values for parameter that have been changed in individual
            var allIndividualParameters   = new PathCache <IParameter>(_entityPathResolver).For(individual.GetAllChildren <IParameter>());
            var allContainerParameters    = new PathCache <IParameter>(_entityPathResolver).For(spatialStructure.TopContainers.SelectMany(x => x.GetAllChildren <IParameter>()));
            var allNeighborhoodParameters = new PathCache <IParameter>(_entityPathResolver).For(spatialStructure.Neighborhoods.SelectMany(x => x.GetAllChildren <IParameter>()));

            _parameterSetUpdater.UpdateValues(allIndividualParameters, allContainerParameters);
            _parameterSetUpdater.UpdateValues(allIndividualParameters, allNeighborhoodParameters);

            _parameterIdUpdater.UpdateBuildingBlockId(allContainerParameters, individual);
            _parameterIdUpdater.UpdateBuildingBlockId(allNeighborhoodParameters, individual);

            copyParameterTags(allIndividualParameters, allContainerParameters);
            copyParameterTags(allIndividualParameters, allNeighborhoodParameters);
        }
Example #17
0
        private Task <LocalizedParameter[]> allParametersChangedByUserFrom(ModelIndividual individual)
        {
            var changedParameters = individual.GetAllChildren <IParameter>(x => x.ShouldExportToSnapshot());

            return(_parameterMapper.LocalizedParametersFrom(changedParameters));
        }
Example #18
0
        private Task <ExpressionContainer[]> expressionFor(IndividualMolecule molecule, ModelIndividual individual)
        {
            var allExpressionContainers = individual.AllMoleculeContainersFor(molecule);

            return(_expressionContainerMapper.MapToSnapshots(allExpressionContainers));
        }
Example #19
0
 public void PrepareForCreating(PKSim.Core.Model.Individual basedIndividual)
 {
     _lazyLoadTask.Load(basedIndividual);
     _populationSettingsDTO = _populationSettingsMapper.MapFrom(basedIndividual);
     this.DoWithinLatch(updateView);
 }
Example #20
0
        private void updateMoleculePropertiesToMolecule(IndividualMolecule molecule, SnapshotExpressionProfile snapshot, ModelIndividual individual, SnapshotContext snapshotContext)
        {
            switch (molecule)
            {
            case IndividualProtein protein:
                var localization = retrieveLocalizationFrom(snapshot, snapshotContext);
                //Set set it first to none to ensure that it is set properly after reading from the snapshot file
                protein.Localization = Localization.None;
                _moleculeExpressionTask.SetExpressionLocalizationFor(protein, localization, individual);

                break;

            case IndividualTransporter transporter:
                _moleculeExpressionTask.SetTransporterTypeFor(transporter, ModelValueFor(snapshot.TransportType));
                break;
            }
        }
Example #21
0
 public PopulationSettingsDTO MapFrom(PKSim.Core.Model.Individual individual)
 {
     return(MapFrom(_individualToPopulationSettingsMapper.MapFrom(individual)));
 }
Example #22
0
        protected override Task Context()
        {
            _individualMapper         = A.Fake <IndividualMapper>();
            _parameterRangeMapper     = A.Fake <ParameterRangeMapper>();
            _genderRepository         = A.Fake <IGenderRepository>();
            _populationSettingsMapper = A.Fake <IIndividualToPopulationSettingsMapper>();
            _logger = A.Fake <IOSPSuiteLogger>();
            sut     = new RandomPopulationSettingsMapper(_parameterRangeMapper, _individualMapper, _populationSettingsMapper, _genderRepository, _logger);

            _ageParameterRange = new ConstrainedParameterRange {
                ParameterName = CoreConstants.Parameters.AGE
            };
            _weightParameterRange = new ParameterRange {
                ParameterName = CoreConstants.Parameters.MEAN_WEIGHT
            };

            A.CallTo(() => _parameterRangeMapper.MapToSnapshot(null)).Returns((Snapshots.ParameterRange)null);
            _ageRangeSnapshot = new Snapshots.ParameterRange();
            A.CallTo(() => _parameterRangeMapper.MapToSnapshot(_ageParameterRange)).Returns(_ageRangeSnapshot);

            _weightRangeSnapshot = new Snapshots.ParameterRange();
            A.CallTo(() => _parameterRangeMapper.MapToSnapshot(_weightParameterRange)).Returns(_weightRangeSnapshot);


            _baseIndividual = new Individual
            {
                OriginData = new OriginData()
            };
            _diseaseStateParameter = new OriginDataParameter(10, "mg/kg", "DIS_STATE_PARAM");
            _baseIndividual.OriginData.AddDiseaseStateParameter(_diseaseStateParameter);

            _diseaseStateParameterRangeSnapshot = new Snapshots.ParameterRange();
            _diseaseStateParameterRange         = new ConstrainedParameterRange {
                ParameterName = _diseaseStateParameter.Name
            };
            A.CallTo(() => _parameterRangeMapper.MapToSnapshot(_diseaseStateParameterRange)).Returns(_diseaseStateParameterRangeSnapshot);


            _snapshotIndividual = new Snapshots.Individual();
            A.CallTo(() => _individualMapper.MapToSnapshot(_baseIndividual)).Returns(_snapshotIndividual);

            _randomPopulationSettings = new RandomPopulationSettings
            {
                NumberOfIndividuals = 10,
                BaseIndividual      = _baseIndividual
            };

            _randomPopulationSettings.AddParameterRange(_weightParameterRange);
            _randomPopulationSettings.AddParameterRange(_ageParameterRange);
            _randomPopulationSettings.AddParameterRange(_diseaseStateParameterRange);

            A.CallTo(() => _genderRepository.Female).Returns(new Gender {
                Id = "Female", Name = "Female"
            });
            A.CallTo(() => _genderRepository.Male).Returns(new Gender {
                Id = "Male", Name = "Male"
            });

            _project         = new PKSimProject();
            _snapshotContext = new SnapshotContext(_project, ProjectVersions.Current);
            return(Task.FromResult(true));
        }
Example #23
0
 protected override async Task Because()
 {
     _newIndividual = await sut.MapToModel(_snapshot, _snapshotContext);
 }
        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);
        }
Example #25
0
        private void addNeighborhoods(ISpatialStructure spatialStructure, Organism organism, Individual individual, ModelProperties modelProperties, IFormulaCache formulaCache)
        {
            var neighborhoodList = _modelNeighborhoodQuery.NeighborhoodsFor(individual.Neighborhoods, modelProperties).ToList();

            foreach (var neighborhood in neighborhoodList)
            {
                addNeighborhood(neighborhood, spatialStructure, individual.OriginData, modelProperties, formulaCache);
            }

            _neighborhoodFinalizer.SetNeighborsIn(organism, neighborhoodList);
        }