Exemple #1
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;
                }
            }
        }
Exemple #2
0
 private IEnumerable <TCompoundProcess> allProcessTemplates <TCompoundProcess>() where TCompoundProcess : CompoundProcess
 {
     return(_compoundProcessRepository.All <TCompoundProcess>());
 }