/usr/include/OpenMS/FORMAT/XMassFile.h is in libopenms-dev 1.11.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | // --------------------------------------------------------------------------
// OpenMS -- Open-Source Mass Spectrometry
// --------------------------------------------------------------------------
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
//
// This software is released under a three-clause BSD license:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of any author or any participating institution
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
// For a full list of authors, refer to the file AUTHORS.
// --------------------------------------------------------------------------
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// --------------------------------------------------------------------------
// $Maintainer: Guillaume Belz$
// $Authors: Guillaume Belz$
// --------------------------------------------------------------------------
#ifndef OPENMS_FORMAT_XMASSFILE_H
#define OPENMS_FORMAT_XMASSFILE_H
#include <OpenMS/FORMAT/HANDLERS/AcqusHandler.h>
#include <OpenMS/FORMAT/HANDLERS/FidHandler.h>
#include <OpenMS/CONCEPT/ProgressLogger.h>
#include <OpenMS/KERNEL/MSExperiment.h>
namespace OpenMS
{
/**
@brief File adapter for 'XMass Analysis (fid)' files.
XMass Analysis files is native format for Bruker spectrometer Flex Series.<br />
Each spectrum are saved in one directory. Each directory contains several files.
We use 2 files for import in OpenMS :<br />
<b>acqus</b> : contains meta data about calibration (conversion for time to mz ratio),
instrument specification and acquisition method.<br />
<b>fid</b> : contains intensity array. Intensity for each point are coded in 4 bytes integer.
@note MZ ratio are calculed with forumla based on article :<br />
<i>A database application for pre-processing, storage and comparison of mass spectra
derived from patients and controls</i><br />
<b>Mark K Titulaer, Ivar Siccama, Lennard J Dekker, Angelique LCT van Rijswijk,
Ron MA Heeren, Peter A Sillevis Smitt, and Theo M Luider</b><br />
BMC Bioinformatics. 2006; 7: 403<br />
http://www.pubmedcentral.nih.gov/picrender.fcgi?artid=1594579&blobtype=pdf<br />
@ingroup FileIO
*/
class OPENMS_DLLAPI XMassFile :
public ProgressLogger
{
public:
/// Default constructor
XMassFile();
/// Destructor
virtual ~XMassFile();
/**
@brief Loads a spectrum from a XMass file.
@param filename Name of the XMass file which should be loaded.
@param spectrum Spectrum in which the data loaded from the file should be stored.
@exception Exception::FileNotFound is thrown if the file could not be read
*/
template <class PeakType>
void load(const String & filename, MSSpectrum<PeakType> & spectrum)
{
Internal::AcqusHandler acqus(filename.prefix(filename.length() - 3) + String("acqus"));
Internal::FidHandler fid(filename);
if (!fid)
{
throw Exception::FileNotFound(__FILE__, __LINE__, __PRETTY_FUNCTION__, filename);
}
// Delete old spectrum
spectrum.clear(true);
//temporary variables
PeakType p;
while (spectrum.size() < acqus.getSize())
{
//fill peak
p.setPosition((typename PeakType::PositionType)acqus.getPosition(fid.getIndex()));
p.setIntensity((typename PeakType::IntensityType)fid.getIntensity());
spectrum.push_back(p);
}
fid.close();
// import metadata
spectrum.setRT(0.0);
spectrum.setMSLevel(1);
spectrum.setName("Xmass analysis file " + acqus.getParam("$ID_raw"));
spectrum.setType(SpectrumSettings::RAWDATA);
spectrum.setNativeID("spectrum=xsd:" + acqus.getParam("$ID_raw").remove('<').remove('>'));
spectrum.setComment("no comment");
InstrumentSettings instrument_settings;
instrument_settings.setScanMode(InstrumentSettings::MASSSPECTRUM);
instrument_settings.setZoomScan(false);
if (acqus.getParam(".IONIZATION MODE") == "LD+")
{
instrument_settings.setPolarity(IonSource::POSITIVE);
}
else if (acqus.getParam(".IONIZATION MODE") == "LD-")
{
instrument_settings.setPolarity(IonSource::NEGATIVE);
}
else
{
instrument_settings.setPolarity(IonSource::POLNULL);
}
spectrum.setInstrumentSettings(instrument_settings);
AcquisitionInfo acquisition_info;
acquisition_info.setMethodOfCombination("Sum of " + acqus.getParam("$NoSHOTS") + " raw spectrum");
spectrum.setAcquisitionInfo(acquisition_info);
SourceFile source_file;
source_file.setNameOfFile("fid");
source_file.setPathToFile(filename.prefix(filename.length() - 3));
source_file.setFileSize(4.0 * acqus.getSize() / 1024 / 1024); // 4 bytes / point
source_file.setFileType("Xmass analysis file (fid)");
spectrum.setSourceFile(source_file);
DataProcessing data_processing;
Software software;
software.setName("FlexControl");
String fc_ver = acqus.getParam("$FCVer"); // FlexControlVersion
if (fc_ver.hasPrefix("<flexControl "))
{
fc_ver = fc_ver.suffix(' ');
}
if (fc_ver.hasSuffix(">"))
{
fc_ver = fc_ver.prefix('>');
}
software.setVersion(fc_ver);
software.setMetaValue("Acquisition method", DataValue(acqus.getParam("$ACQMETH").remove('<').remove('>')));
data_processing.setSoftware(software);
std::set<DataProcessing::ProcessingAction> actions;
actions.insert(DataProcessing::SMOOTHING);
actions.insert(DataProcessing::BASELINE_REDUCTION);
actions.insert(DataProcessing::CALIBRATION);
data_processing.setProcessingActions(actions);
data_processing.setCompletionTime(DateTime::now());
std::vector<DataProcessing> data_processing_vector;
data_processing_vector.push_back(data_processing);
spectrum.setDataProcessing(data_processing_vector);
}
/**
@brief Import settings from a XMass file.
@param filename File from which the experimental settings should be loaded.
@param exp MSExperiment where the experimental settings will be stored.
@exception Exception::FileNotFound is thrown if the file could not be opened.
*/
template <class PeakType>
void importExperimentalSettings(const String & filename, MSExperiment<PeakType> & exp)
{
Internal::AcqusHandler acqus(filename.prefix(filename.length() - 3) + String("acqus"));
ExperimentalSettings & experimental_settings = exp.getExperimentalSettings();
Instrument & instrument = experimental_settings.getInstrument();
instrument.setName(acqus.getParam("SPECTROMETER/DATASYSTEM"));
instrument.setVendor(acqus.getParam("ORIGIN"));
instrument.setModel(acqus.getParam("$InstrID").remove('<').remove('>'));
std::vector<IonSource> & ionSourceList = instrument.getIonSources();
ionSourceList.clear();
ionSourceList.resize(1);
if (acqus.getParam(".INLET") == "DIRECT")
{
ionSourceList[0].setInletType(IonSource::DIRECT);
}
else
{
ionSourceList[0].setInletType(IonSource::INLETNULL);
ionSourceList[0].setIonizationMethod(IonSource::MALDI);
}
if (acqus.getParam(".IONIZATION MODE") == "LD+")
{
ionSourceList[0].setPolarity(IonSource::POSITIVE);
}
else if (acqus.getParam(".IONIZATION MODE") == "LD-")
{
ionSourceList[0].setPolarity(IonSource::NEGATIVE);
}
else
{
ionSourceList[0].setPolarity(IonSource::POLNULL);
}
ionSourceList[0].setMetaValue("MALDI target reference", DataValue(acqus.getParam("$TgIDS").remove('<').remove('>')));
ionSourceList[0].setOrder(0);
std::vector<MassAnalyzer> & massAnalyzerList = instrument.getMassAnalyzers();
massAnalyzerList.clear();
massAnalyzerList.resize(1);
if (acqus.getParam(".SPECTROMETER TYPE") == "TOF")
{
massAnalyzerList[0].setType(MassAnalyzer::TOF);
}
else
{
massAnalyzerList[0].setType(MassAnalyzer::ANALYZERNULL);
}
DateTime date;
date.set(acqus.getParam("$AQ_DATE").remove('<').remove('>'));
experimental_settings.setDateTime(date);
}
/**
@brief Stores a spectrum in a XMass file (not avaible)
@exception Exception::FileNotWritable is thrown
*/
template <typename SpectrumType>
void store(const String & /*filename*/, const SpectrumType & /*spectrum*/)
{
throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
}
};
} // namespace OpenMS
#endif // OPENMS_FORMAT_XMASSFILE_H
|