public void UpdateGrid() { double monoisotopicMass = Workspace.GetAminoAcidFormulas().GetMonoisotopicMass(PeptideAnalysis.Peptide.Sequence); var masses = PeptideAnalysis.GetTurnoverCalculator().GetMzs(0); if (MassColumn == null) { MassColumn = new DataGridViewTextBoxColumn { HeaderText = "Mass", Name = "colMass", Width = 60, ReadOnly = true, }; Columns.Add(MassColumn); } if (ExcludedColumn == null) { ExcludedColumn = new DataGridViewCheckBoxColumn { HeaderText = "Excluded", Name = "colExcluded", Width = 50, SortMode = DataGridViewColumnSortMode.NotSortable, }; Columns.Add(ExcludedColumn); } if (Rows.Count != PeptideAnalysis.GetMassCount()) { Rows.Clear(); Rows.Add(PeptideAnalysis.GetMassCount()); for (int iRow = 0; iRow < Rows.Count; iRow++) { Rows[iRow].Tag = iRow; } } for (int iRow = 0; iRow < Rows.Count; iRow++) { var row = Rows[iRow]; var iMass = (int)row.Tag; double massDifference = masses[iMass].Center - monoisotopicMass; var label = massDifference.ToString("0.#"); if (label[0] != '-') { label = "+" + label; } label = "M" + label; row.Cells[MassColumn.Index].Value = label; row.Cells[MassColumn.Index].ToolTipText = "Mass:" + masses[iMass]; row.Cells[MassColumn.Index].Style.BackColor = TracerChromatogramForm.GetColor(iRow, Rows.Count); row.Cells[ExcludedColumn.Index].Value = ExcludedMasses.IsMassExcluded(iMass); } }
protected virtual ICollection <int> GetSelectedMasses() { var result = new List <int>(); int massCount = PeptideAnalysis.GetMassCount(); for (int i = 0; i < massCount; i++) { result.Add(i); } return(result); }
void DisplaySpectrum(int scanIndex) { if (!TopographForm.Instance.EnsureMsDataFile(PeptideFileAnalysis.MsDataFile, true)) { return; } SpectrumForm spectrumForm; spectrumForm = new SpectrumForm(PeptideFileAnalysis.MsDataFile) { ScanIndex = scanIndex, }; spectrumForm.SetPeptideAnalysis(PeptideAnalysis); spectrumForm.Show(TopLevelControl); double minMz = 2000; double maxMz = 0; var selectedCharges = GetSelectedCharges(); var selectedMasses = GetSelectedMasses(); for (int charge = PeptideAnalysis.MinCharge; charge <= PeptideAnalysis.MaxCharge; charge++) { if (selectedCharges.Count > 0 && !selectedCharges.Contains(charge)) { continue; } for (int iMass = 0; iMass < PeptideAnalysis.GetMassCount(); iMass++) { if (selectedMasses.Count > 0 && !selectedMasses.Contains(iMass)) { continue; } var mzRange = PeptideAnalysis.GetMzs()[charge][iMass]; minMz = Math.Min(minMz, mzRange.Min); maxMz = Math.Max(maxMz, mzRange.Max); } } if (minMz <= maxMz) { spectrumForm.Zoom(minMz - 1, maxMz + 1); } }
protected void ShowChromatograms() { if (MsGraphControl.GraphPane == null) { // TODO: How can this happen? return; } MsGraphControl.GraphPane.GraphObjList.Clear(); MsGraphControl.GraphPane.CurveList.Clear(); var selectedCharges = gridIntensities.GetSelectedCharges(); var selectedMasses = gridIntensities.GetSelectedMasses(); var chromatograms = PeptideFileAnalysis.ChromatogramSet; var mzRanges = PeptideFileAnalysis.TurnoverCalculator.GetMzs(0); var monoisotopicMass = Workspace.GetAminoAcidFormulas().GetMonoisotopicMass(PeptideAnalysis.Peptide.Sequence); for (int charge = PeptideAnalysis.MinCharge; charge <= PeptideAnalysis.MaxCharge; charge++) { if (selectedCharges.Count > 0 && !selectedCharges.Contains(charge)) { continue; } for (int iMass = 0; iMass < PeptideAnalysis.GetMassCount(); iMass++) { var mzKey = new MzKey(charge, iMass); double massDifference = mzRanges[iMass].Center - monoisotopicMass; var label = massDifference.ToString("0.#"); if (label[0] != '-') { label = "+" + label; } label = "M" + label; label += new string('+', charge); if (selectedMasses.Count > 0) { if (!selectedMasses.Contains(iMass)) { continue; } } else { if (ExcludedMasses.IsExcluded(mzKey.MassIndex)) { continue; } } ChromatogramSetData.Chromatogram chromatogram; if (!chromatograms.Chromatograms.TryGetValue(mzKey, out chromatogram)) { continue; } var graphItem = new ChromatogramGraphItem { Title = label, }; graphItem.Color = TracerChromatogramForm.GetColor(iMass, PeptideAnalysis.GetMassCount()); var mzRange = PeptideFileAnalysis.TurnoverCalculator.GetMzs(mzKey.Charge)[mzKey.MassIndex]; var massAccuracy = PeptideAnalysis.GetMassAccuracy(); var intensities = chromatogram.ChromatogramPoints.Select(point => point.GetIntensity(mzRange, massAccuracy)).ToArray(); if (Smooth) { intensities = TracerChromatograms.SavitzkyGolaySmooth(intensities); } PointPairList points = new PointPairList(chromatograms.Times, intensities); graphItem.Points = points; var lineItem = (LineItem)MsGraphControl.AddGraphItem(MsGraphControl.GraphPane, graphItem); lineItem.Line.Style = TracerChromatogramForm.GetDashStyle(charge - PeptideAnalysis.MinCharge); lineItem.Line.Width = Settings.Default.ChromatogramLineWidth; lineItem.Label.IsVisible = false; } } }