Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Hendrik Weisser $
6 // $Authors: Hendrik Weisser, Chris Bielow $
7 // --------------------------------------------------------------------------
9 #pragma once
15 #include <QtCore/QJsonArray> // for JSON export
17 namespace SQLite
18 {
19  class Database;
20 } // namespace SQLite
22 namespace OpenMS
23 {
24  class FeatureMap;
25  class ConsensusMap;
27  namespace Internal
28  {
35  {
36  public:
49  OMSFileLoad(const String& filename, LogType log_type);
59  void load(IdentificationData& id_data);
62  void load(FeatureMap& features);
65  void load(ConsensusMap& consensus);
68  void exportToJSON(std::ostream& output);
70  private:
72  static bool isEmpty_(const SQLite::Statement& query);
75  static DataValue makeDataValue_(const SQLite::Statement& query);
77  // static CVTerm loadCVTerm_(int id);
116  template <class MapType> String loadMapMetaDataTemplate_(MapType& features);
119  void loadMapMetaData_(FeatureMap& features);
122  void loadMapMetaData_(ConsensusMap& consensus);
125  void loadDataProcessing_(std::vector<DataProcessing>& data_processing);
128  void loadFeatures_(FeatureMap& features);
131  Feature loadFeatureAndSubordinates_(SQLite::Statement& query_feat,
132  SQLite::Statement& query_meta,
133  SQLite::Statement& query_match,
134  SQLite::Statement& query_hull);
143  BaseFeature makeBaseFeature_(int id, SQLite::Statement& query_feat,
144  SQLite::Statement& query_meta,
145  SQLite::Statement& query_match);
148  void prepareQueriesBaseFeature_(SQLite::Statement& query_meta,
149  SQLite::Statement& query_match);
152  bool prepareQueryMetaInfo_(SQLite::Statement& query, const String& parent_table);
155  void handleQueryMetaInfo_(SQLite::Statement& query, MetaInfoInterface& info,
156  Key parent_id);
159  bool prepareQueryAppliedProcessingStep_(SQLite::Statement& query,
160  const String& parent_table);
164  SQLite::Statement& query,
166  Key parent_id);
170  SQLite::Statement& query, IdentificationData::ParentMatches& parent_matches,
171  Key molecule_id);
175  SQLite::Statement& query, IdentificationData::ObservationMatch& match,
176  Key parent_id);
179  QJsonArray exportTableToJSON_(const QString& table, const QString& order_by);
182  std::unique_ptr<SQLite::Database> db_;
186  QString subquery_score_;
188  // mappings between database keys and loaded data:
189  std::unordered_map<Key, IdentificationData::ScoreTypeRef> score_type_refs_;
190  std::unordered_map<Key, IdentificationData::InputFileRef> input_file_refs_;
191  std::unordered_map<Key, IdentificationData::ProcessingSoftwareRef> processing_software_refs_;
192  std::unordered_map<Key, IdentificationData::ProcessingStepRef> processing_step_refs_;
193  std::unordered_map<Key, IdentificationData::SearchParamRef> search_param_refs_;
194  std::unordered_map<Key, IdentificationData::ObservationRef> observation_refs_;
195  std::unordered_map<Key, IdentificationData::ParentSequenceRef> parent_sequence_refs_;
196  std::unordered_map<Key, IdentificationData::IdentifiedMolecule> identified_molecule_vars_;
197  std::unordered_map<Key, IdentificationData::ObservationMatchRef> observation_match_refs_;
198  std::unordered_map<Key, IdentificationData::AdductRef> adduct_refs_;
200  // mapping: table name -> ordering critera (for JSON export)
201  // @TODO: could use 'unordered_map' here, but would need to specify hash function for 'QString'
202  static std::map<QString, QString> export_order_by_;
203  };
204  }
205 }
A basic LC-MS feature.
Definition: BaseFeature.h:33
A container for consensus elements.
Definition: ConsensusMap.h:66
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:33
A container for features.
Definition: FeatureMap.h:80
An LC-MS feature.
Definition: Feature.h:46
Definition: IdentificationData.h:87
IdentificationDataInternal::ParentMatches ParentMatches
Definition: IdentificationData.h:138
Helper class for loading .oms files (SQLite format)
Definition: OMSFileLoad.h:35
String loadMapMetaDataTemplate_(MapType &features)
Helper function for loading meta data on feature/consensus maps from the database.
void loadConsensusFeatures_(ConsensusMap &consensus)
Load information on consensus features from the database into a consensus map.
std::unordered_map< Key, IdentificationData::IdentifiedMolecule > identified_molecule_vars_
Definition: OMSFileLoad.h:196
void loadParentSequences_(IdentificationData &id_data)
Load information on parent sequences (e.g. proteins) from the database into IdentificationData.
void loadIdentifiedSequences_(IdentificationData &id_data)
Load information on identified sequences (peptides or oligonucleotides) from the database into Identi...
std::unordered_map< Key, IdentificationData::ProcessingSoftwareRef > processing_software_refs_
Definition: OMSFileLoad.h:191
void load(IdentificationData &id_data)
Load data from database and populate an IdentificationData object.
void loadProcessingSoftwares_(IdentificationData &id_data)
Load information on data processing software from the database into IdentificationData.
void loadScoreTypes_(IdentificationData &id_data)
Load information on score type from the database into IdentificationData.
std::unordered_map< Key, IdentificationData::ParentSequenceRef > parent_sequence_refs_
Definition: OMSFileLoad.h:195
void loadDataProcessing_(std::vector< DataProcessing > &data_processing)
Load information on data processing for feature/consensus maps from the database.
std::unordered_map< Key, IdentificationData::InputFileRef > input_file_refs_
Definition: OMSFileLoad.h:190
void loadObservationMatches_(IdentificationData &id_data)
Load information on observation matches (e.g. PSMs) from the database into IdentificationData.
OMSFileStore::Key Key
Type used for database keys.
Definition: OMSFileLoad.h:37
static DataValue makeDataValue_(const SQLite::Statement &query)
Generate a DataValue with information returned by an SQL query.
void loadMapMetaData_(FeatureMap &features)
Load feature map meta data from the database.
QJsonArray exportTableToJSON_(const QString &table, const QString &order_by)
Export the contents of a database table to JSON.
int version_number_
schema version number
Definition: OMSFileLoad.h:184
void loadFeatures_(FeatureMap &features)
Load information on features from the database into a feature map.
void loadParentGroupSets_(IdentificationData &id_data)
Load information on parent group sets (e.g. protein groups) from the database into IdentificationData...
Feature loadFeatureAndSubordinates_(SQLite::Statement &query_feat, SQLite::Statement &query_meta, SQLite::Statement &query_match, SQLite::Statement &query_hull)
Generate a feature (incl. subordinate features) from data returned by SQL queries.
void handleQueryAppliedProcessingStep_(SQLite::Statement &query, IdentificationDataInternal::ScoredProcessingResult &result, Key parent_id)
Store results from an SQL query on processing metadata in a ScoredProcessingResult(-derived) object.
void exportToJSON(std::ostream &output)
Export database contents in JSON format, write to stream.
std::unordered_map< Key, IdentificationData::ObservationRef > observation_refs_
Definition: OMSFileLoad.h:194
void load(ConsensusMap &consensus)
Load data from database and populate a ConsensusMap object.
std::unordered_map< Key, IdentificationData::SearchParamRef > search_param_refs_
Definition: OMSFileLoad.h:193
void load(FeatureMap &features)
Load data from database and populate a FeatureMap object.
QString subquery_score_
query for score types used in JSON export
Definition: OMSFileLoad.h:186
bool prepareQueryMetaInfo_(SQLite::Statement &query, const String &parent_table)
Prepare SQL query for loading meta values associated with a particular class (stored in parent_table)
bool prepareQueryAppliedProcessingStep_(SQLite::Statement &query, const String &parent_table)
Prepare SQL query for loading processing metadata associated with a particular class (stored in paren...
void handleQueryParentMatch_(SQLite::Statement &query, IdentificationData::ParentMatches &parent_matches, Key molecule_id)
Store results from an SQL query on parent matches.
void loadProcessingSteps_(IdentificationData &id_data)
Load information on data processing steps from the database into IdentificationData.
std::unordered_map< Key, IdentificationData::ObservationMatchRef > observation_match_refs_
Definition: OMSFileLoad.h:197
BaseFeature makeBaseFeature_(int id, SQLite::Statement &query_feat, SQLite::Statement &query_meta, SQLite::Statement &query_match)
Generate a BaseFeature (parent class) from data returned by SQL queries.
void loadAdducts_(IdentificationData &id_data)
Load information on adducts from the database into IdentificationData.
void handleQueryPeakAnnotation_(SQLite::Statement &query, IdentificationData::ObservationMatch &match, Key parent_id)
Store results from an SQL query on peak annotations in an observation match.
void loadConsensusColumnHeaders_(ConsensusMap &consensus)
Load consensus map column headers from the database.
void loadObservations_(IdentificationData &id_data)
Load information on observations (e.g. spectra) from the database into IdentificationData.
OMSFileLoad(const String &filename, LogType log_type)
std::unordered_map< Key, IdentificationData::ScoreTypeRef > score_type_refs_
Definition: OMSFileLoad.h:189
void loadInputFiles_(IdentificationData &id_data)
Load information on input files from the database into IdentificationData.
std::unique_ptr< SQLite::Database > db_
The database connection (read)
Definition: OMSFileLoad.h:182
void loadDBSearchParams_(IdentificationData &id_data)
Load information on sequence database search parameters from the database into IdentificationData.
std::unordered_map< Key, IdentificationData::ProcessingStepRef > processing_step_refs_
Definition: OMSFileLoad.h:192
void prepareQueriesBaseFeature_(SQLite::Statement &query_meta, SQLite::Statement &query_match)
Prepare SQL queries for loading (meta) data on BaseFeatures from the database.
std::unordered_map< Key, IdentificationData::AdductRef > adduct_refs_
Definition: OMSFileLoad.h:198
void loadMapMetaData_(ConsensusMap &consensus)
Load consensus map meta data from the database.
void handleQueryMetaInfo_(SQLite::Statement &query, MetaInfoInterface &info, Key parent_id)
Store results from an SQL query on meta values in a MetaInfoInterface(-derived) object.
static bool isEmpty_(const SQLite::Statement &query)
Does the query contain an empty SQL statement (signifying that it shouldn't be executed)?
static std::map< QString, QString > export_order_by_
Definition: OMSFileLoad.h:202
void loadIdentifiedCompounds_(IdentificationData &id_data)
Load information on identified compounds from the database into IdentificationData.
int64_t Key
< Type used for database keys
Definition: OMSFileStore.h:62
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:35
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
Possible log types.
Definition: ProgressLogger.h:43
A more convenient string class.
Definition: String.h:34
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
Definition: OMSFileLoad.h:18
Representation of a search hit (e.g. peptide-spectrum match).
Definition: ObservationMatch.h:48
Base class for ID data with scores and processing steps (and meta info)
Definition: ScoredProcessingResult.h:19