OpenMS  2.8.0
OMSFileLoad.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Hendrik Weisser $
32 // $Authors: Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
40 
41 class QSqlQuery;
42 
43 namespace OpenMS
44 {
45  namespace Internal
46  {
53  {
54  public:
55  using Key = qint64;
56 
67  OMSFileLoad(const String& filename, LogType log_type);
68 
75 
77  void load(IdentificationData& id_data);
78 
80  void load(FeatureMap& features);
81 
82  private:
83  // static CVTerm loadCVTerm_(int id);
84 
86 
88 
90 
92 
94 
96 
98 
100 
102 
104 
106 
108 
109  void loadMapMetaData_(FeatureMap& features);
110 
112 
113  void loadFeatures_(FeatureMap& features);
114 
115  Feature loadFeatureAndSubordinates_(QSqlQuery& query_feat,
116  std::optional<QSqlQuery>& query_meta,
117  std::optional<QSqlQuery>& query_hull,
118  std::optional<QSqlQuery>& query_match);
119 
120  static DataValue makeDataValue_(const QSqlQuery& query);
121 
122  bool prepareQueryMetaInfo_(QSqlQuery& query, const String& parent_table);
123 
124  void handleQueryMetaInfo_(QSqlQuery& query, MetaInfoInterface& info,
125  Key parent_id);
126 
127  bool prepareQueryAppliedProcessingStep_(QSqlQuery& query,
128  const String& parent_table);
129 
131  QSqlQuery& query,
133  Key parent_id);
134 
136  QSqlQuery& query, IdentificationData::ParentMatches& parent_matches,
137  Key molecule_id);
138 
140  QSqlQuery& query, IdentificationData::ObservationMatch& match,
141  Key parent_id);
142 
143  // store name, not database connection itself (see https://stackoverflow.com/a/55200682):
144  QString db_name_;
145 
146  // mappings between database keys and loaded data:
147  std::unordered_map<Key, IdentificationData::ScoreTypeRef> score_type_refs_;
148  std::unordered_map<Key, IdentificationData::InputFileRef> input_file_refs_;
149  std::unordered_map<Key, IdentificationData::ProcessingSoftwareRef> processing_software_refs_;
150  std::unordered_map<Key, IdentificationData::ProcessingStepRef> processing_step_refs_;
151  std::unordered_map<Key, IdentificationData::SearchParamRef> search_param_refs_;
152  std::unordered_map<Key, IdentificationData::ObservationRef> observation_refs_;
153  std::unordered_map<Key, IdentificationData::ParentSequenceRef> parent_refs_;
154  std::unordered_map<Key, IdentificationData::IdentifiedMolecule> identified_molecule_vars_;
155  std::unordered_map<Key, IdentificationData::ObservationMatchRef> observation_match_refs_;
156  std::unordered_map<Key, IdentificationData::AdductRef> adduct_refs_;
157  };
158  }
159 }
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:59
A container for features.
Definition: FeatureMap.h:106
An LC-MS feature.
Definition: Feature.h:72
Representation of spectrum identification results and associated data.
Definition: IdentificationData.h:95
IdentificationDataInternal::ParentMatches ParentMatches
Definition: IdentificationData.h:146
Helper class for loading .oms files (SQLite format)
Definition: OMSFileLoad.h:53
std::unordered_map< Key, IdentificationData::IdentifiedMolecule > identified_molecule_vars_
Definition: OMSFileLoad.h:154
void loadParentSequences_(IdentificationData &id_data)
void loadIdentifiedSequences_(IdentificationData &id_data)
std::unordered_map< Key, IdentificationData::ProcessingSoftwareRef > processing_software_refs_
Definition: OMSFileLoad.h:149
void load(IdentificationData &id_data)
Load data from database and populate an IdentificationData object.
void loadProcessingSoftwares_(IdentificationData &id_data)
void loadScoreTypes_(IdentificationData &id_data)
void handleQueryParentMatch_(QSqlQuery &query, IdentificationData::ParentMatches &parent_matches, Key molecule_id)
std::unordered_map< Key, IdentificationData::InputFileRef > input_file_refs_
Definition: OMSFileLoad.h:148
void loadObservationMatches_(IdentificationData &id_data)
void loadMapMetaData_(FeatureMap &features)
void loadFeatures_(FeatureMap &features)
void loadParentGroupSets_(IdentificationData &id_data)
qint64 Key
Type used for database keys.
Definition: OMSFileLoad.h:55
bool prepareQueryMetaInfo_(QSqlQuery &query, const String &parent_table)
std::unordered_map< Key, IdentificationData::ObservationRef > observation_refs_
Definition: OMSFileLoad.h:152
std::unordered_map< Key, IdentificationData::ParentSequenceRef > parent_refs_
Definition: OMSFileLoad.h:153
std::unordered_map< Key, IdentificationData::SearchParamRef > search_param_refs_
Definition: OMSFileLoad.h:151
void load(FeatureMap &features)
Load data from database and populate a FeatureMap object.
static DataValue makeDataValue_(const QSqlQuery &query)
void loadProcessingSteps_(IdentificationData &id_data)
std::unordered_map< Key, IdentificationData::ObservationMatchRef > observation_match_refs_
Definition: OMSFileLoad.h:155
void loadAdducts_(IdentificationData &id_data)
void loadObservations_(IdentificationData &id_data)
void handleQueryMetaInfo_(QSqlQuery &query, MetaInfoInterface &info, Key parent_id)
OMSFileLoad(const String &filename, LogType log_type)
Constructor.
std::unordered_map< Key, IdentificationData::ScoreTypeRef > score_type_refs_
Definition: OMSFileLoad.h:147
bool prepareQueryAppliedProcessingStep_(QSqlQuery &query, const String &parent_table)
void loadInputFiles_(IdentificationData &id_data)
void handleQueryAppliedProcessingStep_(QSqlQuery &query, IdentificationDataInternal::ScoredProcessingResult &result, Key parent_id)
void handleQueryPeakAnnotation_(QSqlQuery &query, IdentificationData::ObservationMatch &match, Key parent_id)
void loadDBSearchParams_(IdentificationData &id_data)
std::unordered_map< Key, IdentificationData::ProcessingStepRef > processing_step_refs_
Definition: OMSFileLoad.h:150
std::unordered_map< Key, IdentificationData::AdductRef > adduct_refs_
Definition: OMSFileLoad.h:156
void loadDataProcessing_(FeatureMap &features)
Feature loadFeatureAndSubordinates_(QSqlQuery &query_feat, std::optional< QSqlQuery > &query_meta, std::optional< QSqlQuery > &query_hull, std::optional< QSqlQuery > &query_match)
void loadIdentifiedCompounds_(IdentificationData &id_data)
QString db_name_
Definition: OMSFileLoad.h:144
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:61
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:53
LogType
Possible log types.
Definition: ProgressLogger.h:69
A more convenient string class.
Definition: String.h:60
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Representation of a search hit (e.g. peptide-spectrum match).
Definition: ObservationMatch.h:74
Base class for ID data with scores and processing steps (and meta info)
Definition: ScoredProcessingResult.h:45