Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DBAdapter Class Reference

A class for accessing and storing data in a SQL database. More...

#include <OpenMS/FORMAT/DB/DBAdapter.h>

Public Member Functions

 DBAdapter (DBConnection &db_con)
 Constructor. More...
 
 ~DBAdapter ()
 Destructor. More...
 
template<class ExperimentType >
void storeExperiment (ExperimentType &exp)
 Stores a MSExperiment. More...
 
template<class ExperimentType >
void loadExperiment (UID id, ExperimentType &exp)
 Reads a MSExperiment. More...
 
template<class SpectrumType >
void loadSpectrum (UID id, SpectrumType &spec)
 Reads a MSSpectrum. More...
 
PeakFileOptionsgetOptions ()
 Mutable access to the options for loading/storing. More...
 
const PeakFileOptionsgetOptions () const
 Non-mutable access to the options for loading/storing. More...
 
bool checkDBVersion (bool warning)
 Returns true if the DB is up-to-date (Checks the version in ADMIN_Version table). More...
 
void createDB ()
 Deletes all tables in the database and creates a new OpenMS database. More...
 

Private Member Functions

 DBAdapter ()
 Not implemented. More...
 
UID storeMetaInfo_ (const String &parent_table, UID parent_id, const MetaInfoInterface &info)
 Stores, updates or deletes MetaInfo data. More...
 
UID storeMetaInfo_ (const String &parent_table, UID parent_id, const Peak1D &peak)
 Overload for Peak1D that does nothing. More...
 
UID storeMetaInfo_ (const String &parent_table, UID parent_id, const RichPeak1D &peak)
 Overloaded method for RichPeak1D, which is both a MetaInfoInterface and a Peak1D. More...
 
UID storeMetaInfo_ (const String &parent_table, UID parent_id, const Precursor &peak)
 Overloaded method for RichPeak1D, which is both a MetaInfoInterface (via CVTermList) and a and a Peak1D. More...
 
void loadMetaInfo_ (UID id, MetaInfoInterface &info)
 Loads MetaInfo data from database. More...
 
void loadMetaInfo_ (UID id, Peak1D &peak)
 Overloaded method for Peak1D, which does nothing. More...
 
void loadMetaInfo_ (UID id, RichPeak1D &peak)
 Overloaded method for RichPeak1D, which is both a MetaInfoInterface and a Peak1D. More...
 
void loadMetaInfo_ (UID id, Precursor &peak)
 Overloaded method for Precursor, which is both a MetaInfoInterface (via CVTermList) and a Peak1D. More...
 
void deleteMetaInfo_ (const String &parent_table, const String &condition)
 Conditionally deletes MetaInfo data from database. More...
 
UID storeFile_ (const String &parent_table, UID parent_id, const SourceFile &file)
 Stores, updates or deletes file information. More...
 
void loadFile_ (UID id, SourceFile &file)
 Loads file information. More...
 
UID storeSample_ (const Sample &sample, UID exp_id, UID parent_id)
 Stores, updates or deletes sample information. More...
 
void loadSample_ (UID id, Sample &sample)
 Loads sample information. More...
 

Private Attributes

DBConnectiondb_con_
 Reference to the DB connection handed over in the constructor. More...
 
PeakFileOptions options_
 

Detailed Description

A class for accessing and storing data in a SQL database.

It can be used to create objects from the DB or store them in the DB.

Todo:

Add DataProcessing to MetaInfoDescription (Hiwi, Mathias)

Check if test is really complete (Hiwi, Mathias)

Check that all values are quoted (Hiwi, Mathias)

Implement StringDataArray and IntegerDataArray of spectrum (Hiwi, Mathias)

Constructor & Destructor Documentation

DBAdapter ( DBConnection db_con)

Constructor.

~DBAdapter ( )

Destructor.

DBAdapter ( )
private

Not implemented.

Member Function Documentation

bool checkDBVersion ( bool  warning)

Returns true if the DB is up-to-date (Checks the version in ADMIN_Version table).

Parameters
warningif this is set, a warning is issued to stderr if the db is not up-to-date.

Referenced by DBAdapter::loadExperiment(), DBAdapter::loadSpectrum(), and DBAdapter::storeExperiment().

void createDB ( )

Deletes all tables in the database and creates a new OpenMS database.

void deleteMetaInfo_ ( const String parent_table,
const String condition 
)
private

Conditionally deletes MetaInfo data from database.

Referenced by DBAdapter::storeExperiment().

PeakFileOptions& getOptions ( )

Mutable access to the options for loading/storing.

Referenced by TOPPViewBase::metadataDatabaseDialog().

const PeakFileOptions& getOptions ( ) const

Non-mutable access to the options for loading/storing.

void loadExperiment ( UID  id,
ExperimentType &  exp 
)

Reads a MSExperiment.

References DBAdapter::checkDBVersion(), ProteinIdentification::SearchParameters::db, DBAdapter::db_con_, DBConnection::executeQuery(), PeakFileOptions::getMetadataOnly(), PeakFileOptions::getMSLevels(), PeakFileOptions::getRTRange(), ProteinIdentification::getSearchParameters(), PeakFileOptions::hasMSLevels(), PeakFileOptions::hasRTRange(), DBAdapter::loadMetaInfo_(), DBAdapter::loadSample_(), DBAdapter::loadSpectrum(), DIntervalBase< D >::maxPosition(), DIntervalBase< D >::minPosition(), DBAdapter::options_, DateTime::set(), ProteinHit::setAccession(), MassAnalyzer::setAccuracy(), IonDetector::setAcquisitionMode(), IonDetector::setADCSamplingFrequency(), ContactPerson::setContactInfo(), ProteinIdentification::setDateTime(), ContactPerson::setEmail(), MassAnalyzer::setFinalMSExponent(), ContactPerson::setFirstName(), ProteinIdentification::setHigherScoreBetter(), ProteinIdentification::setHits(), IonSource::setInletType(), ContactPerson::setInstitution(), IonSource::setIonizationMethod(), MassAnalyzer::setIsolationWidth(), ContactPerson::setLastName(), MassAnalyzer::setMagneticFieldStrength(), Software::setName(), IonDetector::setOrder(), IonSource::setOrder(), MassAnalyzer::setOrder(), IonSource::setPolarity(), ProteinHit::setRank(), MassAnalyzer::setReflectronState(), IonDetector::setResolution(), MassAnalyzer::setResolution(), MassAnalyzer::setResolutionMethod(), MassAnalyzer::setResolutionType(), MassAnalyzer::setScanDirection(), MassAnalyzer::setScanLaw(), MassAnalyzer::setScanRate(), MassAnalyzer::setScanTime(), ProteinHit::setScore(), ProteinIdentification::setScoreType(), ProteinIdentification::setSearchEngine(), ProteinIdentification::setSearchEngineVersion(), ProteinIdentification::setSearchParameters(), ProteinHit::setSequence(), ProteinIdentification::setSignificanceThreshold(), MassAnalyzer::setTOFTotalPathLength(), IonDetector::setType(), MassAnalyzer::setType(), Software::setVersion(), String::toInt(), and String::toQString().

Referenced by TOPPViewBase::addDataDB(), and TOPPViewBase::metadataDatabaseDialog().

void loadFile_ ( UID  id,
SourceFile file 
)
private

Loads file information.

Referenced by DBAdapter::loadSpectrum().

void loadMetaInfo_ ( UID  id,
MetaInfoInterface info 
)
private

Loads MetaInfo data from database.

Referenced by DBAdapter::loadExperiment(), and DBAdapter::loadSpectrum().

void loadMetaInfo_ ( UID  id,
Peak1D peak 
)
private

Overloaded method for Peak1D, which does nothing.

void loadMetaInfo_ ( UID  id,
RichPeak1D peak 
)
private

Overloaded method for RichPeak1D, which is both a MetaInfoInterface and a Peak1D.

void loadMetaInfo_ ( UID  id,
Precursor peak 
)
private

Overloaded method for Precursor, which is both a MetaInfoInterface (via CVTermList) and a Peak1D.

void loadSample_ ( UID  id,
Sample sample 
)
private

Loads sample information.

Referenced by DBAdapter::loadExperiment().

void loadSpectrum ( UID  id,
SpectrumType &  spec 
)
void storeExperiment ( ExperimentType &  exp)
UID storeFile_ ( const String parent_table,
UID  parent_id,
const SourceFile file 
)
private

Stores, updates or deletes file information.

Returns
the id of the new META_File table row

Referenced by DBAdapter::storeExperiment().

UID storeMetaInfo_ ( const String parent_table,
UID  parent_id,
const MetaInfoInterface info 
)
private

Stores, updates or deletes MetaInfo data.

Returns
the id of the new META_MetaInfo table row

Referenced by DBAdapter::storeExperiment().

UID storeMetaInfo_ ( const String parent_table,
UID  parent_id,
const Peak1D peak 
)
private

Overload for Peak1D that does nothing.

UID storeMetaInfo_ ( const String parent_table,
UID  parent_id,
const RichPeak1D peak 
)
private

Overloaded method for RichPeak1D, which is both a MetaInfoInterface and a Peak1D.

UID storeMetaInfo_ ( const String parent_table,
UID  parent_id,
const Precursor peak 
)
private

Overloaded method for RichPeak1D, which is both a MetaInfoInterface (via CVTermList) and a and a Peak1D.

UID storeSample_ ( const Sample sample,
UID  exp_id,
UID  parent_id 
)
private

Stores, updates or deletes sample information.

Returns
the id of the new META_Sample table row

Referenced by DBAdapter::storeExperiment().

Member Data Documentation

DBConnection& db_con_
private

Reference to the DB connection handed over in the constructor.

Referenced by DBAdapter::loadExperiment(), DBAdapter::loadSpectrum(), and DBAdapter::storeExperiment().

PeakFileOptions options_
private

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:30 using doxygen 1.8.5