示例#1
0
        private static SrmDocument CopyPaste(SrmDocument sourceDoc, IEnumerable <DocNode> nodes, SrmDocument targetDoc, IdentityPath to)
        {
            SetDefaultModifications(targetDoc);
            if (nodes != null)
            {
                sourceDoc = sourceDoc.RemoveAllBut(nodes);
            }

            var stringWriter = new XmlStringWriter();

            using (var writer = new XmlTextWriter(stringWriter)
            {
                Formatting = Formatting.Indented
            })
            {
                XmlSerializer ser = new XmlSerializer(typeof(SrmDocument));
                ser.Serialize(writer, sourceDoc);
            }
            IdentityPath newPath, nextAdd;

            targetDoc = targetDoc.ImportDocumentXml(new StringReader(stringWriter.ToString()),
                                                    null,
                                                    MeasuredResults.MergeAction.remove,
                                                    false,
                                                    null,
                                                    Settings.Default.StaticModList,
                                                    Settings.Default.HeavyModList,
                                                    to,
                                                    out newPath,
                                                    out nextAdd,
                                                    false);
            return(targetDoc);
        }
示例#2
0
 public SrmDocument ImportTo(SrmDocument document, PeptideLibraries.FindLibrary findLibrary, out IdentityPath firstAdded)
 {
     firstAdded = null;
     using (var reader = GetReader())
     {
         return(reader != null
             ? document.ImportDocumentXml(reader,
                                          string.Empty,
                                          MeasuredResults.MergeAction.remove,
                                          false,
                                          findLibrary,
                                          Settings.Default.StaticModList,
                                          Settings.Default.HeavyModList,
                                          document.Children.Any()?new IdentityPath(document.Children.First().Id) : null,
                                          out firstAdded,
                                          out _,
                                          false)
             : null);
     }
 }
示例#3
0
        public static ProcessedIrtAverages ProcessRetentionTimes(IProgressMonitor monitor,
                                                                 IRetentionTimeProvider[] providers, DbIrtPeptide[] standardPeptideList, DbIrtPeptide[] items)
        {
            var matchedStandard = IrtStandard.WhichStandard(standardPeptideList.Select(pep => pep.ModifiedTarget));

            if (matchedStandard != null)
            {
                var dummyDoc = new SrmDocument(SrmSettingsList.GetDefault());
                using (var reader = matchedStandard.GetDocumentReader())
                {
                    if (reader != null)
                    {
                        dummyDoc = dummyDoc.ImportDocumentXml(reader,
                                                              string.Empty,
                                                              MeasuredResults.MergeAction.remove,
                                                              false,
                                                              null,
                                                              Settings.Default.StaticModList,
                                                              Settings.Default.HeavyModList,
                                                              null,
                                                              out _,
                                                              out _,
                                                              false);
                        standardPeptideList = standardPeptideList.Select(pep => new DbIrtPeptide(pep)).ToArray();
                        foreach (var dummyPep in dummyDoc.Molecules.Where(pep => pep.HasExplicitMods))
                        {
                            var standardPepIdx = standardPeptideList.IndexOf(pep => dummyPep.ModifiedTarget.Equals(pep.ModifiedTarget));
                            standardPeptideList[standardPepIdx] = new DbIrtPeptide(standardPeptideList[standardPepIdx])
                            {
                                ModifiedTarget = dummyDoc.Settings.GetModifiedSequence(dummyPep.ModifiedTarget, IsotopeLabelType.heavy, dummyPep.ExplicitMods)
                            };
                        }
                    }
                }
            }

            IProgressStatus status = new ProgressStatus(Resources.LibraryGridViewDriver_ProcessRetentionTimes_Adding_retention_times);
            var             dictPeptideAverages = new Dictionary <Target, IrtPeptideAverages>();
            var             providerData        = new List <RetentionTimeProviderData>();
            var             runCount            = 0;

            foreach (var retentionTimeProvider in providers)
            {
                if (monitor.IsCanceled)
                {
                    return(null);
                }
                monitor.UpdateProgress(status = status.ChangeMessage(string.Format(
                                                                         Resources.LibraryGridViewDriver_ProcessRetentionTimes_Converting_retention_times_from__0__,
                                                                         retentionTimeProvider.Name)));

                runCount++;

                var data = new RetentionTimeProviderData(retentionTimeProvider, standardPeptideList);
                if (data.RegressionSuccess || data.CalcRegressionWith(retentionTimeProvider, standardPeptideList, items))
                {
                    AddRetentionTimesToDict(retentionTimeProvider, data.RegressionRefined, dictPeptideAverages, standardPeptideList);
                }
                providerData.Add(data);

                monitor.UpdateProgress(status = status.ChangePercentComplete(runCount * 100 / providers.Length));
            }

            monitor.UpdateProgress(status.Complete());
            return(new ProcessedIrtAverages(dictPeptideAverages, providerData));
        }
示例#4
0
        private static SrmDocument CopyPaste(SrmDocument sourceDoc, IEnumerable<DocNode> nodes, SrmDocument targetDoc, IdentityPath to)
        {
            SetDefaultModifications(targetDoc);
            if(nodes != null)
                sourceDoc = sourceDoc.RemoveAllBut(nodes);

            var stringWriter = new XmlStringWriter();
            using (var writer = new XmlTextWriter(stringWriter) { Formatting = Formatting.Indented })
            {
                XmlSerializer ser = new XmlSerializer(typeof(SrmDocument));
                ser.Serialize(writer, sourceDoc);
            }
            IdentityPath newPath, nextAdd;
            targetDoc = targetDoc.ImportDocumentXml(new StringReader(stringWriter.ToString()),
                                                    null,
                                                    MeasuredResults.MergeAction.remove,
                                                    false,
                                                    null,
                                                    Settings.Default.StaticModList,
                                                    Settings.Default.HeavyModList,
                                                    to,
                                                    out newPath,
                                                    out nextAdd,
                                                    false);
            return targetDoc;
        }