entrez_search_dlg.cpp
来自「ncbi源码」· C++ 代码 · 共 507 行 · 第 1/2 页
CPP
507 行
/* * =========================================================================== * PRODUCTION $Log: entrez_search_dlg.cpp,v $ * PRODUCTION Revision 1000.0 2004/06/01 21:27:00 gouriano * PRODUCTION PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.3 * PRODUCTION * =========================================================================== *//* $Id: entrez_search_dlg.cpp,v 1000.0 2004/06/01 21:27:00 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: * CEntrezSearchDlg -- search Entrez databases for sequence information */#include <ncbi_pch.hpp>#include "entrez_search_dlg.hpp"#include "entrez_record_table.hpp"#include <gui/core/version.hpp>#include <gui/core/doc_manager.hpp>#include <gui/utils/message_box.hpp>#include <gui/utils/fltk_utils.hpp>#include <objects/entrez2/entrez2_client.hpp>#include <objects/entrez2/Entrez2_info.hpp>#include <objects/entrez2/Entrez2_eval_boolean.hpp>#include <objects/entrez2/Entrez2_boolean_reply.hpp>#include <objects/entrez2/Entrez2_boolean_exp.hpp>#include <objects/entrez2/Entrez2_boolean_element.hpp>#include <objects/entrez2/Entrez2_id_list.hpp>#include <objects/entrez2/Entrez2_docsum.hpp>#include <objects/entrez2/Entrez2_docsum_list.hpp>#include <objects/entrez2/Entrez2_docsum_data.hpp>#include <objects/entrez2/Entrez2_db_id.hpp>#include <objects/entrez2/Entrez2_limits.hpp>#include <objmgr/util/sequence.hpp>#include <gui/plugin/PluginMessage.hpp>#include <gui/plugin/PluginRequest.hpp>#include <gui/plugin/PluginCommand.hpp>#include <gui/plugin/PluginArg.hpp>#include <gui/plugin/PluginValue.hpp>#include <gui/core/plugin_utils.hpp>#include <gui/core/plugin_handle.hpp>#include <gui/core/plugin_registry.hpp>#include <gui/objutils/label.hpp>#include <serial/serial.hpp>#include <serial/objostr.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);#include "entrez_search_dlg_.cpp"CEntrezSearchDlg::CEntrezSearchDlg() : m_Start(0) , m_Visible(10) , m_Length(0){ m_Window.reset(x_CreateWindow()); CenterOnActive(); // retrieve our list of databases list<string> dbs; m_Table->GetDatabases(dbs); int default_idx = 0; ITERATE (list<string>, iter, dbs) { int idx = m_DB->add(iter->c_str()); if (*iter == "Nucleotide") { default_idx = idx; } } m_DB->value(default_idx); m_Table->SetDatabase(m_DB->text(default_idx)); m_Table->SetReporter(m_StatusBar); m_StatusBar->PushMessage("Ready");}void CEntrezSearchDlg::SetQuery(const string& str){ m_QueryStr->value(str.c_str()); x_OnChangeTerms();}void CEntrezSearchDlg::SetDB(const string& str){ for (int i = 0; i < m_DB->size(); ++i) { const char* ptr = m_DB->text(i); if (ptr && str == ptr) { m_DB->value(i); x_OnChangeDB(); break; } }}void CEntrezSearchDlg::x_OnPrevious(){ if (m_Visible > 0 && m_Start > 0) { m_Start = max(0, m_Start - m_Visible); x_OnSearch(); }}void CEntrezSearchDlg::x_OnNext(){ if (m_Visible > 0 && (m_Start + m_Visible < m_Length)) { m_Start = min(m_Length - m_Visible, m_Start + m_Visible); m_Start = max(0, m_Start); x_OnSearch(); }}void CEntrezSearchDlg::x_OnLoad(){ CStatusBarGuard GUARD(*m_StatusBar, "Loading accessions..."); m_Table->OnNewDocument();#if 0 CPluginArg::TValues value_list; // this is a hack to get the nice GUI effect we want // we simply create a new default scope and use it to load our sequences CRef<CScope> scope(new CScope(CDocManager::GetObjectManager())); scope->AddDefaults(); try { // gather our docsums and prepare to do the docsum -> seqid conversion CEntrez2_docsum_list docsums; for (size_t i = 0; i < m_Table->GetRows(); ++i) { if ( !m_Table->IsRowSelected(i) ) { continue; } CRef<CEntrez2_docsum> ref = m_Table->GetData(i); docsums.SetList().push_back(ref); } docsums.SetCount(docsums.GetList().size()); // retrieve our handler and get our IDs. const char* p = m_DB->text(); if ( !p ) { throw runtime_error("No database chosen."); } IEntrezDBHandler& handler = m_DbManager.GetHandler(p); IEntrezDBHandler::TIds ids = handler.GetSeqIds(docsums); // force loading to make a nice GUI statement... size_t idx = 0; ITERATE (IEntrezDBHandler::TIds, iter, ids) { string str; try { CBioseq_Handle handle = scope->GetBioseqHandle(**iter); if (handle) { str = "Loaded sequence "; string id_str; CLabel::GetLabel(**iter, &id_str, CLabel::eDefault, scope); str += id_str; CRef<CPluginValue> value(new CPluginValue()); value->SetString(id_str); value_list.push_back(value); } } catch (CException& e) { str = "Failed to load sequence "; CLabel::GetLabel(**iter, &str, CLabel::eDefault); str += ": " + e.GetMsg(); } catch (...) { } if (str.empty()) { str = "Failed to load sequence "; CLabel::GetLabel(**iter, &str, CLabel::eDefault); } m_StatusBar->SetMessage(str); ++idx; m_StatusBar->SetPctCompleted(100 * idx / ids.size()); } } catch (CException& e) { string str("Can't load accessions:\n"); str += e.GetMsg(); NcbiMessageBox(str); } catch (std::exception& e) { string str("Can't load accessions:\n"); str += e.what(); NcbiMessageBox(str); } catch (...) { } if (value_list.size() != 0) { CPluginHandle ph = CPluginRegistry::GetPlugin("CDataPlugin_GenbankLoader"); if (ph) { CRef<CPluginMessage> msg = ph.CreateMessage(eDataCommand_load); CPluginArg& arg = msg->SetRequest().SetCommand()["acc"]; arg.SetList(value_list); CPluginUtils::CallPlugin(*msg); } } m_StatusBar->SetPctCompleted(0);#endif}void CEntrezSearchDlg::x_OnChangeTerms(){ m_Start = 0; x_OnSearch();}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?