SpectrumFileReaderFactory.GetReader

Creates a reader for an MS data file, chosen by its extension, and opens it.


Remarks

A static method. The reader returned is already open; call its Close method when finished.


Syntax

SyntaxDescription
static GetReader(string file, MSFilter filter)Creates a reader for the file, chosen by its extension, and opens it.

Parameters

NameTypeDescription
filestringThe file to open.
filterMSFilterThe MS levels to read.

Returns

TypeDescription
ISpectrumFileReaderA reader with the file open.

Exceptions

ExceptionCondition
ArgumentExceptionThe file extension is not a recognized format.
SpectrumFileOpenExceptionThe file could not be opened or indexed.

Example

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

try
{
  ISpectrumFileReader reader = SpectrumFileReaderFactory.GetReader("DDA.mzML", MSFilter.MS2);
  Spectrum spectrum = reader.GetSpectrum();
  reader.Close();
}
catch (SpectrumFileOpenException ex)
{
  Console.WriteLine(ex.Message);
}
This post is licensed under CC BY 4.0 by the author.

Trending Tags