ISpectrum<T>
The contract for a mass spectrum as a series of data points of type T.
Remarks
The contract for a mass spectrum as a series of data points of type T, which is SpecDataPoint or SpecDataPointEx. Implemented by TSpectrum<T>, and through it by Spectrum and SpectrumEx.
Implements
IDisposable
Properties
| Identifier | Type | Description |
|---|---|---|
| Count | int | The number of data points. |
| DataPoints | T[] | The data points. |
Methods
| Method | Returns | Description |
|---|---|---|
| Deserialize(byte[] data) | void | Loads the spectrum from a Serialize payload. |
| GetMz(double mz, double ppm = 0) | int | Finds the data point at an m/z, or the nearest one within a tolerance in parts per million. |
| Resize(int sz) | void | Replaces the data points with a new, empty array of the given size. Existing points are discarded. |
| Serialize() | byte[] | Serializes the spectrum to a byte array, suitable as a pipe message payload. Read back by Deserialize. |
Example
1
2
3
4
5
6
7
8
using Nova.Data;
// Nearest point within 10 ppm of the target, or -1.
int index = spectrum.GetMz(445.1200, 10);
if (index >= 0)
{
Console.WriteLine(spectrum.DataPoints[index].Intensity);
}
Code written against the interface handles both spectrum types.
1
2
3
4
5
6
7
8
9
static double TotalIntensity<T>(ISpectrum<T> spectrum) where T : struct, ISpecDataPoint
{
double total = 0;
for (int i = 0; i < spectrum.Count; i++)
{
total += spectrum.DataPoints[i].Intensity;
}
return total;
}
This post is licensed under CC BY 4.0 by the author.