public void SetSelectedFile(string file) { var group = _replicateGroups?.FirstOrDefault(g => (g.FileInfo != null && g.FileInfo.FilePath.GetFileName() == file) || (g.FileInfo == null && file == null)); if (group != null) { SelectedGroup = group; GraphSummary.UpdateUI(); } }
protected override void ChangeSelection(int selectedIndex, IdentityPath identityPath) { if (_replicateGroups == null || 0 > selectedIndex || selectedIndex >= _replicateGroups.Count) { return; } var previousFile = SelectedGroup != null ? SelectedGroup.FileInfo : null; SelectedGroup = _replicateGroups[selectedIndex]; if (SelectedGroup.FileInfo != null) { foreach (var graph in Program.MainWindow.GraphChromatograms) { var files = graph.Files; var index = files.IndexOf(SelectedGroup.FileInfo.FilePath.GetFileName()); if (index >= 0) { graph.SelectedFileIndex = index; } } } // When the user clicks on the graph, they either intend to change // the currently selected replicate, or the currently selected IdentityPath. // We want to prevent the UI from drilling in too deep when the user // just wants to see a different replicate at the same level currently // being viewed (e.g. peptide). // Therefore, only change the currently selected IdentityPath if the currently // selected Replicate is the last replicate in the ReplicateGroup that they // have clicked on. // Updated 10/3/2016 now can drill down to peptide level because multi peptide RT graph is supported. var resultIndicesArray = IndexOfReplicate(selectedIndex).ToArray(); int iSelection = Array.IndexOf(resultIndicesArray, GraphSummary.ResultsIndex); if (iSelection == resultIndicesArray.Length - 1 && (IsMultiSelect || !GraphChromatogram.IsSingleTransitionDisplay) && ReferenceEquals(previousFile, SelectedGroup.FileInfo)) { GraphSummary.StateProvider.SelectPath(identityPath); UpdateGraph(true); return; } // If there is more than one replicate in the group that they // have clicked on, then select the next replicate in that group. // The user has clicked on a group which does not contain the // currently selected replicate, then iSelection will be -1, and // the first replicate in that group will be selected. int newReplicateIndex = resultIndicesArray[((iSelection + 1) % resultIndicesArray.Length)]; ChangeSelectedIndex(newReplicateIndex); UpdateGraph(true); }
protected virtual void InitData() { List <DocNode> docNodes = new List <DocNode>(); List <IdentityPath> docNodePaths = new List <IdentityPath>(); List <List <PointPairList> > pointPairLists = new List <List <PointPairList> >(); List <String> docNodeLabels = new List <string>(); ReplicateGroups = new ReplicateGroup[0]; foreach (var docNodePath in _selectedDocNodePaths) { var nodeArray = _document.ToNodeArray(docNodePath); var docNode = nodeArray.Last(); var replicateIndices = Enumerable.Range(0, _document.Settings.MeasuredResults.Chromatograms.Count); // ReSharper disable CanBeReplacedWithTryCastAndCheckForNull if (docNode is TransitionDocNode) { var nodeTran = (TransitionDocNode)docNode; ReplicateGroups = GetReplicateGroups(replicateIndices).ToArray(); docNodes.Add(nodeTran); docNodePaths.Add(docNodePath); pointPairLists.Add(GetPointPairLists((PeptideDocNode)nodeArray[1], (TransitionGroupDocNode)nodeArray[2], nodeTran, _displayType)); docNodeLabels.Add(ChromGraphItem.GetTitle(nodeTran)); } else if (docNode is TransitionGroupDocNode) { var nodeGroup = (TransitionGroupDocNode)docNode; var peptideDocNode = (PeptideDocNode)nodeArray[1]; ReplicateGroups = GetReplicateGroups(replicateIndices).ToArray(); if (_displayType == DisplayTypeChrom.single || _displayType == DisplayTypeChrom.total) { docNodes.Add(nodeGroup); docNodePaths.Add(docNodePath); pointPairLists.Add(GetPointPairLists(peptideDocNode, nodeGroup, _displayType)); docNodeLabels.Add(ChromGraphItem.GetTitle(nodeGroup)); } else { foreach (TransitionDocNode nodeTran in GraphChromatogram.GetDisplayTransitions(nodeGroup, _displayType)) { docNodes.Add(nodeTran); docNodePaths.Add(new IdentityPath(docNodePath, nodeTran.Id)); pointPairLists.Add(GetPointPairLists(peptideDocNode, nodeGroup, nodeTran, _displayType)); docNodeLabels.Add(ChromGraphItem.GetTitle(nodeTran)); } } } else if (docNode is PeptideDocNode) { var nodePep = (PeptideDocNode)docNode; ReplicateGroups = GetReplicateGroups(replicateIndices).ToArray(); var isMultiSelect = _selectedDocNodePaths.Count > 1 || (_selectedDocNodePaths.Count == 1 && Program.MainWindow != null && Program.MainWindow.SelectedNode is PeptideGroupTreeNode); foreach (var tuple in GetPeptidePointPairLists((PeptideGroupDocNode)nodeArray[0], nodePep, isMultiSelect)) { docNodes.Add(tuple.Node); docNodePaths.Add(docNodePath); pointPairLists.Add(tuple.PointPairList); docNodeLabels.Add(tuple.DisplaySeq); } } } // ReSharper restore CanBeReplacedWithTryCastAndCheckForNull PointPairLists = pointPairLists; DocNodes = docNodes; _docNodePaths = ImmutableList.ValueOf(docNodePaths); DocNodeLabels = docNodeLabels; var oldGroupNames = ReplicateGroups.Select(g => g.GroupName).ToArray(); var uniqueGroupNames = oldGroupNames.Distinct().ToArray(); // Instert "All" groups and point pair lists in their correct positions InsertAllGroupsAndPointPairLists(uniqueGroupNames, docNodes.Count); // Collect all references to points that have a valid Y value var references = CollectValidPointRefs(uniqueGroupNames, oldGroupNames, docNodes.Count); // Merge groups if their replicate index is the same and each peptide only occurs in one of the files MergeGroups(uniqueGroupNames, references); // Remove groups that don't have any peptides in them RemoveEmptyGroups(docNodes.Count); }
protected bool Equals(ReplicateGroup other) { return(string.Equals(GroupName, other.GroupName) && Equals(FileInfo, other.FileInfo) && Equals(ReplicateIndexes, other.ReplicateIndexes) && IsAllGroup == other.IsAllGroup); }