gnomon.cpp
来自「ncbi源码」· C++ 代码 · 共 256 行
CPP
256 行
/* * =========================================================================== * PRODUCTION $Log: gnomon.cpp,v $ * PRODUCTION Revision 1000.4 2004/06/01 20:56:23 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8 * PRODUCTION * =========================================================================== *//* $Id: gnomon.cpp,v 1000.4 2004/06/01 20:56:23 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: * */#include <ncbi_pch.hpp>#include "gnomon.hpp"#include <corelib/ncbiapp.hpp>#include <algo/gnomon/gnomon.hpp>#include <gui/core/version.hpp>#include <gui/core/idocument.hpp>#include <gui/utils/system_path.hpp>#include <gui/utils/message_box.hpp>#include <gui/objutils/utils.hpp>#include <gui/plugin/PluginInfo.hpp>#include <gui/plugin/PluginCommandSet.hpp>#include <gui/plugin/PluginRequest.hpp>#include <gui/plugin/PluginCommand.hpp>#include <gui/plugin/PluginArg.hpp>#include <gui/plugin/PluginValueConstraint.hpp>#include <objmgr/util/sequence.hpp>#include <objmgr/util/feature.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(ncbi::objects);static const string sc_human("Human (Homo sapiens)");static const string sc_worm ("Worm (Caenorhabditas elegans)");static const string sc_fly ("Fly (Drosophila melanogaster)");void CPluginGnomon::GetInfo(CPluginInfo& info){ info.Reset(); // version info macro info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0, string(__DATE__) + " " + string(__TIME__), "CPluginGnomon", "Search/Ab-Initio Predicion of Genes", "Search for genes using a pure ab-initio method", ""); // command info CPluginCommand& cmd = info.SetCommands().AddAlgoCommand(eAlgoCommand_run); cmd.AddArgument("loc", "Sequence to evaluate", CSeq_loc::GetTypeInfo()); cmd.SetConstraint("loc", (*CPluginValueConstraint::CreateSeqMol(), CSeq_inst::eMol_na, CSeq_inst::eMol_dna)); cmd.AddDefaultArgument("model", "Model Organism Data", CPluginArg::eString, sc_worm); cmd.SetConstraint("model", (*CPluginValueConstraint::CreateSet(), sc_human, sc_worm, sc_fly));}void CPluginGnomon::RunCommand(CPluginMessage& msg){ const CPluginCommand& cmd = msg.GetRequest().GetCommand(); CPluginReply& reply = msg.SetReply(); reply.SetStatus(eMessageStatus_failed); const CSeq_loc& loc = dynamic_cast<const CSeq_loc&>(cmd["loc"].AsObject()); const IDocument* doc = cmd["loc"].GetDocument(); // retrieve the sequence to scan CBioseq_Handle handle = doc->GetScope().GetBioseqHandle(loc); CSeqVector vec = handle.GetSequenceView(loc, CBioseq_Handle::eViewConstructed); // // retrieve the correct model file // string model_file; {{ model_file = cmd["model"].AsString(); if (model_file == sc_human) { model_file = "Human.inp"; } else if (model_file == sc_worm) { model_file = "Worm.inp"; } else if (model_file == sc_fly) { model_file = "Fly.inp"; } }} {{ CNcbiApplication* app = CNcbiApplication::Instance(); _ASSERT(app); CNcbiRegistry& registry = app->GetConfig(); // By default the rebase "NAR format" file // is assumed to be <std>/etc/rebase.nar. // This can be overridden in gbench.ini, via the application registry // variable [PROSITE_SEARCH] PrositeData. string model_path = registry.GetString("GNOMON", "ModelDataPath", ""); if ( !model_path.empty() ) { model_path += model_file + ", "; } model_path += "<home>/etc/" + model_file + ", <std>/etc/" + model_file; model_file = CSystemPath::ResolvePathExisting(model_path); }} if ( model_file.empty() ) { NcbiMessageBox("Couldn't find model data."); return; } CRef<CSeq_annot> annot; // // run GNOMON! // try { CGnomon gnomon; gnomon.SetSequence(vec); gnomon.SetModelData(model_file); gnomon.Run(); annot = gnomon.GetAnnot(); } catch (CException& e) { string msg("Gene scan failed:\n"); msg += e.GetMsg(); NcbiMessageBox(msg); return; } if ( !annot || !annot->GetData().IsFtable() || annot->GetData().GetFtable().size() == 0) { NcbiMessageBox("No genes found in the selected region"); return; } // // correct our locations // this involves remapping the locations through our seq-loc // and setting our IDs correctly // while we're at it, fill in our dialog // if ( !m_Dialog.get() ) { m_Dialog.reset(new CMultiColDlg()); m_Dialog->SetTitle("Ab-Initio Gene Scan"); m_Dialog->SetColumn(0, "Feature", FL_ALIGN_LEFT, 0.5f); m_Dialog->SetColumn(1, "Location", FL_ALIGN_LEFT, 0.5f); } string label("Ab-Initio prediction found "); label += NStr::IntToString(annot->GetData().GetFtable().size() / 2); label += " potential genes:"; m_Dialog->SetLabel(label); m_Dialog->SetRows(0); int row = 0; const CSeq_id& id = sequence::GetId(loc); NON_CONST_ITERATE (CSeq_annot::TData::TFtable, iter, annot->SetData().SetFtable()) { CSeq_feat& feat = **iter; feat.SetLocation().SetId(id); feat.SetLocation (*CSeqUtils::RemapChildToParent(loc, feat.GetLocation())); feature::GetLabel(feat, &m_Dialog->SetCell(row, 0), feature::eBoth); feat.GetLocation().GetLabel(&m_Dialog->SetCell(row, 1)); ++row; } const_cast<IDocument*>(doc)->AttachAnnot(*annot); const_cast<IDocument*>(doc)->PostDocumentChanged(); m_Dialog->SetRows(row); m_Dialog->Show(); reply.SetStatus(eMessageStatus_success);}END_NCBI_SCOPE/* * =========================================================================== * $Log: gnomon.cpp,v $ * Revision 1000.4 2004/06/01 20:56:23 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8 * * Revision 1.8 2004/05/21 22:27:47 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.7 2004/05/03 13:05:42 dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.6 2004/02/17 20:35:26 rsmith * moved core/settings.[ch]pp and core/system_path.[ch]pp to config and utils, respectively. * * Revision 1.5 2003/12/22 19:27:06 dicuccio * Changed to match API change in IDocument - UpdateAllViews() goes away * * Revision 1.4 2003/12/09 15:46:54 dicuccio * Use CException::GetMsg() instead of what() * * Revision 1.3 2003/11/24 15:45:30 dicuccio * Renamed CVersion to CPluginVersion * * Revision 1.2 2003/11/05 14:28:25 dicuccio * Changed calling semantics to match new plugin API * * Revision 1.1 2003/10/24 16:56:50 dicuccio * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?