FileReader
Reads spectra and chromatograms from an MS data file, choosing the reader by file extension.
Remarks
Reads spectra and chromatograms from an MS data file, choosing the reader by file extension. Enumerating it yields each spectrum in file order.
Implements
IEnumerable
Constructors
| Syntax | Description |
|---|---|
| FileReader(MSFilter filter = MSFilter.MS1 | MSFilter.MS2 | MSFilter.MS3) | Creates a reader with no file open. |
| FileReader(string filename, MSFilter filter = MSFilter.MS1 | MSFilter.MS2 | MSFilter.MS3) | Creates a reader and opens the file. |
Properties
| Identifier | Type | Description |
|---|---|---|
| ChromatCount | int | Number of chromatograms in the open file, or 0 for formats that carry none. |
| FileName | string | The name of the file currently being read. |
| FirstScan | int | The scan number of the first spectrum in the file. |
| Format | FileFormat | Identifies the format of the most recently opened file. |
| LastScan | int | The scan number of the last spectrum in the file. |
| MaxRetentionTime | double | The retention time at the end of the run, in minutes. |
| ScanCount | int | The number of spectra in the open file. |
Methods
| Method | Returns | Description |
|---|---|---|
| static CheckFileFormat(string fileName) | FileFormat | Reads a file name string and returns the FileFormat value based on the file extension characters. |
| GetEnumerator() | IEnumerator | Yields each spectrum in the open file in file order, subject to the current filter, then resets the reader. |
| OpenSpectrumFile(string fileName) | bool | Opens a file for reading, closing any file already open. |
| ReadChromatogram(string fileName = “”, int chromatIndex = -1) | Chromatogram | Reads a chromatogram, opening the file first if it is not the current one. |
| ReadSpectrum(string fileName = “”, int scanNumber = -1, bool centroid = true) | Spectrum | Reads a spectrum, opening the file first if it is not the current one. |
| ReadSpectrumEx(string fileName = “”, int scanNumber = -1, bool centroid = true) | SpectrumEx | 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. |
| Reset() | void | Returns to the start of the open file for sequential reading. |
| SetFilter(MSFilter filter) | void | Sets the MS levels to read, for this reader and any file it has open. |
Example
1
2
3
4
5
6
7
8
9
10
using Nova.Io.Read;
using Nova.Data;
// Reads all MS1 scans from a Thermo Fisher Scientific data file
FileReader reader = new FileReader("DDA.raw", MSFilter.MS1);
foreach (Spectrum spec in reader)
{
// Report each scan number and number of data points
Console.WriteLine(spec.ScanNumber + " has " + spec.Count + " data points.");
}
This post is licensed under CC BY 4.0 by the author.