All classes for file and database IO can be found in the FORMAT folder.
File adapter classes
The interface of most file adapter classes is very similar. They implement a load and a store method, that take a file name and the appropriate data structure.
The following example (Tutorial_FileIO.C) demonstrates the use of MzMLFile and MzXMLFile to convert one format into another using MSExperiment to hold the temporary data:
int main(
int argc,
const char** argv)
{
if (argc < 2) return 1;
String tutorial_data_path(argv[1]);
MzXMLFile mzxml;
MzMLFile mzml;
MSExperiment<Peak1D> map;
mzxml.load(tutorial_data_path + "/data/Tutorial_FileIO.mzXML", map);
mzml.store("Tutorial_FileIO.mzML", map);
return 0;
}
- FileHandler
- In order to make the handling of different file types easier, the class FileHandler can be used. It loads a file into the appropriate data structure independently of the file type. The file type is determined from the file extension or the file contents:
MSExperiment<> in;
FileHandler handler();
handler.loadExperiment("input.mzML",in);
DB access
For database access, the class DBAdapter is used. As its interface is very similar to the interface of the file adapters, no example is shown here.
PeakFileOptions
In order to have more control over loading data from files or databases, most adapters can be configured using PeakFileOptions. The following options are available:
- only a specific retention time range is loaded
- only a specific mass-to.charge ratio range is loaded
- only a specific intensity range is loaded
- only spectra with a given MS level are loaded
- only meta data of the whole experiment is loaded (ExperimentalSettings)