Sleipnir
src/database.h
00001 /*****************************************************************************
00002 * This file is provided under the Creative Commons Attribution 3.0 license.
00003 *
00004 * You are free to share, copy, distribute, transmit, or adapt this work
00005 * PROVIDED THAT you attribute the work to the authors listed below.
00006 * For more information, please see the following web page:
00007 * http://creativecommons.org/licenses/by/3.0/
00008 *
00009 * This file is a component of the Sleipnir library for functional genomics,
00010 * authored by:
00011 * Curtis Huttenhower (chuttenh@princeton.edu)
00012 * Mark Schroeder
00013 * Maria D. Chikina
00014 * Olga G. Troyanskaya (ogt@princeton.edu, primary contact)
00015 *
00016 * If you use this library, the included executable tools, or any related
00017 * code in your work, please cite the following publication:
00018 * Curtis Huttenhower, Mark Schroeder, Maria D. Chikina, and
00019 * Olga G. Troyanskaya.
00020 * "The Sleipnir library for computational functional genomics"
00021 *****************************************************************************/
00022 #ifndef DATABASE_H
00023 #define DATABASE_H
00024 
00025 #include "databasei.h"
00026 
00027 namespace Sleipnir {
00028 
00029 class IBayesNet;
00030 
00073 class CDatabase : CDatabaseImpl {
00074 public:
00075 
00125     bool Open( const std::vector<std::string>& vecstrGenes, const std::string& strInputDirectory,
00126         const IBayesNet* pBayesNet, const std::string& strOutputDirectory, size_t iFiles, const map<string, size_t>& mapstriZeros);
00127 
00128 
00129     //Qian
00130     bool Open( const std::vector<std::string>& vecstrGenes, const std::vector<std::string>& vecstrDatasets,
00131         const std::string& strInputDirectory, const std::string& strOutputDirectory, size_t iFiles, const map<string, size_t>& mapstriZeros);
00132 
00133     //Qian
00134     CDatabase(bool isNibble) : CDatabaseImpl(isNibble){
00135     }
00136 
00137     bool Reorganize(const char*, const size_t&);
00138 
00139 
00140     bool GetGene(const string &, vector<unsigned char>&) const;
00141     bool GetGene(const size_t &, vector<unsigned char>&) const;
00142 
00143 
00154     bool Open( const std::string& strInputDirectory );
00155 
00156 
00179     bool Get( size_t iOne, size_t iTwo, std::vector<unsigned char>& vecbData ) const {
00180 
00181         return m_vecpDBs[ iOne % m_vecpDBs.size( ) ]->Get( iOne / m_vecpDBs.size( ), iTwo, vecbData ); }
00182 
00206     bool Get( size_t iGene, std::vector<unsigned char>& vecbData, bool fReplace = false ) const {
00207 
00208         return m_vecpDBs[ iGene % m_vecpDBs.size( ) ]->Get( iGene / m_vecpDBs.size( ), vecbData, fReplace ); }
00209 
00236     bool Get( size_t iGene, const std::vector<size_t>& veciGenes,
00237         std::vector<unsigned char>& vecbData, bool fReplace = false ) const {
00238 
00239         return m_vecpDBs[ iGene % m_vecpDBs.size( ) ]->Get( iGene / m_vecpDBs.size( ), veciGenes, vecbData,
00240             fReplace ); }
00241 
00249     size_t GetGenes( ) const {
00250 
00251         return m_mapstriGenes.size( ); }
00252 
00263     size_t GetGene( const std::string& strGene ) const {
00264 
00265         return CDatabaseImpl::GetGene( strGene ); }
00266 
00284     const std::string& GetGene( size_t iGene ) const {
00285         static const std::string    c_strEmpty  = "";
00286 
00287         return ( m_vecpDBs.empty( ) ? c_strEmpty : m_vecpDBs[ iGene % m_vecpDBs.size( ) ]->GetGene( iGene /
00288             m_vecpDBs.size( ) ) ); }
00289 
00301     size_t GetDatasets( ) const {
00302 
00303         return ( m_vecpDBs.empty( ) ? 0 : m_vecpDBs[ 0 ]->GetDatasets( ) ); }
00304 
00305     //Used by SeekMiner and SeekServer
00306     bool Open(const string &, const vector<string> &, const size_t &, const size_t &);
00307     bool Open(const char *, const vector<string> &, const size_t &, const size_t &);
00308 
00309 
00320     void SetMemmap( bool fMemmap ) {
00321 
00322         m_fMemmap = fMemmap; }
00323 
00342     void SetBlockOut( size_t iSize ) {
00343 
00344         m_iBlockOut = iSize; }
00345 
00363     void SetBlockIn( size_t iSize ) {
00364 
00365         m_iBlockIn = iSize; }
00366 
00384     void SetBuffer( bool fBuffer ) {
00385 
00386         m_fBuffer = fBuffer; }
00387 };
00388 
00389 }
00390 
00391 #endif // DATABASE_H