private bool TryGetSelectedPeptide(out PeptideGroupDocNode peptideGroup, out PeptideDocNode peptide) { peptide = null; peptideGroup = null; SequenceTree sequenceTree = _skylineWindow.SequenceTree; if (null != sequenceTree) { PeptideTreeNode peptideTreeNode = sequenceTree.GetNodeOfType<PeptideTreeNode>(); if (null != peptideTreeNode) { peptide = peptideTreeNode.DocNode; } PeptideGroupTreeNode peptideGroupTreeNode = sequenceTree.GetNodeOfType<PeptideGroupTreeNode>(); if (null != peptideGroupTreeNode) { peptideGroup = peptideGroupTreeNode.DocNode; } } return peptide != null; }
// Support multiple selection (though using peptide settings is more efficient way to do this filtering) public static List <PeptideGroupTreeNode> PeptideSelection(SequenceTree sequenceTree) { var peptideGroupTreeNodes = new List <PeptideGroupTreeNode>(); foreach (var node in sequenceTree.SelectedNodes) { PeptideGroupTreeNode peptideGroupTreeNode = null; var treeNode = node as SrmTreeNode; if (treeNode != null) { peptideGroupTreeNode = treeNode.GetNodeOfType <PeptideGroupTreeNode>(); } if (peptideGroupTreeNode != null && peptideGroupTreeNode.ChildDocNodes.Cast <PeptideDocNode>().Any(n => n.IsProteomic)) { peptideGroupTreeNodes.Add(peptideGroupTreeNode); } } return(peptideGroupTreeNodes); }
// Support multiple selection (though using peptide settings is more efficient way to do this filtering) public static List <PeptideGroupTreeNode> PeptideSelection(SequenceTree sequenceTree) { HashSet <PeptideGroupTreeNode> treeNodeSet = new HashSet <PeptideGroupTreeNode>(); var peptideGroupTreeNodes = new List <PeptideGroupTreeNode>(); foreach (var node in sequenceTree.SelectedNodes) { PeptideGroupTreeNode peptideGroupTreeNode = null; var treeNode = node as SrmTreeNode; if (treeNode != null) { peptideGroupTreeNode = treeNode.GetNodeOfType <PeptideGroupTreeNode>(); } if (peptideGroupTreeNode == null || !treeNodeSet.Add(peptideGroupTreeNode)) { continue; } if (peptideGroupTreeNode.DocNode.Peptides.Any()) { peptideGroupTreeNodes.Add(peptideGroupTreeNode); } } return(peptideGroupTreeNodes); }
public override string GetDisplayText(DisplaySettings settings) { return(PeptideGroupTreeNode.ProteinModalDisplayText(this)); }
private void DisplayCalibrationCurve() { CalibrationCurveOptions options = Settings.Default.CalibrationCurveOptions; zedGraphControl.GraphPane.YAxis.Type = zedGraphControl.GraphPane.XAxis.Type = options.LogPlot ? AxisType.Log : AxisType.Linear; zedGraphControl.GraphPane.Legend.IsVisible = options.ShowLegend; _scatterPlots = null; CalibrationCurve = null; SrmDocument document = DocumentUiContainer.DocumentUI; if (!document.Settings.HasResults) { zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_No_results_available; return; } PeptideDocNode peptide = null; PeptideGroupDocNode peptideGroup = null; SequenceTree sequenceTree = _skylineWindow.SequenceTree; if (null != sequenceTree) { PeptideTreeNode peptideTreeNode = sequenceTree.GetNodeOfType <PeptideTreeNode>(); if (null != peptideTreeNode) { peptide = peptideTreeNode.DocNode; } PeptideGroupTreeNode peptideGroupTreeNode = sequenceTree.GetNodeOfType <PeptideGroupTreeNode>(); if (null != peptideGroupTreeNode) { peptideGroup = peptideGroupTreeNode.DocNode; } } if (null == peptide) { zedGraphControl.GraphPane.Title.Text = QuantificationStrings .CalibrationForm_DisplayCalibrationCurve_Select_a_peptide_to_see_its_calibration_curve; return; } PeptideQuantifier peptideQuantifier = PeptideQuantifier.GetPeptideQuantifier(document.Settings, peptideGroup, peptide); CalibrationCurveFitter curveFitter = new CalibrationCurveFitter(peptideQuantifier, document.Settings); if (peptideQuantifier.QuantificationSettings.RegressionFit == RegressionFit.NONE) { if (string.IsNullOrEmpty( peptideQuantifier.QuantificationSettings.NormalizationMethod.IsotopeLabelTypeName)) { zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_Use_the_Quantification_tab_on_the_Peptide_Settings_dialog_to_control_the_conversion_of_peak_areas_to_concentrations_; } else { if (!peptide.InternalStandardConcentration.HasValue) { zedGraphControl.GraphPane.Title.Text = string.Format(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_convert_peak_area_ratios_to_concentrations__specify_the_internal_standard_concentration_for__0__, peptide); } else { zedGraphControl.GraphPane.Title.Text = null; } } } else { if (curveFitter.GetStandardConcentrations().Any()) { zedGraphControl.GraphPane.Title.Text = null; } else { zedGraphControl.GraphPane.Title.Text = QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_To_fit_a_calibration_curve__set_the_Sample_Type_of_some_replicates_to_Standard__and_specify_their_concentration_; } } zedGraphControl.GraphPane.XAxis.Title.Text = curveFitter.GetXAxisTitle(); zedGraphControl.GraphPane.YAxis.Title.Text = curveFitter.GetYAxisTitle(); CalibrationCurve = curveFitter.GetCalibrationCurve(); double minX = double.MaxValue, maxX = double.MinValue; _scatterPlots = new CurveList(); foreach (var sampleType in SampleType.ListSampleTypes()) { if (!Options.DisplaySampleType(sampleType)) { continue; } PointPairList pointPairList = new PointPairList(); for (int iReplicate = 0; iReplicate < document.Settings.MeasuredResults.Chromatograms.Count; iReplicate++) { ChromatogramSet chromatogramSet = document.Settings.MeasuredResults.Chromatograms[iReplicate]; if (!Equals(sampleType, chromatogramSet.SampleType)) { continue; } double?y = curveFitter.GetYValue(iReplicate); double?x = curveFitter.GetSpecifiedXValue(iReplicate) ?? curveFitter.GetCalculatedXValue(CalibrationCurve, iReplicate); if (y.HasValue && x.HasValue) { PointPair point = new PointPair(x.Value, y.Value) { Tag = iReplicate }; pointPairList.Add(point); if (!Options.LogPlot || x.Value > 0) { minX = Math.Min(minX, x.Value); } maxX = Math.Max(maxX, x.Value); } } if (pointPairList.Any()) { var lineItem = zedGraphControl.GraphPane.AddCurve(sampleType.ToString(), pointPairList, sampleType.Color, sampleType.SymbolType); lineItem.Line.IsVisible = false; lineItem.Symbol.Fill = new Fill(sampleType.Color); _scatterPlots.Add(lineItem); } } List <string> labelLines = new List <String>(); RegressionFit regressionFit = document.Settings.PeptideSettings.Quantification.RegressionFit; if (regressionFit != RegressionFit.NONE) { if (minX <= maxX) { int interpolatedLinePointCount = 100; if (!options.LogPlot) { if (regressionFit == RegressionFit.LINEAR_THROUGH_ZERO) { minX = Math.Min(0, minX); } if (regressionFit != RegressionFit.QUADRATIC) { interpolatedLinePointCount = 2; } } LineItem interpolatedLine = CreateInterpolatedLine(CalibrationCurve, minX, maxX, interpolatedLinePointCount, Options.LogPlot); if (null != interpolatedLine) { zedGraphControl.GraphPane.CurveList.Add(interpolatedLine); } } labelLines.Add(CalibrationCurve.ToString()); if (CalibrationCurve.RSquared.HasValue) { labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_ + CalibrationCurve.RSquared.Value.ToString("0.####")); // Not L10N } if (!Equals(curveFitter.QuantificationSettings.RegressionWeighting, RegressionWeighting.NONE)) { labelLines.Add(string.Format("{0}: {1}", // Not L10N QuantificationStrings.Weighting, curveFitter.QuantificationSettings.RegressionWeighting)); } } if (options.ShowSelection) { double?ySelected = curveFitter.GetYValue(_skylineWindow.SelectedResultsIndex); double?xSelected = curveFitter.GetCalculatedXValue(CalibrationCurve, _skylineWindow.SelectedResultsIndex); if (xSelected.HasValue && ySelected.HasValue) { ArrowObj arrow = new ArrowObj(xSelected.Value, ySelected.Value, xSelected.Value, ySelected.Value) { Line = { Color = GraphSummary.ColorSelected } }; zedGraphControl.GraphPane.GraphObjList.Insert(0, arrow); } var quantificationResult = curveFitter.GetQuantificationResult(_skylineWindow.SelectedResultsIndex); if (quantificationResult.CalculatedConcentration.HasValue) { labelLines.Add(string.Format("{0} = {1}", // Not L10N QuantificationStrings.Calculated_Concentration, quantificationResult)); } else if (!quantificationResult.NormalizedArea.HasValue) { labelLines.Add(QuantificationStrings.CalibrationForm_DisplayCalibrationCurve_The_selected_replicate_has_missing_or_truncated_transitions); } } if (labelLines.Any()) { TextObj text = new TextObj(TextUtil.LineSeparate(labelLines), .01, 0, CoordType.ChartFraction, AlignH.Left, AlignV.Top) { IsClippedToChartRect = true, ZOrder = ZOrder.E_BehindCurves, FontSpec = GraphSummary.CreateFontSpec(Color.Black), }; zedGraphControl.GraphPane.GraphObjList.Add(text); } }
/// <summary> /// Create the ordered list of dropdown items, with a rational sort order: /// First present any sequence matches, sorted by sequence /// Then present any name, accession, gene, preferredname, or species metadata matches, sorted by the matched metadata field /// Then present any matches against the description field, sorted by the description text starting at the match location /// </summary> public static IList <ListViewItem> CreateListViewItems(IList <ProteinMatch> matches, String searchText, ProteinMatchType matchTypes, int maxCount) { var listItems = new SortedList <string, ListViewItem>(); var listUsedMatches = new List <string>(); // First check for matching by sequence foreach (var match in matches) { if (0 != (matchTypes & match.MatchType & ProteinMatchType.sequence)) { foreach (DigestedPeptide digestedPeptide in match.DigestedPeptides) { var listItem = new ListViewItem { Text = digestedPeptide.Sequence, Tag = new StatementCompletionItem { Peptide = digestedPeptide.Sequence, ProteinInfo = match.Protein.ProteinMetadata, SearchText = searchText }, }; StatementCompletionForm.AddDescription(listItem, match.Protein.ProteinMetadata.TextForMatchTypes(matchTypes), null); listUsedMatches.Add(match.Protein.Name); listItem.ImageIndex = (int)ImageId.peptide; var tooltip = new StringBuilder(); tooltip.AppendLine(Resources.StatementCompletionTextBox_CreateListViewItems_Descriptions) .Append(match.Protein.ProteinMetadata.TextForMatchTypes(matchTypes)); foreach (var name in match.Protein.AlternativeNames) { tooltip.AppendLine().Append(name.TextForMatchTypes(matchTypes)); } listItem.ToolTipText = StripTabs(tooltip.ToString()); // Note the leading space in this sort key - we'd like to list sequence matches first var key = TextUtil.SpaceSeparate(" ", listItem.Text, listItem.ToolTipText); // Not L10N if (!listItems.ContainsKey(key)) { listItems.Add(key, listItem); } } } } if (listItems.Count >= maxCount) { return(new List <ListViewItem>(listItems.Values)); // We used to exit here if we had any matches - but that's frustrating when you're not actually trying to match by sequence } // Decide which field not to display on righthand side, based on what's already showing on the left due to View|Targets|By* menu ProteinMatchType displayMatchType = ProteinMatchType.all; switch (SequenceTree.ProteinsDisplayMode) { case ProteinDisplayMode.ByName: displayMatchType &= ~ProteinMatchType.name; break; case ProteinDisplayMode.ByAccession: displayMatchType &= ~ProteinMatchType.accession; break; case ProteinDisplayMode.ByGene: displayMatchType &= ~ProteinMatchType.gene; break; case ProteinDisplayMode.ByPreferredName: displayMatchType &= ~ProteinMatchType.preferredName; break; } foreach (var match in matches) { // Try matching on name, accession etc - cycle through name, accession, preferredName, gene for (int bit = 1; bit < (int)ProteinMatchType.all; bit = bit << 1) { ProteinMatchType tryType = (ProteinMatchType)bit; if ((tryType != ProteinMatchType.sequence) && // We already did sequence (tryType != ProteinMatchType.description) && // And aren't ready for description (0 != (matchTypes & match.MatchType & tryType) && !listUsedMatches.Contains(match.Protein.Name))) { var listItem = new ListViewItem(); // Show description, and any other fields we were searching on if (match.AlternativeName != null) { listItem.Text = PeptideGroupTreeNode.ProteinModalDisplayText(match.AlternativeName, Settings.Default.ShowPeptidesDisplayMode); listItem.Tag = new StatementCompletionItem { ProteinInfo = match.AlternativeName, SearchText = searchText }; StatementCompletionForm.AddDescription(listItem, match.AlternativeName.TextForMatchTypes(displayMatchType & ~ProteinMatchType.name), searchText); } else { listItem.Text = PeptideGroupTreeNode.ProteinModalDisplayText(match.Protein.ProteinMetadata, Settings.Default.ShowPeptidesDisplayMode); listItem.Tag = new StatementCompletionItem { ProteinInfo = match.Protein.ProteinMetadata, SearchText = searchText }; StatementCompletionForm.AddDescription(listItem, match.Protein.ProteinMetadata.TextForMatchTypes(displayMatchType), searchText); } listUsedMatches.Add(match.Protein.Name); listItem.ImageIndex = (int)ImageId.protein; var tooltip = new StringBuilder(); tooltip.AppendLine(Resources.StatementCompletionTextBox_CreateListViewItems_Descriptions) .Append(match.Protein.ProteinMetadata.TextForMatchTypes(displayMatchType)); foreach (var altName in match.Protein.AlternativeNames) { tooltip.AppendLine().Append(altName.TextForMatchTypes(displayMatchType)); } listItem.ToolTipText = StripTabs(tooltip.ToString()); // We want the sort to be on the particular bit of metadata that we matched var key = TextUtil.SpaceSeparate(match.Protein.ProteinMetadata.TextForMatchTypes(tryType), listItem.Text, listItem.ToolTipText); if (!listItems.ContainsKey(key)) { listItems.Add(key, listItem); } break; } } } if (listItems.Count >= maxCount) { return(new List <ListViewItem>(listItems.Values)); // We used to exit here if we had any matches - but that's frustrating when you're not actually trying to match by sequence } // Any matches by description? foreach (var match in matches) { if ((0 != (match.MatchType & ProteinMatchType.description)) && !listUsedMatches.Contains(match.Protein.Name)) { ProteinMetadata mainName = match.AlternativeDescription; string matchName = match.Protein.Name; var proteinInfo = match.Protein.ProteinMetadata; if (matchName.Length > MAX_NAME_LENGTH) { proteinInfo = proteinInfo.ChangeName(matchName.Substring(0, MAX_NAME_LENGTH) + "..."); // Not L10N } var alternativeNames = new List <ProteinMetadata>(); if (mainName == null) { mainName = proteinInfo; } else { alternativeNames.Add(proteinInfo); } var listItem = new ListViewItem { Text = PeptideGroupTreeNode.ProteinModalDisplayText(mainName, Settings.Default.ShowPeptidesDisplayMode), ImageIndex = (int)ImageId.protein, Tag = new StatementCompletionItem { ProteinInfo = proteinInfo, SearchText = searchText } }; StatementCompletionForm.AddDescription(listItem, mainName.TextForMatchTypes(displayMatchType), searchText); if (match.Protein.AlternativeNames.Count > 0) { alternativeNames.AddRange(match.Protein.AlternativeNames); StringBuilder tooltip = new StringBuilder(Resources.StatementCompletionTextBox_CreateListViewItems_Alternative_Names); foreach (var altName in alternativeNames) { if (altName.Name == mainName.Name) { continue; } tooltip.AppendLine().Append(altName.TextForMatchTypes(displayMatchType | ProteinMatchType.name)); } listItem.ToolTipText = StripTabs(tooltip.ToString()); } // We want the sort to be on what we matched in the description, and what follows. var remains = match.Protein.ProteinMetadata.Description; int pos = remains.ToLower().IndexOf(searchText.ToLower(), StringComparison.Ordinal); if (pos > 0) { remains = remains.Substring(pos); } var key = TextUtil.SpaceSeparate(remains, listItem.Text, listItem.ToolTipText); if (!listItems.ContainsKey(key)) { listItems.Add(key, listItem); } } } return(new List <ListViewItem>(listItems.Values)); }