1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// Flex series file support
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2009 -- Guillaume Belz (guillaume.belz@chu-lyon.fr)
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
// --------------------------------------------------------------------------
24
// $Maintainer: Guillaume Belz$
25
// $Authors: Guillaume Belz$
26
// --------------------------------------------------------------------------
28
#ifndef OPENMS_FORMAT_XMASSFILE_H
29
#define OPENMS_FORMAT_XMASSFILE_H
31
#include <OpenMS/FORMAT/HANDLERS/AcqusHandler.h>
32
#include <OpenMS/FORMAT/HANDLERS/FidHandler.h>
33
#include <OpenMS/CONCEPT/ProgressLogger.h>
34
#include <OpenMS/KERNEL/MSExperiment.h>
39
@brief File adapter for 'XMass Analysis (fid)' files.
41
XMass Analysis files is native format for Bruker spectrometer Flex Series.<br />
42
Each spectrum are saved in one directory. Each directory contains several files.
43
We use 2 files for import in OpenMS :<br />
44
<b>acqus</b> : contains meta data about calibration (conversion for time to mz ratio),
45
instrument specification and acquisition method.<br />
46
<b>fid</b> : contains intensity array. Intensity for each point are coded in 4 bytes integer.
48
@note MZ ratio are calculed with forumla based on article :<br />
49
<i>A database application for pre-processing, storage and comparison of mass spectra
50
derived from patients and controls</i><br />
51
<b>Mark K Titulaer, Ivar Siccama, Lennard J Dekker, Angelique LCT van Rijswijk,
52
Ron MA Heeren, Peter A Sillevis Smitt, and Theo M Luider</b><br />
53
BMC Bioinformatics. 2006; 7: 403<br />
54
http://www.pubmedcentral.nih.gov/picrender.fcgi?artid=1594579&blobtype=pdf<br />
59
class OPENMS_DLLAPI XMassFile
60
: public ProgressLogger
63
/// Default constructor
69
@brief Loads a spectrum from a XMass file.
71
@param filename Name of the XMass file which should be loaded.
72
@param spectrum Spectrum in which the data loaded from the file should be stored.
74
@exception Exception::FileNotFound is thrown if the file could not be read
76
template <class PeakType>
77
void load(const String& filename, MSSpectrum<PeakType>& spectrum)
79
Internal::AcqusHandler acqus(filename.prefix(filename.length()-3) + String("acqus"));
81
Internal::FidHandler fid(filename);
84
throw Exception::FileNotFound(__FILE__, __LINE__, __PRETTY_FUNCTION__, filename);
87
// Delete old spectrum
93
while (spectrum.size() < acqus.getSize())
96
p.setPosition( (typename PeakType::PositionType) acqus.getPosition(fid.getIndex()) );
97
p.setIntensity( (typename PeakType::IntensityType) fid.getIntensity() );
98
spectrum.push_back(p);
104
spectrum.setMSLevel(1);
105
spectrum.setName("Xmass analysis file " + acqus.getParam("$ID_raw"));
106
spectrum.setType(SpectrumSettings::RAWDATA);
107
spectrum.setNativeID("spectrum=xsd:" + acqus.getParam("$ID_raw").remove('<').remove('>'));
108
spectrum.setComment("no comment");
110
InstrumentSettings instrument_settings;
111
instrument_settings.setScanMode(InstrumentSettings::MASSSPECTRUM);
112
instrument_settings.setZoomScan(false);
114
if(acqus.getParam(".IONIZATION MODE") == "LD+")
116
instrument_settings.setPolarity(IonSource::POSITIVE);
118
else if (acqus.getParam(".IONIZATION MODE") == "LD-")
120
instrument_settings.setPolarity(IonSource::NEGATIVE);
124
instrument_settings.setPolarity(IonSource::POLNULL);
126
spectrum.setInstrumentSettings(instrument_settings);
128
AcquisitionInfo acquisition_info;
129
acquisition_info.setMethodOfCombination("Sum of " + acqus.getParam("$NoSHOTS") + " raw spectrum");
130
spectrum.setAcquisitionInfo(acquisition_info);
132
SourceFile source_file;
133
source_file.setNameOfFile("fid");
134
source_file.setPathToFile(filename.prefix(filename.length()-3));
135
source_file.setFileSize(4.0 * acqus.getSize() / 1024 / 1024); // 4 bytes / point
136
source_file.setFileType("Xmass analysis file (fid)");
137
spectrum.setSourceFile(source_file);
139
DataProcessing data_processing;
141
software.setName("FlexControl");
142
String fc_ver = acqus.getParam("$FCVer"); // FlexControlVersion
143
if(fc_ver.hasPrefix("<flexControl "))
145
fc_ver = fc_ver.suffix(' ');
147
if(fc_ver.hasSuffix(">"))
149
fc_ver = fc_ver.prefix('>');
151
software.setVersion(fc_ver);
152
software.setMetaValue("Acquisition method", DataValue(acqus.getParam("$ACQMETH").remove('<').remove('>')));
153
data_processing.setSoftware(software);
154
std::set<DataProcessing::ProcessingAction> actions;
155
actions.insert(DataProcessing::SMOOTHING);
156
actions.insert(DataProcessing::BASELINE_REDUCTION);
157
actions.insert(DataProcessing::CALIBRATION);
158
data_processing.setProcessingActions(actions);
159
data_processing.setCompletionTime(DateTime::now());
161
std::vector<DataProcessing> data_processing_vector;
162
data_processing_vector.push_back(data_processing);
163
spectrum.setDataProcessing(data_processing_vector);
167
@brief Import settings from a XMass file.
169
@param filename File from which the experimental settings should be loaded.
170
@param exp MSExperiment where the experimental settings will be stored.
172
@exception Exception::FileNotFound is thrown if the file could not be opened.
174
template <class PeakType>
175
void importExperimentalSettings(const String& filename, MSExperiment<PeakType>& exp)
177
Internal::AcqusHandler acqus(filename.prefix(filename.length()-3) + String("acqus"));
179
ExperimentalSettings& experimental_settings = exp.getExperimentalSettings();
181
Instrument& instrument = experimental_settings.getInstrument();
182
instrument.setName(acqus.getParam("SPECTROMETER/DATASYSTEM"));
183
instrument.setVendor(acqus.getParam("ORIGIN"));
184
instrument.setModel(acqus.getParam("$InstrID").remove('<').remove('>'));
186
std::vector<IonSource>& ionSourceList = instrument.getIonSources();
187
ionSourceList.clear();
188
ionSourceList.resize(1);
189
if (acqus.getParam(".INLET") == "DIRECT")
191
ionSourceList[0].setInletType(IonSource::DIRECT);
195
ionSourceList[0].setInletType(IonSource::INLETNULL);
196
ionSourceList[0].setIonizationMethod(IonSource::MALDI);
198
if (acqus.getParam(".IONIZATION MODE") == "LD+")
200
ionSourceList[0].setPolarity(IonSource::POSITIVE);
202
else if (acqus.getParam(".IONIZATION MODE") == "LD-")
204
ionSourceList[0].setPolarity(IonSource::NEGATIVE);
208
ionSourceList[0].setPolarity(IonSource::POLNULL);
210
ionSourceList[0].setMetaValue("MALDI target reference", DataValue(acqus.getParam("$TgIDS").remove('<').remove('>')));
211
ionSourceList[0].setOrder(0);
213
std::vector<MassAnalyzer>& massAnalyzerList = instrument.getMassAnalyzers();
214
massAnalyzerList.clear();
215
massAnalyzerList.resize(1);
216
if(acqus.getParam(".SPECTROMETER TYPE") == "TOF")
218
massAnalyzerList[0].setType(MassAnalyzer::TOF);
222
massAnalyzerList[0].setType(MassAnalyzer::ANALYZERNULL);
226
date.set(acqus.getParam("$AQ_DATE").remove('<').remove('>') );
227
experimental_settings.setDateTime(date);
231
@brief Stores a spectrum in a XMass file (not avaible)
233
@exception Exception::FileNotWritable is thrown
235
template <typename SpectrumType>
236
void store(const String& /*filename*/, const SpectrumType& /*spectrum*/)
238
throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
242
} // namespace OpenMS
244
#endif // OPENMS_FORMAT_XMASSFILE_H