Skip to content
Open

Test #155

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,5 @@ the authors tag in the respective file header.
- Witold Wolski
- Xiao Liang
- Yasset Perez-Riverol
- Peter Jones
- Peter Jones
- Anjali Gajurel
2 changes: 1 addition & 1 deletion contrib
Submodule contrib updated 1 files
+12 −11 CMakeLists.txt
6 changes: 6 additions & 0 deletions src/openms/include/OpenMS/IONMOBILITY/IMTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ namespace OpenMS
OPENMS_DLLAPI const std::string& toString(const DriftTimeUnit value);

/// Different ways to represent ion mobility data in a spectrum
/// Note:
/// 1. MIXED is only used for MSExperiment, not for MSSpectrum
/// 2. UNKNOWN should be used if the format is not yet determined.
/// FileHandler or e.g. IM peak picker should ideally set the format a known value.
enum class IMFormat
{
NONE, ///< no ion mobility
CONCATENATED, ///< ion mobility frame is stacked in a single spectrum (i.e. has an IM float data array)
MULTIPLE_SPECTRA,///< ion mobility is recorded as multiple spectra per frame (i.e. has one IM annotation per spectrum)
MIXED, ///< an MSExperiment contains both CONCATENATED and MULTIPLE_SPECTRA
CENTROIDED, ///< ion mobility of peaks after centroiding in IM dimension. Ion mobility is annotated in a single float data array (i.e., each peak might have a different IM value in the data array); identical to CONCATENATED in terms of data layout.
UNKNOWN, ///< ion mobility format not yet determined.
SIZE_OF_IMFORMAT
};
/// Names of IMFormat
Expand Down
6 changes: 3 additions & 3 deletions src/openms/include/OpenMS/METADATA/MetaInfoInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace OpenMS
public:

/// Constructor
MetaInfoInterface();
MetaInfoInterface() = default;
/// Copy constructor
MetaInfoInterface(const MetaInfoInterface& rhs);
/// Move constructor
Expand Down Expand Up @@ -107,8 +107,8 @@ namespace OpenMS
/// Creates the MetaInfo object if it does not exist
inline void createIfNotExists_();

/// Pointer to the MetaInfo object (0 by default)
MetaInfo* meta_;
/// Pointer to the MetaInfo object
MetaInfo* meta_ = nullptr;
};

} // namespace OpenMS
22 changes: 17 additions & 5 deletions src/openms/include/OpenMS/METADATA/SpectrumSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// --------------------------------------------------------------------------
// $Maintainer: Timo Sachsenberg $
// $Authors: Marc Sturm $
// $Authors: Marc Sturm, Timo Sachsenberg $
// --------------------------------------------------------------------------

#pragma once
Expand All @@ -16,6 +16,7 @@
#include <OpenMS/METADATA/Product.h>
#include <OpenMS/METADATA/PeptideIdentification.h>
#include <OpenMS/METADATA/DataProcessing.h>
#include <OpenMS/IONMOBILITY/IMTypes.h>

#include <map>
#include <vector>
Expand Down Expand Up @@ -52,13 +53,13 @@ namespace OpenMS
static const std::string NamesOfSpectrumType[SIZE_OF_SPECTRUMTYPE];

/// Constructor
SpectrumSettings();
SpectrumSettings() = default;
/// Copy constructor
SpectrumSettings(const SpectrumSettings &) = default;
/// Move constructor
SpectrumSettings(SpectrumSettings&&) = default;
SpectrumSettings(SpectrumSettings&&) noexcept = default;
/// Destructor
~SpectrumSettings();
~SpectrumSettings() noexcept = default;

// Assignment operator
SpectrumSettings & operator=(const SpectrumSettings &) = default;
Expand All @@ -78,6 +79,16 @@ namespace OpenMS
///sets the spectrum type
void setType(SpectrumType type);

/// @brief sets the IMFormat of the spectrum
/// @param im_type
void setIMFormat(const IMFormat& im_type);

/// @brief returns the IMFormat of the spectrum if set. Otherwise UNKNOWN (default).
///
/// Note: If UNKNOWN, use IMFormat::determineIMFormat to determine the IMFormat based on the data.
/// @return IMFormat of the spectrum
IMFormat getIMFormat() const;

/// returns the native identifier for the spectrum, used by the acquisition software.
const String & getNativeID() const;
/// sets the native identifier for the spectrum, used by the acquisition software.
Expand Down Expand Up @@ -141,7 +152,8 @@ namespace OpenMS

protected:

SpectrumType type_;
SpectrumType type_ = UNKNOWN;
IMFormat im_type_ = IMFormat::UNKNOWN;
String native_id_;
String comment_;
InstrumentSettings instrument_settings_;
Expand Down
71 changes: 71 additions & 0 deletions src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
// SPDX-License-Identifier: BSD-3-Clause
//
// --------------------------------------------------------------------------
// $Author: Timo Sachsenberg, Mohammed Alhigaylan $
// $Maintainer: Timo Sachsenberg $
// -------------------------------------------------------------------------------------------------------------------------------------------

#pragma once

#include <OpenMS/KERNEL/MSSpectrum.h>
#include <OpenMS/DATASTRUCTURES/Param.h>

namespace OpenMS
{
/**
@brief Peak picking algorithm for ion mobility data

@ingroup PeakPicking
*/
class OPENMS_DLLAPI PeakPickerIM
{
public:
/// Default constructor initializing parameters with default values.
PeakPickerIM();

/// Destructor.
virtual ~PeakPickerIM();

/// Picks ion mobility traces from the given spectrum.
void pickIMTraces(MSSpectrum& spectrum);

/// Sets the parameters for peak picking.
void setParameters(const Param& param);

/// Gets the current parameters.
Param getParameters() const;

protected:
/// Updates internal member variables when parameters are changed.
void updateMembers_();

/// Returns the default parameters.
Param getDefaultParameters() const;

/// Stores the parameters for peak picking.
Param parameters_;

private:
/// determine sampling rate for linear resampler
double computeOptimalSamplingRate(const std::vector<MSSpectrum>& spectra);

/// Sum up the intensity of data points with nearly identical float values
MSSpectrum SumFrame(const MSSpectrum& spectrum, double ppm_tolerance = 0.01);

/// Compute lower and upper m/z bounds based on ppm
std::pair<double, double> ppmBounds(double mz, double ppm);

/// Extract ion mobility traces as MSSpectra from the raw TimsTOF frame
/// Ion mobility is temporarily written in place of m/z inside Peak1D object.
/// raw m/z values are allocated to float data arrays with the label 'raw_mz'
std::vector<MSSpectrum> extractIonMobilityTraces(
const MSSpectrum& picked_spectrum,
const MSSpectrum& raw_spectrum);

/// compute m/z and ion mobility centers for picked traces. Returns centroided spectrum.
MSSpectrum ComputeCenters(const std::vector<MSSpectrum>& mobilogram_traces,
const std::vector<MSSpectrum>& picked_traces);
};

} // namespace OpenMS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(directory include/OpenMS/PROCESSING/CENTROIDING)
set(sources_list_h
PeakPickerHiRes.h
PeakPickerIterative.h
PeakPickerIM.h
)

### add path to the filenames
Expand Down
42 changes: 27 additions & 15 deletions src/openms/source/IONMOBILITY/IMTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace OpenMS
{

const std::string NamesOfDriftTimeUnit[] = {"<NONE>", "ms", "1/K0", "FAIMS_CV"};
const std::string NamesOfIMFormat[] = {"none", "concatenated", "multiple_spectra", "mixed"};
const std::string NamesOfIMFormat[] = {"none", "concatenated", "multiple_spectra", "mixed", "centroided", "unknown"};


DriftTimeUnit toDriftTimeUnit(const std::string& dtu_string)
Expand Down Expand Up @@ -73,33 +73,45 @@ namespace OpenMS
if (occs.empty())
{
return IMFormat::NONE;
}
if (occs.size() == 1 && (occs.find(IMFormat::CONCATENATED) != occs.end() || occs.find(IMFormat::MULTIPLE_SPECTRA) != occs.end()))
}

if (occs.size() == 1)
{
return *occs.begin();
auto format = *occs.begin();
if (format != IMFormat::CONCATENATED
&& format != IMFormat::MULTIPLE_SPECTRA
&& format != IMFormat::CENTROIDED)
{
throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "subfunction returned invalid value(s)", "Number of different values: " + String(occs.size()));
}
return format;
}
if (occs.size() == 2 && occs.find(IMFormat::CONCATENATED) != occs.end() && occs.find(IMFormat::MULTIPLE_SPECTRA) != occs.end())
else
{
return IMFormat::MIXED;
}

throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "subfunction returned invalid value(s)", "Number of different values: " + String(occs.size()));
}
}

IMFormat IMTypes::determineIMFormat(const MSSpectrum& spec)
{
bool has_float_data = spec.containsIMData(); // cache value; query is 'expensive'
bool has_drift_time = spec.getDriftTime() != DRIFTTIME_NOT_SET;
if (has_float_data && has_drift_time)
// First check if format is already set and not UNKNOWN
IMFormat current_format = spec.getIMFormat();
if (current_format != IMFormat::UNKNOWN)
{
const auto& fda = spec.getFloatDataArrays()[spec.getIMData().first];
String array_val = fda.empty() ? "[empty]" : String(fda[0]);
throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "MSSpectrum contains both an float-data-array and a single drift time. At most one is allowed per spectrum!", String("Array: ") + array_val + ", ... <> Spec: " + spec.getDriftTime());
return current_format;
}

// If format is UNKNOWN, determine it
bool has_float_data = spec.containsIMData(); // cache value; query is 'expensive'
bool has_drift_time = spec.getDriftTime() != DRIFTTIME_NOT_SET;

if (has_float_data)
{
return IMFormat::CONCATENATED;
if (has_drift_time)
{
OPENMS_LOG_DEBUG << "both drift time and IM data array found in spectrum " << spec.getNativeID() << "\n. Support for both is experimental." << std::endl;
}
return IMFormat::CONCATENATED; // TODO: or CENTROIDED. for now assume that no picking was done (otherwise we would have annotated it)
}
else if (has_drift_time)
{
Expand Down
6 changes: 0 additions & 6 deletions src/openms/source/METADATA/MetaInfoInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ using namespace std;

namespace OpenMS
{

MetaInfoInterface::MetaInfoInterface() :
meta_(nullptr)
{
}

/// Copy constructor
MetaInfoInterface::MetaInfoInterface(const MetaInfoInterface& rhs) :
meta_(nullptr)
Expand Down
32 changes: 14 additions & 18 deletions src/openms/source/METADATA/SpectrumSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <OpenMS/METADATA/SpectrumSettings.h>

#include <OpenMS/CONCEPT/Helpers.h>
#include <boost/iterator/indirect_iterator.hpp> // for equality

using namespace std;

Expand All @@ -18,23 +17,6 @@ namespace OpenMS

const std::string SpectrumSettings::NamesOfSpectrumType[] = {"Unknown", "Centroid", "Profile"};

SpectrumSettings::SpectrumSettings() :
MetaInfoInterface(),
type_(UNKNOWN),
native_id_(),
comment_(),
instrument_settings_(),
source_file_(),
acquisition_info_(),
precursors_(),
products_(),
identification_(),
data_processing_()
{
}

SpectrumSettings::~SpectrumSettings() = default;

bool SpectrumSettings::operator==(const SpectrumSettings & rhs) const
{
return MetaInfoInterface::operator==(rhs) &&
Expand Down Expand Up @@ -94,6 +76,20 @@ namespace OpenMS
type_ = type;
}

void SpectrumSettings::setIMFormat(const IMFormat& im_type)
{
if (im_type == IMFormat::MIXED)
{
throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Single spectrum can't have MIXED ion mobility format.", "SIZE_OF_IMFORMAT");
}
im_type_ = im_type;
}

IMFormat SpectrumSettings::getIMFormat() const
{
return im_type_;
}

const String & SpectrumSettings::getComment() const
{
return comment_;
Expand Down
Loading