OpenMS
OMSFileStore Class Reference

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

#include <OpenMS/FORMAT/OMSFileStore.h>

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

Public Types

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

Public Member Functions

 OMSFileStore (const String &filename, LogType log_type)
 Constructor. More...
 
 ~OMSFileStore ()
 Destructor. More...
 
void store (const IdentificationData &id_data)
 Write data from an IdentificationData object to database. More...
 
void store (const FeatureMap &features)
 Write data from a FeatureMap object to database. More...
 
void store (const ConsensusMap &consensus)
 Write data from a ConsensusMap object to database. 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 setLogger (ProgressLoggerImpl *logger)
 Sets the logger to be used for progress logging. 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 createTable_ (const String &name, const String &definition, bool may_exist=false)
 Helper function to create a database table. More...
 
void createTableDataValue_DataType_ ()
 Create a database table for the data types used in DataValue. More...
 
void createTableCVTerm_ ()
 Create a database table (and prepare a query) for storing CV terms. More...
 
void createTableMetaInfo_ (const String &parent_table, const String &key_column="id")
 Create a database table (and prepare a query) for storing meta values. More...
 
void storeVersionAndDate_ ()
 Store version information and current date/time in the database. More...
 
Key storeCVTerm_ (const CVTerm &cv_term)
 Store a CV term in the database. More...
 
void storeMetaInfo_ (const MetaInfoInterface &info, const String &parent_table, Key parent_id)
 Store meta values (associated with one object) in the database. More...
 
template<class MetaInfoInterfaceContainer , class DBKeyTable >
void storeMetaInfos_ (const MetaInfoInterfaceContainer &container, const String &parent_table, const DBKeyTable &db_keys)
 Store meta values (for all objects in a container) in the database. More...
 
Helper functions for storing identification data

Store score type information from IdentificationData in the database

void storeScoreTypes_ (const IdentificationData &id_data)
 
void storeInputFiles_ (const IdentificationData &id_data)
 Store input file information from IdentificationData in the database. More...
 
void storeProcessingSoftwares_ (const IdentificationData &id_data)
 Store information on data processing software from IdentificationData in the database. More...
 
void storeDBSearchParams_ (const IdentificationData &id_data)
 Store sequence database search parameters from IdentificationData in the database. More...
 
void storeProcessingSteps_ (const IdentificationData &id_data)
 Store information on data processing steps from IdentificationData in the database. More...
 
void storeObservations_ (const IdentificationData &id_data)
 Store information on observations (e.g. spectra) from IdentificationData in the database. More...
 
void storeParentSequences_ (const IdentificationData &id_data)
 Store information on parent sequences (e.g. proteins) from IdentificationData in the database. More...
 
void storeParentGroupSets_ (const IdentificationData &id_data)
 Store information on parent group sets (e.g. protein groups) from IdentificationData in the database. More...
 
void storeIdentifiedCompounds_ (const IdentificationData &id_data)
 Store information on identified compounds from IdentificationData in the database. More...
 
void storeIdentifiedSequences_ (const IdentificationData &id_data)
 Store information on identified sequences (peptides or oligonucleotides) from IdentificationData in the database. More...
 
void storeAdducts_ (const IdentificationData &id_data)
 Store information on adducts from IdentificationData in the database. More...
 
void storeObservationMatches_ (const IdentificationData &id_data)
 Store information on observation matches (e.g. PSMs) from IdentificationData in the database. More...
 
void createTableMoleculeType_ ()
 Create a database table for molecule types (proteins, compounds, RNA) More...
 
void createTableAppliedProcessingStep_ (const String &parent_table)
 Create a database table for storing processing metadata. More...
 
void storeAppliedProcessingStep_ (const IdentificationData::AppliedProcessingStep &step, Size step_order, const String &parent_table, Key parent_id)
 Store processing metadata for a particular class (stored in parent_table) in the database. More...
 
void createTableIdentifiedMolecule_ ()
 Create a database table for storing identified molecules (peptides, compounds, oligonucleotides) More...
 
Key getDatabaseKey_ (const IdentificationData::IdentifiedMolecule &molecule_var)
 Return the database key used for an identified molecule (peptide, compound or oligonucleotide) More...
 
void createTableParentMatches_ ()
 Create a database table for storing parent matches (e.g. proteins for a peptide) More...
 
void storeParentMatches_ (const IdentificationData::ParentMatches &matches, Key molecule_id)
 Store information on parent matches in the database. More...
 
template<class ScoredProcessingResultContainer , class DBKeyTable >
void storeScoredProcessingResults_ (const ScoredProcessingResultContainer &container, const String &parent_table, const DBKeyTable &db_keys)
 Store metadata on scores/processing steps (for all objects in a container) in the database. More...
 
Helper functions for storing (consensus) feature data

Create a table for storing feature information

void createTableBaseFeature_ (bool with_metainfo, bool with_idmatches)
 
void storeBaseFeature_ (const BaseFeature &feature, int feature_id, int parent_id)
 Store information on a feature in the database. More...
 
void storeFeatures_ (const FeatureMap &features)
 Store information on features from a feature map in the database. More...
 
void storeFeatureAndSubordinates_ (const Feature &feature, int &feature_id, int parent_id)
 Store a feature (incl. its subordinate features) in the database. More...
 
template<class FeatureContainer , class Predicate >
bool anyFeaturePredicate_ (const FeatureContainer &features, const Predicate &pred)
 check whether a predicate is true for any feature (or subordinate thereof) in a container More...
 
template<class MapType >
void storeMapMetaData_ (const MapType &features, const String &experiment_type="")
 Store feature/consensus map meta data in the database. More...
 
void storeDataProcessing_ (const std::vector< DataProcessing > &data_processing)
 Store information on data processing from a feature/consensus map in the database. More...
 
void storeConsensusFeatures_ (const ConsensusMap &consensus)
 Store information on consensus features from a consensus map in the database. More...
 
void storeConsensusColumnHeaders_ (const ConsensusMap &consensus)
 Store information on column headers from a consensus map in the database. More...
 

Private Attributes

std::unique_ptr< SQLite::Database > db_
 The database connection (read/write) More...
 
std::map< std::string, std::unique_ptr< SQLite::Statement > > prepared_queries_
 Prepared queries for inserting data into different tables. More...
 
std::map< const IdentificationData::ScoreType *, Keyscore_type_keys_
 
std::map< const IdentificationData::InputFile *, Keyinput_file_keys_
 
std::map< const IdentificationData::ProcessingSoftware *, Keyprocessing_software_keys_
 
std::map< const IdentificationData::ProcessingStep *, Keyprocessing_step_keys_
 
std::map< const IdentificationData::DBSearchParam *, Keysearch_param_keys_
 
std::map< const IdentificationData::Observation *, Keyobservation_keys_
 
std::map< const IdentificationData::ParentSequence *, Keyparent_sequence_keys_
 
std::map< const IdentificationData::ParentGroupSet *, Keyparent_grouping_keys_
 
std::map< const IdentificationData::IdentifiedCompound *, Keyidentified_compound_keys_
 
std::map< const IdentificationData::IdentifiedPeptide *, Keyidentified_peptide_keys_
 
std::map< const IdentificationData::IdentifiedOligo *, Keyidentified_oligo_keys_
 
std::map< const AdductInfo *, Keyadduct_keys_
 
std::map< const IdentificationData::ObservationMatch *, Keyobservation_match_keys_
 
std::map< const DataProcessing *, Keyfeat_processing_keys_
 

Additional Inherited Members

- 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 storing .oms files (SQLite format)

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

Member Typedef Documentation

◆ Key

using Key = int64_t

< Type used for database keys

Constructor & Destructor Documentation

◆ OMSFileStore()

OMSFileStore ( const String filename,
LogType  log_type 
)

Constructor.

Deletes the output file if it exists, then creates an SQLite database in its place. Opens the database and configures it for fast writing.

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

◆ ~OMSFileStore()

Destructor.

Closes the connection to the database file.

Member Function Documentation

◆ anyFeaturePredicate_()

bool anyFeaturePredicate_ ( const FeatureContainer &  features,
const Predicate &  pred 
)
inlineprivate

check whether a predicate is true for any feature (or subordinate thereof) in a container

◆ createTable_()

void createTable_ ( const String name,
const String definition,
bool  may_exist = false 
)
private

Helper function to create a database table.

Parameters
nameName of the new table
definitionTable definition in SQL
may_existIf true, the table may already exist (otherwise this is an error)

◆ createTableAppliedProcessingStep_()

void createTableAppliedProcessingStep_ ( const String parent_table)
private

Create a database table for storing processing metadata.

Referenced by OMSFileStore::storeScoredProcessingResults_().

◆ createTableBaseFeature_()

void createTableBaseFeature_ ( bool  with_metainfo,
bool  with_idmatches 
)
private

◆ createTableCVTerm_()

void createTableCVTerm_ ( )
private

Create a database table (and prepare a query) for storing CV terms.

◆ createTableDataValue_DataType_()

void createTableDataValue_DataType_ ( )
private

Create a database table for the data types used in DataValue.

◆ createTableIdentifiedMolecule_()

void createTableIdentifiedMolecule_ ( )
private

Create a database table for storing identified molecules (peptides, compounds, oligonucleotides)

◆ createTableMetaInfo_()

void createTableMetaInfo_ ( const String parent_table,
const String key_column = "id" 
)
private

Create a database table (and prepare a query) for storing meta values.

Referenced by OMSFileStore::storeMetaInfos_().

◆ createTableMoleculeType_()

void createTableMoleculeType_ ( )
private

Create a database table for molecule types (proteins, compounds, RNA)

◆ createTableParentMatches_()

void createTableParentMatches_ ( )
private

Create a database table for storing parent matches (e.g. proteins for a peptide)

◆ getDatabaseKey_()

Key getDatabaseKey_ ( const IdentificationData::IdentifiedMolecule molecule_var)
private

Return the database key used for an identified molecule (peptide, compound or oligonucleotide)

◆ store() [1/3]

void store ( const ConsensusMap consensus)

Write data from a ConsensusMap object to database.

◆ store() [2/3]

void store ( const FeatureMap features)

Write data from a FeatureMap object to database.

◆ store() [3/3]

void store ( const IdentificationData id_data)

Write data from an IdentificationData object to database.

◆ storeAdducts_()

void storeAdducts_ ( const IdentificationData id_data)
private

Store information on adducts from IdentificationData in the database.

◆ storeAppliedProcessingStep_()

void storeAppliedProcessingStep_ ( const IdentificationData::AppliedProcessingStep step,
Size  step_order,
const String parent_table,
Key  parent_id 
)
private

Store processing metadata for a particular class (stored in parent_table) in the database.

Referenced by OMSFileStore::storeScoredProcessingResults_().

◆ storeBaseFeature_()

void storeBaseFeature_ ( const BaseFeature feature,
int  feature_id,
int  parent_id 
)
private

Store information on a feature in the database.

◆ storeConsensusColumnHeaders_()

void storeConsensusColumnHeaders_ ( const ConsensusMap consensus)
private

Store information on column headers from a consensus map in the database.

◆ storeConsensusFeatures_()

void storeConsensusFeatures_ ( const ConsensusMap consensus)
private

Store information on consensus features from a consensus map in the database.

◆ storeCVTerm_()

Key storeCVTerm_ ( const CVTerm cv_term)
private

Store a CV term in the database.

◆ storeDataProcessing_()

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

Store information on data processing from a feature/consensus map in the database.

◆ storeDBSearchParams_()

void storeDBSearchParams_ ( const IdentificationData id_data)
private

Store sequence database search parameters from IdentificationData in the database.

◆ storeFeatureAndSubordinates_()

void storeFeatureAndSubordinates_ ( const Feature feature,
int &  feature_id,
int  parent_id 
)
private

Store a feature (incl. its subordinate features) in the database.

◆ storeFeatures_()

void storeFeatures_ ( const FeatureMap features)
private

Store information on features from a feature map in the database.

◆ storeIdentifiedCompounds_()

void storeIdentifiedCompounds_ ( const IdentificationData id_data)
private

Store information on identified compounds from IdentificationData in the database.

◆ storeIdentifiedSequences_()

void storeIdentifiedSequences_ ( const IdentificationData id_data)
private

Store information on identified sequences (peptides or oligonucleotides) from IdentificationData in the database.

◆ storeInputFiles_()

void storeInputFiles_ ( const IdentificationData id_data)
private

Store input file information from IdentificationData in the database.

◆ storeMapMetaData_()

void storeMapMetaData_ ( const MapType features,
const String experiment_type = "" 
)
private

Store feature/consensus map meta data in the database.

◆ storeMetaInfo_()

void storeMetaInfo_ ( const MetaInfoInterface info,
const String parent_table,
Key  parent_id 
)
private

Store meta values (associated with one object) in the database.

Referenced by OMSFileStore::storeMetaInfos_().

◆ storeMetaInfos_()

void storeMetaInfos_ ( const MetaInfoInterfaceContainer &  container,
const String parent_table,
const DBKeyTable &  db_keys 
)
inlineprivate

Store meta values (for all objects in a container) in the database.

References OMSFileStore::createTableMetaInfo_(), and OMSFileStore::storeMetaInfo_().

Referenced by OMSFileStore::storeScoredProcessingResults_().

◆ storeObservationMatches_()

void storeObservationMatches_ ( const IdentificationData id_data)
private

Store information on observation matches (e.g. PSMs) from IdentificationData in the database.

◆ storeObservations_()

void storeObservations_ ( const IdentificationData id_data)
private

Store information on observations (e.g. spectra) from IdentificationData in the database.

◆ storeParentGroupSets_()

void storeParentGroupSets_ ( const IdentificationData id_data)
private

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

◆ storeParentMatches_()

void storeParentMatches_ ( const IdentificationData::ParentMatches matches,
Key  molecule_id 
)
private

Store information on parent matches in the database.

◆ storeParentSequences_()

void storeParentSequences_ ( const IdentificationData id_data)
private

Store information on parent sequences (e.g. proteins) from IdentificationData in the database.

◆ storeProcessingSoftwares_()

void storeProcessingSoftwares_ ( const IdentificationData id_data)
private

Store information on data processing software from IdentificationData in the database.

◆ storeProcessingSteps_()

void storeProcessingSteps_ ( const IdentificationData id_data)
private

Store information on data processing steps from IdentificationData in the database.

◆ storeScoredProcessingResults_()

void storeScoredProcessingResults_ ( const ScoredProcessingResultContainer &  container,
const String parent_table,
const DBKeyTable &  db_keys 
)
inlineprivate

Store metadata on scores/processing steps (for all objects in a container) in the database.

References OMSFileStore::createTableAppliedProcessingStep_(), OMSFileStore::storeAppliedProcessingStep_(), and OMSFileStore::storeMetaInfos_().

◆ storeScoreTypes_()

void storeScoreTypes_ ( const IdentificationData id_data)
private

◆ storeVersionAndDate_()

void storeVersionAndDate_ ( )
private

Store version information and current date/time in the database.

Member Data Documentation

◆ adduct_keys_

std::map<const AdductInfo*, Key> adduct_keys_
private

◆ db_

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

The database connection (read/write)

◆ feat_processing_keys_

std::map<const DataProcessing*, Key> feat_processing_keys_
private

◆ identified_compound_keys_

std::map<const IdentificationData::IdentifiedCompound*, Key> identified_compound_keys_
private

◆ identified_oligo_keys_

std::map<const IdentificationData::IdentifiedOligo*, Key> identified_oligo_keys_
private

◆ identified_peptide_keys_

std::map<const IdentificationData::IdentifiedPeptide*, Key> identified_peptide_keys_
private

◆ input_file_keys_

std::map<const IdentificationData::InputFile*, Key> input_file_keys_
private

◆ observation_keys_

std::map<const IdentificationData::Observation*, Key> observation_keys_
private

◆ observation_match_keys_

std::map<const IdentificationData::ObservationMatch*, Key> observation_match_keys_
private

◆ parent_grouping_keys_

std::map<const IdentificationData::ParentGroupSet*, Key> parent_grouping_keys_
private

◆ parent_sequence_keys_

std::map<const IdentificationData::ParentSequence*, Key> parent_sequence_keys_
private

◆ prepared_queries_

std::map<std::string, std::unique_ptr<SQLite::Statement> > prepared_queries_
private

Prepared queries for inserting data into different tables.

◆ processing_software_keys_

std::map<const IdentificationData::ProcessingSoftware*, Key> processing_software_keys_
private

◆ processing_step_keys_

std::map<const IdentificationData::ProcessingStep*, Key> processing_step_keys_
private

◆ score_type_keys_

std::map<const IdentificationData::ScoreType*, Key> score_type_keys_
private

◆ search_param_keys_

std::map<const IdentificationData::DBSearchParam*, Key> search_param_keys_
private