Post

ISpectrumFileReader.GetSpectrum

Reads a spectrum from the currently open MS data file.


Remarks

With a scan number, that scan is read, or an empty spectrum if it does not pass the filter. With -1, the next spectrum that passes the filter is read, and an empty spectrum, with ScanNumber 0, marks the end of the file.


Syntax

SyntaxDescription
GetSpectrum(int scanNumber = -1, bool centroid = true)Reads a spectrum from the currently open MS data file.

Parameters

NameTypeDescription
scanNumberintOptional scan number to grab. If omitted (or negative), the next spectrum in the file is loaded.
centroidboolIndicates the preferred peak type. Note that this preference is not guaranteed and should be checked using the Spectrum.Centroid property.

Returns

TypeDescription
SpectrumSpectrum object.

Example

1
2
3
4
5
6
7
8
9
10
11
using Nova.Data;
using Nova.Io.Read;

ISpectrumFileReader reader = SpectrumFileReaderFactory.GetReader("DDA.mzML", MSFilter.MS2);
Spectrum spectrum = reader.GetSpectrum();
while (spectrum.ScanNumber > 0)
{
  Console.WriteLine(spectrum.ScanNumber + ": " + spectrum.Count + " peaks");
  spectrum = reader.GetSpectrum();
}
reader.Close();
This post is licensed under CC BY 4.0 by the author.

Trending Tags