Post

FileReader

Class capable of reading spectra from multiple formats.


Remarks

A versatile class for reading multiple formats of mass spectrometry data. Internally, FileReader implements the SpectrumFileReaderFactory to support all Nova compatible spectra files. Additional functionality has been added beyond the individual file reader classes in Nova.

Implements

IEnumerable


Constructors

SyntaxDescription  
FileReader(MSFilter filter = MSFilter.MS1MSFilter.MS2MSFilter.MS3)Initializes the FileReader class and defaults to parsing all MS, MS/MS, and MS3 scans.
FileReader(string filename,MSFilter filter = MSFilter.MS1MSFilter.MS2MSFilter.MS3)Initializes the FileReader class and opens the requeested file, defaults to parsing all MS, MS/MS, and MS3 scans.

Properties

IdentifierTypeDescription
FileNamestringThe names of the file currently being read, or empty if no file has been opened.
FirstScanNumberintNumber of the first scan event in the file.
LastScanNumberintNumber of the last scan event in the file.
MaxRetentionTimedoubleRetention time (in minutes) of the last scan event in the file.
ScanCountintTotal number of scan events in the file.

Methods

MethodReturnsDescription
CheckFileFormat(string fileName)FileFormatReads a file name string and returns the FileFormat value based on the file extension characters. FormatException thrown if file doesn’t have an exception or the extension isn’t recognized.
Close()voidCloses an open MS data file.
OpenSpectrumFile(string fileName)boolOpens an mzML file and parses the index and meta information.
ReadSpectrum(string filename=””, int scanNumber = -1, bool centroid = true)SpectrumOpens and/or reads the requested spectrum or the next spectrum if a valid scanNumber is not given. Data are returned in centroid, if possible, unless otherwise requested. Providing an empty string for the file name reads from the previously opened data file, or throws an exception if a file has not been previously opened.
ReadSpectrumEx(string filename=””, int scanNumber = -1, bool centroid = true)SpectrumExOpens and/or reads the requested spectrum or the next spectrum if a valid scanNumber is not given, and returns the data in the extended spectrum format. Data are returned in centroid, if possible, unless otherwise requested. Providing an empty string for the file name reads from the previously opened data file, or throws an exception if a file has not been previously opened.
Reset()voidResets the reader to the beginning of the file if sequentially reading the spectra.
SetFilter(MSFilter filter)voidSets the spectrum type filter to the values requested.

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.

Trending Tags