示例#1
0
        private void updateTransporterTagsFor(ITransportBuilder transporterBuilder, InducedProcess inducedProcess)
        {
            var sourceCriteria = transporterBuilder.SourceCriteria;
            var allSourceTags  = sourceCriteria.OfType <MatchTagCondition>().Select(x => x.Tag).ToList();

            var(sourceIsLumen, sourceIsMucosa) = (allSourceTags.Contains(LUMEN), allSourceTags.Contains(MUCOSA));

            var targetCriteria = transporterBuilder.TargetCriteria;
            var allTargetTags  = targetCriteria.OfType <MatchTagCondition>().Select(x => x.Tag).ToList();

            var(targetIsLumen, targetIsMucosa) = (allTargetTags.Contains(LUMEN), allTargetTags.Contains(MUCOSA));

            var isLumen  = sourceIsLumen || targetIsLumen;
            var isMucosa = sourceIsMucosa || targetIsMucosa;

            if (isLumen && isMucosa)
            {
                //We just want to remove GI segments from the include list as we know, that the transport is between Lumen and Mucosa in this case
                var segmentToDeletes = inducedProcess.OrgansToExclude.Intersect(LumenSegmentsDuodenumToRectum).ToList();
                var criteria         = sourceIsLumen ? sourceCriteria : targetCriteria;
                addAsNotMatchToCriteria(criteria, segmentToDeletes);
                return;
            }

            // This is a specific transport and we do not need to do anything
            if (allSourceTags.Count > 1)
            {
                return;
            }

            addAsNotMatchToCriteria(sourceCriteria, inducedProcess.OrgansToExclude);
        }
示例#2
0
        private IReadOnlyCollection <InducedProcess> allInducedProcessesFor(IndividualTransporter transporter, Individual individual)
        {
            var inducedProcessCache      = new Cache <string, InducedProcess>(x => x.Name, x => null);
            var allTransporterContainers = individual.AllMoleculeContainersFor <TransporterExpressionContainer>(transporter)
                                           .Where(x => x.TransportDirection != TransportDirectionId.None).ToList();

            //Global containers surrogate do not have a logical container associated
            var allOrganNames = new HashSet <string>(allTransporterContainers.Select(x => x.LogicalContainerName).Where(x => !string.IsNullOrEmpty(x)));

            foreach (var transporterContainer in allTransporterContainers)
            {
                //Logical containerName is empty for surrogate containers
                var logicalContainer = transporterContainer.LogicalContainerName;

                var allTransportTemplates = _transportTemplateRepository.All()
                                            .Where(x => x.TransportDirection == transporterContainer.TransportDirection);

                //a logical container is defined. We are dealing with a localized transporter
                if (!string.IsNullOrEmpty(logicalContainer))
                {
                    //For apical transport for Lumen => Mucosa, the compartment is the name of our mapping
                    allTransportTemplates = allTransportTemplates
                                            .Where(x => (x.SourceOrgan == logicalContainer || x.SourceCompartment == logicalContainer));
                }

                foreach (var transportTemplate in allTransportTemplates)
                {
                    var inducedProcess = inducedProcessCache[transportTemplate.ProcessName];
                    if (inducedProcess == null)
                    {
                        inducedProcess = new InducedProcess {
                            Name = transportTemplate.ProcessName
                        };
                        inducedProcess.AddOrgansToExclude(allOrganNames);
                        inducedProcessCache.Add(inducedProcess);
                    }

                    // For lumen transport. The source organ or target organ is in fact defined as a compartment
                    inducedProcess.AddSourceOrgan(transportTemplate.SourceOrgan.IsLumen() ? transportTemplate.SourceCompartment : transportTemplate.SourceOrgan);
                    inducedProcess.AddTargetOrgan(transportTemplate.TargetOrgan.IsLumen() ? transportTemplate.TargetCompartment : transportTemplate.TargetOrgan);
                }
            }

            return(inducedProcessCache);
        }
示例#3
0
        private ITransportBuilder activeTransportFrom(CompoundProcess process, InducedProcess inducedProcess, IFormulaCache formulaCache)
        {
            //retrieve process for the simulation and create a clone
            var simulationProcess = _simulationActiveProcessRepository.TransportFor(inducedProcess.Name, process.InternalName);

            if (simulationProcess == null)
            {
                throw new PKSimException(PKSimConstants.Error.CannotCreateTransportProcessWithKinetic(inducedProcess.Name, process.Name));
            }

            var activeTransport = _cloner.Clone(simulationProcess);

            updateTransporterFormulaFromCache(activeTransport, formulaCache);
            //remove all parameters defined in the builder
            var allParameters = activeTransport.Parameters.ToList();

            allParameters.Each(activeTransport.RemoveParameter);
            return(activeTransport);
        }