当前位置: 首页>>代码示例>>C#>>正文


C# SrmDocument.ChangeSettings方法代码示例

本文整理汇总了C#中SrmDocument.ChangeSettings方法的典型用法代码示例。如果您正苦于以下问题:C# SrmDocument.ChangeSettings方法的具体用法?C# SrmDocument.ChangeSettings怎么用?C# SrmDocument.ChangeSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SrmDocument的用法示例。


在下文中一共展示了SrmDocument.ChangeSettings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoTest

        protected override void DoTest()
        {
            var document = new SrmDocument(SrmSettingsList.GetDefault());
            var staticMods = document.Settings.PeptideSettings.Modifications.StaticModifications.ToList();
            staticMods.Add(UniMod.GetModification("Phospho (ST)", true).ChangeVariable(true));
            var heavyMods = new List<StaticMod> {UniMod.GetModification("Label:13C(6)15N(4) (C-term R)", false)};
            document = document.ChangeSettings(document.Settings
                .ChangePeptideModifications(mods => mods.ChangeStaticModifications(staticMods).ChangeHeavyModifications(heavyMods))
                .ChangeTransitionFilter(filt => filt.ChangePrecursorCharges(new [] {2, 3, 4, 5})));
            Assert.IsTrue(SkylineWindow.SetDocument(document, SkylineWindow.Document));

            RunUI(() => SkylineWindow.Paste(TextUtil.LineSeparate(PEPTIDE_MODIFIED, PEPTIDE_UNMODIFIED)));
            document = WaitForDocumentChangeLoaded(document);
            RunUI(() => SkylineWindow.Paste(PEPTIDE_EXTRA));
            var docPaste1 = WaitForDocumentChangeLoaded(document);
            AssertEx.IsDocumentState(docPaste1, null, 2, 6, 44, 129);

            TestErrorMessages();
            TestUse();
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:20,代码来源:RefineListDlgTest.cs

示例2: ValidateLibraryDocs

 private static void ValidateLibraryDocs(SrmDocument docTarget, SrmDocument docActual, LibraryManager libraryManager)
 {
     var docContainer = new TestDocumentContainer();
     libraryManager.Register(docContainer);
     try
     {
         AssertEx.IsDocumentState(docActual, 0, docTarget.PeptideGroupCount, docTarget.PeptideCount,
             docTarget.PeptideTransitionGroupCount, docTarget.PeptideTransitionCount);
         docActual = docActual.ChangeSettings(docActual.Settings.ConnectLibrarySpecs(FindLibrarySpec));
         Assert.IsTrue(docContainer.SetDocument(docActual, null, true));
         SrmDocument docLoaded = docContainer.Document;
         AssertEx.DocumentCloned(docTarget, docLoaded);
     //                Assert.IsTrue(ArrayUtil.ReferencesEqual(docActual.Transitions.ToArray(), docLoaded.Transitions.ToArray()));
     //                Assert.IsTrue(ArrayUtil.ReferencesEqual(docActual.TransitionGroups.ToArray(), docLoaded.TransitionGroups.ToArray()));
     //                Assert.IsTrue(ArrayUtil.ReferencesEqual(docActual.Peptides.ToArray(), docLoaded.Peptides.ToArray()));
         Assert.IsTrue(ArrayUtil.ReferencesEqual(docActual.Children, docLoaded.Children));
     }
     finally
     {
         libraryManager.Unregister(docContainer);
     }
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:22,代码来源:LibrarySettingsTest.cs

示例3: CheckTranstions

        private static SrmDocument CheckTranstions(SrmDocument document, string startName, string endName, int ionDiff)
        {
            SrmSettings settings = document.Settings;
            SrmDocument docNew = document.ChangeSettings(settings.ChangeTransitionFilter(
                    f => f.ChangeFragmentRangeFirstName(startName). ChangeFragmentRangeLastName(endName)).
                ChangeTransitionInstrument(i => i.ChangeMaxMz(5000)));

            // length-n ions
            foreach (PeptideDocNode nodePeptide in docNew.Peptides)
            {
                Assert.AreEqual(Math.Max(0, nodePeptide.Peptide.Sequence.Length - ionDiff),
                    nodePeptide.TransitionCount);
            }

            return docNew;
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:16,代码来源:SrmSettingsChangeTest.cs

示例4: ImportSearchInternal

        private bool ImportSearchInternal(CommandArgs commandArgs, ref SrmDocument doc)
        {
            var progressMonitor = new CommandProgressMonitor(_out, new ProgressStatus(String.Empty));
            var import = new ImportPeptideSearch
            {
                SearchFilenames = commandArgs.SearchResultsFiles.ToArray(),
                CutoffScore = commandArgs.CutoffScore.GetValueOrDefault()
            };

            // Build library
            var builder = import.GetLibBuilder(doc, commandArgs.Saving ? commandArgs.SaveFile : commandArgs.SkylineFile, commandArgs.IncludeAmbiguousMatches);
            ImportPeptideSearch.ClosePeptideSearchLibraryStreams(doc);
            _out.WriteLine(Resources.CommandLine_ImportSearch_Creating_spectral_library_from_files_);
            foreach (var file in commandArgs.SearchResultsFiles)
                _out.WriteLine(Path.GetFileName(file));
            if (!builder.BuildLibrary(progressMonitor))
                return false;

            if (!string.IsNullOrEmpty(builder.AmbiguousMatchesMessage))
                _out.WriteLine(builder.AmbiguousMatchesMessage);

            var docLibSpec = builder.LibrarySpec.ChangeDocumentLibrary(true);

            _out.WriteLine(Resources.CommandLine_ImportSearch_Loading_library);
            var libraryManager = new LibraryManager();
            if (!import.LoadPeptideSearchLibrary(libraryManager, docLibSpec, progressMonitor))
                return false;

            doc = import.AddDocumentSpectralLibrary(doc, docLibSpec);
            if (doc == null)
                return false;

            if (!import.VerifyRetentionTimes(import.GetFoundResultsFiles().Select(f => f.Path)))
            {
                _out.WriteLine(TextUtil.LineSeparate(
                    Resources.ImportPeptideSearchDlg_NextPage_The_document_specific_spectral_library_does_not_have_valid_retention_times_,
                    Resources.ImportPeptideSearchDlg_NextPage_Please_check_your_peptide_search_pipeline_or_contact_Skyline_support_to_ensure_retention_times_appear_in_your_spectral_libraries_));
                return false;
            }

            // Look for results files to import
            import.InitializeSpectrumSourceFiles(doc);
            import.UpdateSpectrumSourceFilesFromDirs(import.GetDirsToSearch(Path.GetDirectoryName(commandArgs.SkylineFile)), false, null);
            var missingResultsFiles = import.GetMissingResultsFiles().ToArray();
            if (missingResultsFiles.Any())
            {
                foreach (var file in missingResultsFiles)
                {
                    if (doc.Settings.HasResults && doc.Settings.MeasuredResults.FindMatchingMSDataFile(new MsDataFilePath(file)) != null)
                        continue;

                    _out.WriteLine(Resources.CommandLine_ImportSearch_Warning__Unable_to_locate_results_file___0__, Path.GetFileName(file));
                }
            }

            // Add all modifications, if requested
            if (commandArgs.AcceptAllModifications)
            {
                import.InitializeModifications(doc);
                var foundMods = import.GetMatchedMods().Count();
                var newModifications = new PeptideModifications(import.MatcherPepMods.StaticModifications,
                    new[] {new TypedModifications(IsotopeLabelType.heavy, import.MatcherHeavyMods)});
                var newSettings = import.AddModifications(doc, newModifications);
                if (!ReferenceEquals(doc.Settings, newSettings))
                {
                    if (foundMods != 1)
                        _out.WriteLine(Resources.CommandLine_ImportSearch_Adding__0__modifications_, foundMods);
                    else
                        _out.WriteLine(Resources.CommandLine_ImportSearch_Adding_1_modification_);
                    doc = doc.ChangeSettings(newSettings);
                    doc.Settings.UpdateDefaultModifications(false);
                }
            }

            // Import FASTA
            if (commandArgs.ImportingFasta)
            {
                _out.WriteLine(Resources.CommandLine_ImportFasta_Importing_FASTA_file__0____, Path.GetFileName(commandArgs.FastaPath));
                doc = ImportPeptideSearch.PrepareImportFasta(doc);
                int emptyProteins;
                try
                {
                    IdentityPath firstAdded, nextAdd;
                    doc = ImportPeptideSearch.ImportFasta(doc, commandArgs.FastaPath, progressMonitor, null,
                        out firstAdded, out nextAdd, out emptyProteins);
                }
                catch (Exception x)
                {
                    _out.WriteLine(Resources.CommandLine_Run_Error__Failed_importing_the_file__0____1_, commandArgs.FastaPath, x.Message);
                    _doc = doc;
                    return true;  // So that document will be saved with the new library
                }

                if (emptyProteins > 0 && !commandArgs.KeepEmptyProteins)
                {
                    doc = ImportPeptideSearch.RemoveEmptyProteins(doc);
                }
            }

            // Import results
//.........这里部分代码省略.........
开发者ID:lgatto,项目名称:proteowizard,代码行数:101,代码来源:CommandLine.cs

示例5: ConnectLibrarySpecs

        private SrmDocument ConnectLibrarySpecs(SrmDocument document, string documentPath)
        {
            string docLibFile = null;
            if (!string.IsNullOrEmpty(documentPath) && document.Settings.PeptideSettings.Libraries.HasDocumentLibrary)
            {
                docLibFile = BiblioSpecLiteSpec.GetLibraryFileName(documentPath);
                if (!File.Exists(docLibFile))
                {
                    _out.WriteLine(Resources.CommandLine_ConnectLibrarySpecs_Error__Could_not_find_the_spectral_library__0__for_this_document_, docLibFile);
                    return null;
                }
            }

            var settings = document.Settings.ConnectLibrarySpecs(library =>
            {
                LibrarySpec spec;
                if (Settings.Default.SpectralLibraryList.TryGetValue(library.Name, out spec))
                {
                    if (File.Exists(spec.FilePath))
                        return spec;
                }

                string fileName = library.FileNameHint;
                if (fileName != null)
                {
                    // First look for the file name in the document directory
                    string pathLibrary = Path.Combine(Path.GetDirectoryName(documentPath) ?? string.Empty, fileName);
                    if (File.Exists(pathLibrary))
                        return library.CreateSpec(pathLibrary).ChangeDocumentLocal(true);
                    // In the user's default library directory
                    pathLibrary = Path.Combine(Settings.Default.LibraryDirectory, fileName);
                    if (File.Exists(pathLibrary))
                        return library.CreateSpec(pathLibrary);
                }
                _out.WriteLine(Resources.CommandLine_ConnectLibrarySpecs_Warning__Could_not_find_the_spectral_library__0_, library.Name);
                return library.CreateSpec(null);
            }, docLibFile);

            if (ReferenceEquals(settings, document.Settings))
                return document;

            // If the libraries were moved to disconnected state, then avoid updating
            // the document tree for this change, or it will strip all the library
            // information off the document nodes.
            if (settings.PeptideSettings.Libraries.DisconnectedLibraries != null)
                return document.ChangeSettingsNoDiff(settings);

            return document.ChangeSettings(settings);
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:49,代码来源:CommandLine.cs

示例6: ConnectIonMobilityDatabase

 private SrmDocument ConnectIonMobilityDatabase(SrmDocument document, string documentPath)
 {
     var settings = document.Settings.ConnectIonMobilityLibrary(imdb => FindIonMobilityDatabase(documentPath, imdb));
     if (settings == null)
         return null;
     if (ReferenceEquals(settings, document.Settings))
         return document;
     return document.ChangeSettings(settings);
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:9,代码来源:CommandLine.cs

示例7: AddPeptides


//.........这里部分代码省略.........
                    {
                        peptideGroupDocNode = null;
                    }
                }
                else
                {
                    peptideGroupDocNode = FindPeptideGroupDocNode(document, proteinName);
                }
                if (peptideGroupDocNode == null)
                {
                    if (string.IsNullOrEmpty(proteinName))
                    {
                        peptideGroupDocNode = new PeptideGroupDocNode(new PeptideGroup(),
                                                                      document.GetPeptideGroupId(true), null,
                                                                      new PeptideDocNode[0]);
                    }
                    else
                    {
                        ProteinMetadata metadata = null;
                        PeptideGroup peptideGroup = backgroundProteome.IsNone ? new PeptideGroup()
                            : (backgroundProteome.GetFastaSequence(proteinName, out metadata) ??
                                                    new PeptideGroup());
                        if (metadata != null)
                            peptideGroupDocNode = new PeptideGroupDocNode(peptideGroup, metadata, new PeptideDocNode[0]);
                        else
                            peptideGroupDocNode = new PeptideGroupDocNode(peptideGroup, proteinName,
                                                                      peptideGroup.Description, new PeptideDocNode[0]);
                    }
                    // Add to the end, if no insert node
                    var to = selectedPath;
                    if (to == null || to.Depth < (int)SrmDocument.Level.MoleculeGroups)
                        document = (SrmDocument)document.Add(peptideGroupDocNode);
                    else
                    {
                        Identity toId = selectedPath.GetIdentity((int) SrmDocument.Level.MoleculeGroups);
                        document = (SrmDocument) document.Insert(toId, peptideGroupDocNode);
                    }
                    selectedPath = new IdentityPath(peptideGroupDocNode.Id);
                }
                var peptides = new List<PeptideDocNode>();
                foreach (PeptideDocNode peptideDocNode in peptideGroupDocNode.Children)
                {
                    peptides.Add(peptideDocNode);
                }

                var fastaSequence = peptideGroupDocNode.PeptideGroup as FastaSequence;
                PeptideDocNode nodePepNew;
                if (fastaSequence != null)
                {
                    // Attempt to create node for error checking.
                    nodePepNew = fastaSequence.CreateFullPeptideDocNode(document.Settings,
                                                                        FastaSequence.StripModifications(pepModSequence));
                    if (nodePepNew == null)
                    {
                        ShowPeptideError(new PasteError
                                             {
                                                 Column = colPeptideSequence.Index,
                                                 Line = i,
                                                 Message = Resources.PasteDlg_AddPeptides_This_peptide_sequence_was_not_found_in_the_protein_sequence
                                             });
                        return null;
                    }
                }
                // Create node using ModificationMatcher.
                nodePepNew = matcher.GetModifiedNode(pepModSequence, fastaSequence).ChangeSettings(document.Settings,
                                                                                                  SrmSettingsDiff.ALL);
                // Avoid adding an existing peptide a second time.
                if (!peptides.Contains(nodePep => Equals(nodePep.Key, nodePepNew.Key)))
                {
                    if (nodePepNew.Peptide.FastaSequence != null)
                    {
                        peptides.Add(nodePepNew);
                        peptides.Sort(FastaSequence.ComparePeptides);
                    }
                    else
                    {
                        int groupGlobalIndex = peptideGroupDocNode.PeptideGroup.GlobalIndex;
                        if (groupGlobalIndex == lastGroupGlobalIndex && lastPeptideIndex != -1)
                        {
                            peptides.Insert(lastPeptideIndex, nodePepNew);
                        }
                        else
                        {
                            lastPeptideIndex = peptides.Count;
                            peptides.Add(nodePepNew);
                        }
                        lastGroupGlobalIndex = groupGlobalIndex;
                    }
                    var newPeptideGroupDocNode = new PeptideGroupDocNode(peptideGroupDocNode.PeptideGroup, peptideGroupDocNode.Annotations, peptideGroupDocNode.Name, peptideGroupDocNode.Description, peptides.ToArray(), false);
                    document = (SrmDocument)document.ReplaceChild(newPeptideGroupDocNode);
                }
            }
            if (!validating && listPeptideSequences.Count > 0)
            {
                var pepModsNew = matcher.GetDocModifications(document);
                document = document.ChangeSettings(document.Settings.ChangePeptideModifications(mods => pepModsNew));
                document.Settings.UpdateDefaultModifications(false);
            }
            return document;
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:101,代码来源:PasteDlg.cs

示例8: ChangeBackgroundProteome

 private static SrmDocument ChangeBackgroundProteome(SrmDocument document, BackgroundProteome backgroundProteome)
 {
     return document.ChangeSettings(
         document.Settings.ChangePeptideSettings(setP => setP.ChangeBackgroundProteome(backgroundProteome)));
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:5,代码来源:BackgroundProteomeManager.cs

示例9: LoadBackground

        protected override bool LoadBackground(IDocumentContainer container, SrmDocument document, SrmDocument docCurrent)
        {
            var calc = GetIrtCalculator(docCurrent);
            if (calc != null && !calc.IsUsable)
                calc = LoadCalculator(container, calc);
            if (calc == null || !ReferenceEquals(document.Id, container.Document.Id))
            {
                // Loading was cancelled or document changed
                EndProcessing(document);
                return false;
            }
            var rtRegression = docCurrent.Settings.PeptideSettings.Prediction.RetentionTime;
            var rtRegressionNew = !ReferenceEquals(calc, rtRegression.Calculator)
                ? rtRegression.ChangeCalculator(calc)
                : rtRegression;
            if (rtRegressionNew.IsAutoCalcRequired(docCurrent, null))
                rtRegressionNew = AutoCalcRegressions(container, rtRegressionNew);

            if (rtRegressionNew == null ||
                !ReferenceEquals(document.Id, container.Document.Id) ||
                // No change in the regression, including reference equal standard peptides
                (Equals(rtRegression, rtRegressionNew) && rtRegression.SamePeptides(rtRegressionNew)))
            {
                // Loading was cancelled or document changed
                EndProcessing(document);
                return false;
            }
            SrmDocument docNew;
            do
            {
                // Change the document to use the new calculator and regression information.
                docCurrent = container.Document;
                if (!ReferenceEquals(rtRegression, docCurrent.Settings.PeptideSettings.Prediction.RetentionTime))
                    return false;
                docNew = docCurrent.ChangeSettings(docCurrent.Settings.ChangePeptidePrediction(predict =>
                    predict.ChangeRetentionTime(rtRegressionNew)));
            }
            while (!CompleteProcessing(container, docNew, docCurrent));
            return true;
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:40,代码来源:IrtDbManager.cs

示例10: EnsureAnnotation

        private SrmDocument EnsureAnnotation(SrmDocument document, string annotationName, bool addAnnotation,
            IEnumerable<string> annotationNames)
        {
            var containsQAnnotation = annotationNames.Contains(annotationName);
            if (!containsQAnnotation && addAnnotation)
            {
                var annotationTargets =
                    AnnotationDef.AnnotationTargetSet.OfValues(AnnotationDef.AnnotationTarget.precursor_result);
                var newAnnotationDef = new AnnotationDef(annotationName, annotationTargets, AnnotationDef.AnnotationType.number,
                    new string[0]);
                AnnotationDef existingAnnotationDef;
                // CONSIDER: Throw error instead of overwriting?
                if (!Settings.Default.AnnotationDefList.TryGetValue(annotationName, out existingAnnotationDef) &&
                    !Equals(existingAnnotationDef, newAnnotationDef))
                {
                    Settings.Default.AnnotationDefList.SetValue(newAnnotationDef);
                }
                else
                {
                    // Use the existing annotation
                    newAnnotationDef = existingAnnotationDef;
                }

                document = document.ChangeSettings(Document.Settings.ChangeAnnotationDefs(defs =>
                {
                    var defsNew = defs.ToList();
                    defsNew.Add(newAnnotationDef);
                    return defsNew;
                }));
            }
            else if (containsQAnnotation && !AddAnnotation)
            {
                document = document.ChangeSettings(Document.Settings.ChangeAnnotationDefs(defs =>
                {
                    var defsNew = defs.ToList();
                    defsNew.RemoveAll(def => Equals(def.Name, annotationName));
                    return defsNew;
                }));
                var annotationNamesToKeep = document.Settings.DataSettings.AnnotationDefs.Select(def => def.Name).ToList();
                document = (SrmDocument) document.StripAnnotationValues(annotationNamesToKeep);
            }
            return document;
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:43,代码来源:MProphetResultsHandler.cs

示例11: InitWiffDocument

        private static SrmDocument InitWiffDocument(TestFilesDir testFilesDir)
        {
            const LabelAtoms labelAtoms = LabelAtoms.C13 | LabelAtoms.N15;
            List<StaticMod> heavyMods = new List<StaticMod>
                {
                    new StaticMod("Heavy K", "K", ModTerminus.C, null, labelAtoms, null, null),
                    new StaticMod("Heavy R", "R", ModTerminus.C, null, labelAtoms, null, null),
                };
            SrmSettings settings = SrmSettingsList.GetDefault();
            settings = settings.ChangePeptideModifications(mods => mods.ChangeHeavyModifications(heavyMods));
            SrmDocument doc = new SrmDocument(settings);

            IdentityPath selectPath;
            string path = testFilesDir.GetTestPath("051309_transition list.csv");
            // Product m/z out of range
            var docError = doc;
            List<MeasuredRetentionTime> irtPeptides;
            List<SpectrumMzInfo> librarySpectra;
            List<TransitionImportErrorInfo> errorList;
            var inputs = new MassListInputs(path)
            {
                FormatProvider = CultureInfo.InvariantCulture,
                Separator = TextUtil.SEPARATOR_CSV
            };
            docError.ImportMassList(inputs, null, out selectPath, out irtPeptides, out librarySpectra, out errorList);
            Assert.AreEqual(errorList.Count, 1);
            AssertEx.AreComparableStrings(TextUtil.SpaceSeparate(Resources.MassListRowReader_CalcTransitionExplanations_The_product_m_z__0__is_out_of_range_for_the_instrument_settings__in_the_peptide_sequence__1_,
                                                Resources.MassListRowReader_CalcPrecursorExplanations_Check_the_Instrument_tab_in_the_Transition_Settings),
                                            errorList[0].ErrorMessage,
                                            2);
            Assert.AreEqual(errorList[0].Column, 1);
            Assert.AreEqual(errorList[0].Row, 19);

            doc = doc.ChangeSettings(settings.ChangeTransitionInstrument(inst => inst.ChangeMaxMz(1800)));
            inputs = new MassListInputs(path)
            {
                FormatProvider = CultureInfo.InvariantCulture,
                Separator = TextUtil.SEPARATOR_CSV
            };
            doc = doc.ImportMassList(inputs, null, out selectPath);

            AssertEx.IsDocumentState(doc, 2, 9, 9, 18, 54);
            return doc;
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:44,代码来源:SmallWiffTest.cs

示例12: DoTest

        protected override void DoTest()
        {
            // Set up initial document quickly, without involving UI
            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault());
            var staticMods = new List<StaticMod>(document.Settings.PeptideSettings.Modifications.StaticModifications);
            staticMods.AddRange(new[]
                                    {
                                        new StaticMod("Phospho", "S,T,Y", null, true, "PO3H", LabelAtoms.None,
                                            RelativeRT.Matching, null, null, new[] {new FragmentLoss("PO4H3")}),
                                        new StaticMod("K(GlyGly)", "K", null, true, "N2H6C4O2", LabelAtoms.None,
                                            RelativeRT.Matching, null, null, null),
                                    });
            document = document.ChangeSettings(document.Settings.ChangePeptideModifications(mods =>
                mods.ChangeStaticModifications(staticMods).ChangeMaxNeutralLosses(2)));
            Assert.IsTrue(SkylineWindow.SetDocument(document, SkylineWindow.Document));

            RunUI(() => SkylineWindow.Paste(TRANSITIONLIST_CSV_MODLOSS_CLIPBOARD_TEXT));

            var docPaste1 = WaitForDocumentChange(document);
            AssertEx.IsDocumentState(docPaste1, null, 3, 4, 12); // revision # is hard to predict with background loaders running
            Assert.AreEqual(4, GetVariableModCount(docPaste1));
            Assert.AreEqual(6, GetLossCount(docPaste1, 1));

            string insertListText = I18n(TRANSITIONS_MODLOSS_CLIPBOARD_TEXT);

            SetClipboardTextUI(insertListText);
            RunDlg<PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg, insertTransDlg =>
                {
                    insertTransDlg.IsMolecule = false; // Make sure it's ready to accept peptides rather than small molecules
                    insertTransDlg.PasteTransitions();
                    insertTransDlg.OkDialog();
                });
            WaitForProteinMetadataBackgroundLoaderCompletedUI();

            // Nothing should have changed
            RunUI(() => Assert.AreSame(docPaste1, SkylineWindow.DocumentUI));

            // Revert to the original empty document
            RunUI(SkylineWindow.Undo);

            Assert.AreSame(document, SkylineWindow.Document);

            RunDlg<PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg, insertTransDlg =>
            {
                insertTransDlg.PasteTransitions();
                insertTransDlg.OkDialog();
            });

            var docInsert1 = WaitForDocumentChange(document);
            AssertEx.IsDocumentState(docInsert1, null, 3, 4, 12); // revision # is hard to predict with background loaders running
            Assert.AreEqual(4, GetVariableModCount(docInsert1));
            Assert.AreEqual(6, GetLossCount(docInsert1, 1));

            string insertPart1 = I18n(TRANSITIONS_PREC_PART1_CLIPBOARD_TEXT);
            string insertPart2 = I18n(TRANSITIONS_PREC_PART2_CLIPBOARD_TEXT);
            string insertSep = I18n(TRANSITIONS_PREC_SEP_CLIPBOARD_TEXT);

            RunDlg<PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg, insertTransDlg =>
            {
                // Check error and grid cell selection for a bad product m/z
                VerifyTransitionListError(insertTransDlg, insertListText, 757.420279, 888.8888, 8, 2);
                // Non-numeric product m/z
                VerifyTransitionListError(insertTransDlg, insertListText, 908.447222, "x", Resources.PasteDlg_AddTransitionList_The_product_m_z_must_be_a_number_, 1, 2);
                // Check error and grid cell selection for a bad precursor m/z
                VerifyTransitionListError(insertTransDlg, insertListText, 648.352161, 777.7777, 6, 1);
                // Non-numeric precursor m/z
                VerifyTransitionListError(insertTransDlg, insertListText, 762.033412, "x", Resources.PasteDlg_AddTransitionList_The_precursor_m_z_must_be_a_number_, 0, 1);
                // Empty peptide
                VerifyTransitionListError(insertTransDlg, insertListText, "TISQSSSLKSSSNSNK", "", Resources.PasteDlg_ListPeptideSequences_The_peptide_sequence_cannot_be_blank, 9, 0);
                // Bad peptide
                VerifyTransitionListError(insertTransDlg, insertListText, "TISQSSSLKSSSNSNK", "BBBbBBBR", Resources.PasteDlg_ListPeptideSequences_This_peptide_sequence_contains_invalid_characters, 9, 0);
                // No mods explain all transitions
                VerifyTransitionListError(insertTransDlg, insertPart1 + insertPart2, null, null, Resources.PeptideGroupBuilder_AppendTransition_Failed_to_explain_all_transitions_for_0__m_z__1__with_a_single_set_of_modifications, 3, 0, 2);
                // Finally a working set of transitions
                SetClipboardText(insertPart1 + insertSep + insertPart2);
                insertTransDlg.PasteTransitions();
                insertTransDlg.OkDialog();
            });

            var docInsert2 = WaitForDocumentChange(docInsert1);
            AssertEx.IsDocumentState(docInsert2, null, 4, 7, 21); // revision # is hard to predict with background loaders running
            Assert.AreEqual(7, GetVariableModCount(docInsert2));
            Assert.AreEqual(11, GetLossCount(docInsert2, 1));
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:84,代码来源:InsertModTest.cs

示例13: ConnectLibrarySpecs

        private SrmDocument ConnectLibrarySpecs(IWin32Window parent, SrmDocument document, string documentPath)
        {
            string docLibFile = null;
            if (!string.IsNullOrEmpty(documentPath) && document.Settings.PeptideSettings.Libraries.HasDocumentLibrary)
            {
                docLibFile = BiblioSpecLiteSpec.GetLibraryFileName(documentPath);
                if (!File.Exists(docLibFile))
                {
                    MessageDlg.Show(this, string.Format(Resources.SkylineWindow_ConnectLibrarySpecs_Could_not_find_the_spectral_library__0__for_this_document__Without_the_library__no_spectrum_ID_information_will_be_available_, docLibFile));
                }
            }

            var settings = document.Settings.ConnectLibrarySpecs(library =>
                {
                    LibrarySpec spec;
                    if (Settings.Default.SpectralLibraryList.TryGetValue(library.Name, out spec))
                    {
                        if (File.Exists(spec.FilePath))
                            return spec;
                    }
                    if (documentPath == null)
                        return null;

                    string fileName = library.FileNameHint;
                    if (fileName != null)
                    {
                        // First look for the file name in the document directory
                        string pathLibrary = Path.Combine(Path.GetDirectoryName(documentPath) ?? string.Empty, fileName);
                        if (File.Exists(pathLibrary))
                            return library.CreateSpec(pathLibrary).ChangeDocumentLocal(true);
                        // In the user's default library directory
                        pathLibrary = Path.Combine(Settings.Default.LibraryDirectory ?? string.Empty, fileName);
                        if (File.Exists(pathLibrary))
                            return library.CreateSpec(pathLibrary);
                    }

                    using (var dlg = new MissingFileDlg
                                  {
                                      ItemName = library.Name,
                                      ItemType = Resources.SkylineWindow_ConnectLibrarySpecs_Spectral_Library,
                                      Filter = library.SpecFilter,
                                      FileHint = fileName,
                                      FileDlgInitialPath = Path.GetDirectoryName(documentPath),
                                      Title = Resources.SkylineWindow_ConnectLibrarySpecs_Find_Spectral_Library
                                  })
                    {
                        if (dlg.ShowDialog(parent) == DialogResult.OK)
                        {
                            Settings.Default.LibraryDirectory = Path.GetDirectoryName(dlg.FilePath);
                            return library.CreateSpec(dlg.FilePath);
                        }
                    }

                    return null;
                }, docLibFile);

            if (settings == null)
                return null; // User cancelled

            if (ReferenceEquals(settings, document.Settings))
                return document;

            // If the libraries were moved to disconnected state, then avoid updating
            // the document tree for this change, or it will strip all the library
            // information off the document nodes.
            if (settings.PeptideSettings.Libraries.DisconnectedLibraries != null)
                return document.ChangeSettingsNoDiff(settings);

            return document.ChangeSettings(settings);
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:70,代码来源:SkylineFiles.cs

示例14: RecalculateAlignments

 public static SrmDocument RecalculateAlignments(SrmDocument document, IProgressMonitor progressMonitor)
 {
     var newSources = ListAvailableRetentionTimeSources(document.Settings);
     var newResultsSources = ListSourcesForResults(document.Settings.MeasuredResults, newSources);
     var allLibraryRetentionTimes = ReadAllRetentionTimes(document, newSources);
     var newFileAlignments = new List<FileRetentionTimeAlignments>();
     var progressStatus = new ProgressStatus("Aligning retention times"); // Not L10N?  Will users see this?
     foreach (var retentionTimeSource in newResultsSources.Values)
     {
         progressStatus = progressStatus.ChangePercentComplete(100*newFileAlignments.Count/newResultsSources.Count);
         progressMonitor.UpdateProgress(progressStatus);
         try
         {
             var fileAlignments = CalculateFileRetentionTimeAlignments(retentionTimeSource.Name, allLibraryRetentionTimes, progressMonitor);
             newFileAlignments.Add(fileAlignments);
         }
         catch (OperationCanceledException)
         {
             progressMonitor.UpdateProgress(progressStatus.Cancel());
             return null;
         }
     }
     var newDocRt = new DocumentRetentionTimes(newSources.Values, newFileAlignments);
     var newDocument = document.ChangeSettings(document.Settings.ChangeDocumentRetentionTimes(newDocRt));
     Debug.Assert(IsLoaded(newDocument));
     progressMonitor.UpdateProgress(progressStatus.Complete());
     return newDocument;
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:28,代码来源:DocumentRetentionTimes.cs

示例15: ChangePeptideModifications

 private static SrmDocument ChangePeptideModifications(SrmDocument doc, IList<TypedModifications> typedHeavyMods)
 {
     var settingsNew =
         doc.Settings.ChangePeptideModifications(mods => new PeptideModifications(mods.StaticModifications,
            typedHeavyMods));
     return doc.ChangeSettings(settingsNew);
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:7,代码来源:PasteTest.cs


注:本文中的SrmDocument.ChangeSettings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。