entrez_search.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:9k
- /*
- * ===========================================================================
- * PRODUCTION $Log: entrez_search.cpp,v $
- * PRODUCTION Revision 1000.0 2004/06/01 21:26:50 gouriano
- * PRODUCTION PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.1
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: entrez_search.cpp,v 1000.0 2004/06/01 21:26:50 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:
- * CDataPlugin_EntrezSearch - load sequence information form Genbank.
- */
- #include <ncbi_pch.hpp>
- #include "entrez_search.hpp"
- #include "entrez_search_dlg.hpp"
- #include <gui/core/version.hpp>
- #include <gui/core/plugin_utils.hpp>
- #include <gui/plugin/PluginCommandSet.hpp>
- #include <gui/plugin/PluginInfo.hpp>
- #include <gui/plugin/PluginValue.hpp>
- #include <gui/utils/message_box.hpp>
- BEGIN_NCBI_SCOPE
- USING_SCOPE(objects);
- //
- // class CDataPlugin_EntrezSearchException defines some internal exception types used in
- // processing files.
- //
- // This class is used internally to avoid an ad-hoc exception mechanism;
- // currently, it reports only errors concerning invalid format types.
- //
- class CDataPlugin_EntrezSearchException : EXCEPTION_VIRTUAL_BASE public CException
- {
- public:
- // Enumerated list of exception types
- enum EErrCode {
- eInvalidId
- };
- // Convert an enuerated exception to a human-readable string representation
- // of this exception.
- virtual const char* GetErrCodeString(void) const
- {
- switch (GetErrCode()) {
- case eInvalidId: return "eInvalidId";
- default: return CException::GetErrCodeString();
- }
- }
- // constructor boilerplate
- NCBI_EXCEPTION_DEFAULT(CDataPlugin_EntrezSearchException, CException);
- };
- void CDataPlugin_EntrezSearch::GetInfo(CPluginInfo& info)
- {
- info.Reset();
- // version info macro
- info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,
- string(__DATE__) + " " + string(__TIME__),
- "CDataPlugin_EntrezSearch", "GenBank (Nucleotide\/Protein\/Genome)",
- "Search public GenBank records", "");
- // command info
- CPluginCommandSet& cmds = info.SetCommands();
- CPluginCommand& search_args = cmds.AddDataCommand(eDataCommand_search);
- {{
- CPluginArg& arg =
- search_args.AddArgument("query", "Search string",
- CPluginArg::eString);
- arg.SetHidden(true);
- }}
- {{
- CPluginArg& arg =
- search_args.AddArgument("db", "Database to search",
- CPluginArg::eString);
- arg.SetHidden(true);
- }}
- }
- CDataPlugin_EntrezSearch::CDataPlugin_EntrezSearch()
- {
- }
- CDataPlugin_EntrezSearch::~CDataPlugin_EntrezSearch()
- {
- }
- //
- // load a record from Genbank into a fully-prepared document
- //
- void CDataPlugin_EntrezSearch::Search(CPluginMessage& msg)
- {
- const CPluginCommand& args = msg.GetRequest().GetCommand();
- CPluginReply& reply = msg.SetReply();
- reply.SetStatus(eMessageStatus_success);
- if ( !m_Dialog.get() ) {
- m_Dialog.reset(new CEntrezSearchDlg());
- }
- if (args.HasArgument("query") && CPluginUtils::IsValid(args["query"])) {
- string query = args["query"].AsString();
- m_Dialog->SetQuery(query);
- }
- if (args.HasArgument("db") && CPluginUtils::IsValid(args["db"])) {
- string db = args["db"].AsString();
- m_Dialog->SetDB(db);
- }
- m_Dialog->Show();
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: entrez_search.cpp,v $
- * Revision 1000.0 2004/06/01 21:26:50 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
- *
- * Revision 1.7 2003/12/22 19:29:20 dicuccio
- * Added explicit passing of query string and database
- *
- * Revision 1.6 2003/12/04 18:14:07 dicuccio
- * Lots of updates. Added a status bar to track actions. General code-clean-up
- *
- * Revision 1.5 2003/11/24 15:45:34 dicuccio
- * Renamed CVersion to CPluginVersion
- *
- * Revision 1.4 2003/11/04 17:49:24 dicuccio
- * Changed calling parameters for plugins - pass CPluginMessage instead of paired
- * CPluginCommand/CPluginReply
- *
- * Revision 1.3 2003/10/07 13:47:05 dicuccio
- * Renamed CPluginURL* to CPluginValue*
- *
- * Revision 1.2 2003/08/01 14:37:20 dicuccio
- * Solved issue with plugin communication - make sure that sequences are loaded
- * when the load button is clicked, not when the dialog closes
- *
- * Revision 1.1 2003/07/31 17:04:00 dicuccio
- * Added GenBank search
- *
- * Revision 1.22 2003/07/14 11:16:52 shomrat
- * Plugin messageing system related changes
- *
- * Revision 1.21 2003/06/25 17:02:58 dicuccio
- * Split CPluginHandle into a handle (pointer-to-implementation) and
- * implementation file. Lots of #include file clean-ups.
- *
- * Revision 1.20 2003/06/20 14:52:57 dicuccio
- * Revised plugin registration - moved GetInfo() into the plugin handler
- *
- * Revision 1.19 2003/06/02 16:06:22 dicuccio
- * Rearranged src/objects/ subtree. This includes the following shifts:
- * - src/objects/asn2asn --> arc/app/asn2asn
- * - src/objects/testmedline --> src/objects/ncbimime/test
- * - src/objects/objmgr --> src/objmgr
- * - src/objects/util --> src/objmgr/util
- * - src/objects/alnmgr --> src/objtools/alnmgr
- * - src/objects/flat --> src/objtools/flat
- * - src/objects/validator --> src/objtools/validator
- * - src/objects/cddalignview --> src/objtools/cddalignview
- * In addition, libseq now includes six of the objects/seq... libs, and libmmdb
- * replaces the three libmmdb? libs.
- *
- * Revision 1.18 2003/05/30 14:15:42 dicuccio
- * Renamed MessageBox to NcbiMessageBox because brain-dead MSVC thinks this is
- * ::MessageBox and rewrites the symbol as MessageBoxA, which results in an
- * unresolved external and conflict with the Win32 API :(.
- *
- * Revision 1.17 2003/05/30 13:10:37 dicuccio
- * Use MessageBox() instead of fl_alter()
- *
- * Revision 1.16 2003/05/19 13:40:44 dicuccio
- * Moved gui/core/plugin/ -> gui/plugin/. Merged core libraries into libgui_core.
- * Removed old, unused dialog box.
- *
- * Revision 1.15 2003/05/01 12:54:34 dicuccio
- * Changed a useful trace -> log post for failure to load accession
- *
- * Revision 1.14 2003/04/29 14:52:31 dicuccio
- * Deprecated old accession entry dialog. Added correct plugin argument to specify accession names
- *
- * Revision 1.13 2003/04/24 16:39:08 dicuccio
- * Updated to reflect changes in plugin API. Changed location of document
- * marshal from framework to plugin
- *
- * Revision 1.12 2003/02/26 14:26:56 dicuccio
- * Removed unnecessary _TRACE() statements
- *
- * Revision 1.11 2003/02/24 13:03:16 dicuccio
- * Renamed classes in plugin spec:
- * CArgSeg --> CPluginArgSet
- * CArgument --> CPluginArg
- * CPluginArgs --> CPluginCommand
- * CPluginCommands --> CPluginCommandSet
- *
- * Revision 1.10 2003/02/20 19:49:56 dicuccio
- * Created new plugin architecture, based on ASN.1 spec. Moved GBENCH
- * frameowrk over to use new plugin architecture.
- *
- * Revision 1.9 2003/02/06 18:48:36 dicuccio
- * Made 'catch (...)' conditional for non-debug builds
- *
- * Revision 1.8 2003/01/15 21:08:34 dicuccio
- * Removed dead _TRACE() statements
- *
- * Revision 1.7 2003/01/13 13:10:07 dicuccio
- * Namespace clean-up. Retired namespace gui -> converted all to namespace
- * ncbi. Moved all FLUID-generated code into namespace ncbi.
- *
- * Revision 1.6 2003/01/03 17:25:50 dicuccio
- * Fixed (finally!) issues regarding input validation of seq-ids.
- *
- * Revision 1.5 2002/12/30 18:44:20 dicuccio
- * Fixed a number of buglets in accession dialog and in handling of empty
- * accessions.
- *
- * Revision 1.4 2002/12/30 17:48:28 dicuccio
- * Added mechanism for data loader plugins to announce supported modes of
- * operation (load, import, save currently)
- *
- * Revision 1.3 2002/12/20 19:17:58 dicuccio
- * Added better handling of sueqnece ID errors (try not to segfault...)
- *
- * Revision 1.2 2002/12/12 15:22:38 dicuccio
- * Minot tweak to avoid a compiler warning.
- *
- * Revision 1.1 2002/11/25 20:51:01 dicuccio
- * Initial revision.
- *
- * ===========================================================================
- */