Post

Chromatogram

A run of retention time and intensity data points.


Remarks

A chromatogram: a run of retention time and intensity data points, with the identifier the source gave it.

FileReader.ReadChromatogram returns one, and FileReader.ChromatCount says how many the open file holds.

Implements

IChromatogram


Constructors

SyntaxDescription
Chromatogram(int count = 0)Creates a chromatogram sized for the given number of data points.

Properties

IdentifierTypeDescription
CountintThe number of data points.
DataPointsChromatDataPoint[]The data points. Assigning a new array here directly does not update Count; use Resize.
IDstringThe identifier the source gave this chromatogram, such as “TIC”. Not carried by Serialize.

Methods

MethodReturnsDescription
Deserialize(byte[] data)voidReads the count as a 32-bit integer, then each data point via ChromatDataPoint.Read.
Dispose()voidA no-op beyond marking the instance disposed.
Resize(int sz)voidReplaces the data points with a new, empty array of the given size. Existing points are discarded.
Serialize()byte[]Writes the count as a 32-bit integer, then each data point via ChromatDataPoint.Write.

Example

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

FileReader reader = new FileReader("DDA.mzML");

for (int i = 0; i < reader.ChromatCount; i++)
{
  Chromatogram chromat = reader.ReadChromatogram("", i);
  Console.WriteLine(chromat.ID + ": " + chromat.Count + " points");

  for (int j = 0; j < chromat.Count; j++)
  {
    ChromatDataPoint point = chromat.DataPoints[j];
    Console.WriteLine(point.RT + "\t" + point.Intensity);
  }
}

Assigning DataPoints directly does not update Count, so size a new chromatogram with Resize.

1
2
3
Chromatogram chromat = new Chromatogram();
chromat.Resize(3);
chromat.DataPoints[0] = new ChromatDataPoint { RT = 10.0, Intensity = 1200 };
This post is licensed under CC BY 4.0 by the author.

Trending Tags