Пример #1
0
        public ICommand AddMoleculeTo <TMolecule>(TSimulationSubject simulationSubject) where TMolecule : IndividualMolecule
        {
            var moleculeFactory = _individualMoleculeFactoryResolver.FactoryFor <TMolecule>();
            var newMolecule     = moleculeFactory.CreateFor(simulationSubject);

            //databse was defined for this species
            if (CanQueryProteinExpressionsFor(simulationSubject))
            {
                return(proteinFromQuery(simulationSubject, newMolecule));
            }

            //no database defined for the species. return the simple configuration
            return(simpleMolecule <TMolecule>(simulationSubject, newMolecule));
        }
        private void updateSpecies(ExpressionProfile expressionProfile, Species species, Type individualMoleculeType, string moleculeName)
        {
            var moleculeFactory = _individualMoleculeFactoryResolver.FactoryFor(individualMoleculeType);

            expressionProfile.Individual = _individualFactory.CreateParameterLessIndividual(species);
            moleculeFactory.AddMoleculeTo(expressionProfile.Individual, moleculeName);
        }
Пример #3
0
        private TMolecule addMoleculeTo <TMolecule>(Model.Individual individual, Molecule molecule) where TMolecule : IndividualMolecule
        {
            var proteinFactory = _moleculeFactoryResolver.FactoryFor <TMolecule>();
            var newMolecule    = proteinFactory.CreateFor(individual);

            newMolecule.ReferenceConcentration.Value = molecule.ReferenceConcentration;
            newMolecule.HalfLifeLiver.Value          = molecule.HalfLifeLiver;
            newMolecule.HalfLifeIntestine.Value      = molecule.HalfLifeIntestine;
            newMolecule.Name = molecule.Name;
            individual.AddMolecule(newMolecule);

            foreach (var expression in molecule.Expressions)
            {
                var expressionParameter = newMolecule.GetRelativeExpressionNormParameterFor(expression.Key);
                if (expressionParameter == null)
                {
                    _batchLogger.AddWarning($"Relative Expression container '{expression.Key}' not found for '{molecule.Name}'");
                    continue;
                }

                expressionParameter.Value = expression.Value;
                _batchLogger.AddDebug($"Relative Expression norm for container '{expression.Key}' set to {expression.Value}");
            }
            return(newMolecule.DowncastTo <TMolecule>());
        }
        public ICommand AddExpressionProfile(TSimulationSubject simulationSubject, ExpressionProfile expressionProfile)
        {
            var moleculeFactory = _individualMoleculeFactoryResolver.FactoryFor(expressionProfile.Molecule);
            var molecule        = moleculeFactory.AddMoleculeTo(simulationSubject, expressionProfile.MoleculeName);

            simulationSubject.AddExpressionProfile(expressionProfile);
            _expressionProfileUpdater.SynchroniseSimulationSubjectWithExpressionProfile(simulationSubject, expressionProfile);
            return(_simulationSubjectExpressionTask.AddMoleculeTo(molecule, simulationSubject));
        }
Пример #5
0
        private IIndividualMoleculeFactory factoryFor(Molecule molecule)
        {
            var moleculeType = molecule.Type;

            switch (moleculeType)
            {
            case QuantityType.Enzyme:
                return(_individualMoleculeFactoryResolver.FactoryFor <IndividualEnzyme>());

            case QuantityType.OtherProtein:
                return(_individualMoleculeFactoryResolver.FactoryFor <IndividualOtherProtein>());

            case QuantityType.Transporter:
                return(_individualMoleculeFactoryResolver.FactoryFor <IndividualTransporter>());

            default:
                throw new SnapshotOutdatedException(PKSimConstants.Error.MoleculeTypeNotSupported(moleculeType.ToString()));
            }
        }
        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()
        {
            _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
                );
        }
Пример #8
0
        private void convertMolecule(IndividualMolecule moleculeToConvert, Individual individual)
        {
            //Complete reorganization of molecules in the new version. We need to update value of relative expression.
            //We know that localization was already updated during xml conversion
            var factory = _individualMoleculeFactoryResolver.FactoryFor(moleculeToConvert);

            //Remove from individual so that we can add it again.
            individual.RemoveMolecule(moleculeToConvert);

            //New molecules is added. We need to update all global parameters as well as relative expression parameters
            var newMolecule = factory.AddMoleculeTo(individual, moleculeToConvert.Name);

            if (newMolecule == null)
            {
                return;
            }

            newMolecule.Ontogeny = moleculeToConvert.Ontogeny;

            var allExpressionParameters = individual.AllExpressionParametersFor(newMolecule);

            moleculeToConvert.GetAllChildren <MoleculeExpressionContainer>().Each(x => { convertParameter(x.RelativeExpressionParameter, allExpressionParameters[x.Name]); });

            moleculeToConvert.AllParameters().Each(p => convertParameter(p, newMolecule.Parameter(p.Name)));

            //Perform normalization
            NormalizeRelativeExpressionCommand.NormalizeExpressions(individual, newMolecule);

            //Do reset default value that may be set to 0
            allExpressionParameters.Each(x => x.DefaultValue = null);

            //molecule specific conversion
            convertIndividualProtein(moleculeToConvert, newMolecule, individual);

            convertIndividualTransporter(moleculeToConvert, newMolecule, individual);
        }