private PeptidesAndTransitionGroups GetSelectedPeptides() { return(PeptidesAndTransitionGroups.Get(GraphSummary.StateProvider.SelectedNodes, GraphSummary.ResultsIndex, 100)); }
[MethodImpl(MethodImplOptions.NoOptimization)] // disable optimizations in hopes of tracking down NullReferenceException public static PeptidesAndTransitionGroups Get(IList <TreeNodeMS> selectedNodes, int resultsIndex, int maxDisplayPeptides) { var peptidesAndTransitionGroups = new PeptidesAndTransitionGroups(); if (!Settings.Default.AllowMultiplePeptideSelection) { return(peptidesAndTransitionGroups); } foreach (var selectedNode in selectedNodes) { // Add all peptides from a selected protein. var proteinNode = selectedNode as PeptideGroupTreeNode; if (proteinNode != null) { peptidesAndTransitionGroups.ProteinSelected = true; foreach (var nodePep in proteinNode.DocNode.Molecules) { peptidesAndTransitionGroups.Add(new IdentityPath(proteinNode.Path, nodePep.Id), nodePep); } } else { // Walk up the sequence tree until we find a peptide. var node = (TreeNode)selectedNode; while (node != null && !(node is PeptideTreeNode)) { node = node.Parent; } var nodePepTree = node as PeptideTreeNode; if (nodePepTree != null) { peptidesAndTransitionGroups.Add(nodePepTree.Path, nodePepTree.DocNode); } } } if (peptidesAndTransitionGroups.NodePeps.Count == 0) { foreach (var selectedNode in selectedNodes) { // Add transition groups directly. var node = (TreeNode)selectedNode; while (node != null && !(node is TransitionGroupTreeNode)) { node = node.Parent; } if (node != null) { var groupTreeNode = (TransitionGroupTreeNode)node; var pepTreeNode = (PeptideTreeNode)groupTreeNode.Parent; if (pepTreeNode != null) { peptidesAndTransitionGroups.Add(pepTreeNode.Path, pepTreeNode.DocNode, groupTreeNode.DocNode); } } } } peptidesAndTransitionGroups.Complete(maxDisplayPeptides, resultsIndex); return(peptidesAndTransitionGroups); }