entrez_db.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:5k
- /*
- * ===========================================================================
- * PRODUCTION $Log: entrez_db.hpp,v $
- * PRODUCTION Revision 1000.0 2004/06/01 21:26:35 gouriano
- * PRODUCTION PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.1
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_PLUGINS_DOC_BASIC___ENTREZ_DB__HPP
- #define GUI_PLUGINS_DOC_BASIC___ENTREZ_DB__HPP
- /* $Id: entrez_db.hpp,v 1000.0 2004/06/01 21:26:35 gouriano Exp $
- * ===========================================================================
- *
- * PUBLIC DOMAIN NOTICE
- * National Center for Biotechnology Information
- *
- * This software/database is a "United States Government Work" under the
- * terms of the United States Copyright Act. It was written as part of
- * the author's official duties as a United States Government employee and
- * thus cannot be copyrighted. This software/database is freely available
- * to the public for use. The National Library of Medicine and the U.S.
- * Government have not placed any restriction on its use or reproduction.
- *
- * Although all reasonable efforts have been taken to ensure the accuracy
- * and reliability of the software and data, the NLM and the U.S.
- * Government do not and cannot warrant the performance or results that
- * may be obtained by using this software or data. The NLM and the U.S.
- * Government disclaim all warranties, express or implied, including
- * warranties of performance, merchantability or fitness for any particular
- * purpose.
- *
- * Please cite the author in any work or product based on this material.
- *
- * ===========================================================================
- *
- * Authors: Mike DiCuccio
- *
- * File Description:
- * CEntrezDBCache -- cache of Entrez database handlers
- */
- #include <corelib/ncbistd.hpp>
- #include <objects/seqloc/Seq_id.hpp>
- #include <objects/entrez2/entrez2_client.hpp>
- #include <objects/entrez2/Entrez2_docsum.hpp>
- #include <objects/entrez2/Entrez2_docsum_list.hpp>
- BEGIN_NCBI_SCOPE
- class IEntrezDBHandler
- {
- public:
- struct SHeaderInfo {
- string name;
- float rel_width;
- SHeaderInfo() {}
- SHeaderInfo(const string& n, float w)
- : name(n)
- , rel_width(w) { }
- };
- virtual ~IEntrezDBHandler() { }
- // get the name of the database as Entrez knows it
- virtual string GetDbName() const = 0;
- // get a copy of the name that is nice to print
- virtual string GetVisibleDbName() const = 0;
- // perform a query in the handled database
- virtual CRef<objects::CEntrez2_docsum_list> Query(const string& terms,
- size_t& total_uids,
- size_t offs = 0,
- size_t count = 0) = 0;
- // return the list of column headers to be used when displaying
- // results for this database
- virtual void GetHeaders(vector<SHeaderInfo>& headers) const = 0;
- // return a vector<string> representing the values for a single docsum
- virtual void Format(const objects::CEntrez2_docsum& ds,
- vector<string>& cols) const = 0;
- // how to resolve to seq-ids when a seq-id is not immediately obvious
- enum ESeqIdFlags {
- // favor nucleotides (proteins favored otherwise)
- fFavorNucleotide = 0x1,
- // return only the "best" id
- fFavorBest = 0x2,
- // return only the RefSeq id(s)
- fFavorRefSeq = 0x4,
- fDefaults = 0
- };
- typedef int TSeqIdFlags;
- // retrieve seq-ids for a given set of docsums
- typedef list< CRef<objects::CSeq_id> > TIds;
- virtual TIds GetSeqIds(const objects::CEntrez2_docsum_list& ds_list,
- TSeqIdFlags flags = fDefaults) = 0;
- virtual TIds GetSeqIds(const objects::CEntrez2_docsum& ds,
- TSeqIdFlags flags = fDefaults) = 0;
- };
- //
- // derived class providing basic query functions
- //
- class CEntrezDBHandler : public IEntrezDBHandler, public CObject
- {
- public:
- virtual CRef<objects::CEntrez2_docsum_list> Query(const string& terms,
- size_t& total_uids,
- size_t offs = 0,
- size_t count = 0);
- protected:
- objects::CEntrez2Client& x_GetClient();
- private:
- CRef<objects::CEntrez2Client> m_Client;
- };
- //
- // manager for instances
- class CEntrezDBManager : public CObject
- {
- public:
- CEntrezDBManager();
- void RegisterHandler(CEntrezDBHandler& handler);
- IEntrezDBHandler& GetHandler(const string& db) const;
- struct SDbEntry {
- string db_name;
- string visible_db_name;
- };
- typedef list<SDbEntry> TEntries;
- void GetDatabases(TEntries& entries);
- private:
- typedef map<string, CRef<CEntrezDBHandler> > THandlers;
- THandlers m_Handlers;
- };
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: entrez_db.hpp,v $
- * Revision 1000.0 2004/06/01 21:26:35 gouriano
- * PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.1
- *
- * Revision 1.1 2004/05/25 17:15:39 dicuccio
- * Initial revision - moved over from old GenBank search
- *
- * ===========================================================================
- */
- #endif // GUI_PLUGINS_DOC_BASIC___ENTREZ_DB__HPP