OpenMS  3.0.0
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-2022.
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: Timo Sachsenberg $
32 // $Authors: Guillaume Belz $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
42 
43 namespace OpenMS
44 {
66  class OPENMS_DLLAPI XMassFile :
67  public ProgressLogger
68  {
69 public:
71  XMassFile();
73  ~XMassFile() override;
74 
83  void load(const String & filename, MSSpectrum & spectrum)
84  {
85  Internal::AcqusHandler acqus(filename.prefix(filename.length() - 3) + String("acqus"));
86 
87  Internal::FidHandler fid(filename);
88  if (!fid)
89  {
90  throw Exception::FileNotFound(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename);
91  }
92 
93  // Delete old spectrum
94  spectrum.clear(true);
95 
96  //temporary variables
97  Peak1D p;
98 
99  while (spectrum.size() < acqus.getSize())
100  {
101  //fill peak
102  p.setPosition((Peak1D::PositionType)acqus.getPosition(fid.getIndex()));
103  p.setIntensity((Peak1D::IntensityType)fid.getIntensity());
104  spectrum.push_back(p);
105  }
106  fid.close();
107 
108  // import metadata
109  spectrum.setRT(0.0);
110  spectrum.setMSLevel(1);
111  spectrum.setName("Xmass analysis file " + acqus.getParam("$ID_raw"));
113  spectrum.setNativeID("spectrum=xsd:" + acqus.getParam("$ID_raw").remove('<').remove('>'));
114  spectrum.setComment("no comment");
115 
116  InstrumentSettings instrument_settings;
117  instrument_settings.setScanMode(InstrumentSettings::MASSSPECTRUM);
118  instrument_settings.setZoomScan(false);
119 
120  if (acqus.getParam(".IONIZATION MODE") == "LD+")
121  {
122  instrument_settings.setPolarity(IonSource::POSITIVE);
123  }
124  else if (acqus.getParam(".IONIZATION MODE") == "LD-")
125  {
126  instrument_settings.setPolarity(IonSource::NEGATIVE);
127  }
128  else
129  {
130  instrument_settings.setPolarity(IonSource::POLNULL);
131  }
132  spectrum.setInstrumentSettings(instrument_settings);
133 
134  AcquisitionInfo acquisition_info;
135  acquisition_info.setMethodOfCombination("Sum of " + acqus.getParam("$NoSHOTS") + " raw spectrum");
136  spectrum.setAcquisitionInfo(acquisition_info);
137 
138  SourceFile source_file;
139  source_file.setNameOfFile("fid");
140  source_file.setPathToFile(filename.prefix(filename.length() - 3));
141  source_file.setFileSize(4.0 * acqus.getSize() / 1024 / 1024); // 4 bytes / point
142  source_file.setFileType("Xmass analysis file (fid)");
143  spectrum.setSourceFile(source_file);
144 
145  DataProcessing data_processing;
146  Software software;
147  software.setName("FlexControl");
148  String fc_ver = acqus.getParam("$FCVer"); // FlexControlVersion
149  if (fc_ver.hasPrefix("<flexControl "))
150  {
151  fc_ver = fc_ver.suffix(' ');
152  }
153  if (fc_ver.hasSuffix(">"))
154  {
155  fc_ver = fc_ver.prefix('>');
156  }
157  software.setVersion(fc_ver);
158  software.setMetaValue("Acquisition method", DataValue(acqus.getParam("$ACQMETH").remove('<').remove('>')));
159  data_processing.setSoftware(software);
160  std::set<DataProcessing::ProcessingAction> actions;
161  actions.insert(DataProcessing::SMOOTHING);
162  actions.insert(DataProcessing::BASELINE_REDUCTION);
163  actions.insert(DataProcessing::CALIBRATION);
164  data_processing.setProcessingActions(actions);
165  data_processing.setCompletionTime(DateTime::now());
166 
167  std::vector< boost::shared_ptr< DataProcessing> > data_processing_vector;
168  data_processing_vector.push_back( boost::shared_ptr< DataProcessing>(new DataProcessing(data_processing)) );
169  spectrum.setDataProcessing(data_processing_vector);
170  }
171 
180  void importExperimentalSettings(const String & filename, PeakMap & exp)
181  {
182  Internal::AcqusHandler acqus(filename.prefix(filename.length() - 3) + String("acqus"));
183 
184  ExperimentalSettings & experimental_settings = exp.getExperimentalSettings();
185 
186  Instrument & instrument = experimental_settings.getInstrument();
187  instrument.setName(acqus.getParam("SPECTROMETER/DATASYSTEM"));
188  instrument.setVendor(acqus.getParam("ORIGIN"));
189  instrument.setModel(acqus.getParam("$InstrID").remove('<').remove('>'));
190 
191  std::vector<IonSource> & ionSourceList = instrument.getIonSources();
192  ionSourceList.clear();
193  ionSourceList.resize(1);
194  if (acqus.getParam(".INLET") == "DIRECT")
195  {
196  ionSourceList[0].setInletType(IonSource::DIRECT);
197  }
198  else
199  {
200  ionSourceList[0].setInletType(IonSource::INLETNULL);
201  ionSourceList[0].setIonizationMethod(IonSource::MALDI);
202  }
203  if (acqus.getParam(".IONIZATION MODE") == "LD+")
204  {
205  ionSourceList[0].setPolarity(IonSource::POSITIVE);
206  }
207  else if (acqus.getParam(".IONIZATION MODE") == "LD-")
208  {
209  ionSourceList[0].setPolarity(IonSource::NEGATIVE);
210  }
211  else
212  {
213  ionSourceList[0].setPolarity(IonSource::POLNULL);
214  }
215  ionSourceList[0].setMetaValue("MALDI target reference", DataValue(acqus.getParam("$TgIDS").remove('<').remove('>')));
216  ionSourceList[0].setOrder(0);
217 
218  std::vector<MassAnalyzer> & massAnalyzerList = instrument.getMassAnalyzers();
219  massAnalyzerList.clear();
220  massAnalyzerList.resize(1);
221  if (acqus.getParam(".SPECTROMETER TYPE") == "TOF")
222  {
223  massAnalyzerList[0].setType(MassAnalyzer::TOF);
224  }
225  else
226  {
227  massAnalyzerList[0].setType(MassAnalyzer::ANALYZERNULL);
228  }
229 
230  DateTime date;
231  date.set(acqus.getParam("$AQ_DATE").remove('<').remove('>'));
232  experimental_settings.setDateTime(date);
233  }
234 
240  void store(const String & /*filename*/, const MSSpectrum & /*spectrum*/)
241  {
242  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
243  }
244 
245  };
246 } // namespace OpenMS
247 
OpenMS::Software
Description of the software used for processing.
Definition: Software.h:48
OpenMS::InstrumentSettings::MASSSPECTRUM
general spectrum type
Definition: InstrumentSettings.h:55
OpenMS::InstrumentSettings
Description of the settings a MS Instrument was run with.
Definition: InstrumentSettings.h:47
OpenMS::MSExperiment::getExperimentalSettings
const ExperimentalSettings & getExperimentalSettings() const
returns the meta information of this experiment (const access)
OpenMS::Software::setName
void setName(const String &name)
Sets the name of the software.
OpenMS::Instrument::setModel
void setModel(const String &model)
sets the instrument model
OpenMS::SourceFile::setPathToFile
void setPathToFile(const String &path_path_to_file)
sets the file path
OpenMS::AcquisitionInfo
Description of the combination of raw data to a single spectrum.
Definition: AcquisitionInfo.h:52
OpenMS::MassAnalyzer::TOF
Time-of-flight.
Definition: MassAnalyzer.h:59
OpenMS::InstrumentSettings::setPolarity
void setPolarity(IonSource::Polarity polarity)
sets the polarity
OpenMS::Instrument::setVendor
void setVendor(const String &vendor)
sets the instrument vendor
OpenMS::SourceFile::setNameOfFile
void setNameOfFile(const String &name_of_file)
sets the file name
OpenMS::Instrument::getMassAnalyzers
const std::vector< MassAnalyzer > & getMassAnalyzers() const
returns a const reference to the mass analyzer list
OpenMS::Instrument::getIonSources
const std::vector< IonSource > & getIonSources() const
returns a const reference to the ion source list
OpenMS::ExperimentalSettings
Description of the experimental settings.
Definition: ExperimentalSettings.h:59
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::Exception::FileNotFound
File not found exception.
Definition: Exception.h:509
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
OpenMS::SpectrumSettings::setType
void setType(SpectrumType type)
sets the spectrum type
OpenMS::String::prefix
String prefix(SizeType length) const
returns the prefix of length length
OpenMS::Peak1D::setIntensity
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:110
OpenMS::XMassFile::load
void load(const String &filename, MSSpectrum &spectrum)
Loads a spectrum from a XMass file.
Definition: XMassFile.h:83
OpenMS::SpectrumSettings::setDataProcessing
void setDataProcessing(const std::vector< DataProcessingPtr > &data_processing)
sets the description of the applied processing
OpenMS::DataProcessing::setCompletionTime
void setCompletionTime(const DateTime &completion_time)
sets the time of completion taking a DateTime object
OpenMS::SpectrumSettings::PROFILE
profile data
Definition: SpectrumSettings.h:74
OpenMS::String::hasPrefix
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
OpenMS::Software::setVersion
void setVersion(const String &version)
Sets the software version.
OpenMS::DateTime::now
static DateTime now()
Returns the current date and time.
OpenMS::Instrument
Description of a MS instrument.
Definition: Instrument.h:63
OpenMS::SourceFile::setFileSize
void setFileSize(float file_size)
sets the file size in MB
OpenMS::SpectrumSettings::setComment
void setComment(const String &comment)
sets the free-text comment
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::SpectrumSettings::setSourceFile
void setSourceFile(const SourceFile &source_file)
sets the source file
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:52
OpenMS::MetaInfoInterface::setMetaValue
void setMetaValue(const String &name, const DataValue &value)
Sets the DataValue corresponding to a name.
OpenMS::DataValue
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:58
ProgressLogger.h
OpenMS::IonSource::DIRECT
Direct.
Definition: IonSource.h:55
OpenMS::InstrumentSettings::setScanMode
void setScanMode(ScanMode scan_mode)
sets the scan mode
OpenMS::Peak1D::setPosition
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:149
OpenMS::XMassFile
File adapter for 'XMass Analysis (fid)' files.
Definition: XMassFile.h:66
OpenMS::MSSpectrum::clear
void clear(bool clear_meta_data)
Clears all data and meta data.
OpenMS::MSSpectrum::setMSLevel
void setMSLevel(UInt ms_level)
Sets the MS level.
OpenMS::String::hasSuffix
bool hasSuffix(const String &string) const
true if String ends with string, false otherwise
OpenMS::Exception::NotImplemented
Not implemented exception.
Definition: Exception.h:428
OpenMS::DateTime::set
void set(UInt month, UInt day, UInt year, UInt hour, UInt minute, UInt second)
sets data from six integers
OpenMS::DataProcessing::CALIBRATION
Calibration of m/z positions.
Definition: DataProcessing.h:69
OpenMS::Peak1D
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:53
OpenMS::DPosition< 1 >
OpenMS::AcquisitionInfo::setMethodOfCombination
void setMethodOfCombination(const String &method_of_combination)
sets the method of combination
OpenMS::DataProcessing::setSoftware
void setSoftware(const Software &software)
sets the software used for processing
OpenMS::DataProcessing::setProcessingActions
void setProcessingActions(const std::set< ProcessingAction > &actions)
sets the description of the applied processing
OpenMS::IonSource::POSITIVE
Positive polarity.
Definition: IonSource.h:143
OpenMS::DataProcessing::SMOOTHING
Smoothing of the signal to reduce noise.
Definition: DataProcessing.h:63
OpenMS::InstrumentSettings::setZoomScan
void setZoomScan(bool zoom_scan)
sets if this scan is a zoom (enhanced resolution) scan
MSExperiment.h
OpenMS::Instrument::setName
void setName(const String &name)
sets the name of the instrument
OpenMS::DataProcessing
Description of the applied preprocessing steps.
Definition: DataProcessing.h:51
float
FidHandler.h
OpenMS::Internal::FidHandler
Read-only fid File handler for XMass Analysis.
Definition: FidHandler.h:51
OpenMS::IonSource::MALDI
Matrix-assisted laser desorption ionization.
Definition: IonSource.h:107
OpenMS::MSSpectrum::setName
void setName(const String &name)
Sets the name.
OpenMS::SourceFile
Description of a file location, used to store the origin of (meta) data.
Definition: SourceFile.h:46
OpenMS::IonSource::POLNULL
Unknown.
Definition: IonSource.h:142
AcqusHandler.h
OpenMS::IonSource::NEGATIVE
Negative polarity.
Definition: IonSource.h:144
OpenMS::SpectrumSettings::setAcquisitionInfo
void setAcquisitionInfo(const AcquisitionInfo &acquisition_info)
sets the acquisition info
OpenMS::SourceFile::setFileType
void setFileType(const String &file_type)
sets the file type
OpenMS::MassAnalyzer::ANALYZERNULL
Unknown.
Definition: MassAnalyzer.h:54
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
OpenMS::XMassFile::store
void store(const String &, const MSSpectrum &)
Stores a spectrum in a XMass file (not available)
Definition: XMassFile.h:240
OpenMS::String::suffix
String suffix(SizeType length) const
returns the suffix of length length
OpenMS::MSSpectrum::setRT
void setRT(double rt)
Sets the absolute retention time (in seconds)
OpenMS::SpectrumSettings::setInstrumentSettings
void setInstrumentSettings(const InstrumentSettings &instrument_settings)
sets the instrument settings of the current spectrum
OpenMS::IonSource::INLETNULL
Unknown.
Definition: IonSource.h:54
StandardTypes.h
OpenMS::DateTime
DateTime Class.
Definition: DateTime.h:58
OpenMS::Internal::AcqusHandler
Read-only acqus File handler for XMass Analysis.
Definition: AcqusHandler.h:52
OpenMS::SpectrumSettings::setNativeID
void setNativeID(const String &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
OpenMS::XMassFile::importExperimentalSettings
void importExperimentalSettings(const String &filename, PeakMap &exp)
Import settings from a XMass file.
Definition: XMassFile.h:180
OpenMS::DataProcessing::BASELINE_REDUCTION
Baseline reduction.
Definition: DataProcessing.h:66