The C# SDK provides a comprehensive set of Parser classes for parsing and processing Aird format mass spectrometry data files. These Parser classes are located in the AirdSDK.Parser namespace and support various mass spectrometry data acquisition modes including DDA, DIA, MRM, PRM, etc.
BaseParser is the base class for all Parser classes, providing common file operations and data parsing functionality.
Main Features:
- File path management and validation
- AirdInfo metadata loading
- Compressor configuration and management
- Random access file reading
Constructors:
// Create parser with index file path
BaseParser parser = new BaseParser("/path/to/index.json");
// Create parser with index file path and AirdInfo
BaseParser parser = new BaseParser("/path/to/index.json", airdInfo);
// Create parser with Aird file path and compressors
BaseParser parser = new BaseParser("/path/to/file.aird", mzCompressor, intCompressor, mobiCompressor, "DDA");Static Methods:
// Automatically select appropriate parser based on file type
BaseParser parser = BaseParser.BuildParser("/path/to/index.json");DDAParser is specifically designed for parsing Data-Dependent Acquisition (DDA) mode mass spectrometry data.
Main Methods:
GetMs1Index()- Get MS1 indexGetAllMs2Index()- Get all MS2 indicesGetMs2IndexMap()- Get MS2 index map keyed by parentNumReadAllToMemory()- Load all DDA data into memory at onceGetMs1SpectraMap()- Return MS1 spectra RT mappingGetSpectraByRtRange()- Get spectra by retention time range
DDAPasefParser is used for parsing DDA-PASEF data with ion mobility separation.
DIAParser is used for parsing Data-Independent Acquisition (DIA) mode mass spectrometry data.
DIAPasefParser is used for parsing DIA-PASEF data with ion mobility separation.
MRMParser is specifically designed for parsing Multiple Reaction Monitoring (MRM) mode chromatography data.
PRMParser is used for parsing Parallel Reaction Monitoring (PRM) mode data.
MSIMaldiParser is used for parsing Mass Spectrometry Imaging (MSI) MALDI data.
ColumnParser provides column-based data parsing functionality.
// 1. Create parser instance
DDAParser parser = new DDAParser("/path/to/dda_data.json");
// 2. Get file information
AirdInfo airdInfo = parser.airdInfo;
Console.WriteLine($"File type: {airdInfo.type}");
// 3. Read data into memory
List<DDAMs> ddaData = parser.ReadAllToMemory();
// 4. Process spectrum data
foreach (DDAMs ddaMs in ddaData)
{
double rt = ddaMs.rt;
Spectrum spectrum = ddaMs.spectrum;
// Process each MS1 spectrum
}
// 5. Release resources
parser.fs?.Close();// Query spectra with retention time between 10-20 minutes
List<DDAMs> spectra = parser.GetSpectraByRtRange(10.0, 20.0, true);
foreach (DDAMs ddaMs in spectra)
{
// Process each spectrum
double[] mzArray = ddaMs.spectrum.mzs;
double[] intensityArray = ddaMs.spectrum.ints;
}// Automatically select appropriate parser based on file type
BaseParser parser = BaseParser.BuildParser("/path/to/index.json");
if (parser is DDAParser ddaParser)
{
// Process DDA data
List<DDAMs> data = ddaParser.ReadAllToMemory();
}
else if (parser is MRMParser mrmParser)
{
// Process MRM data
// ...
}Represents mass spectrometry scan data in DDA mode.
Main Properties:
rt- Retention timespectrum- Spectrum datanum- Scan numbermsLevel- Mass spectrometry levelms2List- MS2 sublist (MS1 only)
Represents a single mass spectrometry spectrum.
Main Properties:
mzs- m/z arrayints- Intensity arrayrt- Retention time
Represents Aird file metadata information.
Main Properties:
type- File type (DDA, DIA, MRM, etc.)indexList- Index listcompressorList- Compressor list
using (DDAParser parser = new DDAParser(filePath))
{
// Use parser
var data = parser.ReadAllToMemory();
// Process data
}
// Resources automatically releasedFor large files, avoid loading all data at once:
// Process data in batches
List<DDAMs> spectra = parser.GetSpectraByRtRange(startRt, endRt, false);try
{
DDAParser parser = new DDAParser(filePath);
if (parser.airdInfo == null)
{
throw new ArgumentException("Invalid Aird file");
}
}
catch (Exception e)
{
Console.WriteLine($"File reading error: {e.Message}");
}A: Use the BaseParser.BuildParser() method, which automatically selects the appropriate parser based on file content.
A: The parser automatically handles data decompression, no manual intervention required.
A: Get complete file metadata through the parser.airdInfo property.
- Batch Processing: Use batch operation methods like
GetSpectraByRtRange()whenever possible - Memory Management: Use streaming processing for large files to avoid memory overflow
- Caching Strategy: Cache frequently accessed data appropriately
- Parallel Processing: Consider parallel processing of different data blocks in multi-core environments
This document is based on C# SDK version: 1.0.0