Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

File and DB access

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 MzDataFile and MzXMLFile to convert one format into another using MSExperiment to hold the temporary data:

Int main()
{
  
  MzXMLFile mzxml;
  MzDataFile mzdata;

  // temporary data storage
  MSExperiment<RawDataPoint1D> map;

  // convert MzXML to MzData
  mzxml.load("Tutorial_FileIO.mzXML",map);
  mzdata.store("Tutorial_FileIO.mzData",map);
  
  return 0;
} //end of main

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.mzData",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:

Param

Most algorithms of OpenMS and some of the TOPP tools have many parameters. The parameters are stored in instances of Param. This class is similar to a Windows INI files. The actual parameters (type, name and value) are stored in sections. Sections can contain parameters and sub-sections, which leads to a tree-like structure. The values are stored in DataValue, but Param supports only the types string, int and float.
Parameter names are given as a string including the sections and subsections in which ':' is used as a delimiter.

The following example (Tutorial_Param.C) shows how a file description is given.

Int main()
{
  Param param;
  
  param.setValue("file:name","test.xml");
  param.setValue("file:size(MB)",572.3);  
  param.setValue("file:data:min_int",0);
  param.setValue("file:data:max_int",16459);
  
  cout << "Name   : " << (String)(param.getValue("file:name")) << endl;
  cout << "Size   : " << (Real)(param.getValue("file:size(MB)")) << endl;
  cout << "Min int: " << (UInt)(param.getValue("file:data:min_int")) << endl;
  cout << "Max int: " << (UInt)(param.getValue("file:data:max_int")) << endl;
  
  return 0;
} //end of main

Generated Tue Apr 1 15:36:40 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1