OpenMS
OMSFileLoad Class Reference

Helper class for loading .oms files (SQLite format) More...

#include <OpenMS/FORMAT/OMSFileLoad.h>

Inheritance diagram for OMSFileLoad:
[legend]
Collaboration diagram for OMSFileLoad:
[legend]

Public Types

using Key = OMSFileStore::Key
 Type used for database keys. More...
 
- Public Types inherited from ProgressLogger
enum  LogType { CMD , GUI , NONE }
 Possible log types. More...
 

Public Member Functions

 OMSFileLoad (const String &filename, LogType log_type)
 Constructor. More...
 
 ~OMSFileLoad ()
 Destructor. More...
 
void load (IdentificationData &id_data)
 Load data from database and populate an IdentificationData object. More...
 
void load (FeatureMap &features)
 Load data from database and populate a FeatureMap object. More...
 
void load (ConsensusMap &consensus)
 Load data from database and populate a ConsensusMap object. More...
 
void exportToJSON (std::ostream &output)
 Export database contents in JSON format, write to stream. More...
 
- Public Member Functions inherited from ProgressLogger
 ProgressLogger ()
 Constructor. More...
 
virtual ~ProgressLogger ()
 Destructor. More...
 
 ProgressLogger (const ProgressLogger &other)
 Copy constructor. More...
 
ProgressLoggeroperator= (const ProgressLogger &other)
 Assignment Operator. More...
 
void setLogType (LogType type) const
 Sets the progress log that should be used. The default type is NONE! More...
 
LogType getLogType () const
 Returns the type of progress log being used. More...
 
void startProgress (SignedSize begin, SignedSize end, const String &label) const
 Initializes the progress display. More...
 
void setProgress (SignedSize value) const
 Sets the current progress. More...
 
void endProgress (UInt64 bytes_processed=0) const
 
void nextProgress () const
 increment progress by 1 (according to range begin-end) More...
 

Private Member Functions

void loadScoreTypes_ (IdentificationData &id_data)
 Load information on score type from the database into IdentificationData. More...
 
void loadInputFiles_ (IdentificationData &id_data)
 Load information on input files from the database into IdentificationData. More...
 
void loadProcessingSoftwares_ (IdentificationData &id_data)
 Load information on data processing software from the database into IdentificationData. More...
 
void loadDBSearchParams_ (IdentificationData &id_data)
 Load information on sequence database search parameters from the database into IdentificationData. More...
 
void loadProcessingSteps_ (IdentificationData &id_data)
 Load information on data processing steps from the database into IdentificationData. More...
 
void loadObservations_ (IdentificationData &id_data)
 Load information on observations (e.g. spectra) from the database into IdentificationData. More...
 
void loadParentSequences_ (IdentificationData &id_data)
 Load information on parent sequences (e.g. proteins) from the database into IdentificationData. More...
 
void loadParentGroupSets_ (IdentificationData &id_data)
 Load information on parent group sets (e.g. protein groups) from the database into IdentificationData. More...
 
void loadIdentifiedCompounds_ (IdentificationData &id_data)
 Load information on identified compounds from the database into IdentificationData. More...
 
void loadIdentifiedSequences_ (IdentificationData &id_data)
 Load information on identified sequences (peptides or oligonucleotides) from the database into IdentificationData. More...
 
void loadAdducts_ (IdentificationData &id_data)
 Load information on adducts from the database into IdentificationData. More...
 
void loadObservationMatches_ (IdentificationData &id_data)
 Load information on observation matches (e.g. PSMs) from the database into IdentificationData. More...
 
template<class MapType >
String loadMapMetaDataTemplate_ (MapType &features)
 Helper function for loading meta data on feature/consensus maps from the database. More...
 
void loadMapMetaData_ (FeatureMap &features)
 Load feature map meta data from the database. More...
 
void loadMapMetaData_ (ConsensusMap &consensus)
 Load consensus map meta data from the database. More...
 
void loadDataProcessing_ (std::vector< DataProcessing > &data_processing)
 Load information on data processing for feature/consensus maps from the database. More...
 
void loadFeatures_ (FeatureMap &features)
 Load information on features from the database into a feature map. More...
 
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. More...
 
void loadConsensusColumnHeaders_ (ConsensusMap &consensus)
 Load consensus map column headers from the database. More...
 
void loadConsensusFeatures_ (ConsensusMap &consensus)
 Load information on consensus features from the database into a consensus map. More...
 
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. More...
 
void prepareQueriesBaseFeature_ (SQLite::Statement &query_meta, SQLite::Statement &query_match)
 Prepare SQL queries for loading (meta) data on BaseFeatures from the database. More...
 
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) More...
 
void handleQueryMetaInfo_ (SQLite::Statement &query, MetaInfoInterface &info, Key parent_id)
 Store results from an SQL query on meta values in a MetaInfoInterface(-derived) object. More...
 
bool prepareQueryAppliedProcessingStep_ (SQLite::Statement &query, const String &parent_table)
 Prepare SQL query for loading processing metadata associated with a particular class (stored in parent_table) More...
 
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. More...
 
void handleQueryParentMatch_ (SQLite::Statement &query, IdentificationData::ParentMatches &parent_matches, Key molecule_id)
 Store results from an SQL query on parent matches. More...
 
void handleQueryPeakAnnotation_ (SQLite::Statement &query, IdentificationData::ObservationMatch &match, Key parent_id)
 Store results from an SQL query on peak annotations in an observation match. More...
 
QJsonArray exportTableToJSON_ (const QString &table, const QString &order_by)
 Export the contents of a database table to JSON. More...
 

Static Private Member Functions

static bool isEmpty_ (const SQLite::Statement &query)
 Does the query contain an empty SQL statement (signifying that it shouldn't be executed)? More...
 
static DataValue makeDataValue_ (const SQLite::Statement &query)
 Generate a DataValue with information returned by an SQL query. More...
 

Private Attributes

std::unique_ptr< SQLite::Database > db_
 The database connection (read) More...
 
int version_number_
 schema version number More...
 
QString subquery_score_
 query for score types used in JSON export More...
 
std::unordered_map< Key, IdentificationData::ScoreTypeRefscore_type_refs_
 
std::unordered_map< Key, IdentificationData::InputFileRefinput_file_refs_
 
std::unordered_map< Key, IdentificationData::ProcessingSoftwareRefprocessing_software_refs_
 
std::unordered_map< Key, IdentificationData::ProcessingStepRefprocessing_step_refs_
 
std::unordered_map< Key, IdentificationData::SearchParamRefsearch_param_refs_
 
std::unordered_map< Key, IdentificationData::ObservationRefobservation_refs_
 
std::unordered_map< Key, IdentificationData::ParentSequenceRefparent_sequence_refs_
 
std::unordered_map< Key, IdentificationData::IdentifiedMoleculeidentified_molecule_vars_
 
std::unordered_map< Key, IdentificationData::ObservationMatchRefobservation_match_refs_
 
std::unordered_map< Key, IdentificationData::AdductRefadduct_refs_
 

Static Private Attributes

static std::map< QString, QString > export_order_by_
 

Additional Inherited Members

- Static Protected Member Functions inherited from ProgressLogger
static String logTypeToFactoryName_ (LogType type)
 Return the name of the factory product used for this log type. More...
 
- Protected Attributes inherited from ProgressLogger
LogType type_
 
time_t last_invoke_
 
ProgressLoggerImplcurrent_logger_
 
- Static Protected Attributes inherited from ProgressLogger
static int recursion_depth_
 

Detailed Description

Helper class for loading .oms files (SQLite format)

This class encapsulates the SQLite database stored in a .oms file and allows to load data from it.

Member Typedef Documentation

◆ Key

Type used for database keys.

Constructor & Destructor Documentation

◆ OMSFileLoad()

OMSFileLoad ( const String filename,
LogType  log_type 
)

Constructor.

Opens the connection to the database file (in read-only mode).

Parameters
filenamePath to the .oms input file (SQLite database)
log_typeType of logging to use
Exceptions
Exception::FailedAPICallDatabase cannot be opened

◆ ~OMSFileLoad()

Destructor.

Closes the connection to the database file.

Member Function Documentation

◆ exportTableToJSON_()

QJsonArray exportTableToJSON_ ( const QString &  table,
const QString &  order_by 
)
private

Export the contents of a database table to JSON.

◆ exportToJSON()

void exportToJSON ( std::ostream &  output)

Export database contents in JSON format, write to stream.

◆ handleQueryAppliedProcessingStep_()

void handleQueryAppliedProcessingStep_ ( SQLite::Statement &  query,
IdentificationDataInternal::ScoredProcessingResult result,
Key  parent_id 
)
private

Store results from an SQL query on processing metadata in a ScoredProcessingResult(-derived) object.

◆ handleQueryMetaInfo_()

void handleQueryMetaInfo_ ( SQLite::Statement &  query,
MetaInfoInterface info,
Key  parent_id 
)
private

Store results from an SQL query on meta values in a MetaInfoInterface(-derived) object.

◆ handleQueryParentMatch_()

void handleQueryParentMatch_ ( SQLite::Statement &  query,
IdentificationData::ParentMatches parent_matches,
Key  molecule_id 
)
private

Store results from an SQL query on parent matches.

◆ handleQueryPeakAnnotation_()

void handleQueryPeakAnnotation_ ( SQLite::Statement &  query,
IdentificationData::ObservationMatch match,
Key  parent_id 
)
private

Store results from an SQL query on peak annotations in an observation match.

◆ isEmpty_()

static bool isEmpty_ ( const SQLite::Statement &  query)
staticprivate

Does the query contain an empty SQL statement (signifying that it shouldn't be executed)?

◆ load() [1/3]

void load ( ConsensusMap consensus)

Load data from database and populate a ConsensusMap object.

◆ load() [2/3]

void load ( FeatureMap features)

Load data from database and populate a FeatureMap object.

◆ load() [3/3]

void load ( IdentificationData id_data)

Load data from database and populate an IdentificationData object.

◆ loadAdducts_()

void loadAdducts_ ( IdentificationData id_data)
private

Load information on adducts from the database into IdentificationData.

◆ loadConsensusColumnHeaders_()

void loadConsensusColumnHeaders_ ( ConsensusMap consensus)
private

Load consensus map column headers from the database.

◆ loadConsensusFeatures_()

void loadConsensusFeatures_ ( ConsensusMap consensus)
private

Load information on consensus features from the database into a consensus map.

◆ loadDataProcessing_()

void loadDataProcessing_ ( std::vector< DataProcessing > &  data_processing)
private

Load information on data processing for feature/consensus maps from the database.

◆ loadDBSearchParams_()

void loadDBSearchParams_ ( IdentificationData id_data)
private

Load information on sequence database search parameters from the database into IdentificationData.

◆ loadFeatureAndSubordinates_()

Feature loadFeatureAndSubordinates_ ( SQLite::Statement &  query_feat,
SQLite::Statement &  query_meta,
SQLite::Statement &  query_match,
SQLite::Statement &  query_hull 
)
private

Generate a feature (incl. subordinate features) from data returned by SQL queries.

◆ loadFeatures_()

void loadFeatures_ ( FeatureMap features)
private

Load information on features from the database into a feature map.

◆ loadIdentifiedCompounds_()

void loadIdentifiedCompounds_ ( IdentificationData id_data)
private

Load information on identified compounds from the database into IdentificationData.

◆ loadIdentifiedSequences_()

void loadIdentifiedSequences_ ( IdentificationData id_data)
private

Load information on identified sequences (peptides or oligonucleotides) from the database into IdentificationData.

◆ loadInputFiles_()

void loadInputFiles_ ( IdentificationData id_data)
private

Load information on input files from the database into IdentificationData.

◆ loadMapMetaData_() [1/2]

void loadMapMetaData_ ( ConsensusMap consensus)
private

Load consensus map meta data from the database.

◆ loadMapMetaData_() [2/2]

void loadMapMetaData_ ( FeatureMap features)
private

Load feature map meta data from the database.

◆ loadMapMetaDataTemplate_()

String loadMapMetaDataTemplate_ ( MapType features)
private

Helper function for loading meta data on feature/consensus maps from the database.

◆ loadObservationMatches_()

void loadObservationMatches_ ( IdentificationData id_data)
private

Load information on observation matches (e.g. PSMs) from the database into IdentificationData.

◆ loadObservations_()

void loadObservations_ ( IdentificationData id_data)
private

Load information on observations (e.g. spectra) from the database into IdentificationData.

◆ loadParentGroupSets_()

void loadParentGroupSets_ ( IdentificationData id_data)
private

Load information on parent group sets (e.g. protein groups) from the database into IdentificationData.

◆ loadParentSequences_()

void loadParentSequences_ ( IdentificationData id_data)
private

Load information on parent sequences (e.g. proteins) from the database into IdentificationData.

◆ loadProcessingSoftwares_()

void loadProcessingSoftwares_ ( IdentificationData id_data)
private

Load information on data processing software from the database into IdentificationData.

◆ loadProcessingSteps_()

void loadProcessingSteps_ ( IdentificationData id_data)
private

Load information on data processing steps from the database into IdentificationData.

◆ loadScoreTypes_()

void loadScoreTypes_ ( IdentificationData id_data)
private

Load information on score type from the database into IdentificationData.

◆ makeBaseFeature_()

BaseFeature makeBaseFeature_ ( int  id,
SQLite::Statement &  query_feat,
SQLite::Statement &  query_meta,
SQLite::Statement &  query_match 
)
private

Generate a BaseFeature (parent class) from data returned by SQL queries.

◆ makeDataValue_()

static DataValue makeDataValue_ ( const SQLite::Statement &  query)
staticprivate

Generate a DataValue with information returned by an SQL query.

◆ prepareQueriesBaseFeature_()

void prepareQueriesBaseFeature_ ( SQLite::Statement &  query_meta,
SQLite::Statement &  query_match 
)
private

Prepare SQL queries for loading (meta) data on BaseFeatures from the database.

◆ prepareQueryAppliedProcessingStep_()

bool prepareQueryAppliedProcessingStep_ ( SQLite::Statement &  query,
const String parent_table 
)
private

Prepare SQL query for loading processing metadata associated with a particular class (stored in parent_table)

◆ prepareQueryMetaInfo_()

bool prepareQueryMetaInfo_ ( SQLite::Statement &  query,
const String parent_table 
)
private

Prepare SQL query for loading meta values associated with a particular class (stored in parent_table)

Member Data Documentation

◆ adduct_refs_

std::unordered_map<Key, IdentificationData::AdductRef> adduct_refs_
private

◆ db_

std::unique_ptr<SQLite::Database> db_
private

The database connection (read)

◆ export_order_by_

std::map<QString, QString> export_order_by_
staticprivate

◆ identified_molecule_vars_

std::unordered_map<Key, IdentificationData::IdentifiedMolecule> identified_molecule_vars_
private

◆ input_file_refs_

std::unordered_map<Key, IdentificationData::InputFileRef> input_file_refs_
private

◆ observation_match_refs_

std::unordered_map<Key, IdentificationData::ObservationMatchRef> observation_match_refs_
private

◆ observation_refs_

std::unordered_map<Key, IdentificationData::ObservationRef> observation_refs_
private

◆ parent_sequence_refs_

std::unordered_map<Key, IdentificationData::ParentSequenceRef> parent_sequence_refs_
private

◆ processing_software_refs_

std::unordered_map<Key, IdentificationData::ProcessingSoftwareRef> processing_software_refs_
private

◆ processing_step_refs_

std::unordered_map<Key, IdentificationData::ProcessingStepRef> processing_step_refs_
private

◆ score_type_refs_

std::unordered_map<Key, IdentificationData::ScoreTypeRef> score_type_refs_
private

◆ search_param_refs_

std::unordered_map<Key, IdentificationData::SearchParamRef> search_param_refs_
private

◆ subquery_score_

QString subquery_score_
private

query for score types used in JSON export

◆ version_number_

int version_number_
private

schema version number