public CurveItem AddChromatogram(PaneKey paneKey, ChromGraphItem chromGraphItem) { var chromDisplayState = (ChromDisplayState)_displayState; chromDisplayState.ChromGraphItems.Add(new KeyValuePair <PaneKey, ChromGraphItem>(paneKey, chromGraphItem)); return(GraphControl.AddGraphItem(chromDisplayState.GetOrCreateGraphPane(GraphControl, paneKey), chromGraphItem, false)); }
public GraphObjTag(ChromGraphItem chromGraphItem, GraphObjType graphObjType, ScaledRetentionTime start, ScaledRetentionTime end) { ChromGraphItem = chromGraphItem; GraphObjType = graphObjType; StartTime = start; EndTime = end; }
protected virtual void InitData() { List <DocNode> docNodes = new List <DocNode>(); List <List <PointPairList> > pointPairLists = new List <List <PointPairList> >(); List <String> docNodeLabels = new List <string>(); // ReSharper disable CanBeReplacedWithTryCastAndCheckForNull if (_docNode is TransitionDocNode) { var nodeTran = (TransitionDocNode)_docNode; ReplicateGroups = GetReplicateGroups(GetReplicateIndices(nodeTran)).ToArray(); docNodes.Add(nodeTran); pointPairLists.Add(GetPointPairLists(null, nodeTran, _displayType)); docNodeLabels.Add(ChromGraphItem.GetTitle(nodeTran)); } else if (_docNode is TransitionGroupDocNode) { var nodeGroup = (TransitionGroupDocNode)_docNode; ReplicateGroups = GetReplicateGroups(GetReplicateIndices(nodeGroup)).ToArray(); if (_displayType == DisplayTypeChrom.single || _displayType == DisplayTypeChrom.total) { docNodes.Add(nodeGroup); pointPairLists.Add(GetPointPairLists(nodeGroup, _displayType)); docNodeLabels.Add(ChromGraphItem.GetTitle(nodeGroup)); } else { foreach (TransitionDocNode nodeTran in GraphChromatogram.GetDisplayTransitions(nodeGroup, _displayType)) { docNodes.Add(nodeTran); pointPairLists.Add(GetPointPairLists(nodeGroup, nodeTran, _displayType)); docNodeLabels.Add(ChromGraphItem.GetTitle(nodeTran)); } } } else if (_docNode is PeptideDocNode) { var nodePep = (PeptideDocNode)_docNode; ReplicateGroups = GetReplicateGroups(GetReplicateIndices(nodePep)).ToArray(); foreach (TransitionGroupDocNode nodeGroup in nodePep.Children) { if (!_paneKey.IncludesTransitionGroup(nodeGroup)) { continue; } docNodes.Add(nodeGroup); pointPairLists.Add(GetPointPairLists(nodeGroup, DisplayTypeChrom.total)); docNodeLabels.Add(ChromGraphItem.GetTitle(nodeGroup)); } } // ReSharper restore CanBeReplacedWithTryCastAndCheckForNull PointPairLists = pointPairLists; DocNodes = docNodes; DocNodeLabels = docNodeLabels; }
protected virtual List <LineInfo> GetPeptidePointPairLists(PeptideGroupDocNode peptideGroup, PeptideDocNode nodePep, bool multiplePeptides) { var pointPairLists = new List <LineInfo>(); foreach (TransitionGroupDocNode nodeGroup in nodePep.Children) { if (!_paneKey.IncludesTransitionGroup(nodeGroup)) { continue; } pointPairLists.Add(new LineInfo(nodeGroup, ChromGraphItem.GetTitle(nodeGroup), GetPointPairLists(nodePep, nodeGroup, DisplayTypeChrom.all))); } return(pointPairLists); }
public GraphObjTag(ChromGraphItem chromGraphItem, GraphObjType graphObjType, ScaledRetentionTime retentionTime) { ChromGraphItem = chromGraphItem; GraphObjType = graphObjType; RetentionTime = retentionTime; }
private ScaledRetentionTime FindBestPeakTime(GraphPane graphPane, CurveItem curve, PointF pt, out ChromGraphItem graphItem) { graphItem = FindBestPeakItem(curve); if (graphItem != null) { double displayTime, yTemp; graphPane.ReverseTransform(pt, out displayTime, out yTemp); return graphItem.GetNearestDisplayTime(displayTime); } return ScaledRetentionTime.ZERO; }
private PeakBoundsDragInfo StartDrag(GraphPane graphPane, ChromGraphItem graphItem, PointF pt, ScaledRetentionTime time, bool bothBoundaries) { var tranPeakInfo = graphItem.TransitionChromInfo; var startTime = time; var endTime = time; if (tranPeakInfo == null) bothBoundaries = true; else { startTime = graphItem.ScaleRetentionTime(tranPeakInfo.StartRetentionTime); endTime = graphItem.ScaleRetentionTime(tranPeakInfo.EndRetentionTime); } bool draggingEnd = Math.Abs(time.DisplayTime - startTime.DisplayTime) > Math.Abs(time.DisplayTime - endTime.DisplayTime); ScaledRetentionTime anchorTime, caretTime; if (bothBoundaries) anchorTime = caretTime = time; else if (draggingEnd) { anchorTime = startTime; caretTime = endTime; } else { anchorTime = endTime; caretTime = startTime; } var retentionMsMs = RetentionMsMs; bool alignedTimes = false; if (retentionMsMs == null) { retentionMsMs = AlignedRetentionMsMs; alignedTimes = true; } var dragType = (draggingEnd ? PeakBoundsChangeType.end : PeakBoundsChangeType.start); var changeType = bothBoundaries ? PeakBoundsChangeType.both : dragType; var peakBoundDragInfo = new PeakBoundsDragInfo(graphPane, graphItem, retentionMsMs, alignedTimes, pt, dragType, changeType) { AnchorTime = anchorTime, CaretTime = caretTime }; return (graphItem.DragInfo = peakBoundDragInfo); }
public PeakBoundsDragInfo(GraphPane graphPane, ChromGraphItem graphItem, double[] retentionTimesMsMs, bool alignedTimes, PointF startPoint, PeakBoundsChangeType dragType, PeakBoundsChangeType changeType) { GraphPane = graphPane; GraphItem = GraphItemBest = graphItem; GraphItemBest.HideBest = true; RetentionTimesMsMs = retentionTimesMsMs; IsAlignedTimes = alignedTimes; StartPoint = startPoint; DragType = dragType; ChangeType = changeType; }
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); }
private static void SetRetentionTimePredictedIndicator(ChromGraphItem chromGraphPrimary, SrmSettings settings, ChromatogramSet chromatograms, PeptideDocNode[] nodePeps, string lookupSequence, ExplicitMods lookupMods) { // Set predicted retention time on the first graph item to make // line, label and shading show. var regression = settings.PeptideSettings.Prediction.RetentionTime; if (regression != null && Settings.Default.ShowRetentionTimePred) { string modSeq = settings.GetModifiedSequence(lookupSequence, IsotopeLabelType.light, lookupMods); var fileId = chromatograms.FindFile(chromGraphPrimary.Chromatogram); double? predictedRT = regression.GetRetentionTime(modSeq, fileId); double window = regression.TimeWindow; chromGraphPrimary.RetentionPrediction = predictedRT; chromGraphPrimary.RetentionWindow = window; } chromGraphPrimary.RetentionExplicit = (nodePeps.Length == 1) ? nodePeps[0].ExplicitRetentionTime : null; }
private void DisplayAllIonsSummary(IRegressionFunction timeRegressionFunction, TransitionDocNode nodeTranSelected, ChromatogramSet chromatograms, ChromExtractor extractor, ref double bestStartTime, ref double bestEndTime) { if (ChromGroupInfos.Length == 0) { return; } var chromGroupInfo = ChromGroupInfos[0]; var info = chromGroupInfo.GetTransitionInfo(0, 0); var fileId = chromatograms.FindFile(chromGroupInfo); var nodeGroup = _nodeGroups != null ? _nodeGroups[0] : null; if (nodeGroup == null) nodeTranSelected = null; TransitionChromInfo tranPeakInfo = null; if (nodeGroup != null) { float maxPeakHeight = float.MinValue; foreach (TransitionDocNode nodeTran in nodeGroup.Children) { // Keep track of which chromatogram owns the tallest member of // the peak on the document tree. var transitionChromInfo = GetTransitionChromInfo(nodeTran, _chromIndex, fileId, 0); if (transitionChromInfo == null) continue; if (nodeTranSelected != null) { if (ReferenceEquals(nodeTran, nodeTranSelected)) tranPeakInfo = transitionChromInfo; } else if (transitionChromInfo.Height > maxPeakHeight) { maxPeakHeight = transitionChromInfo.Height; tranPeakInfo = transitionChromInfo; } // Adjust best peak window used to zoom the graph to the best peak AddBestPeakTimes(transitionChromInfo, ref bestStartTime, ref bestEndTime); } } // Apply active transform info.Transform(Transform); int numPeaks = info.NumPeaks; var annotationFlags = new bool[numPeaks]; for (int i = 0; i < numPeaks; i++) { // Exclude any peaks between the boundaries of the chosen peak. annotationFlags[i] = !IntersectPeaks(info.GetPeak(i), tranPeakInfo); } var graphItem = new ChromGraphItem(nodeGroup, nodeTranSelected, info, tranPeakInfo, timeRegressionFunction, annotationFlags, null, 0, true, true, 0, COLORS_GROUPS[(int)extractor], FontSize, LineWidth); _graphHelper.AddChromatogram(new PaneKey(nodeGroup), graphItem); }
public NotFoundChromGraphItem(TransitionGroupDocNode nodeGroup) : base(string.Format(Resources.NotFoundChromGraphItem_NotFoundChromGraphItem__0__not_found, ChromGraphItem.GetTitle(nodeGroup))) { }
private void DisplayOptimizationTotals(IRegressionFunction timeRegressionFunction, ChromatogramSet chromatograms, float mzMatchTolerance, ref double bestStartTime, ref double bestEndTime) { // Construct and add graph items for all relevant transition groups. float fontSize = FontSize; int lineWidth = LineWidth; int iColor = 0; // Get the one and only group var nodeGroup = _nodeGroups[0]; var chromGroupInfo = ChromGroupInfos[0]; ChromFileInfoId fileId = chromatograms.FindFile(chromGroupInfo); int numPeaks = chromGroupInfo.NumPeaks; // Collect the chromatogram info for the transition children // of this transition group. var listChromInfoSets = new List<ChromatogramInfo[]>(); var listTranisitionChromInfoSets = new List<TransitionChromInfo[]>(); int totalOptCount = chromatograms.OptimizationFunction.StepCount*2 + 1; foreach (TransitionDocNode nodeTran in nodeGroup.Children) { var infos = chromGroupInfo.GetAllTransitionInfo((float) nodeTran.Mz, mzMatchTolerance, chromatograms.OptimizationFunction); if (infos.Length == 0) continue; // Make sure the total number of chrom info entries match the expected // no matter what, so that chromatogram colors will match up with peak // area charts. if (infos.Length != totalOptCount) infos = ResizeArrayChromInfo(infos, totalOptCount); listChromInfoSets.Add(infos); var transitionChromInfos = new TransitionChromInfo[totalOptCount]; int steps = infos.Length/2; int offset = totalOptCount/2 - steps; for (int i = 0; i < infos.Length; i++) { transitionChromInfos[i + offset] = GetTransitionChromInfo(nodeTran, _chromIndex, fileId, i - steps); } listTranisitionChromInfoSets.Add(transitionChromInfos); } if (listChromInfoSets.Count == 0 || totalOptCount == 0) throw new InvalidDataException(Resources.GraphChromatogram_DisplayOptimizationTotals_No_optimization_data_available); // Enumerate optimization steps, grouping the data into graph data by step var listGraphData = new List<OptimizationGraphData>(); for (int i = 0; i < listChromInfoSets.Count; i++) { var chromInfos = listChromInfoSets[i]; var transitionChromInfos = listTranisitionChromInfoSets[i]; for (int j = 0; j < chromInfos.Length; j++) { if (listGraphData.Count <= j) listGraphData.Add(new OptimizationGraphData(numPeaks)); listGraphData[j].Add(chromInfos[j], transitionChromInfos[j]); } } // Total and transform the data, and compute which optimization // set has the most intense peak for each peak group. int bestPeakData = -1; TransitionChromInfo tranPeakInfo = null; float maxPeakHeight = float.MinValue; var maxPeakData = new int[numPeaks]; var maxPeakHeights = new float[numPeaks]; for (int i = 0; i < numPeaks; i++) maxPeakHeights[i] = float.MinValue; var transform = Transform; for (int i = 0; i < listGraphData.Count; i++) { var graphData = listGraphData[i]; var infoPrimary = graphData.InfoPrimary; if (infoPrimary == null) continue; // Sum intensities of all transitions in this // optimization bucket infoPrimary.SumIntensities(graphData.ChromInfos); // Apply any transform the user has chosen infoPrimary.Transform(transform); for (int j = 0; j < numPeaks; j++) { float height = graphData.PeakHeights[j]; if (height > maxPeakHeights[j]) { maxPeakHeights[j] = height; maxPeakData[j] = i; } } if (maxPeakHeight < graphData.TotalHeight) { maxPeakHeight = graphData.TotalHeight; bestPeakData = i; tranPeakInfo = graphData.TransitionInfoPrimary; } AddBestPeakTimes(graphData.TransitionInfoPrimary, ref bestStartTime, ref bestEndTime); } // Hide all peaks between the best peak extents if (tranPeakInfo != null) { for (int j = 0; j < numPeaks; j++) { if (maxPeakHeights[j] == 0) continue; var graphData = listGraphData[maxPeakData[j]]; if (graphData.InfoPrimary == null) continue; ChromPeak peak = graphData.InfoPrimary.GetPeak(j); if (peak.IsForcedIntegration) continue; if (IntersectPeaks(peak, tranPeakInfo)) maxPeakHeights[j] = 0; } } // Create graph items int totalSteps = totalOptCount/2; for (int i = 0; i < listGraphData.Count; i++) { var graphData = listGraphData[i]; if (graphData.InfoPrimary != null) { int step = i - totalSteps; int width = lineWidth; Color color; if (step == 0) { color = ChromGraphItem.ColorSelected; width++; } else if (nodeGroup.HasLibInfo) color = COLORS_LIBRARY[iColor % COLORS_LIBRARY.Length]; else color = COLORS_LIBRARY[iColor % COLORS_LIBRARY.Length]; // color = COLORS_HEURISTIC[iColor % COLORS_HEURISTIC.Length]; TransitionChromInfo tranPeakInfoGraph = null; if (bestPeakData == i) tranPeakInfoGraph = tranPeakInfo; var graphItem = new ChromGraphItem(nodeGroup, null, graphData.InfoPrimary, tranPeakInfoGraph, timeRegressionFunction, GetAnnotationFlags(i, maxPeakData, maxPeakHeights), null, 0, false, false, step, color, fontSize, width); _graphHelper.AddChromatogram(PaneKey.PRECURSORS, graphItem); } iColor++; } }
private ScaledRetentionTime FindBestPeakBoundary(PointF pt, out GraphPane graphPane, out ChromGraphItem graphItem) { double deltaBest = double.MaxValue; ScaledRetentionTime timeBest = ScaledRetentionTime.ZERO; graphItem = null; ChromGraphItem graphItemBest = null; graphPane = GraphPaneFromPoint(pt); if (null != graphPane) { double time, yTemp; graphPane.ReverseTransform(pt, out time, out yTemp); foreach (var graphItemNext in GetGraphItems(graphPane)) { var transitionChromInfo = graphItemNext.TransitionChromInfo; if (transitionChromInfo == null) { continue; } var timeMatch = graphItemNext.GetNearestBestPeakBoundary(time); if (!timeMatch.IsZero) { double delta = Math.Abs(time - timeMatch.DisplayTime); if (delta < deltaBest) { deltaBest = delta; timeBest = timeMatch; graphItemBest = graphItemNext; } } } // Only match if the best time is close enough in absolute pixels if (graphItemBest != null && Math.Abs(pt.X - graphPane.XAxis.Scale.Transform(timeBest.DisplayTime)) > 3) graphItemBest = null; graphItem = graphItemBest; } if (graphItem == null) { return ScaledRetentionTime.ZERO; } return timeBest; }
private void DisplayTransitions(IRegressionFunction timeRegressionFunction, TransitionDocNode nodeTranSelected, ChromatogramSet chromatograms, float mzMatchTolerance, TransitionGroupDocNode nodeGroup, ChromatogramGroupInfo chromGroupInfo, PaneKey graphPaneKey, DisplayTypeChrom displayType, ref double bestStartTime, ref double bestEndTime) { var fileId = chromatograms.FindFile(chromGroupInfo); // Get points for all transitions, and pick maximum peaks. ChromatogramInfo[] arrayChromInfo; var displayTrans = GetDisplayTransitions(nodeGroup, displayType).ToArray(); int numTrans = displayTrans.Length; int numSteps = 0; bool allowEmpty = false; if (IsSingleTransitionDisplay && nodeTranSelected != null) { if (!displayTrans.Contains(nodeTranSelected)) { arrayChromInfo = new ChromatogramInfo[0]; displayTrans = new TransitionDocNode[0]; numTrans = 0; } else { arrayChromInfo = chromGroupInfo.GetAllTransitionInfo((float) nodeTranSelected.Mz, mzMatchTolerance, chromatograms.OptimizationFunction); if (chromatograms.OptimizationFunction != null) { // Make sure the number of steps matches what will show up in the summary // graphs, or the colors won't match up. int numStepsExpected = chromatograms.OptimizationFunction.StepCount*2 + 1; if (arrayChromInfo.Length != numStepsExpected) { arrayChromInfo = ResizeArrayChromInfo(arrayChromInfo, numStepsExpected); allowEmpty = true; } } numTrans = arrayChromInfo.Length; displayTrans = new TransitionDocNode[numTrans]; for (int i = 0; i < numTrans; i++) displayTrans[i] = nodeTranSelected; } numSteps = numTrans/2; } else { arrayChromInfo = new ChromatogramInfo[numTrans]; for (int i = 0; i < numTrans; i++) { var nodeTran = displayTrans[i]; // Get chromatogram info for this transition arrayChromInfo[i] = chromGroupInfo.GetTransitionInfo((float) nodeTran.Mz, mzMatchTolerance); } } int bestPeakTran = -1; TransitionChromInfo tranPeakInfo = null; float maxPeakHeight = float.MinValue; int numPeaks = chromGroupInfo.NumPeaks; var maxPeakTrans = new int[numPeaks]; var maxPeakHeights = new float[numPeaks]; for (int i = 0; i < numPeaks; i++) maxPeakHeights[i] = float.MinValue; var transform = Transform; // Prepare arrays of values for library dot-product double[] expectedIntensities = null; double[][] peakAreas = null; bool isShowingMs = displayTrans.Any(nodeTran => nodeTran.IsMs1); bool isShowingMsMs = displayTrans.Any(nodeTran => !nodeTran.IsMs1); bool isFullScanMs = DocumentUI.Settings.TransitionSettings.FullScan.IsEnabledMs && isShowingMs; if ((isFullScanMs && !isShowingMsMs && nodeGroup.HasIsotopeDist) || (!isFullScanMs && nodeGroup.HasLibInfo)) { expectedIntensities = new double[numTrans]; peakAreas = new double[numPeaks][]; for (int i = 0; i < numPeaks; i++) peakAreas[i] = new double[numTrans]; } // Find the transition with the maximum peak height for the best peak for (int i = 0; i < numTrans; i++) { var nodeTran = displayTrans[i]; int step = (numSteps > 0 ? i - numSteps : 0); var transitionChromInfo = GetTransitionChromInfo(nodeTran, _chromIndex, fileId, step); if (transitionChromInfo == null) continue; if (maxPeakHeight < transitionChromInfo.Height) { maxPeakHeight = transitionChromInfo.Height; bestPeakTran = i; tranPeakInfo = transitionChromInfo; } AddBestPeakTimes(transitionChromInfo, ref bestStartTime, ref bestEndTime); } for (int i = 0; i < numTrans; i++) { var nodeTran = displayTrans[i]; // Store library intensities for dot-product if (expectedIntensities != null) { if (isFullScanMs) expectedIntensities[i] = nodeTran.HasDistInfo ? nodeTran.IsotopeDistInfo.Proportion : 0; else expectedIntensities[i] = nodeTran.HasLibInfo ? nodeTran.LibInfo.Intensity : 0; } var info = arrayChromInfo[i]; if (info == null) continue; // Apply any active transform info.Transform(transform); for (int j = 0; j < numPeaks; j++) { var peak = info.GetPeak(j); // Exclude any peaks between the boundaries of the chosen peak. if (IntersectPeaks(peak, tranPeakInfo)) continue; // Store peak intensity for dot-product if (peakAreas != null) peakAreas[j][i] = peak.Area; // Keep track of which transition has the max height for each peak if (maxPeakHeights[j] < peak.Height) { maxPeakHeights[j] = peak.Height; maxPeakTrans[j] = i; } } } // Calculate library dot-products, if possible double[] dotProducts = null; double bestProduct = 0; int minProductTrans = isFullScanMs ? TransitionGroupDocNode.MIN_DOT_PRODUCT_MS1_TRANSITIONS : TransitionGroupDocNode.MIN_DOT_PRODUCT_TRANSITIONS; if (peakAreas != null && numTrans >= minProductTrans) { var tranGroupChromInfo = GetTransitionGroupChromInfo(nodeGroup, fileId, _chromIndex); double? dotProduct = null; if (tranGroupChromInfo != null) { dotProduct = isFullScanMs ? tranGroupChromInfo.IsotopeDotProduct : tranGroupChromInfo.LibraryDotProduct; } if (dotProduct.HasValue) { bestProduct = dotProduct.Value; var statExpectedIntensities = new Statistics(expectedIntensities); for (int i = 0; i < peakAreas.Length; i++) { var statPeakAreas = new Statistics(peakAreas[i]); double dotProductCurrent = statPeakAreas.NormalizedContrastAngleSqrt(statExpectedIntensities); // Only show products that are greater than the best peak product, // and by enough to be a significant improvement. Also the library product // on the group node is stored as a float, which means the version // hear calculated as a double can be larger, but really represent // the same number. if (dotProductCurrent > bestProduct && dotProductCurrent > 0.5 && dotProductCurrent - bestProduct > 0.05) { if (dotProducts == null) dotProducts = new double[numPeaks]; dotProducts[i] = dotProductCurrent; } } } } // Create graph items int iColor = 0; int lineWidth = LineWidth; float fontSize = FontSize; // We want the product ion colors to stay the same whether they are displayed: // 1. In a single pane with the precursor ions (Transitions -> All) // 2. In a separate pane of the split graph (Transitions -> All AND Transitions -> Split Graph) // 3. In a single pane by themselves (Transition -> Products) // We will use an offset in the colors array for cases 2 and 3 so that we do not reuse the precursor ion colors. var nodeDisplayType = GetDisplayType(DocumentUI, nodeGroup); int colorOffset = 0; if(displayType == DisplayTypeChrom.products && (nodeDisplayType != DisplayTypeChrom.single || (nodeDisplayType == DisplayTypeChrom.single && chromatograms.OptimizationFunction == null))) { colorOffset = GetDisplayTransitions(nodeGroup, DisplayTypeChrom.precursors).Count(); } for (int i = 0; i < numTrans; i++) { var info = arrayChromInfo[i]; if (info == null && !allowEmpty) continue; var nodeTran = displayTrans[i]; int step = numSteps != 0 ? i - numSteps : 0; Color color; bool shade = false; int width = lineWidth; if ((numSteps == 0 && ReferenceEquals(nodeTran, nodeTranSelected) || (numSteps > 0 && step == 0))) { color = ChromGraphItem.ColorSelected; shade = true; width++; } else { color = COLORS_LIBRARY[(iColor + colorOffset) % COLORS_LIBRARY.Length]; } TransitionChromInfo tranPeakInfoGraph = null; if (bestPeakTran == i) tranPeakInfoGraph = tranPeakInfo; var scanName = nodeTran.FragmentIonName; if (nodeTran.Transition.Charge != 1) // Positive singly charged is uninteresting scanName += Transition.GetChargeIndicator(nodeTran.Transition.Charge); if (nodeTran.Transition.MassIndex != 0) scanName += Environment.NewLine + Transition.GetMassIndexText(nodeTran.Transition.MassIndex); var fullScanInfo = new FullScanInfo { ChromInfo = info, ScanName = scanName }; if (fullScanInfo.ChromInfo != null && fullScanInfo.ChromInfo.ExtractionWidth > 0) _enableTrackingDot = true; var graphItem = new ChromGraphItem(nodeGroup, nodeTran, info, tranPeakInfoGraph, timeRegressionFunction, GetAnnotationFlags(i, maxPeakTrans, maxPeakHeights), dotProducts, bestProduct, isFullScanMs, false, step, color, fontSize, width, fullScanInfo); _graphHelper.AddChromatogram(graphPaneKey, graphItem); if (shade) { ShadeGraph(tranPeakInfo,info,timeRegressionFunction,dotProducts,bestProduct,isFullScanMs,step,fontSize,width,fullScanInfo,graphPaneKey); } iColor++; } var graphPane = _graphHelper.GetGraphPane(graphPaneKey); if (graphPane == null) _enableTrackingDot = false; if (_enableTrackingDot) { graphPane.CurveList.Insert(FULLSCAN_TRACKING_INDEX, CreateScanPoint(Color.Black)); graphPane.CurveList.Insert(FULLSCAN_SELECTED_INDEX, CreateScanPoint(Color.Red)); } }
private void DisplayTotals(IRegressionFunction timeRegressionFunction, ChromatogramSet chromatograms, float mzMatchTolerance, int countLabelTypes, ref double bestStartTime, ref double bestEndTime) { // Construct and add graph items for all relevant transition groups. float fontSize = FontSize; int lineWidth = LineWidth; int iCharge = -1; int? charge = null; var chromGroupInfos = ChromGroupInfos; for (int i = 0; i < _nodeGroups.Length; i++) { var nodeGroup = _nodeGroups[i]; var chromGroupInfo = chromGroupInfos[i]; if (chromGroupInfo == null) continue; ChromFileInfoId fileId = chromatograms.FindFile(chromGroupInfo); // Collect the chromatogram info for the transition children // of this transition group. ChromatogramInfo infoPrimary = null; TransitionChromInfo tranPeakInfo = null; float maxPeakHeight = float.MinValue; var listChromInfo = new List<ChromatogramInfo>(); foreach (TransitionDocNode nodeTran in nodeGroup.Children) { var info = chromGroupInfo.GetTransitionInfo((float)nodeTran.Mz, mzMatchTolerance); if (info == null) continue; listChromInfo.Add(info); // Keep track of which chromatogram owns the tallest member of // the peak on the document tree. var transitionChromInfo = GetTransitionChromInfo(nodeTran, _chromIndex, fileId, 0); if (transitionChromInfo == null) continue; if (transitionChromInfo.Height > maxPeakHeight) { maxPeakHeight = transitionChromInfo.Height; tranPeakInfo = transitionChromInfo; infoPrimary = info; } // Adjust best peak window used to zoom the graph to the best peak AddBestPeakTimes(transitionChromInfo, ref bestStartTime, ref bestEndTime); } // If any transitions are present for this group, add a graph item to // the graph for it. if (listChromInfo.Count > 0) { if (infoPrimary == null) infoPrimary = listChromInfo[0]; // Sum the intensities of all transitions into the first chromatogram infoPrimary.SumIntensities(listChromInfo); // Apply any transform the user has chosen infoPrimary.Transform(Transform); int iColor = GetColorIndex(nodeGroup, countLabelTypes, ref charge, ref iCharge); Color color = COLORS_GROUPS[iColor % COLORS_GROUPS.Length]; bool[] annotateAll = new bool[infoPrimary.NumPeaks]; for (int j = 0; j < annotateAll.Length; j++) { var peak = infoPrimary.GetPeak(j); if (peak.IsForcedIntegration) continue; // Exclude any peaks between the boundaries of the chosen peak. if (tranPeakInfo != null && tranPeakInfo.StartRetentionTime < peak.RetentionTime && peak.RetentionTime < tranPeakInfo.EndRetentionTime) continue; annotateAll[j] = true; } var graphItem = new ChromGraphItem(nodeGroup, null, infoPrimary, tranPeakInfo, timeRegressionFunction, annotateAll, null, 0, false, false, 0, color, fontSize, lineWidth); var graphPaneKey = new PaneKey(nodeGroup); _graphHelper.AddChromatogram(graphPaneKey, graphItem); } } }
/// <summary> /// Display summed transitions for multiple selected peptides. /// </summary> private void DisplayPeptides(IRegressionFunction timeRegressionFunction, ChromatogramSet chromatograms, float mzMatchTolerance, int countLabelTypes, IList<PeptideDocNode> peptideDocNodes, ref double bestStartTime, ref double bestEndTime, out double leftPeakWidth, out double rightPeakWidth) { leftPeakWidth = 0; rightPeakWidth = 0; // Construct and add graph items for all relevant transition groups. float fontSize = FontSize; int lineWidth = LineWidth; var chromGroupInfos = ChromGroupInfos; var lookupChromGroupInfoIndex = new Dictionary<int, int>(_nodeGroups.Length); for (int i = 0; i < _nodeGroups.Length; i++) lookupChromGroupInfoIndex[_nodeGroups[i].Id.GlobalIndex] = i; // Generate a unique short identifier for each peptide. var peptideNames = new Tuple<string,bool>[peptideDocNodes.Count]; for (int i = 0; i < peptideDocNodes.Count; i++) peptideNames[i] = new Tuple<string,bool>(peptideDocNodes[i].RawTextId, peptideDocNodes[i].IsProteomic); var uniqueNames = new UniquePrefixGenerator(peptideNames, 3); var displayPeptides = new List<DisplayPeptide>(); for (int peptideIndex = 0; peptideIndex < peptideDocNodes.Count; peptideIndex++) { var peptideDocNode = peptideDocNodes[peptideIndex]; TransitionChromInfo bestPeakInfo = null; ChromatogramInfo sumInfo = null; float maxPeakHeight = float.MinValue; foreach (var precursor in peptideDocNode.TransitionGroups) { int indexInfo; if (!lookupChromGroupInfoIndex.TryGetValue(precursor.Id.GlobalIndex, out indexInfo)) continue; var chromGroupInfo = chromGroupInfos[indexInfo]; if (chromGroupInfo == null) continue; ChromFileInfoId fileId = chromatograms.FindFile(chromGroupInfo); foreach (var nodeTran in precursor.Transitions) { var info = chromGroupInfo.GetTransitionInfo((float)nodeTran.Mz, mzMatchTolerance); if (info == null) continue; if (sumInfo == null) sumInfo = info; else { float[] sumTimes; float[] sumIntensities; if (!AddTransitions.Add( info.Times, info.Intensities, sumInfo.Times, sumInfo.Intensities, out sumTimes, out sumIntensities)) continue; sumInfo = new ChromatogramInfo(sumTimes, sumIntensities); } // Keep track of which chromatogram owns the tallest member of // the peak on the document tree. var transitionChromInfo = GetTransitionChromInfo(nodeTran, _chromIndex, fileId, 0); if (transitionChromInfo == null) continue; if (transitionChromInfo.Height > maxPeakHeight) { maxPeakHeight = transitionChromInfo.Height; bestPeakInfo = transitionChromInfo; } } } if (sumInfo != null && bestPeakInfo != null) { displayPeptides.Add(new DisplayPeptide { PeptideIndex = peptideIndex, SumInfo = sumInfo, BestPeakInfo = bestPeakInfo }); } } // Order the peptides by height of best peak. displayPeptides = displayPeptides.OrderByDescending(e => e.BestPeakInfo.Height).ToList(); // Display only the top peptides. int lastPeptideIndex = Math.Min(MaxPeptidesDisplayed, displayPeptides.Count); var graphItems = new List<ChromGraphItem>(); for (int i = lastPeptideIndex-1; i >= 0; i--) // smallest peaks first for good z-ordering in graph { var bestPeakInfo = displayPeptides[i].BestPeakInfo; var sumInfo = displayPeptides[i].SumInfo; var peptideDocNode = peptideDocNodes[displayPeptides[i].PeptideIndex]; // Intersect best peak with summed transition. if (bestPeakInfo != null && sumInfo.Times.Length > 0) { float startRetentionTime = Math.Max(bestPeakInfo.StartRetentionTime, sumInfo.Times[0]); float endRetentionTime = Math.Min(bestPeakInfo.EndRetentionTime, sumInfo.Times[sumInfo.Times.Length - 1]); if (endRetentionTime > startRetentionTime) { if (bestStartTime > startRetentionTime) { bestStartTime = startRetentionTime; leftPeakWidth = endRetentionTime - startRetentionTime; } if (bestEndTime < endRetentionTime) { bestEndTime = endRetentionTime; rightPeakWidth = endRetentionTime - startRetentionTime; } bestPeakInfo = new TransitionChromInfo(startRetentionTime, endRetentionTime); } } // Get peptide graph color from SequenceTree. var peptideGraphInfo = _stateProvider.GetPeptideGraphInfo(peptideDocNode); Color color = peptideGraphInfo.Color; sumInfo.Transform(Transform); bool[] annotateAll = new bool[sumInfo.NumPeaks]; ChromGraphItem graphItem = new ChromGraphItem(null, null, sumInfo, bestPeakInfo, timeRegressionFunction, annotateAll, null, 0, false, false, 0, color, fontSize, lineWidth) { CurveAnnotation = uniqueNames.GetUniquePrefix(peptideDocNode.RawTextId, peptideDocNode.IsProteomic), IdPath = _groupPaths[displayPeptides[i].PeptideIndex], GraphInfo = peptideGraphInfo }; if (peptideGraphInfo.IsSelected) graphItems.Insert(0, graphItem); else graphItems.Add(graphItem); } foreach (var graphItem in graphItems) { var curveItem = _graphHelper.AddChromatogram(new PaneKey(), graphItem); // Make the fill color under the curve more opaque if the curve is selected. var fillAlpha = graphItem.GraphInfo.IsSelected ? 60 : 15; ((LineItem)curveItem).Line.Fill = new Fill(Color.FromArgb(fillAlpha, graphItem.GraphInfo.Color)); } }
private ScaledRetentionTime GetRetentionTimeOfZeroOptStep(ChromGraphItem graphItem, ScaledRetentionTime peakTime) { if (graphItem.OptimizationStep == 0) { return peakTime; } ChromGraphItem mainGraphItem = GraphItems.FirstOrDefault(item => 0 == item.OptimizationStep && ReferenceEquals(item.TransitionNode, graphItem.TransitionNode) && ReferenceEquals(item.TransitionGroupNode, graphItem.TransitionGroupNode)); if (mainGraphItem == null) { return ScaledRetentionTime.ZERO; } int iPeak = graphItem.Chromatogram.IndexOfPeak(peakTime.MeasuredTime); ChromPeak mainPeak = mainGraphItem.Chromatogram.GetPeak(iPeak); return mainGraphItem.ScaleRetentionTime(mainPeak.RetentionTime); }
public FailedChromGraphItem(TransitionGroupDocNode nodeGroup, Exception x) : base(string.Format(Resources.FailedChromGraphItem_FailedChromGraphItem__0__load_failed__1__, ChromGraphItem.GetTitle(nodeGroup), x.Message)) { }
private void SetRetentionTimeIdIndicators(ChromGraphItem chromGraphPrimary, SrmSettings settings, IEnumerable<TransitionGroupDocNode> nodeGroups, string lookupSequence, ExplicitMods lookupMods) { // Set any MS/MS IDs on the first graph item also if (settings.TransitionSettings.FullScan.IsEnabled && settings.PeptideSettings.Libraries.IsLoaded) { var transitionGroups = nodeGroups.Select(nodeGroup => nodeGroup.TransitionGroup).ToArray(); if (Settings.Default.ShowPeptideIdTimes) { var listTimes = new List<double>(); foreach (var group in transitionGroups) { IsotopeLabelType labelType; double[] retentionTimes; if (settings.TryGetRetentionTimes(lookupSequence, group.PrecursorCharge, lookupMods, FilePath, out labelType, out retentionTimes)) { listTimes.AddRange(retentionTimes); var selectedSpectrum = _stateProvider.SelectedSpectrum; if (selectedSpectrum != null && Equals(FilePath, selectedSpectrum.FilePath)) { chromGraphPrimary.SelectedRetentionMsMs = selectedSpectrum.RetentionTime; } } } if (listTimes.Count > 0) chromGraphPrimary.RetentionMsMs = listTimes.ToArray(); } if (Settings.Default.ShowAlignedPeptideIdTimes) { var listTimes = new List<double>(settings.GetAlignedRetentionTimes(FilePath, lookupSequence, lookupMods)); if (listTimes.Count > 0) { var sortedTimes = listTimes.Distinct().ToArray(); Array.Sort(sortedTimes); chromGraphPrimary.AlignedRetentionMsMs = sortedTimes; } } if (Settings.Default.ShowUnalignedPeptideIdTimes) { var listTimes = new List<double>(settings.GetRetentionTimesNotAlignedTo(FilePath, lookupSequence, lookupMods)); if (listTimes.Count > 0) { var sortedTimes = listTimes.Distinct().ToArray(); Array.Sort(sortedTimes); chromGraphPrimary.UnalignedRetentionMsMs = sortedTimes; } } } }
public void UpdateUI(bool selectionChanged = true) { // Only worry about updates, if the graph is visible // And make sure it is not disposed, since rendering happens on a timer if (!Visible || IsDisposed) { return; } // Clear existing data from the graph pane var graphPane = (MSGraphPane)graphControl.MasterPane[0]; graphPane.CurveList.Clear(); graphPane.GraphObjList.Clear(); GraphItem = null; GraphHelper.FormatGraphPane(graphControl.GraphPane); GraphHelper.FormatFontSize(graphControl.GraphPane, Settings.Default.SpectrumFontSize); // Try to find a tree node with spectral library info associated // with the current selection. var nodeTree = _stateProvider.SelectedNode as SrmTreeNode; var nodeGroupTree = nodeTree as TransitionGroupTreeNode; var nodeTranTree = nodeTree as TransitionTreeNode; if (nodeTranTree != null) { nodeGroupTree = nodeTranTree.Parent as TransitionGroupTreeNode; } var nodeGroup = (nodeGroupTree != null ? nodeGroupTree.DocNode : null); PeptideTreeNode nodePepTree; if (nodeGroup == null) { nodePepTree = nodeTree as PeptideTreeNode; if (nodePepTree != null) { var listInfoGroups = GetLibraryInfoChargeGroups(nodePepTree); if (listInfoGroups.Length == 1) { nodeGroup = listInfoGroups[0]; } else if (listInfoGroups.Length > 1) { _nodeGroup = null; toolBar.Visible = false; _graphHelper.SetErrorGraphItem(new NoDataMSGraphItem( Resources.GraphSpectrum_UpdateUI_Multiple_charge_states_with_library_spectra)); return; } } } else { nodePepTree = nodeGroupTree.Parent as PeptideTreeNode; } // Check for appropriate spectrum to load SrmSettings settings = DocumentUI.Settings; PeptideLibraries libraries = settings.PeptideSettings.Libraries; bool available = false; if (nodeGroup == null || (!nodeGroup.HasLibInfo && !libraries.HasMidasLibrary)) { _spectra = null; } else { TransitionGroup group = nodeGroup.TransitionGroup; TransitionDocNode transition = (nodeTranTree == null ? null : nodeTranTree.DocNode); var lookupSequence = group.Peptide.Target;// Sequence or custom ion id ExplicitMods lookupMods = null; if (nodePepTree != null) { lookupSequence = nodePepTree.DocNode.SourceUnmodifiedTarget; lookupMods = nodePepTree.DocNode.SourceExplicitMods; } try { // Try to load a list of spectra matching the criteria for // the current node group. if (libraries.HasLibraries && libraries.IsLoaded) { if (NodeGroupChanged(nodeGroup)) { try { UpdateSpectra(nodeGroup, lookupSequence, lookupMods); UpdateToolbar(); } catch (Exception) { _spectra = null; UpdateToolbar(); throw; } _nodeGroup = nodeGroup; if (settings.TransitionSettings.Instrument.IsDynamicMin) { ZoomSpectrumToSettings(); } } var spectrum = SelectedSpectrum; if (spectrum != null) { IsotopeLabelType typeInfo = spectrum.LabelType; var types = _stateProvider.ShowIonTypes(group.IsProteomic); var adducts = (group.IsProteomic ? Transition.DEFAULT_PEPTIDE_LIBRARY_CHARGES : nodeGroup.InUseAdducts).ToArray(); var charges = _stateProvider.ShowIonCharges(adducts); var rankTypes = group.IsProteomic ? settings.TransitionSettings.Filter.PeptideIonTypes : settings.TransitionSettings.Filter.SmallMoleculeIonTypes; var rankAdducts = group.IsProteomic ? settings.TransitionSettings.Filter.PeptideProductCharges : settings.TransitionSettings.Filter.SmallMoleculeFragmentAdducts; var rankCharges = Adduct.OrderedAbsoluteChargeValues(rankAdducts); // Make sure the types and charges in the settings are at the head // of these lists to give them top priority, and get rankings correct. int i = 0; foreach (IonType type in rankTypes) { if (types.Remove(type)) { types.Insert(i++, type); } } i = 0; var showAdducts = new List <Adduct>(); foreach (var charge in rankCharges) { if (charges.Remove(charge)) { charges.Insert(i++, charge); } // NB for all adducts we just look at abs value of charge // CONSIDER(bspratt): we may want finer per-adduct control for small molecule use showAdducts.AddRange(adducts.Where(a => charge == Math.Abs(a.AdductCharge))); } showAdducts.AddRange(adducts.Where(a => charges.Contains(Math.Abs(a.AdductCharge)) && !showAdducts.Contains(a))); SpectrumPeaksInfo spectrumInfo = spectrum.SpectrumPeaksInfo; var spectrumInfoR = new LibraryRankedSpectrumInfo(spectrumInfo, typeInfo, nodeGroup, settings, lookupSequence, lookupMods, showAdducts, types, rankAdducts, rankTypes); GraphItem = new SpectrumGraphItem(nodeGroup, transition, spectrumInfoR, spectrum.LibName) { ShowTypes = types, ShowCharges = charges, ShowRanks = Settings.Default.ShowRanks, ShowMz = Settings.Default.ShowIonMz, ShowObservedMz = Settings.Default.ShowObservedMz, ShowDuplicates = Settings.Default.ShowDuplicateIons, FontSize = Settings.Default.SpectrumFontSize, LineWidth = Settings.Default.SpectrumLineWidth }; LibraryChromGroup chromatogramData = null; if (Settings.Default.ShowLibraryChromatograms) { chromatogramData = spectrum.LoadChromatogramData(); } if (null == chromatogramData) { _graphHelper.ResetForSpectrum(new[] { nodeGroup.TransitionGroup }); _graphHelper.AddSpectrum(GraphItem); _graphHelper.ZoomSpectrumToSettings(DocumentUI, nodeGroup); } else { _graphHelper.ResetForChromatograms(new[] { nodeGroup.TransitionGroup }); var displayType = GraphChromatogram.GetDisplayType(DocumentUI, nodeGroup); IList <TransitionDocNode> displayTransitions = GraphChromatogram.GetDisplayTransitions(nodeGroup, displayType).ToArray(); int numTrans = displayTransitions.Count; var allChromDatas = chromatogramData.ChromDatas.Where( chromData => DisplayTypeMatches(chromData, displayType)).ToList(); var chromDatas = new List <LibraryChromGroup.ChromData>(); for (int iTran = 0; iTran < numTrans; iTran++) { var displayTransition = displayTransitions[iTran]; var indexMatch = allChromDatas.IndexOf(chromData => IonMatches(displayTransition.Transition, chromData)); if (indexMatch >= 0) { chromDatas.Add(allChromDatas[indexMatch]); allChromDatas.RemoveAt(indexMatch); } else { chromDatas.Add(null); } } allChromDatas.Sort((chromData1, chromData2) => chromData1.Mz.CompareTo(chromData2.Mz)); chromDatas.AddRange(allChromDatas); double maxHeight = chromDatas.Max(chromData => null == chromData ? double.MinValue : chromData.Height); int iChromDataPrimary = chromDatas.IndexOf(chromData => null != chromData && maxHeight == chromData.Height); int colorOffset = displayType == DisplayTypeChrom.products ? GraphChromatogram.GetDisplayTransitions(nodeGroup, DisplayTypeChrom. precursors).Count() : 0; for (int iChromData = 0; iChromData < chromDatas.Count; iChromData++) { var chromData = chromDatas[iChromData]; if (chromData == null) { continue; } string label; var pointAnnotation = GraphItem.AnnotatePoint(new PointPair(chromData.Mz, 1.0)); if (null != pointAnnotation) { label = pointAnnotation.Label; } else { label = chromData.Mz.ToString(@"0.####"); } TransitionDocNode matchingTransition; Color color; if (iChromData < numTrans) { matchingTransition = displayTransitions[iChromData]; color = GraphChromatogram.COLORS_LIBRARY[ (iChromData + colorOffset) % GraphChromatogram.COLORS_LIBRARY.Count]; } else { matchingTransition = null; color = GraphChromatogram.COLORS_GROUPS[ iChromData % GraphChromatogram.COLORS_GROUPS.Count]; } TransitionChromInfo tranPeakInfo; ChromatogramInfo chromatogramInfo; MakeChromatogramInfo(nodeGroup.PrecursorMz, chromatogramData, chromData, out chromatogramInfo, out tranPeakInfo); var graphItem = new ChromGraphItem(nodeGroup, matchingTransition, chromatogramInfo, iChromData == iChromDataPrimary ? tranPeakInfo : null, null, new[] { iChromData == iChromDataPrimary }, null, 0, false, false, null, 0, color, Settings.Default.ChromatogramFontSize, 1); LineItem curve = (LineItem)_graphHelper.AddChromatogram(PaneKey.DEFAULT, graphItem); if (matchingTransition == null) { curve.Label.Text = label; } curve.Line.Width = Settings.Default.ChromatogramLineWidth; if (null != transition) { if (IonMatches(transition.Transition, chromData)) { color = ChromGraphItem.ColorSelected; } } curve.Color = color; } graphPane.Title.IsVisible = false; graphPane.Legend.IsVisible = true; _graphHelper.FinishedAddingChromatograms(chromatogramData.StartTime, chromatogramData.EndTime, false); graphControl.Refresh(); } graphControl.IsEnableVPan = graphControl.IsEnableVZoom = !Settings.Default.LockYAxis; available = true; } } } catch (Exception) { _graphHelper.SetErrorGraphItem(new NoDataMSGraphItem( Resources.GraphSpectrum_UpdateUI_Failure_loading_spectrum__Library_may_be_corrupted)); return; } } // Show unavailable message, if no spectrum loaded if (!available) { UpdateToolbar(); _nodeGroup = null; _graphHelper.SetErrorGraphItem(new UnavailableMSGraphItem()); } }
private void SetRetentionTimeIndicators(ChromGraphItem chromGraphPrimary, SrmSettings settings, ChromatogramSet chromatograms, PeptideDocNode[] nodePeps, TransitionGroupDocNode[] nodeGroups, string lookupSequence, ExplicitMods lookupMods) { // FUTURE: Fix this when we can predict retention time for small molecules if (lookupSequence == null) { return; } SetRetentionTimePredictedIndicator(chromGraphPrimary, settings, chromatograms, nodePeps, lookupSequence, lookupMods); SetRetentionTimeIdIndicators(chromGraphPrimary, settings, nodeGroups, lookupSequence, lookupMods); }
private void ShadeGraph(TransitionChromInfo tranPeakInfo, ChromatogramInfo info, IRegressionFunction timeRegressionFunction, double[] dotProducts, double bestProduct, bool isFullScanMs, int step, float fontSize, int width, FullScanInfo fullScanInfo, PaneKey graphPaneKey) { if (tranPeakInfo == null) return; // Nothing to shade float end = tranPeakInfo.EndRetentionTime; float start = tranPeakInfo.StartRetentionTime; double[] allTimes; double[] allIntensities; info.AsArrays(out allTimes, out allIntensities); var peakTimes = new List<float>(); var peakIntensities = new List<float>(); for (int j = 0; j < allTimes.Length; j++) { if (start > allTimes[j]) continue; if (end < allTimes[j]) break; peakTimes.Add((float) allTimes[j]); peakIntensities.Add((float) allIntensities[j]); } if (peakIntensities.Count == 0) return; // Add peak area shading float[] peakTimesArray = peakTimes.ToArray(); info = new ChromatogramInfo(peakTimesArray, peakIntensities.ToArray()); var peakShadeItem = new ChromGraphItem(null, null, info, null, timeRegressionFunction, new bool[info.NumPeaks], dotProducts, bestProduct, isFullScanMs, false, step, ChromGraphItem.ColorSelected, fontSize, width, fullScanInfo); var peakShadeCurveItem = _graphHelper.AddChromatogram(graphPaneKey, peakShadeItem); peakShadeCurveItem.Label.IsVisible = false; var lineItem = peakShadeCurveItem as LineItem; if (lineItem != null) { const int fillAlpha = 50; lineItem.Line.Fill = new Fill(Color.FromArgb(fillAlpha, lineItem.Color)); } // Add peak background shading float min = Math.Min(peakIntensities.First(), peakIntensities.Last()); info = new ChromatogramInfo(peakTimesArray, peakIntensities.Select(intensity => Math.Min(intensity, min)).ToArray()); var backgroundShadeItem = new ChromGraphItem(null, null, info, null, timeRegressionFunction, new bool[info.NumPeaks], dotProducts, bestProduct, isFullScanMs, false, step, Color.DarkGray, fontSize, 2, fullScanInfo); var backgroundShadeCurveItem = _graphHelper.AddChromatogram(graphPaneKey, backgroundShadeItem); backgroundShadeCurveItem.Label.IsVisible = false; var lineItem2 = backgroundShadeCurveItem as LineItem; if (lineItem2 != null) { const int fillAlpha = 70; lineItem2.Line.Fill = new Fill(Color.FromArgb(fillAlpha, Color.Black)); } }
public CurveItem AddChromatogram(PaneKey paneKey, ChromGraphItem chromGraphItem) { var chromDisplayState = (ChromDisplayState) _displayState; chromDisplayState.ChromGraphItems.Add(new KeyValuePair<PaneKey, ChromGraphItem>(paneKey, chromGraphItem)); return GraphControl.AddGraphItem(chromDisplayState.GetOrCreateGraphPane(GraphControl, paneKey), chromGraphItem, false); }