Exemplo n.º 1
0
        /// <summary>
        /// Copies the peaks in view to the user's clipboard.
        /// </summary>
        private void SaveToClipboardImplementation()
        {
            if (this.currentSpectrum == null)
            {
                return;
            }

            if (this.peakDataPoints == null)
            {
                this.peakDataPoints = new IList <PeakDataPoint> [0];
            }

            var fragmentPeaks =
                this.peakDataPoints.SelectMany(peaks => peaks)
                .Where(peak => !peak.X.Equals(double.NaN))
                .Where(peak => !peak.Y.Equals(double.NaN))
                .OrderBy(peak => peak.X)
                .ToArray();

            var peakExporter = new SpectrumPeakExporter(string.Empty, null, IcParameters.Instance.ProductIonTolerancePpm);

            peakExporter.ExportToClipBoard(
                this.currentSpectrum,
                fragmentPeaks,
                this.PlotModel.XAxis.ActualMinimum,
                this.PlotModel.XAxis.ActualMaximum);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Prompt user for file path and save spectrum as TSV to that path.
        /// </summary>
        private void SaveAsTsvImplementation()
        {
            if (this.currentSpectrum == null)
            {
                return;
            }

            if (this.peakDataPoints == null)
            {
                this.peakDataPoints = new IList <PeakDataPoint> [0];
            }

            var filePath = this.dialogService.SaveFile(".tsv", @"TSV Files (*.tsv)|*.tsv");

            if (string.IsNullOrWhiteSpace(filePath))
            {
                return;
            }

            var fragmentPeaks =
                this.peakDataPoints.SelectMany(peaks => peaks)
                .Where(peak => !peak.X.Equals(double.NaN))
                .Where(peak => !peak.Y.Equals(double.NaN))
                .OrderBy(peak => peak.X)
                .ToArray();

            var peakExporter = new SpectrumPeakExporter(string.Empty, null, IcParameters.Instance.ProductIonTolerancePpm);

            peakExporter.Export(
                this.currentSpectrum,
                fragmentPeaks,
                filePath);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Prompt user for file path and save data table as list.
        /// </summary>
        private void SaveDataTableImpl()
        {
            var filePath = this.dialogService.SaveFile(".tsv", @"Tab-separated value Files (*.tsv)|*.tsv");

            if (string.IsNullOrWhiteSpace(filePath))
            {
                return;
            }

            try
            {
                var directory = Path.GetDirectoryName(filePath);
                if (directory == null || !Directory.Exists(directory))
                {
                    throw new FormatException(
                              string.Format("Cannot save image due to invalid file name: {0}", filePath));
                }

                var peakExporter = new SpectrumPeakExporter(filePath);
                peakExporter.Export(this.DataTable.Where(p => !p.X.Equals(double.NaN)).ToList());
            }
            catch (Exception e)
            {
                this.dialogService.ExceptionAlert(e);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets a command that exports the spectra peaks to TSV for the selected identifications.
        /// </summary>
        /// <returns>Task that asynchronously exports plots.</returns>
        private async Task ExportPeaksImplementation()
        {
            var folderPath = this.dialogService.OpenFolder();

            if (!string.IsNullOrEmpty(folderPath))
            {
                var exporter = new SpectrumPeakExporter(folderPath);
                await exporter.ExportAsync(this.FilteredData);
            }
        }
Exemplo n.º 5
0
        public void TestMassExportPeakLists(string rawFile, string idFile)
        {
            // Read files
            var lcms         = PbfLcMsRun.GetLcMsRun(rawFile);
            var idFileReader = IdFileReaderFactory.CreateReader(idFile);
            var ids          = idFileReader.Read().ToList();

            foreach (var id in ids)
            {
                id.LcMs        = lcms;
                id.RawFileName = Path.GetFileNameWithoutExtension(rawFile);
            }

            var outputDir = MsPathFinderTest.CreateTestResultDirectory("ExporterTest");

            var exporter = new SpectrumPeakExporter(outputDir.FullName);

            exporter.Export(ids.ToList());
        }
Exemplo n.º 6
0
        public void TestMassExportPeakLists(string rawFile, string idFile)
        {
            // Read files
            var lcms         = PbfLcMsRun.GetLcMsRun(rawFile);
            var idFileReader = IdFileReaderFactory.CreateReader(idFile);
            var ids          = idFileReader.Read();

            foreach (var id in ids)
            {
                id.LcMs        = lcms;
                id.RawFileName = Path.GetFileNameWithoutExtension(rawFile);
            }

            var dirPath = @"C:\Users\wilk011\Documents\DataFiles\TestResults\ExporterTest";

            Directory.CreateDirectory(dirPath);

            var exporter = new SpectrumPeakExporter(dirPath);

            exporter.Export(ids.ToList());
        }