Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
XMassFile.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2013.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Guillaume Belz$
32 // $Authors: Guillaume Belz$
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_FORMAT_XMASSFILE_H
36 #define OPENMS_FORMAT_XMASSFILE_H
37 
42 
43 namespace OpenMS
44 {
66  class OPENMS_DLLAPI XMassFile :
67  public ProgressLogger
68  {
69 public:
71  XMassFile();
73  virtual ~XMassFile();
74 
83  template <class PeakType>
84  void load(const String & filename, MSSpectrum<PeakType> & spectrum)
85  {
86  Internal::AcqusHandler acqus(filename.prefix(filename.length() - 3) + String("acqus"));
87 
88  Internal::FidHandler fid(filename);
89  if (!fid)
90  {
91  throw Exception::FileNotFound(__FILE__, __LINE__, __PRETTY_FUNCTION__, filename);
92  }
93 
94  // Delete old spectrum
95  spectrum.clear(true);
96 
97  //temporary variables
98  PeakType p;
99 
100  while (spectrum.size() < acqus.getSize())
101  {
102  //fill peak
103  p.setPosition((typename PeakType::PositionType)acqus.getPosition(fid.getIndex()));
104  p.setIntensity((typename PeakType::IntensityType)fid.getIntensity());
105  spectrum.push_back(p);
106  }
107  fid.close();
108 
109  // import metadata
110  spectrum.setRT(0.0);
111  spectrum.setMSLevel(1);
112  spectrum.setName("Xmass analysis file " + acqus.getParam("$ID_raw"));
114  spectrum.setNativeID("spectrum=xsd:" + acqus.getParam("$ID_raw").remove('<').remove('>'));
115  spectrum.setComment("no comment");
116 
117  InstrumentSettings instrument_settings;
118  instrument_settings.setScanMode(InstrumentSettings::MASSSPECTRUM);
119  instrument_settings.setZoomScan(false);
120 
121  if (acqus.getParam(".IONIZATION MODE") == "LD+")
122  {
123  instrument_settings.setPolarity(IonSource::POSITIVE);
124  }
125  else if (acqus.getParam(".IONIZATION MODE") == "LD-")
126  {
127  instrument_settings.setPolarity(IonSource::NEGATIVE);
128  }
129  else
130  {
131  instrument_settings.setPolarity(IonSource::POLNULL);
132  }
133  spectrum.setInstrumentSettings(instrument_settings);
134 
135  AcquisitionInfo acquisition_info;
136  acquisition_info.setMethodOfCombination("Sum of " + acqus.getParam("$NoSHOTS") + " raw spectrum");
137  spectrum.setAcquisitionInfo(acquisition_info);
138 
139  SourceFile source_file;
140  source_file.setNameOfFile("fid");
141  source_file.setPathToFile(filename.prefix(filename.length() - 3));
142  source_file.setFileSize(4.0 * acqus.getSize() / 1024 / 1024); // 4 bytes / point
143  source_file.setFileType("Xmass analysis file (fid)");
144  spectrum.setSourceFile(source_file);
145 
146  DataProcessing data_processing;
147  Software software;
148  software.setName("FlexControl");
149  String fc_ver = acqus.getParam("$FCVer"); // FlexControlVersion
150  if (fc_ver.hasPrefix("<flexControl "))
151  {
152  fc_ver = fc_ver.suffix(' ');
153  }
154  if (fc_ver.hasSuffix(">"))
155  {
156  fc_ver = fc_ver.prefix('>');
157  }
158  software.setVersion(fc_ver);
159  software.setMetaValue("Acquisition method", DataValue(acqus.getParam("$ACQMETH").remove('<').remove('>')));
160  data_processing.setSoftware(software);
161  std::set<DataProcessing::ProcessingAction> actions;
162  actions.insert(DataProcessing::SMOOTHING);
163  actions.insert(DataProcessing::BASELINE_REDUCTION);
164  actions.insert(DataProcessing::CALIBRATION);
165  data_processing.setProcessingActions(actions);
166  data_processing.setCompletionTime(DateTime::now());
167 
168  std::vector<DataProcessing> data_processing_vector;
169  data_processing_vector.push_back(data_processing);
170  spectrum.setDataProcessing(data_processing_vector);
171  }
172 
181  template <class PeakType>
183  {
184  Internal::AcqusHandler acqus(filename.prefix(filename.length() - 3) + String("acqus"));
185 
186  ExperimentalSettings & experimental_settings = exp.getExperimentalSettings();
187 
188  Instrument & instrument = experimental_settings.getInstrument();
189  instrument.setName(acqus.getParam("SPECTROMETER/DATASYSTEM"));
190  instrument.setVendor(acqus.getParam("ORIGIN"));
191  instrument.setModel(acqus.getParam("$InstrID").remove('<').remove('>'));
192 
193  std::vector<IonSource> & ionSourceList = instrument.getIonSources();
194  ionSourceList.clear();
195  ionSourceList.resize(1);
196  if (acqus.getParam(".INLET") == "DIRECT")
197  {
198  ionSourceList[0].setInletType(IonSource::DIRECT);
199  }
200  else
201  {
202  ionSourceList[0].setInletType(IonSource::INLETNULL);
203  ionSourceList[0].setIonizationMethod(IonSource::MALDI);
204  }
205  if (acqus.getParam(".IONIZATION MODE") == "LD+")
206  {
207  ionSourceList[0].setPolarity(IonSource::POSITIVE);
208  }
209  else if (acqus.getParam(".IONIZATION MODE") == "LD-")
210  {
211  ionSourceList[0].setPolarity(IonSource::NEGATIVE);
212  }
213  else
214  {
215  ionSourceList[0].setPolarity(IonSource::POLNULL);
216  }
217  ionSourceList[0].setMetaValue("MALDI target reference", DataValue(acqus.getParam("$TgIDS").remove('<').remove('>')));
218  ionSourceList[0].setOrder(0);
219 
220  std::vector<MassAnalyzer> & massAnalyzerList = instrument.getMassAnalyzers();
221  massAnalyzerList.clear();
222  massAnalyzerList.resize(1);
223  if (acqus.getParam(".SPECTROMETER TYPE") == "TOF")
224  {
225  massAnalyzerList[0].setType(MassAnalyzer::TOF);
226  }
227  else
228  {
229  massAnalyzerList[0].setType(MassAnalyzer::ANALYZERNULL);
230  }
231 
232  DateTime date;
233  date.set(acqus.getParam("$AQ_DATE").remove('<').remove('>'));
234  experimental_settings.setDateTime(date);
235  }
236 
242  template <typename SpectrumType>
243  void store(const String & /*filename*/, const SpectrumType & /*spectrum*/)
244  {
245  throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
246  }
247 
248  };
249 } // namespace OpenMS
250 
251 #endif // OPENMS_FORMAT_XMASSFILE_H
Descripton of the applied preprocessing steps.
Definition: DataProcessing.h:51
void setMetaValue(const String &name, const DataValue &value)
sets the DataValue corresponding to a name
void load(const String &filename, MSSpectrum< PeakType > &spectrum)
Loads a spectrum from a XMass file.
Definition: XMassFile.h:84
Description of a MS instrument.
Definition: Instrument.h:64
Real IntensityType
Intensity type.
Definition: Peak2D.h:63
void setAcquisitionInfo(const AcquisitionInfo &acquisition_info)
sets the acquisition info
Description of the settings a MS Instrument was run with.
Definition: InstrumentSettings.h:48
A more convenient string class.
Definition: String.h:56
const std::vector< IonSource > & getIonSources() const
returns a const reference to the ion source list
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:55
Unknown.
Definition: IonSource.h:54
void setZoomScan(bool zoom_scan)
sets if this scan is a zoom (enhanced resolution) scan
void set(UInt month, UInt day, UInt year, UInt hour, UInt minute, UInt second)
sets data from six integers
void setInstrumentSettings(const InstrumentSettings &instrument_settings)
sets the instrument settings of the current spectrum
Description of the combination of raw data to a single spectrum.
Definition: AcquisitionInfo.h:54
bool hasSuffix(const String &string) const
true if String ends with string, false otherwise
void setVendor(const String &vendor)
sets the instrument vendor
Negative polarity.
Definition: IonSource.h:144
const std::vector< MassAnalyzer > & getMassAnalyzers() const
returns a const reference to the mass analyer list
void setFileType(const String &file_type)
sets the file type
void setScanMode(ScanMode scan_mode)
sets the scan mode
Positive polarity.
Definition: IonSource.h:143
void setComment(const String &comment)
sets the free-text comment
void setProcessingActions(const std::set< ProcessingAction > &actions)
sets the description of the applied processing
void setPolarity(IonSource::Polarity polarity)
sets the polarity
void setName(const String &name)
sets the name of the instrument
Baseline reduction.
Definition: DataProcessing.h:66
Description of a file location, used to store the origin of (meta) data.
Definition: SourceFile.h:47
void setName(const String &name)
Sets the name.
Definition: MSSpectrum.h:249
Raw data (also called profile data)
Definition: SpectrumSettings.h:75
File not found exception.
Definition: Exception.h:524
Description of the software used for processing.
Definition: Software.h:49
File adapter for &#39;XMass Analysis (fid)&#39; files.
Definition: XMassFile.h:66
void setIntensity(IntensityType intensity)
Non-mutable access to the data point intensity (height)
Definition: Peak2D.h:167
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:57
Time-of-flight.
Definition: MassAnalyzer.h:60
Unknown.
Definition: MassAnalyzer.h:55
void setCompletionTime(const DateTime &completion_time)
sets the time of completition taking a DateTime object
Read-only fid File handler for XMass Analysis.
Definition: FidHandler.h:52
Calibration of m/z positions.
Definition: DataProcessing.h:69
const ExperimentalSettings & getExperimentalSettings() const
returns the meta information of this experiment (const access)
Definition: MSExperiment.h:664
void setSoftware(const Software &software)
sets the software used for processing
void setMSLevel(UInt ms_level)
Sets the MS level.
Definition: MSSpectrum.h:237
void setPosition(const PositionType &position)
Mutable access to the position.
Definition: Peak2D.h:185
void clear(bool clear_meta_data)
Clears all data and meta data.
Definition: MSSpectrum.h:605
void setNameOfFile(const String &name_of_file)
sets the file name
void setVersion(const String &version)
sets the software version
Representation of a mass spectrometry experiment.
Definition: MSExperiment.h:68
void setSourceFile(const SourceFile &source_file)
sets the source file
void setType(SpectrumType type)
sets the spectrum type
void store(const String &, const SpectrumType &)
Stores a spectrum in a XMass file (not avaible)
Definition: XMassFile.h:243
void setMethodOfCombination(const String &method_of_combination)
sets the method of combination
void setFileSize(Real file_size)
sets the file size in MB
Smoothing of the signal to reduce noise.
Definition: DataProcessing.h:63
void setRT(DoubleReal rt)
Sets the absolute retention time (is seconds)
Definition: MSSpectrum.h:221
String prefix(SizeType length) const
returns the prefix of length length
void setDataProcessing(const std::vector< DataProcessing > &data_processing)
sets the description of the applied processing
DateTime Class.
Definition: DateTime.h:55
Base class for all classes that want to report their progess.
Definition: ProgressLogger.h:56
void setNativeID(const String &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
Read-only acqus File handler for XMass Analysis.
Definition: AcqusHandler.h:53
general spectrum type
Definition: InstrumentSettings.h:56
void importExperimentalSettings(const String &filename, MSExperiment< PeakType > &exp)
Import settings from a XMass file.
Definition: XMassFile.h:182
static DateTime now()
Returns the current date and time.
void setName(const String &name)
sets the name of the software
void setModel(const String &model)
sets the instrument model
void setPathToFile(const String &path_path_to_file)
sets the file path
String suffix(SizeType length) const
returns the suffix of length length
Matrix-assisted laser desorption ionization.
Definition: IonSource.h:107
Not implemented exception.
Definition: Exception.h:437
Description of the experimental settings.
Definition: ExperimentalSettings.h:59
Unknown.
Definition: IonSource.h:142
Direct.
Definition: IonSource.h:55
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:23 using doxygen 1.8.5