public override string ToString() { if (MZToleranceIsPPM) { return("m/z: " + MZ.ToString("0.0") + ", MZTolerance: " + MZTolerance.ToString("0.0") + " ppm"); } return("m/z: " + MZ.ToString("0.0") + ", MZTolerance: " + MZTolerance.ToString("0.000") + " Da"); }
public FragmentationStatisticsForm(IDPickerForm owner) { InitializeComponent(); this.owner = owner; FormClosing += delegate(object sender, FormClosingEventArgs e) { e.Cancel = true; DockState = DockState.DockBottomAutoHide; }; Text = TabText = "Fragmentation Statistics"; Icon = Properties.Resources.BlankIcon; refreshButton.Image = new Icon(Properties.Resources.Refresh, refreshButton.Width / 2, refreshButton.Height / 2).ToBitmap(); refreshDataLabel.LinkClicked += (sender, e) => refreshButton_Click(sender, e); percentTicGraphForm = new DockableForm { Text = "%TIC" }; percentPeakCountGraphForm = new DockableForm { Text = "%PeakCount" }; meanMzErrorGraphForm = new DockableForm { Text = "Mean m/z error" }; percentTicGraphControl = new ZedGraphControl { Dock = DockStyle.Fill, Text = percentTicGraphForm.Text }; percentPeakCountGraphControl = new ZedGraphControl { Dock = DockStyle.Fill, Text = percentPeakCountGraphForm.Text }; meanMzErrorGraphControl = new ZedGraphControl { Dock = DockStyle.Fill, Text = meanMzErrorGraphForm.Text }; percentTicGraphForm.Controls.Add(percentTicGraphControl); percentPeakCountGraphForm.Controls.Add(percentPeakCountGraphControl); meanMzErrorGraphForm.Controls.Add(meanMzErrorGraphControl); initializeGraphControl(percentTicGraphControl); initializeGraphControl(percentPeakCountGraphControl); initializeGraphControl(meanMzErrorGraphControl); lastActiveGraphForm = meanMzErrorGraphForm; graphControls = new List <ZedGraphControl> { percentTicGraphControl, percentPeakCountGraphControl, meanMzErrorGraphControl }; percentTicGraphForm.FormClosing += (sender, e) => e.Cancel = true; percentPeakCountGraphForm.FormClosing += (sender, e) => e.Cancel = true; meanMzErrorGraphForm.FormClosing += (sender, e) => e.Cancel = true; fragmentTolerance = new MZTolerance(0.5, MZTolerance.Units.MZ); fragmentToleranceUnitsComboBox.Text = fragmentTolerance.value.ToString(); fragmentToleranceUnitsComboBox.SelectedIndex = (int)fragmentTolerance.units; }
public override void Update (GraphItem item, pwiz.MSGraph.MSPointList points, GraphObjList annotations) { if (!Enabled) return; if (!(item is MassSpectrum)) return; // throw exception? GraphObjList list = annotations; Peptide peptide; try { peptide = new Peptide(sequence, pwiz.CLI.proteome.ModificationParsing.ModificationParsing_Auto, pwiz.CLI.proteome.ModificationDelimiter.ModificationDelimiter_Brackets); } catch (Exception) { return; } var spectrum = (item as MassSpectrum).Element; if (ReferenceEquals(manualTolerance, null)) { MZTolerance maxTolerance = new MZTolerance(0.5); foreach (var scan in spectrum.scanList.scans.Where(o => o.instrumentConfiguration != null)) { // assume the last analyzer of the instrument configuration is responsible for the resolution if (scan.instrumentConfiguration.componentList.Count == 0) continue; var analyzer = scan.instrumentConfiguration.componentList.Where(o => o.type == ComponentType.ComponentType_Analyzer).Last().cvParamChild(CVID.MS_mass_analyzer_type); if (analyzer.cvid == CVID.CVID_Unknown) continue; MZTolerance analyzerTolerance = null; foreach (var kvp in mzToleranceByAnalyzer) if (CV.cvIsA(analyzer.cvid, kvp.Key)) { analyzerTolerance = kvp.Value; break; } if (analyzerTolerance == null) continue; if (maxTolerance.units == analyzerTolerance.units) { if (maxTolerance.value < analyzerTolerance.value) maxTolerance = analyzerTolerance; } else if (analyzerTolerance.units == MZTolerance.Units.PPM) maxTolerance = analyzerTolerance; } tolerance = maxTolerance; } else tolerance = manualTolerance; if (ionSeriesIsEnabled(IonSeries.Auto)) foreach (var precursor in spectrum.precursors) foreach (var method in precursor.activation.cvParamChildren(CVID.MS_dissociation_method)) { if (!ionSeriesByDissociationMethod.Contains(method.cvid)) ionSeries = IonSeries.All; else ionSeries |= ionSeriesByDissociationMethod[method.cvid]; } int nSeries = (ionSeriesIsEnabled(IonSeries.a) ? 1 : 0) + (ionSeriesIsEnabled(IonSeries.b) ? 1 : 0) + (ionSeriesIsEnabled(IonSeries.c) ? 1 : 0); int cSeries = (ionSeriesIsEnabled(IonSeries.x) ? 1 : 0) + (ionSeriesIsEnabled(IonSeries.y) ? 1 : 0) + (ionSeriesIsEnabled(IonSeries.z) ? 1 : 0) + (ionSeriesIsEnabled(IonSeries.zRadical) ? 1 : 0); showLadders = showLadders && nSeries < 2 && cSeries < 2; string unmodifiedSequence = peptide.sequence; int sequenceLength = unmodifiedSequence.Length; Fragmentation fragmentation = peptide.fragmentation(fragmentMassType == 0 ? true : false, true); for (int i = 1; i <= sequenceLength; ++i) { if (ionSeriesIsEnabled(IonSeries.Immonium)) addFragment(list, points, "immonium-" + unmodifiedSequence[i - 1], 0, 1, immoniumIonByResidue[unmodifiedSequence[i - 1]]); for (int charge = min; charge <= max; ++charge) { if (ionSeriesIsEnabled(IonSeries.a)) addFragment(list, points, "a", i, charge, fragmentation.a(i, charge)); if (ionSeriesIsEnabled(IonSeries.b)) addFragment(list, points, "b", i, charge, fragmentation.b(i, charge)); if (ionSeriesIsEnabled(IonSeries.y)) addFragment(list, points, "y", i, charge, fragmentation.y(i, charge)); if (ionSeriesIsEnabled(IonSeries.z)) addFragment(list, points, "z", i, charge, fragmentation.z(i, charge)); if (ionSeriesIsEnabled(IonSeries.zRadical)) addFragment(list, points, "z*", i, charge, fragmentation.zRadical(i, charge)); if (i < sequenceLength) { if (ionSeriesIsEnabled(IonSeries.c)) addFragment(list, points, "c", i, charge, fragmentation.c(i, charge)); if (ionSeriesIsEnabled(IonSeries.x)) addFragment(list, points, "x", i, charge, fragmentation.x(i, charge)); } } } if (showLadders || showFragmentationSummary) { string topSeries = ionSeriesIsEnabled(IonSeries.a) ? "a" : ionSeriesIsEnabled(IonSeries.b) ? "b" : ionSeriesIsEnabled(IonSeries.c) ? "c" : ""; string bottomSeries = ionSeriesIsEnabled(IonSeries.x) ? "x" : ionSeriesIsEnabled(IonSeries.y) ? "y" : ionSeriesIsEnabled(IonSeries.z) ? "z" : ionSeriesIsEnabled(IonSeries.zRadical) ? "z*" : ""; if (showLadders) addIonSeries(list, points, peptide, fragmentation, topSeries, bottomSeries); if (showFragmentationSummary) addFragmentationSummary(list, points, peptide, fragmentation, topSeries, bottomSeries); } // fill peptide info table annotationPanels.peptideInfoGridView.Rows.Clear(); if (spectrum.precursors.Count > 0 && spectrum.precursors[0].selectedIons.Count > 0 && spectrum.precursors[0].selectedIons[0].hasCVParam(CVID.MS_selected_ion_m_z) && spectrum.precursors[0].selectedIons[0].hasCVParam(CVID.MS_charge_state)) { double selectedMz = (double) spectrum.precursors[0].selectedIons[0].cvParam(CVID.MS_selected_ion_m_z).value; int chargeState = (int) spectrum.precursors[0].selectedIons[0].cvParam(CVID.MS_charge_state).value; double calculatedMass = (precursorMassType == 0 ? peptide.monoisotopicMass(chargeState) : peptide.molecularWeight(chargeState)) * chargeState; double observedMass = selectedMz * chargeState; annotationPanels.peptideInfoGridView.Rows.Add("Calculated mass:", calculatedMass, "Mass error (daltons):", observedMass - calculatedMass); annotationPanels.peptideInfoGridView.Rows.Add("Observed mass:", observedMass, "Mass error (ppm):", ((observedMass - calculatedMass) / calculatedMass) * 1e6); } else annotationPanels.peptideInfoGridView.Rows.Add("Calculated neutral mass:", precursorMassType == 0 ? peptide.monoisotopicMass() : peptide.molecularWeight()); annotationPanels.peptideInfoGridView.Columns[1].DefaultCellStyle.Format = "F4"; foreach (DataGridViewRow row in annotationPanels.peptideInfoGridView.Rows) row.Height = row.InheritedStyle.Font.Height + 2; // show/hide/update fragment table if (!annotationPanels.showFragmentationTableCheckBox.Checked || ionSeries <= IonSeries.Auto) { annotationPanels.fragmentInfoGridView.Visible = false; annotationPanels.fragmentInfoGridView.Rows.Clear(); return; } annotationPanels.fragmentInfoGridView.Visible = true; annotationPanels.fragmentInfoGridView.SuspendLayout(); if (annotationPanels.fragmentInfoGridView.Columns.Count == 0) { #region Add columns for fragment types if (ionSeriesIsEnabled(IonSeries.a)) for (int charge = min; charge <= max; ++charge) annotationPanels.fragmentInfoGridView.Columns.Add( "a" + charge.ToString(), "a" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (ionSeriesIsEnabled(IonSeries.b)) for (int charge = min; charge <= max; ++charge) annotationPanels.fragmentInfoGridView.Columns.Add( "b" + charge.ToString(), "b" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (ionSeriesIsEnabled(IonSeries.c)) for (int charge = min; charge <= max; ++charge) annotationPanels.fragmentInfoGridView.Columns.Add( "c" + charge.ToString(), "c" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); annotationPanels.fragmentInfoGridView.Columns.Add("N", ""); annotationPanels.fragmentInfoGridView.Columns.Add("Sequence", ""); annotationPanels.fragmentInfoGridView.Columns.Add("C", ""); if (ionSeriesIsEnabled(IonSeries.x)) for (int charge = min; charge <= max; ++charge) annotationPanels.fragmentInfoGridView.Columns.Add( "x" + charge.ToString(), "x" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (ionSeriesIsEnabled(IonSeries.y)) for (int charge = min; charge <= max; ++charge) annotationPanels.fragmentInfoGridView.Columns.Add( "y" + charge.ToString(), "y" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (ionSeriesIsEnabled(IonSeries.z)) for (int charge = min; charge <= max; ++charge) annotationPanels.fragmentInfoGridView.Columns.Add( "z" + charge.ToString(), "z" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (ionSeriesIsEnabled(IonSeries.zRadical)) for (int charge = min; charge <= max; ++charge) annotationPanels.fragmentInfoGridView.Columns.Add( "z*" + charge.ToString(), "z*" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); #endregion foreach (DataGridViewColumn column in annotationPanels.fragmentInfoGridView.Columns) { column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; if (column.Name != "N" && column.Name != "C" && column.Name != "Sequence") column.DefaultCellStyle.Format = "F3"; } } while (annotationPanels.fragmentInfoGridView.Rows.Count > sequenceLength) annotationPanels.fragmentInfoGridView.Rows.RemoveAt(annotationPanels.fragmentInfoGridView.Rows.Count - 1); if (sequenceLength - annotationPanels.fragmentInfoGridView.Rows.Count > 0) annotationPanels.fragmentInfoGridView.Rows.Add(sequenceLength - annotationPanels.fragmentInfoGridView.Rows.Count); for (int i = 1; i <= sequenceLength; ++i) { int cTerminalLength = sequenceLength - i + 1; var row = annotationPanels.fragmentInfoGridView.Rows[i - 1]; var values = new List<object>(10); //var row = annotationPanels.fragmentInfoGridView.Rows.Add()]; if (ionSeriesIsEnabled(IonSeries.a)) for (int charge = min; charge <= max; ++charge) values.Add(fragmentation.a(i, charge)); if (ionSeriesIsEnabled(IonSeries.b)) for (int charge = min; charge <= max; ++charge) values.Add(fragmentation.b(i, charge)); if (ionSeriesIsEnabled(IonSeries.c)) for (int charge = min; charge <= max; ++charge) if (i < sequenceLength) values.Add(fragmentation.c(i, charge)); else values.Add(""); values.Add(i); values.Add(unmodifiedSequence[i - 1]); values.Add(cTerminalLength); if (ionSeriesIsEnabled(IonSeries.x)) for (int charge = min; charge <= max; ++charge) if (i > 1) values.Add(fragmentation.x(cTerminalLength, charge)); else values.Add(""); if (ionSeriesIsEnabled(IonSeries.y)) for (int charge = min; charge <= max; ++charge) values.Add(fragmentation.y(cTerminalLength, charge)); if (ionSeriesIsEnabled(IonSeries.z)) for (int charge = min; charge <= max; ++charge) values.Add(fragmentation.z(cTerminalLength, charge)); if (ionSeriesIsEnabled(IonSeries.zRadical)) for (int charge = min; charge <= max; ++charge) values.Add(fragmentation.zRadical(cTerminalLength, charge)); row.SetValues(values.ToArray()); } foreach (DataGridViewRow row in annotationPanels.fragmentInfoGridView.Rows) { row.Height = row.InheritedStyle.Font.Height + 2; foreach (DataGridViewCell cell in row.Cells) { if (!(cell.Value is double)) continue; double mz = (double) cell.Value; if (findPointWithTolerance(points, mz, tolerance) > -1) cell.Style.Font = new Font(annotationPanels.fragmentInfoGridView.Font, FontStyle.Bold); else cell.Style.Font = annotationPanels.fragmentInfoGridView.Font; } } annotationPanels.fragmentInfoGridView.ResumeLayout(); }
private int findPointWithTolerance(pwiz.MSGraph.MSPointList points, double mz, MZTolerance tolerance, bool scaled = false) { double lowestMatchMz = mz - tolerance; double highestMatchMz = mz + tolerance; var pointPairList = scaled ? points.ScaledList : points.FullList; int index = scaled ? points.ScaledLowerBound(mz) : points.FullLowerBound(mz); // if index is below the tolerance threshold, bump it to the next one or set to -1 if doing so would exceed the list size if (index > -1 && pointPairList[index].X < lowestMatchMz) index = index + 1 == pointPairList.Count ? -1 : index + 1; if (index == -1 || pointPairList[index].X > highestMatchMz) return -1; return index; }
void toleranceChanged (object sender, EventArgs e) { if (panel.Tag != this) return; if (String.IsNullOrEmpty(annotationPanels.fragmentToleranceTextBox.Text)) manualTolerance = null; else { manualTolerance = new MZTolerance(); manualTolerance.value = Convert.ToDouble(annotationPanels.fragmentToleranceTextBox.Text); manualTolerance.units = (MZTolerance.Units) annotationPanels.fragmentToleranceUnitsComboBox.SelectedIndex; } OnOptionsChanged(this, EventArgs.Empty); }
public PeptideFragmentationAnnotation (string sequence, int minCharge, int maxCharge, MZTolerance tolerance, IonSeries ionSeries, bool showFragmentationLadders, bool showMissedFragments, bool showLabels, bool showFragmentationSummary) { this.sequence = sequence; this.min = minCharge; this.max = maxCharge; this.manualTolerance = tolerance; this.tolerance = new MZTolerance(0.5); this.ionSeries = ionSeries; this.showLadders = showFragmentationLadders; this.showMisses = showMissedFragments; this.showLabels = showLabels; this.showFragmentationSummary = showFragmentationSummary; annotationPanels.precursorMassTypeComboBox.SelectedIndex = 0; annotationPanels.fragmentMassTypeComboBox.SelectedIndex = 0; if (!ReferenceEquals(tolerance, null)) annotationPanels.fragmentToleranceUnitsComboBox.SelectedIndex = (int) tolerance.units; else annotationPanels.fragmentToleranceUnitsComboBox.SelectedIndex = 0; annotationPanels.sequenceTextBox.TextChanged += sequenceTextBox_TextChanged; annotationPanels.minChargeUpDown.ValueChanged += checkBox_CheckedChanged; annotationPanels.maxChargeUpDown.ValueChanged += checkBox_CheckedChanged; annotationPanels.fragmentToleranceTextBox.TextChanged += toleranceChanged; annotationPanels.fragmentToleranceUnitsComboBox.SelectedIndexChanged += toleranceChanged; annotationPanels.precursorMassTypeComboBox.SelectedIndexChanged += checkBox_CheckedChanged; annotationPanels.fragmentMassTypeComboBox.SelectedIndexChanged += checkBox_CheckedChanged; annotationPanels.aCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.bCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.cCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.xCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.yCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.zCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.zRadicalCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.immoniumCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.showFragmentationLaddersCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.showMissesCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.showFragmentationSummaryCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.showFragmentationTableCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.fragmentInfoGridView.Columns.Clear(); }
public PeptideFragmentationAnnotation () { sequence = "PEPTIDE"; min = 1; max = 1; tolerance = manualTolerance = new MZTolerance(0.5); precursorMassType = 0; fragmentMassType = 0; showLadders = true; showMisses = false; showLabels = true; showFragmentationSummary = false; annotationPanels.precursorMassTypeComboBox.SelectedIndex = precursorMassType; annotationPanels.fragmentMassTypeComboBox.SelectedIndex = fragmentMassType; annotationPanels.fragmentToleranceUnitsComboBox.SelectedIndex = 0; annotationPanels.sequenceTextBox.TextChanged += sequenceTextBox_TextChanged; annotationPanels.minChargeUpDown.ValueChanged += checkBox_CheckedChanged; annotationPanels.maxChargeUpDown.ValueChanged += checkBox_CheckedChanged; annotationPanels.fragmentToleranceTextBox.TextChanged += toleranceChanged; annotationPanels.fragmentToleranceUnitsComboBox.SelectedIndexChanged += toleranceChanged; annotationPanels.precursorMassTypeComboBox.SelectedIndexChanged += checkBox_CheckedChanged; annotationPanels.fragmentMassTypeComboBox.SelectedIndexChanged += checkBox_CheckedChanged; annotationPanels.aCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.bCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.cCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.xCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.yCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.zCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.zRadicalCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.immoniumCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.showFragmentationLaddersCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.showMissesCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.showFragmentationSummaryCheckBox.CheckedChanged += checkBox_CheckedChanged; annotationPanels.showFragmentationTableCheckBox.CheckedChanged += checkBox_CheckedChanged; }
public FragmentationStatisticsForm (IDPickerForm owner) { InitializeComponent(); this.owner = owner; FormClosing += delegate(object sender, FormClosingEventArgs e) { e.Cancel = true; DockState = DockState.DockBottomAutoHide; }; Text = TabText = "Fragmentation Statistics"; Icon = Properties.Resources.BlankIcon; refreshButton.Image = new Icon(Properties.Resources.Refresh, refreshButton.Width / 2, refreshButton.Height / 2).ToBitmap(); refreshDataLabel.LinkClicked += (sender, e) => refreshButton_Click(sender, e); percentTicGraphForm = new DockableForm { Text = "%TIC" }; percentPeakCountGraphForm = new DockableForm { Text = "%PeakCount" }; meanMzErrorGraphForm = new DockableForm { Text = "Mean m/z error" }; percentTicGraphControl = new ZedGraphControl { Dock = DockStyle.Fill, Text = percentTicGraphForm.Text }; percentPeakCountGraphControl = new ZedGraphControl { Dock = DockStyle.Fill, Text = percentPeakCountGraphForm.Text }; meanMzErrorGraphControl = new ZedGraphControl { Dock = DockStyle.Fill, Text = meanMzErrorGraphForm.Text }; percentTicGraphForm.Controls.Add(percentTicGraphControl); percentPeakCountGraphForm.Controls.Add(percentPeakCountGraphControl); meanMzErrorGraphForm.Controls.Add(meanMzErrorGraphControl); initializeGraphControl(percentTicGraphControl); initializeGraphControl(percentPeakCountGraphControl); initializeGraphControl(meanMzErrorGraphControl); lastActiveGraphForm = meanMzErrorGraphForm; graphControls = new List<ZedGraphControl> { percentTicGraphControl, percentPeakCountGraphControl, meanMzErrorGraphControl }; percentTicGraphForm.FormClosing += (sender, e) => e.Cancel = true; percentPeakCountGraphForm.FormClosing += (sender, e) => e.Cancel = true; meanMzErrorGraphForm.FormClosing += (sender, e) => e.Cancel = true; fragmentTolerance = new MZTolerance(0.5, MZTolerance.Units.MZ); fragmentToleranceUnitsComboBox.Text = fragmentTolerance.value.ToString(); fragmentToleranceUnitsComboBox.SelectedIndex = (int) fragmentTolerance.units; }
void spectrumTableForm_SpectrumViewVisualize (object sender, SpectrumViewVisualizeEventArgs e) { var spectrum = e.Spectrum; var source = e.SpectrumSource; string sourcePath; if (source.Metadata != null) { //BeginInvoke(new MethodInvoker(() => toolStripStatusLabel.Text = "Extracting embedded spectrum source: " + source.Name)); // accessing the Metadata property creates a temporary mz5 file var mz5 = source.Metadata as TemporaryMSDataFile; sourcePath = mz5.Filepath; } else { sourcePath = LocateSpectrumSource(source.Name, session.Connection.GetDataSource()); if (String.IsNullOrEmpty(sourcePath)) return; // file still not found, abort the visualization } var param = e.Analysis.Parameters.Where(o => o.Name == "SpectrumListFilters").SingleOrDefault(); string spectrumListFilters = param == null ? String.Empty : param.Value; spectrumListFilters = spectrumListFilters.Replace("0 ", "false "); var ionSeries = PeptideFragmentationAnnotation.IonSeries.Auto; if (sourcePath.ToLower().EndsWith(".mgf")) ionSeries = PeptideFragmentationAnnotation.IonSeries.b | PeptideFragmentationAnnotation.IonSeries.y; bool showFragmentationLadders = true; bool showMissedFragments = false; bool showLabels = true; bool showFragmentationSummary = false; MZTolerance tolerance = null; if (manager.CurrentGraphForm != null && annotationByGraphForm[manager.CurrentGraphForm] != null) { var panel = PeptideFragmentationAnnotation.annotationPanels; showFragmentationLadders = panel.showFragmentationLaddersCheckBox.Checked; showMissedFragments = panel.showMissesCheckBox.Checked; showFragmentationSummary = panel.showFragmentationSummaryCheckBox.Checked; if (panel.fragmentToleranceTextBox.Text.Length > 0) { tolerance = new MZTolerance(); tolerance.value = Convert.ToDouble(panel.fragmentToleranceTextBox.Text); tolerance.units = (MZTolerance.Units) panel.fragmentToleranceUnitsComboBox.SelectedIndex; } else tolerance = null; } var annotation = new PeptideFragmentationAnnotation(e.ModifiedSequence, 1, Math.Max(1, e.Charge - 1), tolerance, ionSeries, showFragmentationLadders, showMissedFragments, showLabels, showFragmentationSummary); (manager.SpectrumAnnotationForm.Controls[0] as ToolStrip).Hide(); (manager.SpectrumAnnotationForm.Controls[1] as SplitContainer).Panel1Collapsed = true; (manager.SpectrumAnnotationForm.Controls[1] as SplitContainer).Dock = DockStyle.Fill; //BeginInvoke(new MethodInvoker(() => toolStripStatusLabel.Text = toolStripStatusLabel.Text = "Opening spectrum source: " + sourcePath)); manager.OpenFile(sourcePath, spectrum.NativeID, annotation, spectrumListFilters); manager.CurrentGraphForm.Focus(); manager.CurrentGraphForm.Icon = Properties.Resources.SpectrumViewIcon; //BeginInvoke(new MethodInvoker(() => toolStripStatusLabel.Text = toolStripStatusLabel.Text = "Ready")); annotationByGraphForm[manager.CurrentGraphForm] = annotation; if (!handlerIsAttached.ContainsKey(manager.CurrentGraphForm)) { handlerIsAttached[manager.CurrentGraphForm] = true; manager.CurrentGraphForm.ZedGraphControl.PreviewKeyDown += CurrentGraphForm_PreviewKeyDown; } }