Post

FileReader.ReadSpectrumEx

Reads a spectrum with the extended per-peak data, opening the file first if it is not the current one.


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.

Only Thermo RAW files provide the extended data. Other formats leave it at zero.


Syntax

SyntaxDescription
ReadSpectrumEx(string fileName = “”, int scanNumber = -1, bool centroid = true)Reads a spectrum with the extended per-peak data where the format provides it, opening the file first if it is not the current one.

Parameters

NameTypeDescription
fileNamestringThe file to read from, or empty for the current file.
scanNumberintThe scan number, or -1 for the next spectrum.
centroidboolThe preferred peak type. Not guaranteed; check the Spectrum.Centroid property.

Returns

TypeDescription
SpectrumExThe spectrum, or an empty one if it could not be read.

Exceptions

ExceptionCondition
SpectrumFileOpenExceptionA new file could not be opened.

Example

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

FileReader reader = new FileReader(MSFilter.MS1);

// The first call names the file; later calls keep reading it.
SpectrumEx spectrum = reader.ReadSpectrumEx("DDA.raw");
while (spectrum.ScanNumber > 0)
{
  Console.WriteLine(spectrum.ScanNumber + ": " + spectrum.Count + " peaks");
  spectrum = reader.ReadSpectrumEx();
}
This post is licensed under CC BY 4.0 by the author.

Trending Tags