예제 #1
0
 private void PerformSort(string title, Comparison <PeptideGroupDocNode> comparison, MessageType type)
 {
     ModifyDocument(title, doc =>
     {
         var listIrt      = new List <PeptideGroupDocNode>();
         var listProteins = new List <PeptideGroupDocNode>(doc.Children.Count);
         var listDecoy    = new List <PeptideGroupDocNode>();
         foreach (var nodePepGroup in doc.MoleculeGroups)
         {
             if (nodePepGroup.IsDecoy)
             {
                 listDecoy.Add(nodePepGroup);
             }
             else if (nodePepGroup.PeptideCount > 0 && nodePepGroup.Peptides.All(nodePep => nodePep.GlobalStandardType == StandardType.IRT))
             {
                 listIrt.Add(nodePepGroup);
             }
             else
             {
                 listProteins.Add(nodePepGroup);
             }
         }
         listIrt.Sort(comparison);
         listProteins.Sort(comparison);
         listDecoy.Sort(comparison);
         return((SrmDocument)doc.ChangeChildrenChecked(listIrt.Concat(listProteins).Concat(listDecoy).ToArray()));
     }, docPair => AuditLogEntry.CreateSingleMessageEntry(new MessageInfo(type, docPair.NewDocumentType)));
 }
예제 #2
0
        public bool ShowGenerateDecoysDlg(IWin32Window owner = null)
        {
            using (var decoysDlg = new GenerateDecoysDlg(DocumentUI))
            {
                if (decoysDlg.ShowDialog(owner ?? SkylineWindow) == DialogResult.OK)
                {
                    var refinementSettings = new RefinementSettings {
                        NumberOfDecoys = decoysDlg.NumDecoys, DecoysMethod = decoysDlg.DecoysMethod
                    };
                    ModifyDocument(Resources.SkylineWindow_ShowGenerateDecoysDlg_Generate_Decoys, refinementSettings.GenerateDecoys,
                                   docPair =>
                    {
                        var plural = refinementSettings.NumberOfDecoys > 1;
                        return(AuditLogEntry.CreateSingleMessageEntry(new MessageInfo(
                                                                          plural ? MessageType.added_peptide_decoys : MessageType.added_peptide_decoy,
                                                                          DocumentUI.DocumentType,
                                                                          refinementSettings.NumberOfDecoys, refinementSettings.DecoysMethod)));
                    });

                    var nodePepGroup = DocumentUI.PeptideGroups.First(nodePeptideGroup => nodePeptideGroup.IsDecoy);
                    SelectedPath = DocumentUI.GetPathTo((int)SrmDocument.Level.MoleculeGroups, DocumentUI.FindNodeIndex(nodePepGroup.Id));
                    return(true);
                }
            }
            return(false);
        }
예제 #3
0
        public void RemovePeaks(SrmDocument.DOCUMENT_TYPE docType, BoundDataGridView dataGridView)
        {
            var parent        = FormUtil.FindTopLevelOwner(dataGridView);
            var selectedPeaks = GetSelectedPeaks(dataGridView).Distinct().ToArray();

            if (selectedPeaks.Length == 0)
            {
                MessageDlg.Show(parent, Resources.RemovePeaksAction_RemovePeaks_No_peaks_are_selected);
                return;
            }

            var    lookup  = selectedPeaks.ToLookup(tuple => tuple.Item1, tuple => tuple.Item2).ToArray();
            string message = GetConfirmRemoveMessage(docType, selectedPeaks.Length, lookup.Length);

            if (MultiButtonMsgDlg.Show(parent, message, MultiButtonMsgDlg.BUTTON_OK) != DialogResult.OK)
            {
                return;
            }

            var skylineWindow = GetSkylineWindow(dataGridView);

            lock (skylineWindow.GetDocumentChangeLock())
            {
                skylineWindow.ModifyDocument(Resources.RemovePeaksAction_RemovePeaks_Remove_peaks,
                                             doc =>
                {
                    var longOperationRunner = new LongOperationRunner
                    {
                        ParentControl = parent,
                        JobTitle      = Resources.RemovePeaksAction_RemovePeaks_Removing_Peaks
                    };
                    SrmDocument resultDocument = doc;
                    doc = doc.BeginDeferSettingsChanges();
                    longOperationRunner.Run(broker =>
                    {
                        for (int iGroup = 0; iGroup < lookup.Length; iGroup++)
                        {
                            broker.ProgressValue = iGroup * 100 / lookup.Length;
                            if (broker.IsCanceled)
                            {
                                return;
                            }
                            doc = RemovePeaks(doc, lookup[iGroup]);
                        }

                        resultDocument = doc.EndDeferSettingsChanges(resultDocument, null);
                    });
                    return(resultDocument);
                },
                                             docPair => AuditLogEntry.CreateSingleMessageEntry(
                                                 new MessageInfo(MessageType.removed_peaks, docPair.NewDocumentType, selectedPeaks.Length, lookup.Length)));
            }
        }
예제 #4
0
        private ToolStripMenuItem MakeExcludeStandardMenuItem(int replicateIndex)
        {
            var document = DocumentUiContainer.DocumentUI;

            if (!document.Settings.HasResults)
            {
                return(null);
            }
            ChromatogramSet chromatogramSet = null;

            if (replicateIndex >= 0 &&
                replicateIndex < document.Settings.MeasuredResults.Chromatograms.Count)
            {
                chromatogramSet = document.Settings.MeasuredResults.Chromatograms[replicateIndex];
            }
            if (chromatogramSet == null)
            {
                return(null);
            }
            if (!chromatogramSet.SampleType.AllowExclude)
            {
                return(null);
            }
            PeptideDocNode      peptideDocNode;
            PeptideGroupDocNode peptideGroupDocNode;

            if (!TryGetSelectedPeptide(out peptideGroupDocNode, out peptideDocNode))
            {
                return(null);
            }
            bool isExcluded   = peptideDocNode.IsExcludeFromCalibration(replicateIndex);
            var  menuItemText = isExcluded ? QuantificationStrings.CalibrationForm_MakeExcludeStandardMenuItem_Include_Standard
                : QuantificationStrings.CalibrationForm_MakeExcludeStandardMenuItem_Exclude_Standard;
            var peptideIdPath = new IdentityPath(peptideGroupDocNode.Id, peptideDocNode.Id);
            var menuItem      = new ToolStripMenuItem(menuItemText, null, (sender, args) =>
            {
                _skylineWindow.ModifyDocument(menuItemText,
                                              doc => SetExcludeStandard(doc, peptideIdPath, replicateIndex, !isExcluded), docPair =>
                {
                    var msgType = isExcluded
                            ? MessageType.set_included_standard
                            : MessageType.set_excluded_standard;
                    return(AuditLogEntry.CreateSingleMessageEntry(docPair.OldDoc,
                                                                  new MessageInfo(msgType, PeptideTreeNode.GetLabel(peptideDocNode, string.Empty), chromatogramSet.Name)));
                });
            });

            return(menuItem);
        }