MzMLWriter.AddSpectrum
Converts a spectrum object into a spectrum element.
Remarks
The spectrum joins the run most recently started with AddRun, which must be called first. Spectra are written in the order they are added.
Syntax
| Syntax | Description |
|---|---|
| AddSpectrum(Spectrum spec) | Converts a spectrum object into a spectrum element. |
Parameters
| Name | Type | Description |
|---|---|---|
| spec | Spectrum | The spectrum to add. |
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using Nova.Data;
using Nova.Io.Read;
using Nova.Io.Write;
MzMLWriter writer = new MzMLWriter();
writer.AddInstrumentConfiguration("IC1", null);
writer.AddRun("run1", "IC1");
// Keep only the MS2 spectra.
FileReader reader = new FileReader("DDA.raw", MSFilter.MS2);
foreach (Spectrum spectrum in reader)
{
writer.AddSpectrum(spectrum);
}
writer.Write("DDA_ms2.mzML");
This post is licensed under CC BY 4.0 by the author.