public void SpectrumData_CombineChannels() { SpectrumData data = SpectrumData.Create( new float[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }, 5, ScaleType.Linear, ScaleType.Linear, 0, 20000 ); var spectrum = data.CombineChannels(new float[] { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f }); Assert.AreEqual(2, spectrum.Count); Assert.AreEqual(5u, spectrum.FrequencyCount); Assert.AreEqual(ScaleType.Linear, spectrum.AmplitudeScale); Assert.AreEqual(ScaleType.Linear, spectrum.FrequencyScale); Assert.AreEqual(0.0f, spectrum.MinFrequency); Assert.AreEqual(20000f, spectrum.MaxFrequency); Assert.AreEqual(4000f, spectrum.FrequencyStep); CollectionAssert.AreEqual(new float[] { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f }, spectrum[0].ToArray()); CollectionAssert.AreEqual(new float[] { 0.6f, 0.7f, 0.8f, 0.9f, 1.0f }, spectrum[1].ToArray()); }
public void SourceConverter_RiseAndFall() { var nextFrame = new VisualizationDataFrame( testFrame.Time.Value.Add(testFrame.Duration), testFrame.Duration, ScalarData.Create(Enumerable.Repeat <float>(1.0f, (int)expectedChannelCount).ToArray()), ScalarData.Create(Enumerable.Repeat <float>(2.0f, (int)expectedChannelCount).ToArray()), SpectrumData.Create( Enumerable.Repeat <float>(1.0f, (int)(expectedChannelCount * expectedFrequencyCount)).ToArray(), expectedChannelCount, ScaleType.Linear, ScaleType.Linear, expectedMinFrequency, expectedMaxFrequency) ); sut.SpectrumRiseTime = TimeSpan.FromMilliseconds(100); sut.SpectrumFallTime = TimeSpan.FromMilliseconds(50); sut.RmsRiseTime = TimeSpan.FromMilliseconds(80); sut.RmsFallTime = TimeSpan.FromMilliseconds(40); sut.PeakRiseTime = TimeSpan.FromMilliseconds(20); sut.PeakFallTime = TimeSpan.FromMilliseconds(200); var data = sut.GetData(); testSource.Frame = nextFrame; data = sut.GetData(); Assert.IsNotNull(data.RMS); Assert.IsNotNull(data.Peak); Assert.IsNotNull(data.Spectrum); }
public void SpectrumData_LogTransform_ZeroResultSizeThrows() { Assert.ThrowsException <ArgumentException>(() => { SpectrumData.CreateEmpty(2, 10, ScaleType.Linear, ScaleType.Linear, 10, 10000).LogarithmicTransform(0, 20, 4000); }); }
public void SpectrumData_LinearTransform_FromFrequencyGTEToFrequencyThrows() { Assert.ThrowsException <ArgumentException>(() => { SpectrumData.CreateEmpty(2, 10, ScaleType.Linear, ScaleType.Linear, 10, 10000).LinearTransform(5, 4000, 4000); }); }
public void SpectrumData_LogTransform_ZeroFromFrequencyThrows() { Assert.ThrowsException <ArgumentException>(() => { SpectrumData.CreateEmpty(2, 10, ScaleType.Linear, ScaleType.Linear, 0, 10000).LogarithmicTransform(5, 0, 4000); }); }
static MsSpectrumGraphObject GetMsSpectrumGraphObject(ICompound compound, Color color, string legend) { string spectrumName = compound.FileName; SpectrumData spectrumData = getSpectrumData(compound); var spectrumGraphObject = new MsSpectrumGraphObject(spectrumData); spectrumGraphObject.DisplaySettings.Color = color; //if (legend != null) // spectrumGraphObject.CreateLegendObject(legend); //else spectrumGraphObject.CreateLegendObject(new List <string> { spectrumData.Name }); spectrumGraphObject.MassOfPrecursorIon = GetMassOfMostAbundantIon(spectrumData); spectrumGraphObject.DisplaySettings.ShowPrecursorIonAnnotation = false; spectrumGraphObject.DisplaySettings.PenSizeFocusedIon = 2f; spectrumGraphObject.DisplaySettings.PenSizeDefaultIon = 1f; // spectrumGraphObject.DisplaySettings.DefaultIonAnnotationFont = GraphicToolsRepository.FontArial10; // spectrumGraphObject.DisplaySettings.FocusedIonAnnotationFont = GraphicToolsRepository.FontArial12Bold; spectrumGraphObject.DisplaySettings.IonAnnotationFormatString = "{0:0.0000}"; spectrumGraphObject.DisplaySettings.IonAnnotationLabelingMode = IonAnnotationLabelingMode.Always; spectrumGraphObject.DisplaySettings.IonAnnotationLabelsMayOverlapIons = true; spectrumGraphObject.DisplaySettings.MaximumNumberOfVisibleIonAnnotationLabels = 20; return(spectrumGraphObject); }
public void SpectrumData_ConvertToDecibels_MinGTEMaxThrows() { Assert.ThrowsException <ArgumentException>(() => { var d = SpectrumData.CreateEmpty(2, 100, ScaleType.Linear, ScaleType.Linear, 0, 20000).ConvertToDecibels(0, 0); }); }
public void SpectrumData_ApplyRiseAndFallToEmpty_WithNullPreviousThrows() { Assert.ThrowsException <ArgumentException>(() => { SpectrumData.ApplyRiseAndFallToEmpty(null, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(1)); }); }
public void SpectrumData_CombineChannels_MapWithLessSizeThanChannelsThrows() { Assert.ThrowsException <ArgumentException>(() => { var d = SpectrumData.CreateEmpty(2, 100, ScaleType.Linear, ScaleType.Linear, 0, 20000).CombineChannels(new float[] { 1 }); }); }
public void SpectrumData_CombineChannels_NullMapThrows() { Assert.ThrowsException <NullReferenceException>(() => { var d = SpectrumData.CreateEmpty(2, 10, ScaleType.Linear, ScaleType.Linear, 0, 20000).CombineChannels(null); }); }
public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false) { if ((_device == null) || isPreview) { return; } lock (SpectrumData) { UpdateLayers(layerModel); if (!SpectrumData.Any()) { return; } var settings = (AudioPropertiesModel)layerModel.Properties; if (settings.Direction == Direction.TopToBottom || settings.Direction == Direction.BottomToTop) { ApplyVertical(settings); } else if (settings.Direction == Direction.LeftToRight || settings.Direction == Direction.RightToLeft) { ApplyHorizontal(settings); } } }
public void SpectrumData_CreateWithValues() { var data = SpectrumData.Create(g_InitialValues, 2, ScaleType.Linear, ScaleType.Linear, 0, 20000); CollectionAssert.AreEqual(g_InitialValues.Take(5).ToArray(), data[0].ToArray()); CollectionAssert.AreEqual(g_InitialValues.Skip(5).ToArray(), data[1].ToArray()); }
public void SpectrumData_LogarithmicTransform() { SpectrumData data = SpectrumData.Create( new float[][] { new float[] { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f } }, ScaleType.Linear, ScaleType.Linear, 0f, 1000f); var log = data.LogarithmicTransform(3, 1, 1000); Assert.AreEqual(1, log.Count); Assert.AreEqual(3u, log.FrequencyCount); Assert.AreEqual(1, log.MinFrequency); Assert.AreEqual(1000, log.MaxFrequency); var expected = new float[] { 0.009495f, 0.1395f, 5.3f }; for (int index = 0; index < log.Count; index++) { Assert.AreEqual(expected[0], log[0][0], 1e-9); Assert.AreEqual(expected[1], log[0][1], 1e-7); Assert.AreEqual(expected[2], log[0][2], 1e-5); } }
public void SpectrumData_ApplyRiseAndFall_WithNEElementCountThrows() { Assert.ThrowsException <ArgumentException>(() => { var p = SpectrumData.CreateEmpty(2, 20, ScaleType.Linear, ScaleType.Linear, 0, 20000); SpectrumData.CreateEmpty(2, 10, ScaleType.Linear, ScaleType.Linear, 0, 20000).ApplyRiseAndFall(p, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)); }); }
public void SpectrumData_CreateArgs_MinF_GT_MaxF() { Assert.ThrowsException <ArgumentException>( () => { var s = SpectrumData.Create(g_InitialValues, 2, ScaleType.Linear, ScaleType.Linear, 30000.0f, 20000f); }, "MinFrequency > MaxFrequency"); }
public void SpectrumData_ApplyRiseAndFall() { var previous = SpectrumData.CreateEmpty(2, 5, ScaleType.Linear, ScaleType.Linear, 0, 20000); var result = ltd.ApplyRiseAndFall(previous, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(1)); CollectionAssert.AreEqual(g_ExpectedRFResult[0], result[0].ToArray()); CollectionAssert.AreEqual(g_ExpectedRFResult[1], result[1].ToArray()); }
public void SpectrumData_CreateArgs_MinFZeroWhenFScaleLog() { Assert.ThrowsException <ArgumentException>( () => { var s = SpectrumData.Create(g_InitialValues, 2, ScaleType.Linear, ScaleType.Logarithmic, 0.0f, 20000f); }, "MinFrequency == 0 while FrequencyScale == Logarithmic"); }
public void SpectrumData_ApplyRiseAndFallToEmpty_WithLogAmpScalePreviousThrows() { Assert.ThrowsException <ArgumentException>(() => { var p = SpectrumData.CreateEmpty(2, 10, ScaleType.Logarithmic, ScaleType.Linear, 0, 20000); SpectrumData.ApplyRiseAndFallToEmpty(p, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(1)); }); }
public void SpectrumData_ConvertToDecibels() { var testValues = new float[] { 0.0f, 0.1f, 1.0f, 1e-6f, 1e6f, -1 }; var data = SpectrumData.Create(testValues, 1, ScaleType.Linear, ScaleType.Linear, 20, 20000); var logData = data.ConvertToDecibels(-100, 0); CollectionAssert.AreEqual(new float[] { -100.0f, -20.0f, 0.0f, -100.0f, 0.0f, -100.0f }, logData[0].ToArray()); }
public void SpectrumData_CreateArgs_ValuesSizeByChannelSizeIsLessThan1() { Assert.ThrowsException <ArgumentException>( () => { var s = SpectrumData.Create(new float[] { 1, 2 }, 3, ScaleType.Linear, ScaleType.Linear, 0.0f, 20000f); }, "Too few init elements"); }
public void SpectrumData_CreateArgs_ValuesAreNull() { Assert.ThrowsException <NullReferenceException>( () => { var s = SpectrumData.Create(null, 2, ScaleType.Linear, ScaleType.Linear, 0.0f, 20000f); }, "Null initializer"); }
public void SpectrumData_CreateArgs_MinF_Negative() { Assert.ThrowsException <ArgumentException>( () => { var s = SpectrumData.Create(g_InitialValues, 2, ScaleType.Linear, ScaleType.Linear, -1.0f, 20000f); }, "MinFrequency < 0"); }
public void Main01() { DDPicture img = DDPictureLoaders.Standard(@"C:\wb2\20200708_動画テストデータ\ss\0020.png"); // g FileTools.Delete(W_DIR); FileTools.CreateDir(W_DIR); this.SpData_L = new SpectrumData(Path.Combine(R_DIR, "Spectrum_L.csv")); this.SpData_R = new SpectrumData(Path.Combine(R_DIR, "Spectrum_R.csv")); SpectrumScreen0002 spScr = new SpectrumScreen0002(); double z = 1.2; double cLv = -1.0; double fowLv = 0.0; while (this.Frame < this.SpData_L.Rows.Length) { double[] row_L = this.SpData_L.Rows[this.Frame]; double[] row_R = this.SpData_R.Rows[this.Frame]; DDDraw.DrawBegin(img, DDConsts.Screen_W / 2, DDConsts.Screen_H / 2 + 80); DDDraw.DrawZoom(z * 1.353); DDDraw.DrawEnd(); DDCurtain.DrawCurtain(Math.Min(cLv, fowLv)); spScr.Draw(row_L); DDDraw.SetAlpha(0.8); DDDraw.DrawBegin(DDPictureLoaders2.Wrapper(spScr.Screen), DDConsts.Screen_W / 2, 180); DDDraw.DrawZoom(-0.9); DDDraw.DrawEnd(); DDDraw.Reset(); spScr.Draw(row_R); DDDraw.SetAlpha(0.8); DDDraw.DrawBegin(DDPictureLoaders2.Wrapper(spScr.Screen), DDConsts.Screen_W / 2, 900); DDDraw.DrawZoom(0.9); DDDraw.DrawEnd(); DDDraw.Reset(); if (this.SpData_L.Rows.Length - 40 < this.Frame) { DDUtils.Approach(ref fowLv, -1.0, 0.9); } if (40 < this.Frame) { DDUtils.Approach(ref cLv, 1.0, 0.99); } DDUtils.Approach(ref z, 1.0, 0.999); this.MG_EachFrame(); } }
private void CustomVisualizer_Draw(IVisualizer sender, VisualizerDrawEventArgs args) { if (!MainPageViewModel.Current.IsVisualizing) { return; } var drawingSession = (CanvasDrawingSession)args.DrawingSession; float barWidth = canvasWidth / (2 * Consts.SpectrumBarCount); // Calculate spectum metrics var barSize = new Vector2(barWidth, canvasHeight - 2 * barWidth); // Get the data if data exists and source is in play state, else use empty var spectrumData = args.Data != null && Visualizer.Source?.PlaybackState == SourcePlaybackState.Playing ? args.Data.Spectrum.LogarithmicTransform(Consts.SpectrumBarCount, 20f, 20000f) : _emptySpectrum; _previousSpectrum = spectrumData.ApplyRiseAndFall(_previousSpectrum, _rmsRiseTime, _rmsFallTime, _frameDuration); _previousPeakSpectrum = spectrumData.ApplyRiseAndFall(_previousPeakSpectrum, _peakRiseTime, _peakFallTime, _frameDuration); var logSpectrum = _previousSpectrum.ConvertToDecibels(-50, 0); var logPeakSpectrum = _previousPeakSpectrum.ConvertToDecibels(-50, 0); var step = canvasWidth / Consts.SpectrumBarCount; var flaw = (step - barSize.X) / 2; using (var brush = new CanvasLinearGradientBrush(drawingSession, new CanvasGradientStop[] { new CanvasGradientStop() { Color = Context.CurrentColor[0], Position = 0f }, new CanvasGradientStop() { Color = Context.CurrentColor[1], Position = 1f } }) { StartPoint = new Vector2(canvasWidth, 0), EndPoint = new Vector2(0, canvasHeight) }) { // Draw spectrum bars for (int index = 0; index < Consts.SpectrumBarCount; index++) { float barX = step * index + flaw; // use average of 2 channel float spectrumBarHeight = barSize.Y * (1.0f - (logSpectrum[0][index] + logSpectrum[1][index]) / -100.0f); drawingSession.FillRoundedRectangle(barX, canvasHeight - barWidth - spectrumBarHeight, barSize.X, spectrumBarHeight, barSize.X / 2, barSize.X / 2, brush); } } // Spectrum points to draw a slow decay line for (int index = 0; index < Consts.SpectrumBarCount; index++) { float X = (index + 0.5f) * step; float spectrumBarHeight = barSize.Y * (1.0f - (logPeakSpectrum[0][index] + logPeakSpectrum[1][index]) / -100.0f); var decayPoint = new Vector2(X, canvasHeight - barWidth - spectrumBarHeight); drawingSession.FillCircle(decayPoint, barSize.X / 2, Context.CurrentColor[0]); } }
public void SpectrumData_CreateEmpty() { var data = SpectrumData.CreateEmpty(2, 10, ScaleType.Linear, ScaleType.Linear, 0, 20000); Assert.AreEqual(2, data.Count()); Assert.AreEqual(2, data.Count, "Channel count property init"); foreach (var item in data) { Assert.AreEqual(10, item.Count); } Assert.AreEqual(10u, data.FrequencyCount, "Frequency bin count"); Assert.AreEqual(20000.0f, data.MaxFrequency, "Max Frequency property init"); Assert.AreEqual(0.0f, data.MinFrequency, "Min Frequency property init"); Assert.AreEqual(2000.0f, data.FrequencyStep); Assert.AreEqual(ScaleType.Linear, data.AmplitudeScale); data = SpectrumData.CreateEmpty(2, 10, ScaleType.Linear, ScaleType.Logarithmic, 20, 20000); Assert.AreEqual(20, data.MinFrequency); Assert.AreEqual(20000, data.MaxFrequency); Assert.AreEqual(ScaleType.Linear, data.AmplitudeScale); Assert.AreEqual(ScaleType.Logarithmic, data.FrequencyScale); Assert.AreEqual(2, data.Count); Assert.AreEqual(10u, data.FrequencyCount); Assert.AreEqual(1.995262f, data.FrequencyStep, 1e-6f); Assert.ThrowsException <ArgumentException>( () => { var s = SpectrumData.CreateEmpty(0, 10, ScaleType.Linear, ScaleType.Linear, 0.0f, 20000f); }, "Zero channels value"); Assert.ThrowsException <ArgumentException>( () => { var s = SpectrumData.CreateEmpty(2, 0, ScaleType.Linear, ScaleType.Linear, 0.0f, 20000f); }, "Zero elements value"); Assert.ThrowsException <ArgumentException>( () => { var s = SpectrumData.CreateEmpty(0, 10, ScaleType.Linear, ScaleType.Linear, 30000.0f, 20000f); }, "MinFrequency > MaxFrequency"); Assert.ThrowsException <ArgumentException>( () => { var s = SpectrumData.CreateEmpty(0, 10, ScaleType.Linear, ScaleType.Linear, 20000f, 20000f); }, "MinFrequency == MaxFrequency"); Assert.ThrowsException <ArgumentException>( () => { var s = SpectrumData.CreateEmpty(0, 10, ScaleType.Linear, ScaleType.Linear, -1.0f, 20000f); }, "MinFrequency < 0"); Assert.ThrowsException <ArgumentException>( () => { var s = SpectrumData.CreateEmpty(0, 10, ScaleType.Linear, ScaleType.Logarithmic, 0.0f, 20000f); }, "MinFrequency == 0 while FrequencyScale == Logarithmic"); }
public void TestInit() { ltd = SpectrumData.Create( new float [] { 1, 2, 3, 4, 5, 10, 20, 30, 40, 50 }, 2, ScaleType.Linear, ScaleType.Linear, 0, 20000 ); }
public float BinFrequency(SpectrumData data, uint bin) { if (data.FrequencyScale == ScaleType.Linear) { return(bin * data.FrequencyStep + data.MinFrequency); } else { return(data.MinFrequency * (float)Math.Pow(data.FrequencyStep, bin)); } }
public void SpectrumData_ApplyRiseAndFall_LogAmpScaleThrows() { #if DEBUG Assert.ThrowsException <COMException>( #else Assert.ThrowsException <Exception>( #endif () => { SpectrumData.CreateEmpty(2, 10, ScaleType.Logarithmic, ScaleType.Linear, 0, 20000).ApplyRiseAndFall(null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)); }); }
public void SpectrumData_ConvertToDecibels_WithLogScaleThrows() { #if DEBUG Assert.ThrowsException <COMException>( #else Assert.ThrowsException <Exception>( #endif () => { var d = SpectrumData.CreateEmpty(2, 100, ScaleType.Logarithmic, ScaleType.Linear, 0, 20000).ConvertToDecibels(-100, 0); }); }
public void SpectrumData_CombineChannels_WithLogScaleThrows() { #if DEBUG Assert.ThrowsException <COMException>( #else Assert.ThrowsException <Exception>( #endif () => { var d = SpectrumData.CreateEmpty(2, 10, ScaleType.Logarithmic, ScaleType.Linear, 0, 20000).CombineChannels(new float[] { 1, 1 }); }); }
public void Redisplay() { if (!IsHandleCreated) { return; } if (_inRedisplay) { return; } try { _inRedisplay = true; tbxMinCharge.Text = MinCharge.ToString(); tbxMaxCharge.Text = MaxCharge.ToString(); tbxPeptideSequence.Text = PeptideSequence; cbxShowPeptideMzs.Enabled = !string.IsNullOrEmpty(PeptideSequence); tbxMassAccuracy.Text = MassAccuracy.ToString(); TurnoverCalculator turnoverCalculator = null; if (!string.IsNullOrEmpty(PeptideSequence)) { turnoverCalculator = new TurnoverCalculator(Workspace, PeptideSequence); } msGraphControlEx1.GraphPane.GraphObjList.Clear(); msGraphControlEx1.GraphPane.CurveList.Clear(); if (_spectrumData == null || comboChromatogram.SelectedIndex >= 0 && null == _chromatogramDatas[comboChromatogram.SelectedIndex]) { using (var msDataFileImpl = new MsDataFileImpl(Workspace.GetDataFilePath(MsDataFile.Name))) { if (comboChromatogram.SelectedIndex >= 0 && null == _chromatogramDatas[comboChromatogram.SelectedIndex]) { string chromatogramName; float[] timeArray; float[] intensityArray; msDataFileImpl.GetChromatogram(comboChromatogram.SelectedIndex, out chromatogramName, out timeArray, out intensityArray); _chromatogramDatas[comboChromatogram.SelectedIndex] = new ChromatogramData(chromatogramName, timeArray, intensityArray); } _spectrumData = _spectrumData ?? new SpectrumData(msDataFileImpl, ScanIndex); } } ChromatogramData chromatogram = null; if (comboChromatogram.SelectedIndex >= 0) { chromatogram = _chromatogramDatas[comboChromatogram.SelectedIndex]; } tbxMsLevel.Text = _spectrumData.MsLevel.ToString(); tbxTime.Text = _spectrumData.Time.ToString(); if (chromatogram != null && ScanIndex < chromatogram.TimeArray.Length) { tbxChromatogramRetentionTime.Text = chromatogram.TimeArray[ScanIndex].ToString(); tbxChromatogramIonCurrent.Text = chromatogram.IntensityArray[ScanIndex].ToString(NumberFormat); } else { tbxChromatogramRetentionTime.Text = tbxChromatogramIonCurrent.Text = @"N/A"; } if (cbxShowProfile.Checked && _spectrumData.ProfileMzs != null) { msGraphControlEx1.AddGraphItem(msGraphControlEx1.GraphPane, new SpectrumGraphItem() { Points = new PointPairList(_spectrumData.ProfileMzs, _spectrumData.ProfileIntensities), GraphItemDrawMethod = MSGraphItemDrawMethod.line, Color = Color.Blue, }); } if (_spectrumData.ProfileIntensities != null) { tbxSumOfProfileIntensities.Text = _spectrumData.ProfileIntensities.Sum().ToString(NumberFormat); } else { tbxSumOfProfileIntensities.Text = ""; } tbxCentroidIntensitySum.Text = _spectrumData.CentroidIntensities.Sum().ToString(NumberFormat); var spectrum = new SpectrumGraphItem { Points = new PointPairList(_spectrumData.CentroidMzs, _spectrumData.CentroidIntensities), GraphItemDrawMethod = MSGraphItemDrawMethod.stick, Color = Color.Black }; if (turnoverCalculator != null) { var mzRanges = new Dictionary<MzRange, String>(); double monoisotopicMass = Workspace.GetAminoAcidFormulas().GetMonoisotopicMass(PeptideSequence); double peptideIntensity = 0.0; for (int charge = MinCharge; charge <= MaxCharge; charge ++) { foreach (var mzRange in turnoverCalculator.GetMzs(charge)) { double mass = (mzRange.Center - AminoAcidFormulas.ProtonMass)* charge; double massDifference = mass - monoisotopicMass; var label = massDifference.ToString("0.#"); if (label[0] != '-') { label = "+" + label; } label = "M" + label; label += new string('+', charge); mzRanges.Add(mzRange, label); var chromatogramPoint = MsDataFileUtil.GetPoint(mzRange, _spectrumData.CentroidMzs, _spectrumData.CentroidIntensities); peptideIntensity += chromatogramPoint.GetIntensity(mzRange, MassAccuracy); } } spectrum.MassAccuracy = MassAccuracy; spectrum.MzRanges = mzRanges; tbxPeptideIntensity.Text = peptideIntensity.ToString(NumberFormat); } if (cbxShowCentroids.Checked) { msGraphControlEx1.AddGraphItem(msGraphControlEx1.GraphPane, spectrum); } if (turnoverCalculator != null && cbxShowPeptideMzs.Checked) { double massAccuracy = MassAccuracy; for (int charge = MinCharge; charge <= MaxCharge; charge++) { var mzs = turnoverCalculator.GetMzs(charge); var height = int.MaxValue; foreach (var mzRange in mzs) { double min = mzRange.MinWithMassAccuracy(massAccuracy); double max = mzRange.MaxWithMassAccuracy(massAccuracy); msGraphControlEx1.GraphPane.GraphObjList.Add(new BoxObj(min, height, max - min, height, Color.Goldenrod, Color.Goldenrod) { IsClippedToChartRect = true, ZOrder = ZOrder.F_BehindGrid }); } } } msGraphControlEx1.Invalidate(); } finally { _inRedisplay = false; } }
private void ShowTheoryValues(string PepSeq) { //PepSeq = ValidePepSeq(PepSeq); if (dtaSpectra != "") { string[] lines = dtaSpectra.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines) { if (char.IsDigit(line, 0)) { string[] tokens = line.Split(new string[] { " ", "\t" }, StringSplitOptions.RemoveEmptyEntries); string mz = tokens[0]; string intensity = tokens[1];// line.Substring(sperator); SpectrumData s = new SpectrumData(float.Parse(tokens[0]), float.Parse(tokens[1])); sd.Add(s); mzint mzi = new mzint(); mzi.mz = float.Parse(mz); mzi.intensity = float.Parse(intensity); mzi.bMatched = false; MZS.Add(mzi); } } bFileReaded = true; } string modifiedSeq = PepSeq; PeptideMW PMW = new PeptideMW(PepSeq); float[] Bs = PMW.GetPepFragmentBValues(); float[] Ys = PMW.GetPepFragmentYValues(); PepSeq = ValidePepSeq(PepSeq); int Length = PepSeq.Length; for (int i = 0; i <= Length - 1; i++) { TableRow trValues = new TableRow(); TableCell tcAA = new TableCell(); TableCell tcYA = new TableCell(); float ModifiedWeight = 0.0F; if (HadModifed(i + 1, modifiedSeq, ref ModifiedWeight)) tcAA.Text = string.Format("{0}<sub>{1}</sub>+{2:F2}", PepSeq.Substring(i, 1), i + 1, ModifiedWeight); else tcAA.Text = string.Format("{0}<sub>{1}</sub>", PepSeq.Substring(i, 1), i + 1); tcAA.HorizontalAlign = HorizontalAlign.Left; trValues.Cells.Add(tcAA); /* B format */ float B1; if (i > (Length - 2)) B1 = Bs[0]; else B1 = Bs[i]; if (i < Length - 1) { TableCell tcB1 = new TableCell(); tcB1.Text = string.Format("{0:F2}", B1); if (IsMatch(B1, MZS)) tcB1.ForeColor = B1Color; console.Text += ""; tcB1.HorizontalAlign = HorizontalAlign.Right; trValues.Cells.Add(tcB1); TableCell tcB2 = new TableCell(); tcB2.Text = string.Format("{0:F2}", (B1 - OH)); if (IsMatch(B1 - OH, MZS)) tcB2.ForeColor = B2Color; tcB2.HorizontalAlign = HorizontalAlign.Right; trValues.Cells.Add(tcB2); TableCell tcB3 = new TableCell(); tcB3.Text = string.Format("{0:F2}", (B1 - H2O)); if (IsMatch(B1 - H2O, MZS)) tcB3.ForeColor = B3Color; tcB3.HorizontalAlign = HorizontalAlign.Right; trValues.Cells.Add(tcB3); float B2 = (B1 + 1) / 2; TableCell tc2B = new TableCell(); tc2B.Text = string.Format("{0:F2}", B2); if (IsMatch(B2, MZS)) tc2B.ForeColor = B1Color; tc2B.HorizontalAlign = HorizontalAlign.Right; trValues.Cells.Add(tc2B); trValues.Height = new Unit("20px"); } else { TableCell tcB1 = new TableCell(); tcB1.Text = ""; trValues.Cells.Add(tcB1); TableCell tcB2 = new TableCell(); tcB2.Text = ""; trValues.Cells.Add(tcB2); TableCell tcB3 = new TableCell(); tcB3.Text = ""; trValues.Cells.Add(tcB3); TableCell tc2B = new TableCell(); tc2B.Text = ""; trValues.Cells.Add(tc2B); trValues.Height = new Unit("20px"); } /* Y format */ float Y1; if (i > (Length - 2) || i == 0) Y1 = Ys[0]; else Y1 = Ys[Length - 1 - i]; if (i != 0) { float Y2 = (Y1 + 1) / 2; TableCell tc2Y = new TableCell(); tc2Y.Text = string.Format("{0:F2}", Y2); if (IsMatch(Y2, MZS)) tc2Y.ForeColor = Y1Color; tc2Y.HorizontalAlign = HorizontalAlign.Right; trValues.Cells.Add(tc2Y); TableCell tcY3 = new TableCell(); tcY3.Text = string.Format("{0:F2}", (Y1 - H2O)); if (IsMatch(Y1 - H2O, MZS)) tcY3.ForeColor = Y3Color; tcY3.HorizontalAlign = HorizontalAlign.Right; trValues.Cells.Add(tcY3); TableCell tcY2 = new TableCell(); tcY2.Text = string.Format("{0:F2}", (Y1 - OH)); if (IsMatch(Y1 - OH, MZS)) tcY2.ForeColor = Y2Color; tcY2.HorizontalAlign = HorizontalAlign.Right; trValues.Cells.Add(tcY2); TableCell tcY1 = new TableCell(); tcY1.Text = string.Format("{0:F2}", Y1); if (IsMatch(Y1, MZS)) tcY1.ForeColor = Y1Color; tcY1.HorizontalAlign = HorizontalAlign.Right; trValues.Cells.Add(tcY1); } else { TableCell tcY1 = new TableCell(); tcY1.Text = ""; trValues.Cells.Add(tcY1); TableCell tcY2 = new TableCell(); tcY2.Text = ""; trValues.Cells.Add(tcY2); TableCell tcY3 = new TableCell(); tcY3.Text = ""; trValues.Cells.Add(tcY3); TableCell tc2Y = new TableCell(); tc2Y.Text = ""; trValues.Cells.Add(tc2Y); } if (HadModifed(i + 1, modifiedSeq, ref ModifiedWeight)) tcYA.Text = string.Format("<div class=\"offset9 span3\"><span class=\"pull-left\">{0}<sub>{1}</sub>+{2:F2}</span></div>", PepSeq.Substring(i, 1), Length - i, ModifiedWeight); else tcYA.Text = string.Format("<div class=\"offset9 span3\"><span class=\"pull-left\">{0}<sub>{1}</sub></span></div>", PepSeq.Substring(i, 1), Length - i); tcYA.HorizontalAlign = HorizontalAlign.Right; trValues.Cells.Add(tcYA); tbTheoryValues.Rows.Add(trValues); } }