/// <summary> /// Render text to the specified <see cref="Graphics"/> device /// by calling the Draw method of each <see cref="GraphItem"/> object in /// the collection. /// </summary> /// <remarks>This method is normally only called by the Draw method /// of the parent <see cref="GraphPane"/> object. /// </remarks> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="PaneBase"/> object that is the parent or /// owner of this object. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> /// <param name="zOrder">A <see cref="ZOrder"/> enumeration that controls /// the placement of this <see cref="GraphItem"/> relative to other /// graphic objects. The order of <see cref="GraphItem"/>'s with the /// same <see cref="ZOrder"/> value is control by their order in /// this <see cref="GraphItemList"/>.</param> public void Draw(Graphics g, PaneBase pane, float scaleFactor, ZOrder zOrder) { // Draw the items in reverse order, so the last items in the // list appear behind the first items (consistent with // CurveList) for (int i = this.Count - 1; i >= 0; i--) { GraphItem item = this[i]; if (item.ZOrder == zOrder && item.IsVisible) { Region region = null; if (item.IsClippedToAxisRect && pane is GraphPane) { region = g.Clip.Clone(); g.SetClip(((GraphPane)pane).AxisRect); } item.Draw(g, pane, scaleFactor); if (item.IsClippedToAxisRect && pane is GraphPane) { g.Clip = region; } } } }
public DataPointTableForm(GraphItem graphItem) { InitializeComponent(); item = graphItem; pointList = item.Points; dataGridView.Rows.Insert( 0, pointList.Count ); }
/// <summary> /// Render text to the specified <see cref="Graphics"/> device /// by calling the Draw method of each <see cref="GraphItem"/> object in /// the collection. /// </summary> /// <remarks>This method is normally only called by the Draw method /// of the parent <see cref="GraphPane"/> object. /// </remarks> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="GraphPane.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> /// <param name="zOrder">A <see cref="ZOrder"/> enumeration that controls /// the placement of this <see cref="GraphItem"/> relative to other /// graphic objects. The order of <see cref="GraphItem"/>'s with the /// same <see cref="ZOrder"/> value is control by their order in /// this <see cref="GraphItemList"/>.</param> public void Draw(Graphics g, GraphPane pane, double scaleFactor, ZOrder zOrder) { // Draw the items in reverse order, so the last items in the // list appear behind the first items (consistent with // CurveList) for (int i = this.Count - 1; i >= 0; i--) { GraphItem item = this[i]; if (item.ZOrder == zOrder) { item.Draw(g, pane, scaleFactor); } } }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="GraphItem"/> object from which to copy</param> public GraphItem(GraphItem rhs) { this.isVisible = rhs.IsVisible; if (rhs.Tag is ICloneable) { this.Tag = ((ICloneable)rhs.Tag).Clone(); } else { this.Tag = rhs.Tag; } this.zOrder = rhs.ZOrder; this.location = (Location)rhs.Location.Clone(); }
/// <summary> /// Find the pane and the object within that pane that lies closest to the specified /// mouse (screen) point. /// </summary> /// <remarks> /// This method first finds the <see cref="GraphPane"/> within the list that contains /// the specified mouse point. It then calls the <see cref="GraphPane.FindNearestObject"/> /// method to determine which object, if any, was clicked. With the exception of the /// <see paramref="pane"/>, all the parameters in this method are identical to those /// in the <see cref="GraphPane.FindNearestObject"/> method. /// If the mouse point lies within the <see cref="PaneBase.PaneRect"/> of any /// <see cref="GraphPane"/> item, then that pane will be returned (otherwise it will be /// null). Further, within the selected pane, if the mouse point is within the /// bounding box of any of the items (or in the case /// of <see cref="ArrowItem"/> and <see cref="CurveItem"/>, within /// <see cref="GraphPane.Default.NearestTol"/> pixels), then the object will be returned. /// You must check the type of the object to determine what object was /// selected (for example, "if ( object is Legend ) ..."). The /// <see paramref="index"/> parameter returns the index number of the item /// within the selected object (such as the point number within a /// <see cref="CurveItem"/> object. /// </remarks> /// <param name="mousePt">The screen point, in pixel coordinates.</param> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane">A reference to the <see cref="GraphPane"/> object that was clicked.</param> /// <param name="nearestObj">A reference to the nearest object to the /// specified screen point. This can be any of <see cref="Axis"/>, /// <see cref="Legend"/>, <see cref="PaneBase.Title"/>, /// <see cref="TextItem"/>, <see cref="ArrowItem"/>, or <see cref="CurveItem"/>. /// Note: If the pane title is selected, then the <see cref="GraphPane"/> object /// will be returned. /// </param> /// <param name="index">The index number of the item within the selected object /// (where applicable). For example, for a <see cref="CurveItem"/> object, /// <see paramref="index"/> will be the index number of the nearest data point, /// accessible via <see cref="CurveItem.Points">CurveItem.Points[index]</see>. /// index will be -1 if no data points are available.</param> /// <returns>true if a <see cref="GraphPane"/> was found, false otherwise.</returns> /// <seealso cref="GraphPane.FindNearestObject"/> public bool FindNearestPaneObject(PointF mousePt, Graphics g, out GraphPane pane, out object nearestObj, out int index) { pane = null; nearestObj = null; index = -1; GraphItem saveGraphItem = null; int saveIndex = -1; float scaleFactor = CalcScaleFactor(); // See if the point is in a GraphItem // If so, just save the object and index so we can see if other overlying objects were // intersected as well. if (this.GraphItemList.FindPoint(mousePt, this, g, scaleFactor, out index)) { saveGraphItem = this.GraphItemList[index]; saveIndex = index; // If it's an "In-Front" item, then just return it if (saveGraphItem.ZOrder == ZOrder.A_InFront) { nearestObj = saveGraphItem; index = saveIndex; return(true); } } foreach (GraphPane tPane in this.paneList) { if (tPane.PaneRect.Contains(mousePt)) { pane = tPane; return(tPane.FindNearestObject(mousePt, g, out nearestObj, out index)); } } // If no items were found in the GraphPanes, then return the item found on the MasterPane (if any) if (saveGraphItem != null) { nearestObj = saveGraphItem; index = saveIndex; return(true); } return(false); }
private void showDataStacked(GraphForm hostGraph, GraphItem item ) { Pane pane = new Pane(); pane.Add( item ); hostGraph.PaneList.Add( pane ); hostGraph.Refresh(); }
private void showDataOverlay(GraphForm hostGraph, GraphItem item ) { hostGraph.PaneList[0].Add( item ); hostGraph.Refresh(); }
private void showData( GraphForm hostGraph, GraphItem item ) { Pane pane; if( hostGraph.PaneList.Count == 0 || hostGraph.PaneList.Count > 1 ) { hostGraph.PaneList.Clear(); pane = new Pane(); hostGraph.PaneList.Add( pane ); } else { pane = hostGraph.PaneList[0]; pane.Clear(); } pane.Add( item ); hostGraph.Refresh(); }
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(); }
public virtual void Update (GraphItem item, pwiz.MSGraph.MSPointList pointList, GraphObjList annotations) { throw new NotImplementedException(); }
public override void Update( GraphItem item, pwiz.MSGraph.MSPointList points, GraphObjList annotations ) { double basePeakIntensity = 0; double cutoff = 0; foreach (var pointlist in points) { if (basePeakIntensity < pointlist.Y) basePeakIntensity = pointlist.Y; } cutoff = basePeakIntensity * basePeakPercentage * 0.01; 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; } //if (annotationPanels.peptideInfoGridView.InvokeRequired) //{ // annotationPanels.peptideInfoGridView.BeginInvoke(new MethodInvoker(() => Update(item, points, annotations))); // //return; //} var spectrum = ( item as MassSpectrum ).Element; if (spectrum.precursors.Count > 0 && ionSeriesIsEnabled(IonSeries.Auto)) { bool cid = (item as MassSpectrum).Element.precursors[0].activation.hasCVParam(CVID.MS_CID); bool etd = (item as MassSpectrum).Element.precursors[0].activation.hasCVParam(CVID.MS_ETD); ionSeries |= cid ? IonSeries.b | IonSeries.y : IonSeries.Off; ionSeries |= etd ? IonSeries.c | IonSeries.zRadical : IonSeries.Off; } string unmodifiedSequence = peptide.sequence; int sequenceLength = unmodifiedSequence.Length; Fragmentation fragmentation = peptide.fragmentation( fragmentMassType == 0 ? true : false, true ); //test neutral ModificationMap modifications = peptide.modifications(); /// #region adding labels for series a/b/c/x/y/z:::::::::naive fragmentation modeling if (!showBasophileModel) { for (int i = 1; i < sequenceLength; ++i) { //test neutral loss //note here the Cseq is slightly different than those in addFragmentSummary string Nseq = peptide.sequence.Substring(0, i); string Cseq = peptide.sequence.Substring(sequenceLength - i, i); string NTempSeq = peptide.sequence.Substring(0, sequenceLength - i); char[] Nseqchars = Nseq.ToCharArray(); char[] NTempSeqchars = NTempSeq.ToCharArray(); char[] seqchars = peptide.sequence.ToCharArray(); int Nphosmodi = 0; int NTempPhosmodi = 0; int Cphosmodi = 0; int phosmodi = 0; for (int k = 0; k < i; k++) { if (Math.Round(modifications[k].monoisotopicDeltaMass()) == 80 && (seqchars[k] == 'S' || seqchars[k] == 'T' || seqchars[k] == 'Y')) { Nphosmodi++; } } for (int k = 0; k < sequenceLength - i; k++) { if (Math.Round(modifications[k].monoisotopicDeltaMass()) == 80 && (seqchars[k] == 'S' || seqchars[k] == 'T' || seqchars[k] == 'Y')) { NTempPhosmodi++; } } for (int k = 0; k < sequenceLength; k++) { if (Math.Round(modifications[k].monoisotopicDeltaMass()) == 80 && (seqchars[k] == 'S' || seqchars[k] == 'T' || seqchars[k] == 'Y')) { phosmodi++; } } Cphosmodi = phosmodi - NTempPhosmodi; 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)); } //test neutral loss #region water loss if (waterLoss == true) { if (Nseq.Contains("S") || Nseq.Contains("T") || Nseq.Contains("E") || Nseq.Contains("D")) { if (ionSeriesIsEnabled(IonSeries.a)) addFragment(list, points, "a-water", i, charge, fragmentation.a(i, charge) - WATERMONOMASS / charge); if (ionSeriesIsEnabled(IonSeries.b)) addFragment(list, points, "b-water", i, charge, fragmentation.b(i, charge) - WATERMONOMASS / charge); if (i < sequenceLength) { if (ionSeriesIsEnabled(IonSeries.c)) addFragment(list, points, "c-water", i, charge, fragmentation.c(i, charge) - WATERMONOMASS / charge); } } if (Cseq.Contains("S") || Cseq.Contains("T") || Cseq.Contains("E") || Cseq.Contains("D")) { if (ionSeriesIsEnabled(IonSeries.y)) addFragment(list, points, "y-water", i, charge, fragmentation.y(i, charge) - WATERMONOMASS / charge); if (ionSeriesIsEnabled(IonSeries.z)) addFragment(list, points, "z-water", i, charge, fragmentation.z(i, charge) - WATERMONOMASS / charge); if (ionSeriesIsEnabled(IonSeries.zRadical)) addFragment(list, points, "z*-water", i, charge, fragmentation.zRadical(i, charge) - WATERMONOMASS / charge); if (i < sequenceLength) { if (ionSeriesIsEnabled(IonSeries.x)) addFragment(list, points, "x-water", i, charge, fragmentation.x(i, charge) - WATERMONOMASS / charge); } } } #endregion //test neutral loss #region ammonium loss if (ammoniumLoss == true) { if (Nseq.Contains("R") || Nseq.Contains("K") || Nseq.Contains("Q") || Nseq.Contains("N")) { if (ionSeriesIsEnabled(IonSeries.a)) addFragment(list, points, "a-ammonium", i, charge, fragmentation.a(i, charge) - AMMONIUMMONOMASS / charge); if (ionSeriesIsEnabled(IonSeries.b)) addFragment(list, points, "b-ammonium", i, charge, fragmentation.b(i, charge) - AMMONIUMMONOMASS / charge); if (i < sequenceLength) { if (ionSeriesIsEnabled(IonSeries.c)) addFragment(list, points, "c-ammonium", i, charge, fragmentation.c(i, charge) - AMMONIUMMONOMASS / charge); } } if (Cseq.Contains("R") || Cseq.Contains("K") || Cseq.Contains("Q") || Cseq.Contains("N")) { if (ionSeriesIsEnabled(IonSeries.y)) addFragment(list, points, "y-ammonium", i, charge, fragmentation.y(i, charge) - AMMONIUMMONOMASS / charge); if (ionSeriesIsEnabled(IonSeries.z)) addFragment(list, points, "z-ammonium", i, charge, fragmentation.z(i, charge) - AMMONIUMMONOMASS / charge); if (ionSeriesIsEnabled(IonSeries.zRadical)) addFragment(list, points, "z*-ammonium", i, charge, fragmentation.zRadical(i, charge) - AMMONIUMMONOMASS / charge); if (i < sequenceLength) { if (ionSeriesIsEnabled(IonSeries.x)) addFragment(list, points, "x-ammonium", i, charge, fragmentation.x(i, charge) - AMMONIUMMONOMASS / charge); } } } #endregion //test neutral loss #region phosphate loss if (phosphateLoss == true) { int minNPhosphate = Math.Min(Nphosmodi, numPhosphate); if (minNPhosphate > 0) { if (ionSeriesIsEnabled(IonSeries.a)) { for (int k = 1; k <= minNPhosphate; k++) { addFragment(list, points, "a-" + k + "phos", i, charge, fragmentation.a(i, charge) - k * PHOSPHATEMONOMASS / charge); } } if (ionSeriesIsEnabled(IonSeries.b)) { for (int k = 1; k <= minNPhosphate; k++) { addFragment(list, points, "b-" + k + "phos", i, charge, fragmentation.b(i, charge) - k * PHOSPHATEMONOMASS / charge); } } if (i < sequenceLength) { if (ionSeriesIsEnabled(IonSeries.c)) { for (int k = 1; k <= minNPhosphate; k++) { addFragment(list, points, "c-" + k + "phos", i, charge, fragmentation.c(i, charge) - k * PHOSPHATEMONOMASS / charge); } } } } int minCPhosphate = Math.Min(Cphosmodi, numPhosphate); if (minCPhosphate > 0) { if (ionSeriesIsEnabled(IonSeries.y)) { for (int k = 1; k <= minCPhosphate; k++) { addFragment(list, points, "y-" + k + "phos", i, charge, fragmentation.y(i, charge) - k * PHOSPHATEMONOMASS / charge); } } if (ionSeriesIsEnabled(IonSeries.z)) { for (int k = 1; k <= minCPhosphate; k++) addFragment(list, points, "z-" + k + "phos", i, charge, fragmentation.z(i, charge) - k * PHOSPHATEMONOMASS / charge); } if (ionSeriesIsEnabled(IonSeries.zRadical)) { for (int k = 1; k <= minCPhosphate; k++) addFragment(list, points, "z*-" + k + "phos", i, charge, fragmentation.zRadical(i, charge) - k * PHOSPHATEMONOMASS / charge); } if (i < sequenceLength) { if (ionSeriesIsEnabled(IonSeries.x)) { for (int k = 1; k <= minCPhosphate; k++) addFragment(list, points, "x-" + k + "phos", i, charge, fragmentation.x(i, charge) - k * PHOSPHATEMONOMASS / charge); } } } } #endregion } } } //for basophile fragmentation modeling else if (showBasophileModel) { //clear the panel //annotationPanels.bCheckBox.Checked = false; //annotationPanels.yCheckBox.Checked = false; String peptideSeq = peptide.sequence; int seqLength = peptideSeq.Length; char[] seq = peptideSeq.ToCharArray(); int totalR = 0, totalK = 0, totalH = 0; for (int i = 0; i < seqLength; ++i) { if (seq[i] == 'R') ++totalR; else if (seq[i] == 'K') ++totalK; else if (seq[i] == 'H') ++totalH; } for (int c = 1; c < seqLength; c++) { int totalNR = 0, totalNK = 0, totalNH = 0, totalNL = 0; int totalCR = 0, totalCK = 0, totalCH = 0, totalCL = 0; for (int i = 0; i < c; ++i) { if (seq[i] == 'R') { ++totalNR; } else if (seq[i] == 'K') { ++totalNK; } else if (seq[i] == 'H') { ++totalNH; } } totalNL = c; totalCR = totalR - totalNR; totalCK = totalK - totalNK; totalCH = totalH - totalNH; totalCL = seqLength - totalNL; double y1_logit = 0.1098112 * totalNR + 0.2085831 * totalNK + 0.1512109 * totalNH + 0.0460839 * totalNL - 0.3872417 * totalCR - 0.3684911 * totalCK - 0.1634741 * totalCH - 0.1693931 * totalCL + 1.2632997; double y2_logit = -0.6345364 * totalNR - 0.3365917 * totalNK - 0.4577882 * totalNH - 0.1492703 * totalNL + 0.7738133 * totalCR + 0.6036758 * totalCK + 0.5942542 * totalCH + 0.0701467 * totalCL + 0.0806280; double b1_logit = 0.0801432 * totalNR - 0.1088081 * totalNK - 0.1338220 * totalNH - 0.1413059 * totalNL - 0.3157957 * totalCR - 0.2708274 * totalCK - 0.3703136 * totalCH + 0.0157418 * totalCL + 1.2124699; double b2_logit = 0.8606449 * totalNR + 0.2763119 * totalNK + 0.4969152 * totalNH + 0.0685712 * totalNL - 1.3346995 * totalCR - 1.0977316 * totalCK - 1.0973677 * totalCH - 0.2028884 * totalCL + 1.9355980; if (ionSeriesIsEnabled(IonSeries.b)) { if (b1_logit > -0.5) addFragment(list, points, "b", c, 1, fragmentation.b(c, 1)); if (b2_logit > 0) addFragment(list, points, "b", c, 2, fragmentation.b(c, 2)); } if (ionSeriesIsEnabled(IonSeries.y)) { if (y1_logit > -0.5) addFragment(list, points, "y", seqLength - c, 1, fragmentation.y(seqLength - c, 1)); if (y2_logit > -0.5) addFragment(list, points, "y", seqLength - c, 2, fragmentation.y(seqLength - c, 2)); } //if (b1_logit > -0.5) // if (ionSeriesIsEnabled(IonSeries.b)) // addFragment(list, points, "b", c, 1, fragmentation.b(c, 1)); //if (b2_logit > 0) // if (ionSeriesIsEnabled(IonSeries.b)) // addFragment(list, points, "b", c, 2, fragmentation.b(c, 2)); //if (y1_logit > -0.5) // if (ionSeriesIsEnabled(IonSeries.y)) // addFragment(list, points, "y", seqLength - c, 1, fragmentation.y(seqLength - c, 1)); //if (y2_logit > -0.5) // if (ionSeriesIsEnabled(IonSeries.y)) // addFragment(list, points, "y", seqLength - c, 2, fragmentation.y(seqLength - c, 2)); } } #endregion if ( showLadders || showFragmentationSummary) { //test neutral loss //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); string topSeries = ""; string bottomSeries = ""; if (ionSeriesIsEnabled(IonSeries.a)) { topSeries = "a"; if (showLadders) addIonSeries(list, points, peptide, fragmentation, topSeries, bottomSeries); if (showFragmentationSummary) addFragmentationSummary(list, points, peptide, fragmentation, topSeries, bottomSeries); } if (ionSeriesIsEnabled(IonSeries.b)) { topSeries = "b"; if (showLadders) addIonSeries(list, points, peptide, fragmentation, topSeries, bottomSeries); if (showFragmentationSummary) addFragmentationSummary(list, points, peptide, fragmentation, topSeries, bottomSeries); } if (ionSeriesIsEnabled(IonSeries.c)) { topSeries = "c"; if (showLadders) addIonSeries(list, points, peptide, fragmentation, topSeries, bottomSeries); if (showFragmentationSummary) addFragmentationSummary(list, points, peptide, fragmentation, topSeries, bottomSeries); } if (ionSeriesIsEnabled(IonSeries.x)) { bottomSeries = "x"; if (showLadders) addIonSeries(list, points, peptide, fragmentation, topSeries, bottomSeries); if (showFragmentationSummary) addFragmentationSummary(list, points, peptide, fragmentation, topSeries, bottomSeries); } if (ionSeriesIsEnabled(IonSeries.y)) { bottomSeries = "y"; if (showLadders) addIonSeries(list, points, peptide, fragmentation, topSeries, bottomSeries); if (showFragmentationSummary) addFragmentationSummary(list, points, peptide, fragmentation, topSeries, bottomSeries); } if (ionSeriesIsEnabled(IonSeries.z)) { bottomSeries = "z"; if (showLadders) addIonSeries(list, points, peptide, fragmentation, topSeries, bottomSeries); if (showFragmentationSummary) addFragmentationSummary(list, points, peptide, fragmentation, topSeries, bottomSeries); } if (ionSeriesIsEnabled(IonSeries.zRadical)) { bottomSeries = "z*"; if (showLadders) addIonSeries(list, points, peptide, fragmentation, topSeries, bottomSeries); if (showFragmentationSummary) addFragmentationSummary(list, points, peptide, fragmentation, topSeries, bottomSeries); } } 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; // TODO: fragmentInfoGridView is slow: make it faster, optional, or both! annotationPanels.fragmentInfoGridView.SuspendLayout(); if( ionSeries > IonSeries.Auto ) { if( annotationPanels.fragmentInfoGridView.Columns.Count == 0 ) { 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", "seq"); 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() + ")" : "")); 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()); } //add my code in between //the purpose is to switch the fragmentInfoGridView table into a html //to solve the bug that the table can be copied, but the bold font information can not be copied //basically, a stringbuilder object is created and going to copy values, formats from gridview, and then output //currently the html output is only stored in local, and I am trying to adapt it into a applet-like viewer. //first a stringbuilder is created StringBuilder sb_original = new StringBuilder(); //Setting HTML and table tags sb_original.Append("<html>"); sb_original.Append("<head>"); sb_original.Append("<title>fragmentGridView2HTML</title>"); sb_original.Append("</head>"); sb_original.Append("<body>"); sb_original.Append("<br>"); sb_original.AppendLine("<" + "table border='2' cellpadding='1' cellspacing='1'>"); sb_original.AppendLine("<tr>"); //setting table headers //make them bold for (int i = 0; i < annotationPanels.fragmentInfoGridView.Columns.Count; i++) { sb_original.AppendLine("<th>" + annotationPanels.fragmentInfoGridView.Columns[i].HeaderText + "</th>"); } sb_original.AppendLine("</tr>"); //starting copying cells to html foreach( DataGridViewRow row in annotationPanels.fragmentInfoGridView.Rows ) { sb_original.AppendLine("<tr>"); row.Height = row.InheritedStyle.Font.Height + 2; foreach( DataGridViewCell cell in row.Cells ) { if (!(cell.Value is double)) { //note: added two line here sb_original.AppendLine("<td>" + cell.FormattedValue + "</td>"); continue; } double mz = (double) cell.Value; int index = -1; if( points != null ) index = points.FullLowerBound(mz - 0.5); if (index == -1 || points.FullList[index].X > (mz + 0.5)) { //note: added two line here //first is to pass value to sb; //second is to change the cell fontstyle back to regular, if previouly bold sb_original.AppendLine("<td>" + cell.FormattedValue + "</td>"); cell.Style.Font = new Font(annotationPanels.fragmentInfoGridView.Font, FontStyle.Regular); continue; } cell.Style.Font = new Font(annotationPanels.fragmentInfoGridView.Font, FontStyle.Bold); //note: added one line here sb_original.AppendLine("<td><b>" + cell.FormattedValue + "</b></td>"); } } sb_original.AppendLine("</tr>"); sb_original.AppendLine("</body>"); sb_original.AppendLine("</head>"); sb_original.AppendLine("</html>"); //for storation of stringbuilder into local file //test only string file_original = "C:\\Temp\\originalTable.html"; Directory.CreateDirectory(Path.GetDirectoryName(file_original)); TextWriter tw_original = new StreamWriter(file_original); tw_original.WriteLine(sb_original.ToString()); tw_original.Flush(); tw_original.Close(); ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //test neutral loss #region Neutral Loss StringBuilder sb_neutral = new StringBuilder(); if (waterLoss == false && ammoniumLoss == false && phosphateLoss == false) { sb_neutral = sb_original; } else //if any of the neutral loss is clicked { #region if any of the neutral loss is clicked DataGridView neutralLossDataGridView = new DataGridView(); /// #region add first columns part if (ionSeriesIsEnabled(IonSeries.a)) for (int charge = min; charge <= max; ++charge) { neutralLossDataGridView.Columns.Add( "a" + charge.ToString(), "a" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (waterLoss == true) neutralLossDataGridView.Columns.Add( "a" + charge.ToString() + "waterLoss", "a" + (charge > 1 ? "(+" + charge.ToString() + ")-H2O" : "-H2O")); if (ammoniumLoss == true) neutralLossDataGridView.Columns.Add( "a" + charge.ToString() + "ammoniumLoss", "a" + (charge > 1 ? "(+" + charge.ToString() + ")-NH3" : "-NH3")); if (phosphateLoss == true) { for (int k = 1; k<= numPhosphate; k++) { if (k == 1) { neutralLossDataGridView.Columns.Add( "a" + charge.ToString() + "phosphateLoss", "a" + (charge > 1 ? "(+" + charge.ToString() + ")-PHO" : "-PHO")); } else { neutralLossDataGridView.Columns.Add( "a" + charge.ToString() + "phosphateLoss", "a" + (charge > 1 ? "(+" + charge.ToString() + ")-"+k+"PHO" : "-"+k+"PHO")); } } } } if (ionSeriesIsEnabled(IonSeries.b)) for (int charge = min; charge <= max; ++charge) { neutralLossDataGridView.Columns.Add( "b" + charge.ToString(), "b" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (waterLoss == true) neutralLossDataGridView.Columns.Add( "b" + charge.ToString() + "waterLoss", "b" + (charge > 1 ? "(+" + charge.ToString() + ")-H2O" : "-H2O")); if (ammoniumLoss == true) neutralLossDataGridView.Columns.Add( "b" + charge.ToString() + "ammoniumLoss", "b" + (charge > 1 ? "(+" + charge.ToString() + ")-NH3" : "-NH3")); if (phosphateLoss == true) { for (int k = 1; k<= numPhosphate; k++) { if (k == 1) { neutralLossDataGridView.Columns.Add( "b" + charge.ToString() + "phosphateLoss", "b" + (charge > 1 ? "(+" + charge.ToString() + ")-PHO" : "-PHO")); } else { neutralLossDataGridView.Columns.Add( "b" + charge.ToString() + "phosphateLoss", "b" + (charge > 1 ? "(+" + charge.ToString() + ")-" + k + "PHO" : "-" + k + "PHO")); } } } } if (ionSeriesIsEnabled(IonSeries.c)) for (int charge = min; charge <= max; ++charge) { neutralLossDataGridView.Columns.Add( "c" + charge.ToString(), "c" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (waterLoss == true) neutralLossDataGridView.Columns.Add( "c" + charge.ToString() + "waterLoss", "c" + (charge > 1 ? "(+" + charge.ToString() + ")-H2O" : "-H2O")); if (ammoniumLoss == true) neutralLossDataGridView.Columns.Add( "c" + charge.ToString() + "ammoniumLoss", "c" + (charge > 1 ? "(+" + charge.ToString() + ")-NH3" : "-NH3")); if (phosphateLoss == true) { for (int k = 1; k<= numPhosphate; k++) { if (k == 1) { neutralLossDataGridView.Columns.Add( "c" + charge.ToString() + "phosphateLoss", "c" + (charge > 1 ? "(+" + charge.ToString() + ")-PHO" : "-PHO")); } else { neutralLossDataGridView.Columns.Add( "c" + charge.ToString() + "phosphateLoss", "c" + (charge > 1 ? "(+" + charge.ToString() + ")-" + k + "PHO" : "-" + k + "PHO")); } } } } #endregion neutralLossDataGridView.Columns.Add("N", "#"); neutralLossDataGridView.Columns.Add("Sequence", "seq"); neutralLossDataGridView.Columns.Add("C", "#"); /// #region add second columns part if (ionSeriesIsEnabled(IonSeries.x)) for (int charge = min; charge <= max; ++charge) { neutralLossDataGridView.Columns.Add( "x" + charge.ToString(), "x" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (waterLoss == true) neutralLossDataGridView.Columns.Add( "x" + charge.ToString() + "waterLoss", "x" + (charge > 1 ? "(+" + charge.ToString() + ")-H2O" : "-H2O")); if (ammoniumLoss == true) neutralLossDataGridView.Columns.Add( "x" + charge.ToString() + "ammoniumLoss", "x" + (charge > 1 ? "(+" + charge.ToString() + ")-NH3" : "-NH3")); if (phosphateLoss == true) { for (int k = 1; k<= numPhosphate; k++) { if (k == 1) { neutralLossDataGridView.Columns.Add( "x" + charge.ToString() + "phosphateLoss", "x" + (charge > 1 ? "(+" + charge.ToString() + ")-PHO" : "-PHO")); } else { neutralLossDataGridView.Columns.Add( "x" + charge.ToString() + "phosphateLoss", "x" + (charge > 1 ? "(+" + charge.ToString() + ")-" + k + "PHO" : "-" + k + "PHO")); } } } } if (ionSeriesIsEnabled(IonSeries.y)) for (int charge = min; charge <= max; ++charge) { neutralLossDataGridView.Columns.Add( "y" + charge.ToString(), "y" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (waterLoss == true) neutralLossDataGridView.Columns.Add( "y" + charge.ToString() + "waterLoss", "y" + (charge > 1 ? "(+" + charge.ToString() + ")-H2O" : "-H2O")); if (ammoniumLoss == true) neutralLossDataGridView.Columns.Add( "y" + charge.ToString() + "ammoniumLoss", "y" + (charge > 1 ? "(+" + charge.ToString() + ")-NH3" : "-NH3")); if (phosphateLoss == true) { for (int k = 1; k<= numPhosphate; k++) { if (k == 1) { neutralLossDataGridView.Columns.Add( "y" + charge.ToString() + "phosphateLoss", "y" + (charge > 1 ? "(+" + charge.ToString() + ")-PHO" : "-PHO")); } else { neutralLossDataGridView.Columns.Add( "y" + charge.ToString() + "phosphateLoss", "y" + (charge > 1 ? "(+" + charge.ToString() + ")-" + k + "PHO" : "-" + k + "PHO")); } } } } if (ionSeriesIsEnabled(IonSeries.z)) for (int charge = min; charge <= max; ++charge) { neutralLossDataGridView.Columns.Add( "z" + charge.ToString(), "z" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (waterLoss == true) neutralLossDataGridView.Columns.Add( "z" + charge.ToString() + "waterLoss", "z" + (charge > 1 ? "(+" + charge.ToString() + ")-H2O" : "-H2O")); if (ammoniumLoss == true) neutralLossDataGridView.Columns.Add( "z" + charge.ToString() + "ammoniumLoss", "z" + (charge > 1 ? "(+" + charge.ToString() + ")-NH3" : "-NH3")); if (phosphateLoss == true) { for (int k = 1; k<= numPhosphate; k++) { if (k == 1) { neutralLossDataGridView.Columns.Add( "z" + charge.ToString() + "phosphateLoss", "z" + (charge > 1 ? "(+" + charge.ToString() + ")-PHO" : "-PHO")); } else { neutralLossDataGridView.Columns.Add( "z" + charge.ToString() + "phosphateLoss", "z" + (charge > 1 ? "(+" + charge.ToString() + ")-" + k + "PHO" : "-" + k + "PHO")); } } } } if (ionSeriesIsEnabled(IonSeries.zRadical)) for (int charge = min; charge <= max; ++charge) { neutralLossDataGridView.Columns.Add( "z*" + charge.ToString(), "z*" + (charge > 1 ? "(+" + charge.ToString() + ")" : "")); if (waterLoss == true) neutralLossDataGridView.Columns.Add( "z*" + charge.ToString() + "waterLoss", "z*" + (charge > 1 ? "(+" + charge.ToString() + ")-H2O" : "-H2O")); if (ammoniumLoss == true) neutralLossDataGridView.Columns.Add( "z*" + charge.ToString() + "ammoniumLoss", "z*" + (charge > 1 ? "(+" + charge.ToString() + ")-NH3" : "-NH3")); if (phosphateLoss == true) { for (int k = 1; k<= numPhosphate; k++) { if (k == 1) { neutralLossDataGridView.Columns.Add( "z*" + charge.ToString() + "phosphateLoss", "z*" + (charge > 1 ? "(+" + charge.ToString() + ")-PHO" : "-PHO")); } else { neutralLossDataGridView.Columns.Add( "z*" + charge.ToString() + "phosphateLoss", "z*" + (charge > 1 ? "(+" + charge.ToString() + ")-" + k + "PHO" : "-" + k + "PHO")); } } } } #endregion while (neutralLossDataGridView.Rows.Count > sequenceLength) neutralLossDataGridView.Rows.RemoveAt(neutralLossDataGridView.Rows.Count - 1); if (sequenceLength - neutralLossDataGridView.Rows.Count > 0) neutralLossDataGridView.Rows.Add(sequenceLength - neutralLossDataGridView.Rows.Count); char[] aminoAcids = peptide.sequence.ToCharArray(); for (int i = 1; i <= sequenceLength; ++i) { int Nphosmodi = 0; int Cphosmodi = 0; int cTerminalLength = sequenceLength - i + 1; var row = neutralLossDataGridView.Rows[i - 1]; var values = new List<object>(); //define the amino acides that are capable of losing water //AA = S,T,E,D bool nSTED = false; bool cSTED = false; bool nRKQN = false; bool cRKQN = false; for (int index = 0; index < i; index++) { if (aminoAcids[index] == 'S' || aminoAcids[index] == 'T' || aminoAcids[index] == 'E' || aminoAcids[index] == 'D') nSTED = true; if (aminoAcids[index] == 'R' || aminoAcids[index] == 'K' || aminoAcids[index] == 'Q' || aminoAcids[index] == 'N') nRKQN = true; if (Math.Round(modifications[index].monoisotopicDeltaMass()) == 80 && (aminoAcids[index] == 'S' || aminoAcids[index] == 'T' || aminoAcids[index] == 'Y')) Nphosmodi++; } //here is more tricky. since the display is //b1 ----- y(seq-1+1) //b2 ----- y(seq-2+1) for (int index = sequenceLength - 1; index >= i - 1; index--) { if (aminoAcids[index] == 'S' || aminoAcids[index] == 'T' || aminoAcids[index] == 'E' || aminoAcids[index] == 'D') cSTED = true; if (aminoAcids[index] == 'R' || aminoAcids[index] == 'K' || aminoAcids[index] == 'Q' || aminoAcids[index] == 'N') cRKQN = true; if (Math.Round(modifications[index].monoisotopicDeltaMass()) == 80 && (aminoAcids[index] == 'S' || aminoAcids[index] == 'T' || aminoAcids[index] == 'Y')) Cphosmodi++; } int minNPhosphate = Math.Min(numPhosphate, Nphosmodi); int minCPhosphate = Math.Min(numPhosphate, Cphosmodi); if (ionSeriesIsEnabled(IonSeries.a)) for (int charge = min; charge <= max; ++charge) { values.Add(Math.Round(fragmentation.a(i, charge), 3)); if (waterLoss == true) { if (nSTED) values.Add(Math.Round(fragmentation.a(i, charge) - WATERMONOMASS / charge, 3)); else values.Add("-"); } if (ammoniumLoss == true) { if (nRKQN) values.Add(Math.Round(fragmentation.a(i, charge) - AMMONIUMMONOMASS / charge, 3)); else values.Add("-"); } if (phosphateLoss == true) { for (int k = 1; k <= numPhosphate; k++) { if (k <= minNPhosphate) { values.Add(Math.Round(fragmentation.a(i, charge) - k*PHOSPHATEMONOMASS / charge, 3)); } else { values.Add("-"); } } } } if (ionSeriesIsEnabled(IonSeries.b)) for (int charge = min; charge <= max; ++charge) { values.Add(Math.Round(fragmentation.b(i, charge), 3)); if (waterLoss == true) { if (nSTED) values.Add(Math.Round(fragmentation.b(i, charge) - WATERMONOMASS / charge, 3)); else values.Add("-"); } if (ammoniumLoss == true) { if (nRKQN) values.Add(Math.Round(fragmentation.b(i, charge) - AMMONIUMMONOMASS / charge, 3)); else values.Add("-"); } if (phosphateLoss == true) { for (int k = 1; k <= numPhosphate; k++) { if (k <= minNPhosphate) { values.Add(Math.Round(fragmentation.b(i, charge) - k * PHOSPHATEMONOMASS / charge, 3)); } else { values.Add("-"); } } } } if (ionSeriesIsEnabled(IonSeries.c)) for (int charge = min; charge <= max; ++charge) { if (i < sequenceLength) values.Add(Math.Round(fragmentation.c(i, charge), 3)); else values.Add("-"); if (waterLoss == true) { if (nSTED && i < sequenceLength) values.Add(Math.Round(fragmentation.c(i, charge) - WATERMONOMASS / charge, 3)); else values.Add("-"); } if (ammoniumLoss == true) { if (nRKQN && i < sequenceLength) values.Add(Math.Round(fragmentation.c(i, charge) - AMMONIUMMONOMASS / charge, 3)); else values.Add("-"); } if (phosphateLoss == true) { if (i < sequenceLength) { for (int k = 1; k <= numPhosphate; k++) { if (k <= minNPhosphate) { values.Add(Math.Round(fragmentation.c(i, charge) - k * PHOSPHATEMONOMASS / charge, 3)); } else { values.Add("-"); } } } 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(Math.Round(fragmentation.x(sequenceLength - i + 1, charge), 3)); else values.Add("-"); if (waterLoss == true) { if (cSTED && i > 1) values.Add(Math.Round(fragmentation.x(sequenceLength - i + 1, charge) - WATERMONOMASS / charge, 3)); else values.Add("-"); } if (ammoniumLoss == true) { if (cRKQN && i > 1) values.Add(Math.Round(fragmentation.x(sequenceLength - i + 1, charge) - AMMONIUMMONOMASS / charge, 3)); else values.Add("-"); } if (phosphateLoss == true) { if (i > 1) { for (int k = 1; k <= numPhosphate; k++) { if (k <= minCPhosphate) { values.Add(Math.Round(fragmentation.x(sequenceLength - i + 1, charge) - k * PHOSPHATEMONOMASS / charge, 3)); } else { values.Add("-"); } } } else values.Add("-"); } } if (ionSeriesIsEnabled(IonSeries.y)) for (int charge = min; charge <= max; ++charge) { values.Add(Math.Round(fragmentation.y(sequenceLength - i + 1, charge), 3)); if (waterLoss == true) { if (cSTED) values.Add(Math.Round(fragmentation.y(sequenceLength - i + 1, charge) - WATERMONOMASS / charge, 3)); else values.Add("-"); } if (ammoniumLoss == true) { if (cRKQN) values.Add(Math.Round(fragmentation.y(sequenceLength - i + 1, charge) - AMMONIUMMONOMASS / charge, 3)); else values.Add("-"); } if (phosphateLoss == true) { for (int k = 1; k <= numPhosphate; k++) { if (k <= minCPhosphate) { values.Add(Math.Round(fragmentation.y(sequenceLength - i + 1, charge) - k * PHOSPHATEMONOMASS / charge, 3)); } else { values.Add("-"); } } } } if (ionSeriesIsEnabled(IonSeries.z)) for (int charge = min; charge <= max; ++charge) { values.Add(Math.Round(fragmentation.z(sequenceLength - i + 1, charge), 3)); if (waterLoss == true) { if (cSTED) values.Add(Math.Round(fragmentation.z(sequenceLength - i + 1, charge) - WATERMONOMASS / charge, 3)); else values.Add("-"); } if (ammoniumLoss == true) { if (cRKQN) values.Add(Math.Round(fragmentation.z(sequenceLength - i + 1, charge) - AMMONIUMMONOMASS / charge, 3)); else values.Add("-"); } if (phosphateLoss == true) { for (int k = 1; k <= numPhosphate; k++) { if (k <= minCPhosphate) { values.Add(Math.Round(fragmentation.z(sequenceLength - i + 1, charge) - k * PHOSPHATEMONOMASS / charge, 3)); } else { values.Add("-"); } } } } if (ionSeriesIsEnabled(IonSeries.zRadical)) for (int charge = min; charge <= max; ++charge) { values.Add(Math.Round(fragmentation.zRadical(sequenceLength - i + 1, charge), 3)); if (waterLoss == true) { if (cSTED) values.Add(Math.Round(fragmentation.zRadical(sequenceLength - i + 1, charge) - WATERMONOMASS / charge, 3)); else values.Add("-"); } if (ammoniumLoss == true) { if (cRKQN) values.Add(Math.Round(fragmentation.zRadical(sequenceLength - i + 1, charge) - AMMONIUMMONOMASS / charge, 3)); else values.Add("-"); } if (phosphateLoss == true) { for (int k = 1; k <= numPhosphate; k++) { if (k <= minCPhosphate) { values.Add(Math.Round(fragmentation.zRadical(sequenceLength - i + 1, charge) - k * PHOSPHATEMONOMASS / charge, 3)); } else { values.Add("-"); } } } } row.SetValues(values.ToArray()); }//end for //add sb_neutral loss table #region add sb_neutral loss table sb_neutral.Append("<html>"); sb_neutral.Append("<head>"); sb_neutral.Append("<title>neutralLossFragmentGridView2HTML</title>"); sb_neutral.Append("</head>"); sb_neutral.Append("<body>"); sb_neutral.Append("<br>"); sb_neutral.AppendLine("<" + "table border='2' cellpadding='1' cellspacing='1'>"); sb_neutral.AppendLine("<tr>"); for (int i = 0; i < neutralLossDataGridView.Columns.Count; i++) { sb_neutral.AppendLine("<th>" + neutralLossDataGridView.Columns[i].HeaderText + "</th>"); } foreach (DataGridViewRow row in neutralLossDataGridView.Rows) { sb_neutral.AppendLine("<tr>"); #region basepeakthresholding is false if (basePeakThresholding == false) { foreach (DataGridViewCell cell in row.Cells) { if (!(cell.Value is double)) { sb_neutral.AppendLine("<td>" + cell.FormattedValue + "</td>"); continue; } double mz = (double)cell.Value; int index = -1; if (points != null) index = points.FullLowerBound(mz - 0.5); if (index == -1 || points.FullList[index].X > (mz + 0.5)) { sb_neutral.AppendLine("<td>" + cell.FormattedValue + "</td>"); //cell.Style.Font = new Font(annotationPanels.fragmentInfoGridView.Font, FontStyle.Regular); continue; } //cell.Style.Font = new Font(annotationPanels.fragmentInfoGridView.Font, FontStyle.Bold); sb_neutral.AppendLine("<td><b>" + cell.FormattedValue + "</b></td>"); } } #endregion else//basepeakthresholding is true { int columnIndex = 0; foreach (DataGridViewCell cell in row.Cells) { if (neutralLossDataGridView.Columns[columnIndex].HeaderText.Contains("H2O") || neutralLossDataGridView.Columns[columnIndex].HeaderText.Contains("NH3") || neutralLossDataGridView.Columns[columnIndex].HeaderText.Contains("PHO")) { if (!(cell.Value is double)) { sb_neutral.AppendLine("<td>" + cell.FormattedValue + "</td>"); columnIndex++; continue; } double mz = (double)cell.Value; int index = -1; if (points != null) index = points.FullLowerBound(mz - 0.5); if (index == -1 || points.FullList[index].X > (mz + 0.5) || points.FullList[index].Y < cutoff) { sb_neutral.AppendLine("<td>" + cell.FormattedValue + "</td>"); columnIndex++; continue; } sb_neutral.AppendLine("<td><b>" + cell.FormattedValue + "</b></td>"); columnIndex++; } else { if (!(cell.Value is double)) { sb_neutral.AppendLine("<td>" + cell.FormattedValue + "</td>"); columnIndex++; continue; } double mz = (double)cell.Value; int index = -1; if (points != null) index = points.FullLowerBound(mz - 0.5); if (index == -1 || points.FullList[index].X > (mz + 0.5)) { sb_neutral.AppendLine("<td>" + cell.FormattedValue + "</td>"); columnIndex++; continue; } sb_neutral.AppendLine("<td><b>" + cell.FormattedValue + "</b></td>"); columnIndex++; } } } } sb_neutral.AppendLine("</tr>"); sb_neutral.AppendLine("</body>"); sb_neutral.AppendLine("</head>"); sb_neutral.AppendLine("</html>"); #endregion #endregion } //end of else string file_neutral = "C:\\Temp\\neutralLossTable.html"; Directory.CreateDirectory(Path.GetDirectoryName(file_neutral)); TextWriter tw_neutral = new StreamWriter(file_neutral); tw_neutral.WriteLine(sb_neutral.ToString()); tw_neutral.Flush(); tw_neutral.Close(); #endregion } else annotationPanels.fragmentInfoGridView.Rows.Clear(); annotationPanels.fragmentInfoGridView.ResumeLayout(); }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="GraphItem"/> object from which to copy</param> public GraphItem( GraphItem rhs ) { this.Tag = rhs.Tag; this.zOrder = rhs.ZOrder; this.location = rhs.Location; }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="GraphItem"/> object from which to copy</param> public GraphItem(GraphItem rhs) { this.Tag = rhs.Tag; this.zOrder = rhs.ZOrder; this.location = rhs.Location; }
/// <summary> /// Insert a <see cref="GraphItem"/> object into the collection /// at the specified zero-based index location. /// </summary> /// <param name="index">The zero-based index location for insertion.</param> /// <param name="item">The <see cref="GraphItem"/> object that is to be /// inserted.</param> /// <seealso cref="IList.Insert"/> public void Insert(int index, GraphItem item) { List.Insert(index, item); }
/// <summary> /// Add a <see cref="GraphItem"/> object to the <see cref="GraphItemList"/> /// collection at the end of the list. /// </summary> /// <param name="item">A reference to the <see cref="GraphItem"/> object to /// be added</param> /// <seealso cref="IList.Add"/> public GraphItem Add(GraphItem item) { List.Add(item); return(item); }
/// <summary> /// Add a <see cref="GraphItem"/> object to the <see cref="GraphItemList"/> /// collection at the end of the list. /// </summary> /// <param name="item">A reference to the <see cref="GraphItem"/> object to /// be added</param> /// <seealso cref="IList.Add"/> public GraphItem Add( GraphItem item ) { List.Add( item ); return item; }
/// <summary> /// Insert a <see cref="GraphItem"/> object into the collection /// at the specified zero-based index location. /// </summary> /// <param name="index">The zero-based index location for insertion.</param> /// <param name="item">The <see cref="GraphItem"/> object that is to be /// inserted.</param> /// <seealso cref="IList.Insert"/> public void Insert( int index, GraphItem item ) { List.Insert( index, item ); }
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( currentSequence, pwiz.CLI.proteome.ModificationParsing.ModificationParsing_Auto, pwiz.CLI.proteome.ModificationDelimiter.ModificationDelimiter_Brackets ); } catch( Exception ) { return; } string unmodifiedSequence = peptide.sequence; int sequenceLength = unmodifiedSequence.Length; Fragmentation fragmentation = peptide.fragmentation( fragmentMassType == 0 ? true : false, true ); // Keeps track of number of fragments predicted and matched in each ion series numFragmentsMatched.Clear(); numFragmentsPredicted.Clear(); for( int charge = min; charge <= max; ++charge ) { for( int i = 1; i <= sequenceLength; ++i ) { if( a ) addFragment( list, points, "a", i, charge, fragmentation.a( i, charge ) ); if( b ) addFragment( list, points, "b", i, charge, fragmentation.b( i, charge ) ); if( y ) addFragment( list, points, "y", i, charge, fragmentation.y( i, charge ) ); if( z ) addFragment( list, points, "z", i, charge, fragmentation.z( i, charge ) ); if( zRadical ) addFragment( list, points, "z*", i, charge, fragmentation.zRadical( i, charge ) ); if( i < sequenceLength ) { if( c ) addFragment( list, points, "c", i, charge, fragmentation.c( i, charge ) ); if( x ) addFragment( list, points, "x", i, charge, fragmentation.x( i, charge ) ); } } } if( showLadders ) { string topSeries = a ? "a" : b ? "b" : c ? "c" : ""; string bottomSeries = x ? "x" : y ? "y" : z ? "z" : zRadical ? "z*" : ""; addIonSeries( list, points, peptide, fragmentation, topSeries, bottomSeries ); } // fill peptide info table annotationPanels.peptideInfoGridView.Rows.Clear(); var spectrum = ( item as MassSpectrum ).Element; //if( spectrum.precursors.Count > 0 && // spectrum.precursors[0].selectedIons.Count > 0 && // spectrum.precursors[0].selectedIons[0].hasCVParam( pwiz.CLI.cv.CVID.MS_selected_ion_m_z ) && // spectrum.precursors[0].selectedIons[0].hasCVParam( pwiz.CLI.cv.CVID.MS_charge_state ) ) //{ // double selectedMz = (double) spectrum.precursors[0].selectedIons[0].cvParam( pwiz.CLI.cv.CVID.MS_selected_ion_m_z ).value; // int chargeState = (int) spectrum.precursors[0].selectedIons[0].cvParam( pwiz.CLI.cv.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() ); if (spectrum.precursors.Count > 0 && spectrum.precursors[0].selectedIons.Count > 0 && spectrum.precursors[0].selectedIons[0].hasCVParam(pwiz.CLI.cv.CVID.MS_selected_ion_m_z)) { double selectedMz = (double)spectrum.precursors[0].selectedIons[0].cvParam(pwiz.CLI.cv.CVID.MS_selected_ion_m_z).value; // Add xcorr score ZedGraph.IPointList peaks = (item as MassSpectrum).Points; List<ScoringUtils.Peak> rawPeaks = new List<ScoringUtils.Peak>(); for (int i = 0; i < peaks.Count; ++i) rawPeaks.Add(new ScoringUtils.Peak(peaks[i].X, peaks[i].Y)); // Remove the precursor and associated neutral loss peaks ScoringUtils.erasePrecursorIons(selectedMz, ref rawPeaks); //selectedMz = precursorMz if (spectrum.precursors[0].selectedIons[0].hasCVParam(pwiz.CLI.cv.CVID.MS_charge_state)) // known precursor charge state { int chargeState = (int)spectrum.precursors[0].selectedIons[0].cvParam(pwiz.CLI.cv.CVID.MS_charge_state).value; double calculatedMass = (precursorMassType == 0 ? peptide.monoisotopicMass(chargeState) : peptide.molecularWeight(chargeState)) * chargeState; double observedMass = selectedMz * chargeState; // compute XCorr double precursorMH = (selectedMz * chargeState) - ((chargeState - 1) * 1.007276); double xcorr = ScoringUtils.computeXCorr(rawPeaks, peptide, precursorMH); annotationPanels.peptideInfoGridView.Rows.Add("Observed precursor charge:", chargeState, "XCorr:", xcorr); 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 // unknown precursor charge state, assume +2 or +3 { int[] assumedChargeStates = new int[2] { 2, 3 }; foreach (int chargeState in assumedChargeStates) { double calculatedMass = (precursorMassType == 0 ? peptide.monoisotopicMass(chargeState) : peptide.molecularWeight(chargeState)) * chargeState; double observedMass = selectedMz * chargeState; // compute XCorr double precursorMH = (selectedMz * chargeState) - ((chargeState - 1) * 1.007276); double xcorr = ScoringUtils.computeXCorr(rawPeaks, peptide, precursorMH); annotationPanels.peptideInfoGridView.Rows.Add("Assumed precursor charge:", chargeState, "XCorr:", xcorr); //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()); // Adds number of fragments matched/predicted in each ion series foreach(var ionSeries in numFragmentsMatched.Keys) annotationPanels.peptideInfoGridView.Rows.Add( ionSeries+" (matched/predicted):", numFragmentsMatched[ionSeries].Count +"/" + numFragmentsPredicted[ionSeries].Count); annotationPanels.peptideInfoGridView.Columns[1].DefaultCellStyle.Format = "F4"; foreach( DataGridViewRow row in annotationPanels.peptideInfoGridView.Rows ) row.Height = row.InheritedStyle.Font.Height + 2; annotationPanels.fragmentInfoGridView.SuspendLayout(); if( a || b || c || x || y || z || zRadical ) { if( annotationPanels.fragmentInfoGridView.Columns.Count == 0 ) { #region Add columns for fragment types if( a ) for( int charge = min; charge <= max; ++charge ) annotationPanels.fragmentInfoGridView.Columns.Add( "a" + charge.ToString(), "a" + ( charge > 1 ? "(+" + charge.ToString() + ")" : "" ) ); if( b ) for( int charge = min; charge <= max; ++charge ) annotationPanels.fragmentInfoGridView.Columns.Add( "b" + charge.ToString(), "b" + ( charge > 1 ? "(+" + charge.ToString() + ")" : "" ) ); if( 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( x ) for( int charge = min; charge <= max; ++charge ) annotationPanels.fragmentInfoGridView.Columns.Add( "x" + charge.ToString(), "x" + ( charge > 1 ? "(+" + charge.ToString() + ")" : "" ) ); if( y ) for( int charge = min; charge <= max; ++charge ) annotationPanels.fragmentInfoGridView.Columns.Add( "y" + charge.ToString(), "y" + ( charge > 1 ? "(+" + charge.ToString() + ")" : "" ) ); if( z ) for( int charge = min; charge <= max; ++charge ) annotationPanels.fragmentInfoGridView.Columns.Add( "z" + charge.ToString(), "z" + ( charge > 1 ? "(+" + charge.ToString() + ")" : "" ) ); if( 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( a ) for( int charge = min; charge <= max; ++charge ) values.Add( fragmentation.a( i, charge ) ); if( b ) for( int charge = min; charge <= max; ++charge ) values.Add( fragmentation.b( i, charge ) ); if( 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( x ) for( int charge = min; charge <= max; ++charge ) if( i > 1 ) values.Add( fragmentation.x( cTerminalLength, charge ) ); else values.Add( "" ); if( y ) for( int charge = min; charge <= max; ++charge ) values.Add( fragmentation.y( cTerminalLength, charge ) ); if( z ) for( int charge = min; charge <= max; ++charge ) values.Add( fragmentation.z( cTerminalLength, charge ) ); if( 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; int index = -1; if( points != null ) index = points.LowerBound( mz - 0.5 ); if( index == -1 || points.ScaledList[index].X > ( mz + 0.5 ) ) continue; cell.Style.Font = new Font( annotationPanels.fragmentInfoGridView.Font, FontStyle.Bold ); } } } else annotationPanels.fragmentInfoGridView.Rows.Clear(); annotationPanels.fragmentInfoGridView.ResumeLayout(); }