示例#1
0
        /// <summary>
        /// Gets replicate indices for a specific grouping annotation and value.
        /// </summary>
        public static int[] GetReplicateIndices(SrmDocument document, ReplicateValue group, object groupValue)
        {
            var defaultResult = Enumerable.Range(0, document.Settings.MeasuredResults.Chromatograms.Count).ToArray();

            if (group == null)
            {
                return(defaultResult);
            }

            var annotationCalculator = new AnnotationCalculator(document);

            return(defaultResult.Where(i => Equals(groupValue,
                                                   group.GetValue(annotationCalculator, document.Settings.MeasuredResults.Chromatograms[i]))).ToArray());
        }
        public void AddApplyRemovePeak(ToolStrip menuStrip, IsotopeLabelType labelType, int separator, ref int iInsert)
        {
            var removePeakItems = removePeakGraphMenuItem.DropDownItems;
            var document        = DocumentUI;

            SkylineWindow.EditMenu.CanApplyOrRemovePeak(removePeakItems, labelType, out var canApply, out var canRemove);
            if (canApply || canRemove)
            {
                if (separator < 0)
                {
                    menuStrip.Items.Insert(iInsert++, toolStripSeparator33);
                }
                if (canApply)
                {
                    menuStrip.Items.Insert(iInsert++, applyPeakAllGraphMenuItem);
                    menuStrip.Items.Insert(iInsert++, applyPeakSubsequentGraphMenuItem);
                    var groupable = ReplicateValue.GetGroupableReplicateValues(document).ToArray();
                    if (groupable.Any())
                    {
                        var groupBy = SkylineWindow.EditMenu.GetGroupApplyToDescription();
                        if (groupBy != null)
                        {
                            applyPeakGroupGraphMenuItem.Text =
                                Resources.SkylineWindow_BuildChromatogramMenu_Apply_Peak_to_ + groupBy;
                            menuStrip.Items.Insert(iInsert++, applyPeakGroupGraphMenuItem);
                        }

                        SkylineWindow.EditMenu.AddGroupByMenuItems(menuStrip, groupApplyToByGraphMenuItem, SkylineWindow.SetGroupApplyToBy, false, Settings.Default.GroupApplyToBy, ref iInsert);
                        groupApplyToByGraphMenuItem.Visible = true;
                    }
                    else
                    {
                        groupApplyToByGraphMenuItem.Visible = false;
                    }
                }
                if (canRemove)
                {
                    menuStrip.Items.Insert(iInsert++, removePeakGraphMenuItem);
                }
                if (separator > 0)
                {
                    menuStrip.Items.Insert(iInsert++, toolStripSeparator33);
                }
            }
        }
示例#3
0
        public static SrmDocument ApplyPeak(SrmDocument doc, PeptideTreeNode nodePepTree, ref TransitionGroupDocNode nodeTranGroup,
                                            int resultsIndex, ChromFileInfoId resultsFile, bool subsequent, ReplicateValue groupBy, object groupByValue, ILongWaitBroker longWaitBroker)
        {
            nodeTranGroup = nodeTranGroup ?? PickTransitionGroup(doc, nodePepTree, resultsIndex);
            GetReferenceData(doc, nodePepTree.DocNode, nodeTranGroup, resultsIndex, resultsFile, out var referenceTarget, out var referenceMatchData, out var runTime);

            var annotationCalculator = new AnnotationCalculator(doc);
            var chromatograms        = doc.Settings.MeasuredResults.Chromatograms;

            for (var i = 0; i < chromatograms.Count; i++)
            {
                var chromSet = chromatograms[i];

                if (groupBy != null)
                {
                    if (!Equals(groupByValue, groupBy.GetValue(annotationCalculator, chromSet)))
                    {
                        continue;
                    }
                }

                for (var j = 0; j < chromSet.MSDataFileInfos.Count; j++)
                {
                    var fileInfo = chromSet.MSDataFileInfos[j];
                    if ((i == resultsIndex && (resultsFile == null || ReferenceEquals(resultsFile, fileInfo.FileId))) ||
                        (subsequent && runTime != null && fileInfo.RunStartTime < runTime))
                    {
                        continue;
                    }

                    var bestMatch = GetPeakMatch(doc, chromSet, fileInfo, nodeTranGroup, referenceTarget, referenceMatchData);
                    if (bestMatch != null)
                    {
                        doc = bestMatch.ChangePeak(doc, nodePepTree, nodeTranGroup, chromSet.Name, fileInfo.FilePath);
                    }
                }
                longWaitBroker.SetProgressCheckCancel(i + 1, chromatograms.Count);
            }
            return(doc);
        }
示例#4
0
        /// <summary>
        /// Gets possible values for an annotation.
        /// </summary>
        public static IEnumerable <object> GetPossibleAnnotations(SrmDocument document, ReplicateValue replicateValue)
        {
            if (!document.Settings.HasResults || null == replicateValue)
            {
                return(new object[0]);
            }
            var annotationCalculator = new AnnotationCalculator(document);

            return(document.Settings.MeasuredResults.Chromatograms
                   .Select(chromSet => replicateValue.GetValue(annotationCalculator, chromSet)).Distinct()
                   .OrderBy(x => x, CollectionUtil.ColumnValueComparer));
        }
示例#5
0
        private void DoStudy7Test()
        {
            // Preparing a Document to Accept the Study 7 Transition List, p. 18
            RunUI(() => SkylineWindow.NewDocument());
            var peptideSettingsUI1 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            if (IsCoverShotMode)
            {
                var modHeavyK = new StaticMod(HEAVY_K, "K", ModTerminus.C, false, null, LabelAtoms.C13 | LabelAtoms.N15, // Not L10N
                                              RelativeRT.Matching, null, null, null);
                AddHeavyMod(modHeavyK, peptideSettingsUI1, "Edit Isotope Modification form", 6);
            }
            var mod13Cr = new StaticMod("Label:13C(6) (C-term R)", "R", ModTerminus.C, false, null, LabelAtoms.C13,
                                        RelativeRT.Matching, null, null, null);

            AddHeavyMod(mod13Cr, peptideSettingsUI1, "Edit Isotope Modification form", 18);
            RunUI(() =>
            {
                peptideSettingsUI1.PickedHeavyMods            = new[] { "Label:13C(6) (C-term R)", HEAVY_K };
                peptideSettingsUI1.PickedLibraries            = new string[0];
                peptideSettingsUI1.SelectedBackgroundProteome = Resources.SettingsList_ELEMENT_NONE_None;
                peptideSettingsUI1.OkDialog();
            });

            // Pasting a Transition List into the Document, p. 19.
            string clipboardSaveText = string.Empty;

            RunUI(() =>
            {
                var filePath = GetTestPath(@"Study 7\Study7 transition list.xls");
                SetExcelFileClipboardText(filePath, "Simple", 6, false);
                clipboardSaveText = ClipboardEx.GetText();
            });
            // We expect this to fail due to instrument settings rather than format issues eg "The product m/z 1519.78 is out of range for the instrument settings, in the peptide sequence YEVQGEVFTKPQLWP. Check the Instrument tab in the Transition Settings."
            {
                var transitionSelectdgl = ShowDialog <ImportTransitionListColumnSelectDlg>(SkylineWindow.Paste);
                var messageDlg          = ShowDialog <ImportTransitionListErrorDlg>(transitionSelectdgl.AcceptButton.PerformClick);
                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),
                                              messageDlg.ErrorList[0].ErrorMessage,
                                              2);
                RunUI(() => messageDlg.Size = new Size(838, 192));
                PauseForScreenShot <ImportTransitionListErrorDlg>("Error message form (expected)", 19);
                OkDialog(messageDlg, messageDlg.CancelButton.PerformClick);          // Acknowledge the error but decline to proceed with import
                RunUI(() => transitionSelectdgl.DialogResult = DialogResult.Cancel); // Cancel the import

                // Restore the clipboard text after pausing
                ClipboardEx.SetText(clipboardSaveText);
            }

            RunDlg <TransitionSettingsUI>(() => SkylineWindow.ShowTransitionSettingsUI(TransitionSettingsUI.TABS.Instrument), transitionSettingsUI =>
            {
                transitionSettingsUI.InstrumentMaxMz = 1800;
                transitionSettingsUI.OkDialog();
            });
            PasteTransitionListSkipColumnSelect();
            RunUI(SkylineWindow.CollapsePeptides);
            PauseForScreenShot("Targets tree (selected from main window)", 20);

            // Adjusting Modifications Manually, p. 19.
            AdjustModifications("AGLCQTFVYGGCR", true, 'V', 747.348);
            PauseForScreenShot("Target tree clipped from main window", 22);

            AdjustModifications("IVGGWECEK", true, 'V', 541.763);
            AdjustModifications("YEVQGEVFTKPQLWP", false, 'L', 913.974);
            RunUI(() => SkylineWindow.SaveDocument(GetTestPath(@"Study 7\Study7.sky")));

            // Importing Data from a Multiple Sample WIFF file, p. 23.
            var importResultsDlg1     = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
            var openDataSourceDialog1 = ShowDialog <OpenDataSourceDialog>(() => importResultsDlg1.NamedPathSets =
                                                                              importResultsDlg1.GetDataSourcePathsFile(null));

            RunUI(() =>
            {
                openDataSourceDialog1.CurrentDirectory = new MsDataFilePath(GetTestPath("Study 7"));
                openDataSourceDialog1.SelectAllFileType(UseRawFilesOrFullData ? ".wiff" : ".mzML"); // Force true wiff for FullData
            });
            if (UseRawFilesOrFullData)
            {
                var importResultsSamplesDlg = ShowDialog <ImportResultsSamplesDlg>(openDataSourceDialog1.Open);
                PauseForScreenShot <ImportResultsSamplesDlg>("Choose Samples form", 24);

                RunUI(() =>
                {
                    if (IsFullData)
                    {
                        importResultsSamplesDlg.CheckAll(true);
                        importResultsSamplesDlg.ExcludeSample(0);           // Blank
                        importResultsSamplesDlg.ExcludeSample(25);          // QC
                        importResultsSamplesDlg.ExcludeSample(26);
                        importResultsSamplesDlg.ExcludeSample(27);
                        importResultsSamplesDlg.ExcludeSample(28);
                        importResultsSamplesDlg.ExcludeSample(45);           // A2
                        importResultsSamplesDlg.ExcludeSample(46);
                        importResultsSamplesDlg.ExcludeSample(47);
                        importResultsSamplesDlg.ExcludeSample(48);
                        importResultsSamplesDlg.ExcludeSample(49);           // gradientwash
                        importResultsSamplesDlg.ExcludeSample(50);
                        importResultsSamplesDlg.ExcludeSample(51);
                        importResultsSamplesDlg.ExcludeSample(52);
                        importResultsSamplesDlg.ExcludeSample(53);           // A3
                        importResultsSamplesDlg.ExcludeSample(54);
                        importResultsSamplesDlg.ExcludeSample(55);
                        importResultsSamplesDlg.ExcludeSample(56);
                    }
                    else
                    {
                        importResultsSamplesDlg.CheckAll(false);
                        importResultsSamplesDlg.IncludeSample(1);
                        importResultsSamplesDlg.IncludeSample(2);
                        importResultsSamplesDlg.IncludeSample(11);
                        importResultsSamplesDlg.IncludeSample(12);
                    }
                });
                OkDialog(importResultsSamplesDlg, importResultsSamplesDlg.OkDialog);
            }
            else
            {
                RunUI(openDataSourceDialog1.Open);
            }

            {
                var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importResultsDlg1.OkDialog);
                PauseForScreenShot <ImportResultsNameDlg>("Import Results Common prefix form", 25);

                OkDialog(importResultsNameDlg, importResultsNameDlg.YesDialog);
            }
            WaitForCondition(() =>
                             SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);
            RestoreViewOnScreen(26);

            // Inspecting and Adjusting Peak Integration, p. 24.
            RunUI(() =>
            {
                SkylineWindow.ShowPeakAreaReplicateComparison();
                SkylineWindow.ShowGraphRetentionTime(true);
                SkylineWindow.Size = new Size(1029, 659);
            });

            if (!IsPauseForScreenShots && !IsFullData)
            {
                TestApplyToAll();
            }

            PauseForScreenShot <GraphSummary.RTGraphView>("Main window with peaks and retention times showing", 26);
            CheckReportCompatibility.CheckAll(SkylineWindow.Document);
            RunUI(SkylineWindow.EditDelete);
            FindNode("IVGGWECEK"); // Not L10N

            TransitionGroupTreeNode selNodeGroup = null;

            RunUI(() =>
            {
                selNodeGroup = (TransitionGroupTreeNode)SkylineWindow.SequenceTree.SelectedNode.Nodes[1];
                Assert.AreEqual(selNodeGroup.StateImageIndex, (int)SequenceTree.StateImageId.peak_blank);
            });
            RunDlg <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI, transitionSettingsUI =>
            {
                transitionSettingsUI.MZMatchTolerance = 0.065;
                transitionSettingsUI.OkDialog();
            });
            RunUI(() =>
            {
                Assert.AreEqual((int)SequenceTree.StateImageId.peak, selNodeGroup.StateImageIndex);
                SkylineWindow.ToggleIntegrateAll();
            });
            RunUI(() =>
            {
                foreach (PeptideDocNode nodePep in SkylineWindow.Document.Molecules)
                {
                    string sequence = nodePep.Peptide.Sequence;
                    int imageIndex  = PeptideTreeNode.GetPeakImageIndex(nodePep, SkylineWindow.SequenceTree);
                    if ((sequence != null) && (sequence.StartsWith("YLA") || sequence.StartsWith("YEV"))) // Not L10N
                    {
                        Assert.AreEqual((int)SequenceTree.StateImageId.keep, imageIndex,
                                        string.Format("Expected keep icon for the peptide {0}, found {1}", sequence, imageIndex));
                    }
                    else if (sequence != null)
                    {
                        Assert.AreEqual((int)SequenceTree.StateImageId.peak, imageIndex,
                                        string.Format("Expected peak icon for the peptide {0}, found {1}", sequence, imageIndex));
                    }
                    else // Custom Ion
                    {
                        Assert.AreEqual((int)SequenceTree.StateImageId.peak_blank, imageIndex,
                                        string.Format("Expected peak_blank icon for the custom ion {0}, found {1}", nodePep.ModifiedTarget, imageIndex));
                    }
                }
            });
            PauseForScreenShot("Main window", 27);

            // Data Inspection with Peak Areas View, p. 29.
            RestoreViewOnScreen(28);
            FindNode("SSDLVALSGGHTFGK"); // Not L10N
            RunUI(NormalizeGraphToHeavy);
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph metafile", 29);

            FindNode((564.7746).ToString(LocalizationHelper.CurrentCulture) + "++"); // ESDTSYVSLK - Not L10N
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph metafile", 30);

            RunUI(SkylineWindow.ExpandPeptides);
            string hgflprLight = (363.7059).ToString(LocalizationHelper.CurrentCulture) + "++";  // HGFLPR - Not L10N

            FindNode(hgflprLight);
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph metafile", 31);

            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.TOTAL));
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph normalized metafile", 32);

            RunUI(() =>
            {
                SkylineWindow.ShowGraphPeakArea(false);
                SkylineWindow.ActivateReplicate("E_03");
                SkylineWindow.Size = new Size(757, 655);
            });
            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile with interference", 32);

            RunUI(() => SkylineWindow.ShowGraphPeakArea(true));
            RunUI(() =>
            {
                SkylineWindow.ShowPeakAreaPeptideGraph();
                SkylineWindow.ShowTotalTransitions();
                SkylineWindow.ShowCVValues(true);
                SkylineWindow.ShowPeptideOrder(SummaryPeptideOrder.document);
            });
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas Peptide Comparison graph metafile", 33);

            float[] concentrations    = { 0f, 60, 175, 513, 1500, 2760, 4980, 9060, 16500, 30000 };
            var     documentGrid      = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true));
            var     pathConcentration = PropertyPath.Parse("AnalyteConcentration");
            var     pathSampleType    = PropertyPath.Parse("SampleType");

            RunUI(() => documentGrid.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates));
            WaitForConditionUI(() => documentGrid.RowCount == (IsFullData ? concentrations.Length * 4 : 4) &&
                               documentGrid.FindColumn(pathConcentration) != null &&
                               documentGrid.FindColumn(pathSampleType) != null);       // Let it initialize
            RunUI(() =>
            {
                // Parent is a DocPane and Parent.Parent is the floating window
                documentGrid.Parent.Parent.Size = new Size(585, 325);
                var documentGridView            = documentGrid.DataGridView;
                var colConcentration            = documentGrid.FindColumn(pathConcentration);
                var colStandardType             = documentGrid.FindColumn(pathSampleType);

                if (IsFullData)
                {
                    for (int i = 0; i < concentrations.Length; i++)
                    {
                        for (int j = i * 4; j < (i + 1) * 4; j++)
                        {
                            double?concentration = concentrations[i];
                            SetCellValue(documentGridView, j, colConcentration.Index, concentration);
                            SetCellValue(documentGridView, j, colStandardType.Index,
                                         concentration == 0 ? SampleType.BLANK : SampleType.STANDARD);
                        }
                    }
                }
                else
                {
                    SetCellValue(documentGridView, 0, colConcentration.Index, 0.0);
                    SetCellValue(documentGridView, 0, colStandardType.Index, SampleType.BLANK);
                    SetCellValue(documentGridView, 1, colConcentration.Index, 0.0);
                    SetCellValue(documentGridView, 1, colStandardType.Index, SampleType.BLANK);
                    SetCellValue(documentGridView, 2, colConcentration.Index, 175.0);
                    SetCellValue(documentGridView, 2, colStandardType.Index, SampleType.STANDARD);
                    SetCellValue(documentGridView, 3, colConcentration.Index, 175.0);
                    SetCellValue(documentGridView, 3, colStandardType.Index, SampleType.STANDARD);
                }
            });
            WaitForGraphs();
            PauseForScreenShot <DocumentGridForm>("Document grid filled (scrolled to the end)", 35);
            RunUI(() => documentGrid.Close());

            FindNode("SSDLVALSGGHTFGK"); // Not L10N
            RunUI(() =>
            {
                SkylineWindow.ShowPeakAreaReplicateComparison();
                var settings         = SkylineWindow.DocumentUI.Settings;
                var valConcentration = ReplicateValue.GetAllReplicateValues(settings).Skip(1).First();
                SkylineWindow.GroupByReplicateValue(valConcentration);
                NormalizeGraphToHeavy();
            });
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph with CVs metafile", 36);

            RunUI(() => SkylineWindow.ShowCVValues(false));
            RunUI(() => SkylineWindow.SaveDocument());
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph grouped by concentration metafile", 37);
            PauseForAuditLog();
            // Further Exploration, p. 33.
            RunUI(() =>
            {
                SkylineWindow.OpenFile(GetTestPath(@"Study 7\Study II\Study 7ii (site 52).sky")); // Not L10N
                SkylineWindow.ShowPeakAreaPeptideGraph();
                SkylineWindow.ShowCVValues(true);
            });
            WaitForCondition(() => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);
            RestoreViewOnScreen(38);
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas peptide comparison graph metafile", 38);
            FindNode("LSEPAELTDAVK");
            RunUI(() =>
            {
                SkylineWindow.ShowGraphPeakArea(false);
                SkylineWindow.Width = 920;
                SkylineWindow.ShowRTReplicateGraph();
            });
            PauseForScreenShot <GraphSummary.RTGraphView>("Retention Times replicate graph metafile", 38);

            FindNode("INDISHTQSVSAK");
            RunUI(SkylineWindow.ShowPeakAreaReplicateComparison);
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas normalized to heave graph metafile", 39);

            if (IsCoverShotMode)
            {
                RunUI(() =>
                {
                    Settings.Default.ChromatogramFontSize = 14;
                    Settings.Default.AreaFontSize         = 14;
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                    SkylineWindow.AutoZoomBestPeak();
                });
                RestoreCoverViewOnScreen();
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SelectedNode.Parent);
                WaitForGraphs();
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SelectedNode.Nodes[0]);
                RunUI(SkylineWindow.FocusDocument);
                TakeCoverShot();
                return;
            }

            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.NONE));
            WaitForGraphs();
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas no normalization graph metafile", 40);

            FindNode(hgflprLight);
            RunUI(() =>
            {
                SkylineWindow.ShowAllTransitions();
                NormalizeGraphToHeavy();
            });
            WaitForGraphs();
            PauseForScreenShot <GraphSummary.AreaGraphView>("Area Ratio to Heavy graph showing interference metafile", 41);

            RunUI(() => SkylineWindow.ShowGraphPeakArea(false));
            RunUI(() => SkylineWindow.ActivateReplicate("E_ 03"));
            WaitForGraphs();
            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile showing slight interference", 41);
        }