agp_reader.cpp
来自「ncbi源码」· C++ 代码 · 共 209 行
CPP
209 行
/* * =========================================================================== * PRODUCTION $Log: agp_reader.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 20:57:21 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10 * PRODUCTION * =========================================================================== *//* $Id: agp_reader.cpp,v 1000.1 2004/06/01 20:57:21 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: Josh Cherry * * File Description: * CDataPlugin_AgpReader - load information from an agp file */#include <ncbi_pch.hpp>#include "agp_reader.hpp"#include <gui/core/doc_exception.hpp>#include <gui/core/doc_manager.hpp>#include <gui/core/idocument.hpp>#include <gui/core/plugin_utils.hpp>#include <gui/core/version.hpp>#include <gui/plugin/PluginCommandSet.hpp>#include <gui/plugin/PluginInfo.hpp>#include <gui/plugin/PluginValueConstraint.hpp>#include <gui/utils/message_box.hpp>#include <gui/objutils/utils.hpp>#include <objects/general/Object_id.hpp>#include <objects/seq/Seqdesc.hpp>#include <objects/seq/Seq_descr.hpp>#include <objtools/readers/agp_read.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);static const string sc_separate = "Load each sequence as a separate document";static const string sc_together = "Group all sequences in a single document";//// factory implementations//void CDataPlugin_AgpReader::GetInfo(CPluginInfo& info){ info.Reset(); // version info macro info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0, string(__DATE__) + " " + string(__TIME__), "CDataPlugin_AgpReader", "AGP File", "Read a file in AGP format", ""); // command info CPluginCommandSet& cmds = info.SetCommands(); CPluginCommand& load_args = cmds.AddDataCommand(eDataCommand_load); load_args.AddArgument("fname", "File to load", CPluginArg::eFile); load_args.AddDefaultArgument("mode", "Treatment of multiple sequences", CPluginArg::eString, sc_separate); load_args.SetConstraint("mode", (*CPluginValueConstraint::CreateSet(), sc_separate, sc_together));}//// Default ctor//CDataPlugin_AgpReader::CDataPlugin_AgpReader(){}//// One and only dtor//CDataPlugin_AgpReader::~CDataPlugin_AgpReader(){}//// Load()// This is a pure virtual requirement and is the main plugin hook.//void CDataPlugin_AgpReader::Load(CPluginMessage& msg){ const CPluginCommand& args = msg.GetRequest().GetCommand(); CPluginReply& reply = msg.SetReply(); const string& fname = args["fname"].AsString(); try { CNcbiIfstream istr(fname.c_str()); if (args["mode"].AsString() == sc_separate) { vector<CRef<CSeq_entry> > entries; AgpRead(istr, entries); NON_CONST_ITERATE(vector<CRef<CSeq_entry> >, iter, entries) { CRef<CSeq_entry> &entry = *iter; CRef<CScope> scope(new CScope(CDocManager::GetObjectManager())); scope->AddTopLevelSeqEntry(*entry); scope->AddDefaults(); IDocument* doc = CDocManager::CreateDocument(*scope, *entry); reply.AddObject(*doc); } } else if (args["mode"].AsString() == sc_together) { CRef<CBioseq_set> bioseq_set = AgpRead(istr); CRef<CSeqdesc> title(new CSeqdesc); title->SetTitle(string("Sequences from file ") + fname); bioseq_set->SetDescr().Set().push_back(title); CRef<CSeq_entry> entry(new CSeq_entry); entry->SetSet(*bioseq_set); CRef<CScope> scope(new CScope(CDocManager::GetObjectManager())); scope->AddTopLevelSeqEntry(*entry); scope->AddDefaults(); IDocument* doc = CDocManager::CreateDocument(*scope, *entry); reply.AddObject(*doc); } else { throw runtime_error(string("invalid load mode: ") + args["mode"].AsString()); } reply.SetStatus(eMessageStatus_success); } catch (exception& _DEBUG_ARG(e)) { _TRACE("failed to read agp: " << e.what()); } catch (...) { _TRACE("failed to read agp: unknown error"); }}END_NCBI_SCOPE/* * =========================================================================== * $Log: agp_reader.cpp,v $ * Revision 1000.1 2004/06/01 20:57:21 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10 * * Revision 1.10 2004/05/25 17:21:59 dicuccio * Modified class names. Fonts to 12 point * * Revision 1.9 2004/05/21 22:27:48 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.8 2004/05/03 13:05:42 dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.7 2004/03/16 15:59:50 vasilche * Removed warning about unused exception variable * * Revision 1.6 2004/02/17 15:17:31 jcherry * Removed help url in favor of new help system * * Revision 1.5 2004/02/11 21:01:51 jcherry * Use file argument rather than manually launching file chooser * * Revision 1.4 2004/01/27 18:45:31 dicuccio * Added missing header files * * Revision 1.3 2003/12/10 15:09:32 dicuccio * Changed menu item - capitalize AGP * * Revision 1.2 2003/12/09 21:33:54 jcherry * Added url for help * * Revision 1.1 2003/12/09 00:20:09 jcherry * Initial version * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?