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

XMassFile.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Guillaume Belz$
00032 // $Authors: Guillaume Belz$
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_FORMAT_XMASSFILE_H
00036 #define OPENMS_FORMAT_XMASSFILE_H
00037 
00038 #include <OpenMS/FORMAT/HANDLERS/AcqusHandler.h>
00039 #include <OpenMS/FORMAT/HANDLERS/FidHandler.h>
00040 #include <OpenMS/CONCEPT/ProgressLogger.h>
00041 #include <OpenMS/KERNEL/MSExperiment.h>
00042 
00043 namespace OpenMS
00044 {
00066   class OPENMS_DLLAPI XMassFile :
00067     public ProgressLogger
00068   {
00069 public:
00071     XMassFile();
00073     virtual ~XMassFile();
00074 
00083     template <class PeakType>
00084     void load(const String & filename, MSSpectrum<PeakType> & spectrum)
00085     {
00086       Internal::AcqusHandler acqus(filename.prefix(filename.length() - 3) + String("acqus"));
00087 
00088       Internal::FidHandler fid(filename);
00089       if (!fid)
00090       {
00091         throw Exception::FileNotFound(__FILE__, __LINE__, __PRETTY_FUNCTION__, filename);
00092       }
00093 
00094       //  Delete old spectrum
00095       spectrum.clear(true);
00096 
00097       //temporary variables
00098       PeakType p;
00099 
00100       while (spectrum.size() < acqus.getSize())
00101       {
00102         //fill peak
00103         p.setPosition((typename PeakType::PositionType)acqus.getPosition(fid.getIndex()));
00104         p.setIntensity((typename PeakType::IntensityType)fid.getIntensity());
00105         spectrum.push_back(p);
00106       }
00107       fid.close();
00108 
00109       // import metadata
00110       spectrum.setRT(0.0);
00111       spectrum.setMSLevel(1);
00112       spectrum.setName("Xmass analysis file " + acqus.getParam("$ID_raw"));
00113       spectrum.setType(SpectrumSettings::RAWDATA);
00114       spectrum.setNativeID("spectrum=xsd:" + acqus.getParam("$ID_raw").remove('<').remove('>'));
00115       spectrum.setComment("no comment");
00116 
00117       InstrumentSettings instrument_settings;
00118       instrument_settings.setScanMode(InstrumentSettings::MASSSPECTRUM);
00119       instrument_settings.setZoomScan(false);
00120 
00121       if (acqus.getParam(".IONIZATION MODE") == "LD+")
00122       {
00123         instrument_settings.setPolarity(IonSource::POSITIVE);
00124       }
00125       else if (acqus.getParam(".IONIZATION MODE") == "LD-")
00126       {
00127         instrument_settings.setPolarity(IonSource::NEGATIVE);
00128       }
00129       else
00130       {
00131         instrument_settings.setPolarity(IonSource::POLNULL);
00132       }
00133       spectrum.setInstrumentSettings(instrument_settings);
00134 
00135       AcquisitionInfo acquisition_info;
00136       acquisition_info.setMethodOfCombination("Sum of " + acqus.getParam("$NoSHOTS") + " raw spectrum");
00137       spectrum.setAcquisitionInfo(acquisition_info);
00138 
00139       SourceFile source_file;
00140       source_file.setNameOfFile("fid");
00141       source_file.setPathToFile(filename.prefix(filename.length() - 3));
00142       source_file.setFileSize(4.0 * acqus.getSize() / 1024 / 1024);   // 4 bytes / point
00143       source_file.setFileType("Xmass analysis file (fid)");
00144       spectrum.setSourceFile(source_file);
00145 
00146       DataProcessing data_processing;
00147       Software software;
00148       software.setName("FlexControl");
00149       String fc_ver = acqus.getParam("$FCVer");   // FlexControlVersion
00150       if (fc_ver.hasPrefix("<flexControl "))
00151       {
00152         fc_ver = fc_ver.suffix(' ');
00153       }
00154       if (fc_ver.hasSuffix(">"))
00155       {
00156         fc_ver = fc_ver.prefix('>');
00157       }
00158       software.setVersion(fc_ver);
00159       software.setMetaValue("Acquisition method", DataValue(acqus.getParam("$ACQMETH").remove('<').remove('>')));
00160       data_processing.setSoftware(software);
00161       std::set<DataProcessing::ProcessingAction> actions;
00162       actions.insert(DataProcessing::SMOOTHING);
00163       actions.insert(DataProcessing::BASELINE_REDUCTION);
00164       actions.insert(DataProcessing::CALIBRATION);
00165       data_processing.setProcessingActions(actions);
00166       data_processing.setCompletionTime(DateTime::now());
00167 
00168       std::vector<DataProcessing> data_processing_vector;
00169       data_processing_vector.push_back(data_processing);
00170       spectrum.setDataProcessing(data_processing_vector);
00171     }
00172 
00181     template <class PeakType>
00182     void importExperimentalSettings(const String & filename, MSExperiment<PeakType> & exp)
00183     {
00184       Internal::AcqusHandler acqus(filename.prefix(filename.length() - 3) + String("acqus"));
00185 
00186       ExperimentalSettings & experimental_settings = exp.getExperimentalSettings();
00187 
00188       Instrument & instrument = experimental_settings.getInstrument();
00189       instrument.setName(acqus.getParam("SPECTROMETER/DATASYSTEM"));
00190       instrument.setVendor(acqus.getParam("ORIGIN"));
00191       instrument.setModel(acqus.getParam("$InstrID").remove('<').remove('>'));
00192 
00193       std::vector<IonSource> & ionSourceList = instrument.getIonSources();
00194       ionSourceList.clear();
00195       ionSourceList.resize(1);
00196       if (acqus.getParam(".INLET") == "DIRECT")
00197       {
00198         ionSourceList[0].setInletType(IonSource::DIRECT);
00199       }
00200       else
00201       {
00202         ionSourceList[0].setInletType(IonSource::INLETNULL);
00203         ionSourceList[0].setIonizationMethod(IonSource::MALDI);
00204       }
00205       if (acqus.getParam(".IONIZATION MODE") == "LD+")
00206       {
00207         ionSourceList[0].setPolarity(IonSource::POSITIVE);
00208       }
00209       else if (acqus.getParam(".IONIZATION MODE") == "LD-")
00210       {
00211         ionSourceList[0].setPolarity(IonSource::NEGATIVE);
00212       }
00213       else
00214       {
00215         ionSourceList[0].setPolarity(IonSource::POLNULL);
00216       }
00217       ionSourceList[0].setMetaValue("MALDI target reference", DataValue(acqus.getParam("$TgIDS").remove('<').remove('>')));
00218       ionSourceList[0].setOrder(0);
00219 
00220       std::vector<MassAnalyzer> & massAnalyzerList = instrument.getMassAnalyzers();
00221       massAnalyzerList.clear();
00222       massAnalyzerList.resize(1);
00223       if (acqus.getParam(".SPECTROMETER TYPE") == "TOF")
00224       {
00225         massAnalyzerList[0].setType(MassAnalyzer::TOF);
00226       }
00227       else
00228       {
00229         massAnalyzerList[0].setType(MassAnalyzer::ANALYZERNULL);
00230       }
00231 
00232       DateTime date;
00233       date.set(acqus.getParam("$AQ_DATE").remove('<').remove('>'));
00234       experimental_settings.setDateTime(date);
00235     }
00236 
00242     template <typename SpectrumType>
00243     void store(const String & /*filename*/, const SpectrumType & /*spectrum*/)
00244     {
00245       throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
00246     }
00247 
00248   };
00249 } // namespace OpenMS
00250 
00251 #endif // OPENMS_FORMAT_XMASSFILE_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:46 using doxygen 1.7.1