lds_loader.cpp
来自「ncbi源码」· C++ 代码 · 共 567 行 · 第 1/2 页
CPP
567 行
const CPluginCommand& args = msg.GetRequest().GetCommand(); CPluginReply& reply = msg.SetReply(); if (!m_DbHolder) { NcbiMessageBox("Local data storage is not configured.", eDialog_Ok, eIcon_Stop, "Error"); reply.SetStatus(eMessageStatus_ignored); return; } CLDS_Database* db = m_DbHolder->GetDefaultDatabase(); if (!db) { NcbiMessageBox("Local data storage is not configured.", eDialog_Ok, eIcon_Stop, "Error"); reply.SetStatus(eMessageStatus_ignored); return; } CLdsSearchDlg dlg(m_DbHolder); if (dlg.Show() == eOK) { Fl_Browser* lst = dlg.m_List; SLDS_TablesCollection& tables = db->GetTables(); CLDS_Query query(tables); CLDS_Set obj_read; // list of objects already loaded for (int i = 1; i <= lst->size(); ++i) { int selected = lst->selected(i); if (selected) { void* data = lst->data(i); int id; ::memcpy(&id, &data, sizeof(id)); if (!id) { continue; } CLDS_Query::SObjectDescr descr = query.GetObjectDescr(db->GetObjTypeMap(), id, true); // check if object is already loaded if (LDS_SetTest(obj_read, descr.id)) { continue; } x_Load(descr, db, &obj_read, reply); } } // for if (obj_read.size() == 0) { NcbiMessageBox("Failed to find local sequence(s).", eDialog_Ok, eIcon_Stop, "Error"); } } reply.SetStatus(eMessageStatus_success);}bool CDataPlugin_LDSLoader::x_Load(const CLDS_Query::SObjectDescr& obj_descr, CLDS_Database* db, CLDS_Set* obj_read, CPluginReply& reply){ try { if (obj_descr.type_str == "Seq-entry" || obj_descr.type_str == "Bioseq" || obj_descr.format == CFormatGuess::eFasta) { return x_LoadLDS_BioTSE(obj_descr.id, db, obj_read, reply); } else { if (obj_descr.type_str == "Seq-annot" || obj_descr.type_str == "Seq-align") { return x_LoadLDS_Annot(obj_descr, db, obj_read, reply); } } } catch (CLDS_Exception& ex) { ERR_POST("failed to read object: " << ex.what()); } return false;}bool CDataPlugin_LDSLoader::x_LoadLDS_BioTSE(int object_id, CLDS_Database* db, CLDS_Set* obj_read, CPluginReply& reply){ SLDS_TablesCollection& tables = db->GetTables(); CRef<CSeq_entry> entry = LDS_LoadTSE(tables, db->GetObjTypeMap(), object_id); if (!entry) { _TRACE("failed to read LDS object id=" << object_id); return false; } obj_read->insert(object_id); string dl_name = "LDS_dataloader_"; dl_name.append(db->GetAlias()); CRef<CScope> scope(new CScope(CDocManager::GetObjectManager())); scope->AddDataLoader(dl_name); scope->AddTopLevelSeqEntry(*entry); scope->AddDefaults(); IDocument* doc = CDocManager::CreateDocument(*scope, *entry); reply.AddObject(*doc); CDocManager::UpdateAllViews(); /** CBioseq_Handle handle = CSeqUtils::CreateBioseqHandle(*scope, *entry); if (handle) { scope->AddDefaults(); IDocument* doc = CDocManager::CreateDocument(*scope, *CSeqUtils::GetBestId(*entry)); reply.AddObject(*doc); CDocManager::UpdateAllViews(); } **/ return true;}bool CDataPlugin_LDSLoader::x_LoadLDS_Annot(const CLDS_Query::SObjectDescr& obj_descr, CLDS_Database* db, CLDS_Set* obj_read, CPluginReply& reply){ SLDS_TablesCollection& tables = db->GetTables(); CRef<CSeq_annot> annot = LDS_LoadAnnot(tables, obj_descr); if (!annot) { _TRACE("failed to read LDS annotation id=" << obj_descr.id); return false; } obj_read->insert(obj_descr.id); string dl_name = "LDS_dataloader_"; dl_name.append(db->GetAlias()); CRef<CScope> scope(new CScope(CDocManager::GetObjectManager())); scope->AddDataLoader(dl_name); scope->AddDefaults(); IDocument* doc = CDocManager::CreateDocument(*scope, *annot); reply.AddObject(*doc); CDocManager::UpdateAllViews(); return true;}END_NCBI_SCOPE/* * =========================================================================== * $Log: lds_loader.cpp,v $ * Revision 1000.5 2004/06/01 20:58:08 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.31 * * Revision 1.31 2004/05/25 17:21:59 dicuccio * Modified class names. Fonts to 12 point * * Revision 1.30 2004/05/21 22:27:48 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.29 2004/05/03 13:05:43 dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.28 2004/03/23 13:39:07 dicuccio * Load objects as seq-entry, not seq-id * * Revision 1.27 2004/03/16 15:59:50 vasilche * Removed warning about unused exception variable * * Revision 1.26 2003/11/24 15:45:38 dicuccio * Renamed CVersion to CPluginVersion * * Revision 1.25 2003/11/18 17:49:02 dicuccio * Added standard processing of return values * * Revision 1.24 2003/11/06 20:12:15 dicuccio * Cleaned up handling of USING_SCOPE - removed from all headers * * Revision 1.23 2003/11/05 13:30:45 kuznets * Fixed application crash when there is no LDS instances configured in the * system. (Search command). Put a warning pop up dialog. * * Revision 1.22 2003/11/04 17:49:25 dicuccio * Changed calling parameters for plugins - pass CPluginMessage instead of paired * CPluginCommand/CPluginReply * * Revision 1.21 2003/10/29 16:25:07 kuznets * Added support for LDS aliases. * * Revision 1.20 2003/10/28 14:21:01 kuznets * Chages to lds loader to support multiple LDS databases * * Revision 1.19 2003/10/09 19:20:53 kuznets * Added message box if Load or Search fails to find anything * * Revision 1.18 2003/10/08 18:20:42 kuznets * Reflecting changes in LDS library * * Revision 1.17 2003/10/07 13:47:05 dicuccio * Renamed CPluginURL* to CPluginValue* * * Revision 1.16 2003/10/03 18:55:52 kuznets * Added search time logging for CDataPlugin_LDSLoader::Load command * * Revision 1.15 2003/09/04 14:51:43 dicuccio * Use IDocument instead of CDocument * * Revision 1.14 2003/08/19 14:38:01 kuznets * Added non default LDS dataloader to all created scopes. * * Revision 1.13 2003/08/08 15:28:53 kuznets * Corrected documents list update when we open new views. * * Revision 1.12 2003/08/07 20:31:35 kuznets * Implemented document opening based on lds_search_dlg selection * * Revision 1.11 2003/08/05 17:16:25 kuznets * Changes to improve code reuse between loaders + CLDS_Database passed as the * construction parameter to the lds search dialog * * Revision 1.10 2003/07/31 20:44:32 kuznets * LDS Plugin uses CDataStore to get the LDS database object. * * Revision 1.9 2003/07/30 14:04:58 kuznets * Improved "gi|" search similar to genbank loader plugin * * Revision 1.8 2003/07/29 20:06:07 kuznets * "Search All" option added to Load command * * Revision 1.7 2003/07/15 17:57:08 kuznets * Added annotaion/alignment search capabilities * * Revision 1.6 2003/07/14 11:17:03 shomrat * Plugin messageing system related changes * * Revision 1.5 2003/07/09 20:59:12 kuznets * Added new lds plugin argument "search_all". Works as a boolean flag * indicating that search should include both seaquences and annotations. * * Revision 1.4 2003/07/01 19:29:14 kuznets * Open command implementation * * Revision 1.3 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.2 2003/06/20 14:52:57 dicuccio * Revised plugin registration - moved GetInfo() into the plugin handler * * Revision 1.1 2003/06/17 20:16:09 kuznets * Initial revision. * * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?