コード例 #1
0
        public override bool GetChromatogram(int id, Target modifiedSequence, Color color, out ChromExtra extra, out TimeIntensities timeIntensities)
        {
            // No mass errors in SRM
            if (_readChromatograms == 0)
            {
                _readStartTime = DateTime.UtcNow; // Said to be 117x faster than Now and this is for a delta
            }

            float[] times, intensities;
            if (!_globalChromatogramExtractor.GetChromatogram(id, out times, out intensities))
            {
                _dataFile.GetChromatogram(id, out string chromId, out times, out intensities);
            }

            timeIntensities = new TimeIntensities(times, intensities, null, null);

            // Assume that each chromatogram will be read once, though this may
            // not always be completely true.
            _readChromatograms++;

            if (!System.Diagnostics.Debugger.IsAttached)
            {
                double predictedMinutes = ExpectedReadDurationMinutes;
                if (_readMaxMinutes > 0 && predictedMinutes > _readMaxMinutes)
                {
                    // TODO: This warning isn't checked in the command line version of Skyline.  Maybe we should do that.
                    if (Status is ChromatogramLoadingStatus)
                    {
                        Status =
                            ((ChromatogramLoadingStatus)Status).ChangeWarningMessage(Resources.ChromatogramDataProvider_GetChromatogram_This_import_appears_to_be_taking_longer_than_expected__If_importing_from_a_network_drive__consider_canceling_this_import__copying_to_local_disk_and_retrying_);
                    }
                }
            }

            if (_readChromatograms < _chromIds.Count)
            {
                SetPercentComplete(50 + _readChromatograms * 50 / _chromIds.Count);
            }

            int index = _chromIndices[id];

            extra = new ChromExtra(index, -1);  // TODO: is zero the right value?

            // Display in AllChromatogramsGraph
            var loadingStatus = Status as ChromatogramLoadingStatus;

            if (loadingStatus != null)
            {
                loadingStatus.Transitions.AddTransition(
                    modifiedSequence,
                    color,
                    index, -1,
                    times,
                    intensities);
            }
            return(true);
        }
コード例 #2
0
        public void ShimadzuFileTypeTest()
        {
            var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);

            string extRaw = ExtensionTestContext.ExtShimadzuRaw;

            // Do file type check
            using (var msData = new MsDataFileImpl(testFilesDir.GetTestPath("BSA-digest__MRM_optimisation_SL_scheduled_001" + extRaw)))
            {
                Assert.IsTrue(msData.IsShimadzuFile);

                // check time is minutes
                msData.GetChromatogram(msData.ChromatogramCount - 1, out _, out float[] times, out _);
                Assert.AreEqual(new KeyValuePair <float, float>(5.908167f, 8.905833f), new KeyValuePair <float, float>(times.First(), times.Last()));
            }
        }
コード例 #3
0
        public bool GetChromatogram(int index, out float[] times, out float[] intensities)
        {
            index -= IndexOffset;

            if (QcTraceByIndex.TryGetValue(index, out MsDataFileImpl.QcTrace qcTrace))
            {
                times       = MsDataFileImpl.ToFloatArray(qcTrace.Times);
                intensities = MsDataFileImpl.ToFloatArray(qcTrace.Intensities);
            }
            else if (index == TicChromatogramIndex || index == BpcChromatogramIndex)
            {
                _dataFile.GetChromatogram(index, out _, out times, out intensities, true);
            }
            else
            {
                times = intensities = null;
            }

            return(times != null);
        }
コード例 #4
0
        public override bool GetChromatogram(int id, Target modifiedSequence, Color color, out ChromExtra extra, out TimeIntensities timeIntensities)
        {
            float[] times, intensities;
            if (!_globalChromatogramExtractor.GetChromatogram(id, out times, out intensities))
            {
                _dataFile.GetChromatogram(id, out _, out times, out intensities);
            }

            timeIntensities = new TimeIntensities(times, intensities, null, null);

            // Assume that each chromatogram will be read once, though this may
            // not always be completely true.
            _readChromatograms++;

            if (_readChromatograms < _chromIds.Count)
            {
                SetPercentComplete(50 + _readChromatograms * 50 / _chromIds.Count);
            }

            int index = _chromIndices[id];

            extra = new ChromExtra(index, -1);  // TODO: is zero the right value?

            // Display in AllChromatogramsGraph
            var loadingStatus = Status as ChromatogramLoadingStatus;

            if (loadingStatus != null)
            {
                loadingStatus.Transitions.AddTransition(
                    modifiedSequence,
                    color,
                    index, -1,
                    times,
                    intensities);
            }
            return(true);
        }
コード例 #5
0
        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;
            }
        }