Exemplo n.º 1
0
        public IReadOnlyList <SimulationPartialProcess> AllFor <TIndividualMolecule, TPartialProcess>(Simulation simulation, Compound compound,
                                                                                                      IReadOnlyList <IPartialProcessMapping> processSelections, bool addDefaultPartialProcess)
            where TIndividualMolecule : IndividualMolecule
            where TPartialProcess : PartialProcess
        {
            var allSimulationPartialProcesses = new List <SimulationPartialProcess>();
            var individual             = simulation.Individual;
            var allIndividualMolecules = individual.AllMolecules <TIndividualMolecule>().Where(moleculeWasDefinedByUser).ToList();
            var allProcesses           = compound.AllProcesses <TPartialProcess>().ToList();

            var steps = new List <Func <TIndividualMolecule, IEnumerable <TPartialProcess>, IEnumerable <IPartialProcessMapping>, IEnumerable <SimulationPartialProcess> > > {
                addExistingProcessSelection
            };

            if (addDefaultPartialProcess)
            {
                steps.Add(addDefaultProcessForMolecule);
            }

            steps.Add(addNotSelectedPartialProcess);


            foreach (var individualMolecule in allIndividualMolecules)
            {
                allSimulationPartialProcesses.AddRange(allPartialProcessesFor(individualMolecule, allProcesses, processSelections, steps));
            }

            return(allSimulationPartialProcesses);
        }
        public virtual void EditProcessesIn(Simulation simulation, CompoundProperties compoundProperties)
        {
            _simulation                  = simulation;
            _compound                    = compoundProperties.Compound;
            _compoundProperties          = compoundProperties;
            _notSelectedSystemicProcess  = new NotSelectedSystemicProcess();
            _notAvailableSystemicProcess = new NotAvailableSystemicProcess();

            _allPartialProcesses = _compound.AllProcesses <TPartialProcess>();

            var partialProcessSelection = ProcessSelectionGroup().AllPartialProcesses();

            _selectedProcesses = _partialProcessRetriever.AllFor <TMolecule, TPartialProcess>(simulation, _compound, partialProcessSelection, addDefaultPartialProcess: true);

            _allPartialProcessesDTO = MapPartialProcesses(_selectedProcesses).ToList();

            createSystemicProcessesFor(simulation);

            _view.BindToPartialProcesses(_allPartialProcessesDTO);
            _view.BindToSystemicProcesses(_allSystemicProcessesDTO);

            ValidateProcessSelection();


            //this needs to be done after binding to the processes, since binding affects the height of the view
            _view.AdjustHeight();
        }
Exemplo n.º 3
0
        public void Visit(Compound compound)
        {
            var allSystemicProcesses = compound.AllProcesses <SystemicProcess>();

            allSystemicProcesses.Each(sp =>
            {
                sp.DataSource = sp.Name;
                sp.RefreshName();
            });
        }
Exemplo n.º 4
0
        private void updatePartialProcessKineticAccordingToTemplate(Compound compound)
        {
            foreach (var partialProcess in compound.AllProcesses <PartialProcess>().ToList())
            {
                if (partialProcess.InternalName.Contains("Hill"))
                {
                    continue;
                }

                //remove the old partial process that needs to be updated
                compound.RemoveChild(partialProcess);

                var templateProcess = _compoundProcessRepository.All <PartialProcess>().FindByName(partialProcess.InternalName);

                bool wasInhibitionProcess = false;
                //process does not exist anymore such as Inhibition. convert to non inhibition
                if (templateProcess == null)
                {
                    var processInternalName = partialProcess.InternalName.Replace("CompetitiveInhibition_", string.Empty);
                    templateProcess      = _compoundProcessRepository.All <PartialProcess>().FindByName(processInternalName);
                    wasInhibitionProcess = true;
                }

                if (templateProcess == null)
                {
                    continue;
                }

                //This updates all local properites from the parital process such as molecule name etc..
                var cloneDbProcess = _cloner.Clone(templateProcess);
                cloneDbProcess.UpdatePropertiesFrom(partialProcess, _cloner);
                compound.Add(cloneDbProcess);

                if (wasInhibitionProcess)
                {
                    cloneDbProcess.Description  = PKSimConstants.Warning.StaticInhibitionRemovedFromApplication(templateProcess.Description);
                    cloneDbProcess.InternalName = templateProcess.InternalName;
                }

                foreach (var parameter in partialProcess.AllParameters())
                {
                    var newParameter = cloneDbProcess.Parameter(parameter.Name);
                    if (newParameter == null)
                    {
                        continue;
                    }

                    //make sure we have the same parameter id as before to ensure smooth update commit
                    newParameter.Id = parameter.Id;
                    _parameterSetUpdater.UpdateValue(parameter, newParameter);
                    //this needs to be done after udpdate value as the Update value also sets the origin
                    newParameter.Origin.ParameterId = parameter.Origin.ParameterId;
                }
            }
        }
Exemplo n.º 5
0
        public void should_have_set_the_name_of_the_data_source_in_all_systemic_processes()
        {
            var allSystemicProcesses = _compound.AllProcesses <SystemicProcess>().ToList();

            allSystemicProcesses.Count.ShouldBeGreaterThan(0);

            foreach (var process in allSystemicProcesses)
            {
                process.DataSource.ShouldNotBeNull();
            }
        }
Exemplo n.º 6
0
 public override void GlobalContext()
 {
     base.GlobalContext();
     LoadProject("IsDefaultConversion_722");
     _compound                = First <Compound>();
     _formulation             = First <Formulation>();
     _event                   = First <PKSimEvent>();
     _simpleProtocol          = First <SimpleProtocol>();
     _advancedProtocol        = First <AdvancedProtocol>();
     _tubularSecretionProcess = _compound.AllProcesses().FirstOrDefault();
 }
Exemplo n.º 7
0
        private void convertSystemicProcesses(Compound compound)
        {
            var allSystemicProcesses = compound.AllProcesses <SystemicProcess>()
                                       .Where(p => p.ContainsName(ConverterConstants.Parameter.Lipophilicity)).ToList();

            foreach (var systemicProcess in allSystemicProcesses)
            {
                var lipo = systemicProcess.Parameter(ConverterConstants.Parameter.Lipophilicity);
                lipo.Visible = true;
                lipo.Name    = CoreConstants.Parameter.LIPOPHILICITY_EXPERIMENT;
                updateLipophilicityReferences(systemicProcess, ConverterConstants.Parameter.BloodPlasmaConcentrationRatio);
                updateLipophilicityReferences(systemicProcess, ConverterConstants.Parameter.PartitionCoefficientWwaterProtein);
            }
        }
 private IReadOnlyList <RemoteTemplate> metabolitesFor(RemoteTemplate remoteTemplate, Compound compound)
 {
     //This will for now assume that the metabolite template are in the same file
     return(compound.AllProcesses <EnzymaticProcess>()
            .Select(x => x.MetaboliteName)
            .Where(x => x.StringIsNotEmpty())
            .Distinct()
            .Select(meta => new RemoteTemplate
     {
         Url = remoteTemplate.Url,
         Type = TemplateType.Compound,
         Name = meta
     })
            .ToList());
 }
        public SystemicProcessDTO MapFrom(SystemicProcess systemicProcess, Compound compound)
        {
            var systemicProcessDTO = new SystemicProcessDTO(systemicProcess)
            {
                ContainerType       = _objectTypeResolver.TypeFor(compound),
                Compound            = compound,
                SystemicProcessType = systemicProcess.SystemicProcessType.DisplayName,
                DataSource          = systemicProcess.DataSource,
                Species             = systemicProcess.Species,
                Description         = systemicProcess.Description
            };

            systemicProcessDTO.AddUsedNames(compound.AllProcesses <CompoundProcess>().Select(x => x.Name));
            return(systemicProcessDTO);
        }
Exemplo n.º 10
0
        private void removeOldStaticInhibitionReferences(ProcessSelectionGroup processSelectionGroup, Compound compound, List <string> oldMappedInhibitionProcessList)
        {
            var allInhibitionProcesses = compound.AllProcesses <PartialProcess>().Where(x => x.InternalName.Contains("Inhibition"));

            foreach (var inhibitionProcess in allInhibitionProcesses)
            {
                var inhibitionSelection = processSelectionGroup.AllPartialProcesses()
                                          .FirstOrDefault(x => string.Equals(x.ProcessName, inhibitionProcess.Name));

                if (inhibitionSelection == null)
                {
                    continue;
                }

                processSelectionGroup.RemovePartialProcessSelection(inhibitionSelection);
                oldMappedInhibitionProcessList.Add(inhibitionProcess.Name);
            }
        }
Exemplo n.º 11
0
        public IPKSimCommand RenameMoleculeForPartialProcessesIn(Compound compound, string moleculeName, Type partialProcessType)
        {
            var allProcessesToRename = compound.AllProcesses <PartialProcess>()
                                       .Where(x => processTypesAreEqual(x.GetType(), partialProcessType))
                                       .Where(x => string.Equals(moleculeName, x.MoleculeName))
                                       .ToList();

            using (var renameDataSourcePresenter = _applicationController.Start <IRenamePartialProcessesMoleculePresenter>())
            {
                renameDataSourcePresenter.AllProcessesToRename = allProcessesToRename;
                if (!renameDataSourcePresenter.Edit(compound))
                {
                    return(new PKSimEmptyCommand());
                }

                return(new RenameMoleculeInPartialProcessesCommand(allProcessesToRename, renameDataSourcePresenter.NewMoleculeName, _executionContext).Run(_executionContext));
            }
        }
Exemplo n.º 12
0
        private void addInteractionParameters(Compound compound, IMoleculeBuilder drug, InteractionProperties interactionProperties)
        {
            foreach (var interactionProcess in compound.AllProcesses <InteractionProcess>())
            {
                if (!shouldGenerateInteractionContainer(interactionProperties, interactionProcess))
                {
                    continue;
                }

                var interactionContainer = _objectBaseFactory.Create <InteractionContainer>()
                                           .WithIcon(interactionProcess.Icon)
                                           .WithName(interactionProcess.InternalName);

                //only add global pamrameters to the intercation container
                _parameterContainerTask.AddProcessBuilderParametersTo(interactionContainer);
                _parameterSetUpdater.UpdateValuesByName(interactionProcess, interactionContainer);
                interactionContainer.Name = interactionProcess.Name;
                drug.AddInteractionContainer(interactionContainer);
            }
        }
Exemplo n.º 13
0
        private void addPartialProcesses <TPartialProcess, TIndividualMolecule, TProcessSelection>(Compound compound, Individual individual, ProcessSelectionGroup processSelectionGroup)
            where TPartialProcess : PartialProcess
            where TIndividualMolecule : IndividualMolecule
            where TProcessSelection : ProcessSelection, new()
        {
            //default mapping with processes: Mapping done only by name
            foreach (var process in compound.AllProcesses <TPartialProcess>())
            {
                var molecule = individual.MoleculeByName <TIndividualMolecule>(process.MoleculeName);
                //enzyme not found in individual
                if (molecule == null)
                {
                    continue;
                }

                processSelectionGroup.AddPartialProcessSelection(new TProcessSelection {
                    ProcessName = process.Name, MoleculeName = molecule.Name, CompoundName = compound.Name
                });
            }
        }
Exemplo n.º 14
0
 private void addPartialProcessesToView <TPartialProcess>(RootNodeType parentNodeType) where TPartialProcess : PartialProcess
 {
     _compound.AllProcesses <TPartialProcess>().Each(p => addPartialProcessToView(p, parentNodeType));
 }