public RTGraphData(SrmDocument document, TransitionGroupDocNode selectedGroup, PeptideGroupDocNode selectedProtein, int?result, DisplayTypeChrom displayType, GraphValues.IRetentionTimeTransformOp retentionTimeTransformOp ) : base(document, selectedGroup, selectedProtein, result, displayType, retentionTimeTransformOp, PaneKey.DEFAULT) { }
// ReSharper disable PossibleMultipleEnumeration protected GraphData(SrmDocument document, TransitionGroupDocNode selectedGroup, PeptideGroupDocNode selectedProtein, int?iResult, DisplayTypeChrom displayType, GraphValues.IRetentionTimeTransformOp retentionTimeTransformOp, PaneKey paneKey) { RetentionTimeTransformOp = retentionTimeTransformOp; // Determine the shortest possible unique ID for each peptide or molecule var sequences = new List <Tuple <string, bool> >(); foreach (var nodePep in document.Molecules) { sequences.Add(new Tuple <string, bool>(nodePep.ModifiedTarget.DisplayName, nodePep.IsProteomic)); } var uniquePrefixGenerator = new UniquePrefixGenerator(sequences, 3); int pointListCount = 0; var dictTypeToSet = new Dictionary <IsotopeLabelType, int>(); bool onePointPerPeptide = PeptideOrder == SummaryPeptideOrder.document && null != paneKey.IsotopeLabelType; // Figure out how many point lists to create bool displayTotals = (displayType == DisplayTypeChrom.total); if (displayTotals) { foreach (var nodeGroup in document.MoleculeTransitionGroups) { if (!paneKey.IncludesTransitionGroup(nodeGroup)) { continue; } IsotopeLabelType labelType = nodeGroup.TransitionGroup.LabelType; if (!dictTypeToSet.ContainsKey(labelType)) { dictTypeToSet.Add(labelType, pointListCount++); } } } else { foreach (var nodeGroup in document.MoleculeTransitionGroups) { if (!paneKey.IncludesTransitionGroup(nodeGroup)) { continue; } pointListCount = Math.Max(pointListCount, GraphChromatogram.GetDisplayTransitions(nodeGroup, displayType).Count()); } } // Build the list of points to show. var listPoints = new List <GraphPointData>(); foreach (PeptideGroupDocNode nodeGroupPep in document.MoleculeGroups) { if (AreaGraphController.AreaScope == AreaScope.protein) { if (!ReferenceEquals(nodeGroupPep, selectedProtein)) { continue; } } foreach (PeptideDocNode nodePep in nodeGroupPep.Children) { bool addBlankPoint = onePointPerPeptide && !nodePep.TransitionGroups.Any(paneKey.IncludesTransitionGroup); foreach (TransitionGroupDocNode nodeGroup in nodePep.Children) { var path = new IdentityPath(nodeGroupPep.PeptideGroup, nodePep.Peptide, nodeGroup.TransitionGroup); var graphPointData = new GraphPointData(nodePep, nodeGroup, path); if (addBlankPoint || paneKey.IncludesTransitionGroup(nodeGroup)) { listPoints.Add(graphPointData); } if (addBlankPoint) { break; } } } } // Sort into correct order var peptideOrder = PeptideOrder; if (peptideOrder == SummaryPeptideOrder.time) { if (displayTotals) { listPoints.Sort(ComparePeptideTimes); } else { listPoints.Sort(CompareGroupTimes); } } else if (peptideOrder == SummaryPeptideOrder.area) { listPoints.Sort(CompareGroupAreas); } else if (peptideOrder == SummaryPeptideOrder.mass_error) { listPoints.Sort(CompareGroupMassErrors); } // Init calculated values var pointPairLists = new List <PointPairList>(); var labels = new List <string>(); var xscalePaths = new List <IdentityPath>(); double maxY = 0; double minY = double.MaxValue; int selectedIndex = -1; for (int i = 0; i < pointListCount; i++) { pointPairLists.Add(new PointPairList()); } // Calculate lists and values PeptideDocNode nodePepCurrent = null; int chargeCount = 0; var chargeCurrent = Adduct.EMPTY; foreach (var dataPoint in listPoints) { var nodePep = dataPoint.NodePep; var nodeGroup = dataPoint.NodeGroup; if (!ReferenceEquals(nodePep, nodePepCurrent)) { nodePepCurrent = nodePep; chargeCount = GetChargeCount(nodePep); chargeCurrent = Adduct.EMPTY; } bool addLabel = !displayTotals; if (displayTotals && !Equals(nodeGroup.TransitionGroup.PrecursorAdduct, chargeCurrent)) { LevelPointPairLists(pointPairLists); addLabel = true; } chargeCurrent = nodeGroup.TransitionGroup.PrecursorAdduct; var transitionGroup = nodeGroup.TransitionGroup; int iGroup = labels.Count; if (addLabel) { string label = uniquePrefixGenerator.GetUniquePrefix(nodePep.ModifiedTarget.DisplayName, nodePep.IsProteomic) + (chargeCount > 1 ? Transition.GetChargeIndicator(transitionGroup.PrecursorAdduct) : string.Empty); if (!displayTotals && null == paneKey.IsotopeLabelType) { label += transitionGroup.LabelTypeText; } if (peptideOrder == SummaryPeptideOrder.time) { label += string.Format(@" ({0:F01})", displayTotals ? dataPoint.TimePepCharge : dataPoint.TimeGroup); } labels.Add(label); xscalePaths.Add(dataPoint.IdentityPath); } double groupMaxY = 0; double groupMinY = double.MaxValue; // ReSharper disable DoNotCallOverridableMethodsInConstructor int?resultIndex = iResult.HasValue && iResult >= 0 ? iResult : null; if (RTLinearRegressionGraphPane.ShowReplicate == ReplicateDisplay.best && nodePep != null) { resultIndex = null; int iBest = nodePep.BestResult; if (iBest != -1) { resultIndex = iBest; } } if (displayTotals) { var labelType = nodeGroup.TransitionGroup.LabelType; if (dictTypeToSet.ContainsKey(labelType)) { if (paneKey.IncludesTransitionGroup(nodeGroup)) { pointPairLists[dictTypeToSet[labelType]].Add(CreatePointPair(iGroup, nodeGroup, ref groupMaxY, ref groupMinY, resultIndex)); } else { pointPairLists[dictTypeToSet[labelType]].Add(PointPairMissing(iGroup)); } } } else { if (paneKey.IncludesTransitionGroup(nodeGroup)) { var nodeTrans = GraphChromatogram.GetDisplayTransitions(nodeGroup, displayType).ToArray(); for (int i = 0; i < pointListCount; i++) { var pointPairList = pointPairLists[i]; pointPairList.Add(i >= nodeTrans.Length ? CreatePointPairMissing(iGroup) : CreatePointPair(iGroup, nodeTrans[i], ref groupMaxY, ref groupMinY, resultIndex)); } } else { for (int i = 0; i < pointListCount; i++) { pointPairLists[i].Add(CreatePointPairMissing(iGroup)); } } } // ReSharper restore DoNotCallOverridableMethodsInConstructor // Save the selected index and its y extent if (ReferenceEquals(selectedGroup, nodeGroup)) { selectedIndex = labels.Count - 1; SelectedMaxY = groupMaxY; SelectedMinY = groupMinY; } // If multiple groups in the selection, make sure y extent is max of them else if (selectedIndex == labels.Count - 1) { SelectedMaxY = Math.Max(groupMaxY, SelectedMaxY); SelectedMinY = Math.Min(groupMinY, SelectedMinY); } maxY = Math.Max(maxY, groupMaxY); minY = Math.Min(minY, groupMinY); } PointPairLists = pointPairLists; Labels = labels.ToArray(); XScalePaths = xscalePaths.ToArray(); SelectedIndex = selectedIndex; MaxY = maxY; if (minY != double.MaxValue) { MinY = minY; } }