Post

Spectrum

A collection of data points acquired during ion analysis.


Remarks

This class is a convenient wrapper around TSpectrum to simplify the coding process and make code more easily readable. It is intended for use to manage most mass spectral scan events.

Implements

ISpectrum, IDisposable


Constructors

SyntaxDescription
Spectrum (int count=0)Initializes the spectrum with a default data point array size of count.

Properties

IdentifierTypeDescription
DataPointsSpecDataPoint[]The array of m/z and intensity pairs that comprise a spectrum.
CountintThe number of data points in the DataPoints array

Methods

MethodReturnsDescription
Deserialize (byte[] data)voidConverts a byte array to the contents of a Spectrum.
Dispose ()voidDisposes of the Spectrum.
GetMz (double mz, double ppm = 0)intReturns the index of the DataPoints array whose m/z value falls within the ppm tolerance of the requested mz value.
Resize (int sz)intResizes, and reinitializes to zero, the DataPoints array of the Spectrum.
Serialize ()byte[]Packages the Spectrum into a byte array for storage or transmission.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Example C# code
using Nova.Io.Read;
using Nova.Data;

int MS1Count=0;
int MS2Count=0;
FileReader reader = new FileReader("TheBestDataEver.mzML",MSFilter.MS1|MSFilter.MS2);
foreach(Spectrum spec in reader)
{
  if(spec.MsLevel==1)
  {
    MS1Count++;
  }
  else
  {
    MS2Count++;
  }
}
Console.WriteLine("There are " + MS1Count + " MS scans and " + MS2Count + " MS/MS scans.");
This post is licensed under CC BY 4.0 by the author.

Trending Tags