Ejemplo n.º 1
0
        public void SetDefaultSettingsForTransporter(IndividualTransporter transporter, string species, string transporterName)
        {
            transporter.TransportType = _transporterContainerTemplateRepository.TransportTypeFor(species, transporterName);

            foreach (var transporterContainer in transporter.AllExpressionsContainers())
            {
                //there is a db template
                var tranporterTemplate = _transporterContainerTemplateRepository.TransportersFor(species, transporterContainer.Name, transporterName).FirstOrDefault();
                if (tranporterTemplate != null)
                {
                    transporterContainer.UpdatePropertiesFrom(tranporterTemplate);
                }
                else
                {
                    UpdateTransporterFromTemplate(transporterContainer, species, MembraneLocationToUse(transporterContainer, transporter.TransportType), transporter.TransportType);
                }
            }

            if (_transporterContainerTemplateRepository.HasTransporterTemplateFor(species, transporterName))
            {
                return;
            }

            //No template was found for the given name. Raise event warning
            _eventPublisher.PublishEvent(new NoTranporterTemplateAvailableEvent(transporter));
        }
Ejemplo n.º 2
0
        public void UpdateExpressionParameters(IndividualTransporterDTO individualTransporterDTO, ISimulationSubject simulationSubject)
        {
            var transporter = individualTransporterDTO.Transporter;

            individualTransporterDTO.ClearExpressionParameters();

            //Local parameters
            foreach (var transporterExpressionContainer in simulationSubject.AllMoleculeContainersFor <TransporterExpressionContainer>(transporter))
            {
                var organ = transporterExpressionContainer.LogicalContainer;
                var isInOrganWithLumenOrBrain = organ.IsOrganWithLumen() || organ.IsBrain();

                foreach (var parameter in transporterExpressionContainer.AllParameters())
                {
                    var expressionParameterDTO = _expressionParameterMapper.MapFrom(parameter);
                    expressionParameterDTO.TransporterExpressionContainer = transporterExpressionContainer;
                    expressionParameterDTO.IsInOrganWithLumenOrBrain      = isInOrganWithLumenOrBrain;
                    var direction = retrieveTransporterDirectionFor(transporterExpressionContainer, parameter, isInOrganWithLumenOrBrain);
                    expressionParameterDTO.TransportDirection = _transportDirectionRepository.ById(direction);
                    individualTransporterDTO.AddExpressionParameter(expressionParameterDTO);
                }
            }

            //Global parameters;
            foreach (var parameter in transporter.AllGlobalExpressionParameters)
            {
                var expressionParameter = _expressionParameterMapper.MapFrom(parameter);
                expressionParameter.TransporterExpressionContainer = parameter.IsNamed(REL_EXP_BLOOD_CELLS)
               ? transporter.BloodCellsContainer
               : transporter.VascularEndotheliumContainer;

                var direction = expressionParameter.TransporterExpressionContainer.TransportDirection;
                expressionParameter.TransportDirection = _transportDirectionRepository.ById(direction);
                individualTransporterDTO.AddExpressionParameter(expressionParameter);
            }

            var hasTemplateForSpecies = _transporterContainerTemplateRepository.HasTransporterTemplateFor(simulationSubject.Species.Name, transporter.Name);

            individualTransporterDTO.DefaultAvailableInDatabase = hasTemplateForSpecies;
        }
Ejemplo n.º 3
0
        public void SetDefaultSettingsForTransporter(ISimulationSubject simulationSubject, IndividualTransporter transporter, string transporterName)
        {
            var speciesName = simulationSubject.Species.Name;

            transporter.TransportType = _transporterContainerTemplateRepository.TransportTypeFor(speciesName, transporterName);

            foreach (var transporterContainer in simulationSubject.AllMoleculeContainersFor <TransporterExpressionContainer>(transporter))
            {
                //there is a db template
                var transporterTemplate = _transporterContainerTemplateRepository
                                          .TransportersFor(speciesName, transporterContainer.LogicalContainerName, transporterName)
                                          .FirstOrDefault();

                updateTransporterContainerFromTemplate(transporterContainer, transporterTemplate, transporter.TransportType);
            }

            if (_transporterContainerTemplateRepository.HasTransporterTemplateFor(speciesName, transporterName))
            {
                return;
            }

            //No template was found for the given name. Raise event warning
            _eventPublisher.PublishEvent(new NoTransporterTemplateAvailableEvent(transporter));
        }
Ejemplo n.º 4
0
        protected override void Context()
        {
            _repository     = A.Fake <ITransporterContainerTemplateRepository>();
            _eventPublisher = A.Fake <IEventPublisher>();
            _transportDirectionRepository = A.Fake <ITransportDirectionRepository>();
            sut = new TransportContainerUpdater(_repository, _eventPublisher);
            _fractionExpressedApical       = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(CoreConstants.Parameters.FRACTION_EXPRESSED_APICAL);
            _fractionExpressedApicalMucosa = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.FRACTION_EXPRESSED_APICAL);
            _fractionExpressedApicalBone   = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(CoreConstants.Parameters.FRACTION_EXPRESSED_APICAL);
            //Indicates that this parameter should not be visible to the user and therefore remains unchanged
            _fractionExpressedApicalBone.Visible = false;
            _individual = A.Fake <ISimulationSubject>();
            _individual.Species.Name = _species;
            _transporter             = new IndividualTransporter {
                TransportType = TransportType.Efflux, Name = "toto"
            };
            var organism         = new Organism();
            var mucosa           = new Container().WithName(CoreConstants.Compartment.MUCOSA).WithParentContainer(organism);
            var liver            = new Container().WithName(CoreConstants.Organ.LIVER).WithParentContainer(organism);
            var liverCell        = new Container().WithName(CoreConstants.Compartment.INTRACELLULAR).WithParentContainer(liver);
            var kidney           = new Container().WithName(CoreConstants.Organ.KIDNEY).WithParentContainer(organism);
            var kidneyCell       = new Container().WithName(CoreConstants.Compartment.INTRACELLULAR).WithParentContainer(kidney);
            var bone             = new Container().WithName(CoreConstants.Organ.BONE).WithParentContainer(organism);
            var boneInterstitial = new Container().WithName(CoreConstants.Compartment.INTERSTITIAL).WithParentContainer(bone);

            _transporterWithTemplate = new TransporterExpressionContainer {
                TransportDirection = TransportDirectionId.InfluxInterstitialToIntracellular
            }
            .WithParentContainer(liverCell);
            _transporterWithoutTemplate = new TransporterExpressionContainer
            {
                TransportDirection = TransportDirectionId.EffluxIntracellularToInterstitial
            }
            .WithParentContainer(kidneyCell);

            _transporterInMucosa = new TransporterExpressionContainer {
                TransportDirection = TransportDirectionId.InfluxInterstitialToIntracellular
            }
            .WithParentContainer(mucosa);

            _transporterInBone = new TransporterExpressionContainer {
                TransportDirection = TransportDirectionId.InfluxInterstitialToIntracellular
            }
            .WithParentContainer(boneInterstitial);

            _transporterInMucosa.Add(_fractionExpressedApicalMucosa);
            _transporterWithoutTemplate.Add(_fractionExpressedApical);
            _transporterInBone.Add(_fractionExpressedApicalBone);

            A.CallTo(() => _individual.AllMoleculeContainersFor <TransporterExpressionContainer>(_transporter))
            .Returns(new[] { _transporterWithTemplate, _transporterWithoutTemplate, _transporterInMucosa, _transporterInBone });

            _transporterContainerTemplate = new TransporterContainerTemplate {
                TransportType = TransportType.Influx
            };
            _allTransporterTemplates.Add(_transporterContainerTemplate);

            A.CallTo(() => _repository.HasTransporterTemplateFor(_species, _transporter.Name)).Returns(true);
            A.CallTo(() => _repository.TransportTypeFor(_species, _transporter.Name)).Returns(TransportType.Influx);
            A.CallTo(() => _repository.TransportersFor(_species, liver.Name, _transporter.Name)).Returns(_allTransporterTemplates);
            A.CallTo(() => _repository.TransportersFor(_species, kidney.Name, _transporter.Name)).Returns(new List <TransporterContainerTemplate>());
        }