Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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
00095 spectrum.clear(true);
00096
00097
00098 PeakType p;
00099
00100 while (spectrum.size() < acqus.getSize())
00101 {
00102
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
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);
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");
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 & , const SpectrumType & )
00244 {
00245 throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
00246 }
00247
00248 };
00249 }
00250
00251 #endif // OPENMS_FORMAT_XMASSFILE_H