コード例 #1
0
 public MsxDemultiplexer(MsDataFileImpl file, SpectrumFilter filter)
     : base(file, filter)
 {
     _isoMapper = new MsxIsolationWindowMapper();
 }
コード例 #2
0
 public OverlapDemultiplexer(MsDataFileImpl file, SpectrumFilter filter)
     : base(file, filter)
 {
     _isoMapper = new OverlapIsolationWindowMapper();
     _overlapRegionsInApprox = 7;
 }
コード例 #3
0
 public OverlapDemultiplexer(MsDataFileImpl file, SpectrumFilter filter)
     : base(file, filter)
 {
     _isoMapper = new OverlapIsolationWindowMapper();
     _overlapRegionsInApprox = 7;
 }
コード例 #4
0
 public MsxTypeDemultiplexer(MsDataFileImpl file, SpectrumFilter filter)
     : base(file, filter)
 {
 }
コード例 #5
0
        /// <summary>
        /// Process a list of spectra - typically of length one,
        /// but possibly a set of drift bins all with same retention time,
        /// or a set of Agilent ramped-CE Mse scans to be averaged
        /// </summary>
        private void ProcessSpectrumList(MsDataSpectrum[] spectra,
            ChromDataCollectorSet chromMap,
            double rt,
            SpectrumFilter filter,
            string scanId)
        {
            lock (_blockWriter)
            {
                foreach (var spectrum in filter.Extract(rt, spectra))
                {
                    if (_loader.IsCanceled)
                        throw new LoadCanceledException(Status);

                    chromMap.ProcessExtractedSpectrum((float) rt, _collectors, GetScanIdIndex(scanId), spectrum, AddChromCollector);
                }
            }
        }
コード例 #6
0
 public LookaheadContext(SpectrumFilter filter, MsDataFileImpl dataFile)
 {
     _lookAheadIndex = 0;
     _lookAheadDataSpectrum = null;
     _filter = filter;
     _dataFile = dataFile;
     _rt = null;
     _previousDriftTime = 0;
     _lenSpectra = dataFile.SpectrumCount;
 }
コード例 #7
0
        public SpectraChromDataProvider(MsDataFileImpl dataFile,
            ChromFileInfo fileInfo,
            SrmDocument document,
            IRetentionTimePredictor retentionTimePredictor,
            string cachePath, // We'll write tempfiles in this directory
            ProgressStatus status,
            int startPercent,
            int endPercent,
            IProgressMonitor loader)
            : base(fileInfo, status, startPercent, endPercent, loader)
        {
            _document = document;
            _filePath = dataFile.FilePath;
            _cachePath = cachePath;

            // If no SRM spectra, then full-scan filtering must be enabled
            _isSrm = dataFile.HasSrmSpectra;
            if (!_isSrm)
            {
                if (!document.Settings.TransitionSettings.FullScan.IsEnabled)
                    throw new NoFullScanFilteringException(dataFile.FilePath);

                // Only use the retention time predictor on non-SRM data, and only when
                // there are enough transitions to cause performance issues with extracting
                // full-gradient in a single pass, and then trimming.
                if (_document.Settings.TransitionSettings.FullScan.RetentionTimeFilterType == RetentionTimeFilterType.scheduling_windows &&
                    _document.MoleculeTransitionCount > MAX_FULL_GRADIENT_TRANSITIONS)
                {
                    _retentionTimePredictor = retentionTimePredictor;
                }
            }

            // Only mzXML from mzWiff requires the introduction of zero values
            // during interpolation.
            _isProcessedScans = dataFile.IsMzWiffXml;

            UpdatePercentComplete();

            // Create the filter responsible for chromatogram extraction
            bool firstPass = (_retentionTimePredictor != null);
            _filter = new SpectrumFilter(_document, FileInfo.FilePath, new DataFileInstrumentInfo(dataFile),
                _retentionTimePredictor, firstPass);

            if (!_isSrm && (_filter.EnabledMs || _filter.EnabledMsMs))
            {
                // Full-scan filtering should always match a single precursor
                // m/z value to a single precursor node in the document tree,
                // because that is the way the filters are constructed in the
                // first place.
                _isSingleMzMatch = true;
            }

            // Get data object used to graph all of the chromatograms.
            if (_loader.HasUI)
                _allChromData = LoadingStatus.Transitions;

            try
            {
                InitSpectrumReader(dataFile);
                InitChromatogramExtraction();
            }
            catch(Exception)
            {
                // If exception thrown before construction is complete than Dispose will not be called.
                if (_spectra == null)
                    dataFile.Dispose();
                else
                    _spectra.Dispose();

                throw;
            }
        }
コード例 #8
0
        public override bool CompleteFirstPass()
        {
            // Ignore this notification, if there is no retention time predictor
            if (_retentionTimePredictor == null)
                return false;

            ExtractionComplete();
            var dataFile = _spectra.Detach();

            // Start the second pass
            _filter = new SpectrumFilter(_document, FileInfo.FilePath, _filter, _retentionTimePredictor);
            _spectra = null;
            _isSrm = false;

            InitSpectrumReader(dataFile);
            InitChromatogramExtraction();
            return true;
        }
コード例 #9
0
        protected override void DoTest()
        {
            string chorusRequestOutputDirectory;
            if (null != TestContext.TestResultsDirectory)
            {
                chorusRequestOutputDirectory = Path.Combine(TestContext.TestResultsDirectory, "chorusrequests");
                Directory.CreateDirectory(chorusRequestOutputDirectory);
            }
            else
            {
                // When running unit tests under resharper, we have no TestResultsDirectory, so we only send
                // the output to Console.Out.
                chorusRequestOutputDirectory = null;
            }
            var xmlSerializer = new XmlSerializer(typeof(pwiz.Skyline.Model.Results.RemoteApi.GeneratedCode.ChromatogramRequestDocument));

            foreach (var chorusDataSet in ChorusDataSets)
            {
                TestFilesDir testFilesDir = TestFilesDirForUrl(chorusDataSet.SkyZipUrl);
                string skyFileName = Path.GetFileName(testFilesDir.FullPath);
                Assert.IsNotNull(skyFileName, "skyFileName != null");
                StringAssert.EndsWith(skyFileName, ".sky");
                skyFileName = Uri.UnescapeDataString(skyFileName);
                string skyFilePath = Path.Combine(testFilesDir.FullPath, skyFileName);
                RunUI(()=>SkylineWindow.OpenFile(skyFilePath));
                WaitForDocumentLoaded();
                SrmDocument document = null;
                RunUI(()=> { document = SkylineWindow.DocumentUI; });
                Assert.IsNotNull(document);
                SpectrumFilter spectrumFilterData = new SpectrumFilter(document, MsDataFileUri.Parse(""), null);
                var chorusRequestDocument = spectrumFilterData.ToChromatogramRequestDocument();
                Console.Out.WriteLine("***BEGIN {0}.chorusrequest.xml***", chorusDataSet.Name);
                using (var xmlWriter = XmlWriter.Create(Console.Out, new XmlWriterSettings {Encoding = Encoding.UTF8}))
                {
                    xmlSerializer.Serialize(xmlWriter, chorusRequestDocument);
                }
                Console.Out.WriteLine("***END {0}.chorusrequest.xml***", chorusDataSet.Name);
                if (null != chorusRequestOutputDirectory)
                {
                    string outputFile = Path.Combine(chorusRequestOutputDirectory,
                        chorusDataSet.Name + ".chorusrequest.xml");
                    using (var stream = new FileStream(outputFile, FileMode.Create))
                    {
                        xmlSerializer.Serialize(stream, chorusRequestDocument);
                    }
                }
            }
        }
コード例 #10
0
            public Spectra(SrmDocument document, SpectrumFilter filter, ChromatogramLoadingStatus.TransitionData allChromData, MsDataFileImpl dataFile)
            {
                _document = document;
                _filter = filter;
                _dataFile = dataFile;

                _allChromData = allChromData;

                _lookaheadContext = new LookaheadContext(_filter, _dataFile);
                _countSpectra = dataFile.SpectrumCount;

                HasSrmSpectra = dataFile.HasSrmSpectra;

                // If possible, find the maximum retention time in order to scale the chromatogram graph.
                if (_allChromData != null && (_filter.EnabledMsMs || _filter.EnabledMs))
                {
                    var retentionTime = _dataFile.GetStartTime(_countSpectra - 1);
                    if (retentionTime.HasValue)
                    {
                        _allChromData.MaxRetentionTime = (float)retentionTime.Value;
                        _allChromData.MaxRetentionTimeKnown = true;
                        _allChromData.Progressive = true;
                    }
                }
            }
コード例 #11
0
ファイル: MsxTest.cs プロジェクト: lgatto/proteowizard
        public void TestMsx(SrmDocument doc, string dataPath)
        {
            // Load the file and check MsDataFileImpl
            using (var file = new MsDataFileImpl(dataPath))
            {
                var filter = new SpectrumFilter(doc, null, null);
                Assert.IsTrue(filter.EnabledMsMs);
                var demultiplexer = new MsxDemultiplexer(file, filter);
                demultiplexer.ForceInitializeFile();

                // Check that the demultiplexer found the correct multiplexing parameters
                Assert.AreEqual(5, demultiplexer.IsoWindowsPerScan);
                Assert.AreEqual(100, demultiplexer.NumIsoWindows);
                Assert.AreEqual(20, demultiplexer.DutyCycleLength);

                var isoMapper = demultiplexer.IsoMapperTest;
                Assert.AreEqual(100, isoMapper.NumWindows);

                // Check the isolation window mapper responsible for mapping each unique isolation
                // window detected in the file to a unique index
                TestIsolationWindowMapper(isoMapper, file, 4.00182);

                var transBinner = new TransitionBinner(filter, isoMapper);

                // Test creation of a transition binner from a spectrum filter
                TestTransitionBinnerFromFilter(transBinner, isoMapper);
                var testSpectrum = file.GetSpectrum(TEST_SPECTRUM);
                // Generate a transition binner containing a lot of tough cases with
                // overlapping transitions and test
                double[] binnedExpected =
                {
                    0.0, 25160.11261, 18254.06375, 18254.06375, 18254.06375,
                    11090.00577, 19780.18628, 19780.18628
                };
                var transBinnerOverlap = TestTransitionBinnerOverlap(testSpectrum, isoMapper, binnedExpected);

                TestSpectrumProcessor(transBinnerOverlap, isoMapper, file, TEST_SPECTRUM);

                TestPeakIntensityCorrection(testSpectrum, isoMapper,
                                            demultiplexer);
                int[] intensityIndices = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 290, 291, 292, 293, 294, 295, 296 };
                double[] intensityValues =
                {
                    0.0, 0.0, 0.0, 0.0, 142.95, 349.75,
                    542.87, 511.77, 248.4, 0.0, 49.28,
                    1033.65, 278.56, 0.0, 0.0, 0.0,
                    0.0, 0.0
                };
                // Test demultiplexing of a real spectrum
                TestSpectrumDemultiplex(demultiplexer, TEST_SPECTRUM, testSpectrum, intensityIndices, intensityValues, 0);
            }
        }
コード例 #12
0
ファイル: MsxTest.cs プロジェクト: lgatto/proteowizard
        public void TestOverlap(SrmDocument doc, string dataPath)
        {
            // Load the file and check MsDataFileImpl
            using (var file = new MsDataFileImpl(dataPath))
            {
                var filter = new SpectrumFilter(doc, null, null);
                Assert.IsTrue(filter.EnabledMsMs);
                var demultiplexer = new OverlapDemultiplexer(file, filter);
                demultiplexer.ForceInitializeFile();

                // Check that the demultiplexer found the correct multiplexing parameters
                Assert.AreEqual(1, demultiplexer.IsoWindowsPerScan);
                Assert.AreEqual(40, demultiplexer.NumIsoWindows);
                Assert.AreEqual(41, demultiplexer.NumDeconvRegions);

                var isoMapper = demultiplexer.IsoMapperTest;

                // Basic checks of IsolationWindowMapper
                TestIsolationWindowMapper(isoMapper, file, 20.009);
                // Checks of overlap-specific functionality in IsolationWindowMapper
                TestOverlapIsolationWindowMapper(isoMapper, file);
                var transBinner = new TransitionBinner(filter, isoMapper);

                // Test creation of a transition binner from a spectrum filter
                TestTransitionBinnerFromFilter(transBinner, isoMapper);
                var testSpectrum = file.GetSpectrum(TEST_SPECTRUM_OVERLAP);
                // Generate a transition binner containing a lot of tough cases with
                // overlapping transitions and test
                double[] binnedExpected =
                    {
                        0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0
                    };
                var transBinnerOverlap = TestTransitionBinnerOverlap(testSpectrum, isoMapper, binnedExpected);

                TestSpectrumProcessor(transBinnerOverlap, isoMapper, file, TEST_SPECTRUM_OVERLAP);
                int[] intensityIndices = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 290, 291, 292, 293, 294, 295, 296};
                double[] intensityValues =
                    {
                        0.0, 0.0, 0.0, 0.0, 4545.85, 15660.49,
                        35050.01, 56321.66, 62715.75, 43598.31, 23179.42,
                        2745.94, 3870.54, 4060.16, 3148.17, 1656.38,
                        0.0, 0.0
                    };
                // Test demultiplexing of a real spectrum
                TestSpectrumDemultiplex(demultiplexer, TEST_SPECTRUM_OVERLAP, testSpectrum, intensityIndices,
                                        intensityValues, 0);
            }
        }
コード例 #13
0
ファイル: MsxDemultiplexer.cs プロジェクト: zrolfs/pwiz
 public MsxOverlapDemultiplexer(MsDataFileImpl file, SpectrumFilter filter)
     : base(file, filter)
 {
     _isoMapper = new OverlapIsolationWindowMapper();
 }
コード例 #14
0
ファイル: MsxDemultiplexer.cs プロジェクト: zrolfs/pwiz
 public MsxTypeDemultiplexer(MsDataFileImpl file, SpectrumFilter filter)
     : base(file, filter)
 {
 }
コード例 #15
0
 private void btnExport_Click(object sender, EventArgs e)
 {
     string strReferenceFile = (string) comboBoxReferenceFile.SelectedItem;
     string strSaveFileName = string.Empty;
     if (!string.IsNullOrEmpty(_documentFilePath))
     {
         strSaveFileName = Path.GetFileNameWithoutExtension(_documentFilePath);
     }
     if (!string.IsNullOrEmpty(strReferenceFile))
     {
         strSaveFileName += Path.GetFileNameWithoutExtension(strReferenceFile);
     }
     strSaveFileName += ".ChorusRequest.xml"; // Not L10N
     strSaveFileName = strSaveFileName.Replace(' ', '_');
     using (var saveFileDialog = new SaveFileDialog { FileName = strSaveFileName})
     {
         if (saveFileDialog.ShowDialog(this) != DialogResult.OK || string.IsNullOrEmpty(saveFileDialog.FileName))
         {
             return;
         }
         SpectrumFilter spectrumFilterData = new SpectrumFilter(Document, MsDataFileUri.Parse(strReferenceFile), null);
         using (var saver = new FileSaver(saveFileDialog.FileName))
         {
             if (!saver.CanSave(this))
             {
                 return;
             }
             using (var stream = new StreamWriter(saver.SafeName))
             {
                 var xmlSerializer = new XmlSerializer(typeof(Model.Results.RemoteApi.GeneratedCode.ChromatogramRequestDocument));
                 xmlSerializer.Serialize(stream, spectrumFilterData.ToChromatogramRequestDocument());
             }
             saver.Commit();
         }
     }
     Close();
 }