public void UpdateTransporterFromTemplate(ITransporterExpressionContainer transporterContainer, string species, MembraneLocation membraneLocation, TransportType transportType)
        {
            //we need to retrieve the process name for the given MembraneTupe/Process Type combo
            var templateToUse = _transporterContainerTemplateRepository.TransportersFor(species, transporterContainer.Name)
                                .Where(x => x.MembraneLocation == membraneLocation)
                                .FirstOrDefault(x => x.TransportType == transportType);

            //That should never happen, otherwise we would have a transporter container with an unknown process
            if (templateToUse == null)
            {
                throw new PKSimException(PKSimConstants.Error.CouldNotFindTransporterFor(transporterContainer.Name, membraneLocation.ToString(), transportType.ToString()));
            }

            transporterContainer.UpdatePropertiesFrom(templateToUse);
        }
Example #2
0
        public override void GlobalContext()
        {
            base.GlobalContext();
            _transporterContainerTemplateRepository = IoC.Resolve <ITransporterContainerTemplateRepository>();
            var allTransporters = _transporterContainerTemplateRepository.TransportersFor(_individual.Species.Name, CoreConstants.Organ.Brain);

            var influxBBB = allTransporters.Where(x => x.MembraneLocation == MembraneLocation.BloodBrainBarrier)
                            .FirstOrDefault(x => x.TransportType == TransportType.Influx);

            _transporter = _transporterFactory.CreateFor(_individual).DowncastTo <IndividualTransporter>().WithName("TRANS");
            var transportContainer = _transporter.ExpressionContainer(CoreConstants.Organ.Brain).DowncastTo <TransporterExpressionContainer>();

            transportContainer.UpdatePropertiesFrom(influxBBB);
            _individual.AddMolecule(_transporter);
            _transportProcess = _cloneManager.Clone(_compoundProcessRepository.ProcessByName(CoreConstantsForSpecs.Process.ACTIVE_TRANSPORT_SPECIFIC_MM)
                                                    .DowncastTo <PartialProcess>());
            _transportProcess.Name = "My Transport Process";
            _compound.AddProcess(_transportProcess);

            _simulation = DomainFactoryForSpecs.CreateModelLessSimulationWith(_individual, _compound, _protocol)
                          .DowncastTo <IndividualSimulation>();

            _simulation.CompoundPropertiesList.First()
            .Processes
            .TransportAndExcretionSelection
            .AddPartialProcessSelection(new EnzymaticProcessSelection {
                CompoundName = _compound.Name, ProcessName = _transportProcess.Name, MoleculeName = _transporter.Name
            });

            DomainFactoryForSpecs.AddModelToSimulation(_simulation);
        }
Example #3
0
 public IEnumerable <MembraneLocation> AllProteinMembraneLocationsFor(TransporterExpressionContainerDTO transporterExpressionContainerDTO)
 {
     return(_transporterContainerTemplateRepository
            .TransportersFor(SimulationSubject.Species.Name, transporterExpressionContainerDTO.ContainerName)
            .Where(x => x.TransportType == _transporter.TransportType)
            .Select(x => x.MembraneLocation)
            .Distinct());
 }
Example #4
0
        private void addLiverZoneExpression(Individual individual, IndividualTransporter transporter, string zoneName)
        {
            var liver = individual.Organism.Organ(CoreConstants.Organ.Liver);
            var zone  = liver.Compartment(zoneName);

            var transportToBile = _transporterContainerTemplateRepository.TransportersFor(individual.Species.Name, zone.Name)
                                  .Where(x => x.MembraneLocation == MembraneLocation.Apical)
                                  .First(x => x.TransportType == TransportType.Efflux);

            var transporterContainer = addTransporterExpressionForContainer(individual, transporter, zone, CoreConstants.Groups.ORGANS_AND_TISSUES, transportToBile);

            transporterContainer.ClearProcessNames();

            transporterContainer.AddProcessName(CoreConstants.Process.BILIARY_CLEARANCE_TO_GALL_BLADDER);
            transporterContainer.AddProcessName(CoreConstants.Process.BILIARY_CLEARANCE_TO_DUODENUM);
            transporterContainer.RelativeExpression     = 100;
            transporterContainer.RelativeExpressionNorm = 1;
        }
Example #5
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));
        }
Example #6
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>());
        }