predict_coiled_coil.cpp
来自「ncbi源码」· C++ 代码 · 共 320 行
CPP
320 行
/* * =========================================================================== * PRODUCTION $Log: predict_coiled_coil.cpp,v $ * PRODUCTION Revision 1000.5 2004/06/01 20:55:30 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.15 * PRODUCTION * =========================================================================== *//* $Id: predict_coiled_coil.cpp,v 1000.5 2004/06/01 20:55:30 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: gbench plugin for predicting coiled coil regions * */#include <ncbi_pch.hpp>#include "predict_coiled_coil.hpp"#include <algo/sequence/coiled_coil.hpp>#include <gui/core/plugin_utils.hpp>#include <gui/core/version.hpp>#include <gui/dialogs/col/multi_col_dlg.hpp>#include <gui/plugin/PluginCommandSet.hpp>#include <gui/plugin/PluginInfo.hpp>#include <gui/plugin/PluginReply.hpp>#include <gui/plugin/PluginRequest.hpp>#include <gui/plugin/PluginValueConstraint.hpp>#include <gui/objutils/utils.hpp>#include <objmgr/seq_vector.hpp>#include <objmgr/util/sequence.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);CAlgoPlugin_PredictCoiledCoil::~CAlgoPlugin_PredictCoiledCoil(){}// standard plugin announce bopilerplatevoid CAlgoPlugin_PredictCoiledCoil::GetInfo(CPluginInfo& info){ info.Reset(); // version info macro info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0, string(__DATE__) + " " + string(__TIME__), "CAlgoPlugin_PredictCoiledCoil", "Protein analysis/Predict coiled coil regions", "Predict coiled coil regions from protein sequence", ""); // command info CPluginCommandSet& cmds = info.SetCommands(); CPluginCommand& args = cmds.AddAlgoCommand(eAlgoCommand_run); args.AddArgument("locs", "Locations to evaluate", CSeq_loc::GetTypeInfo(), CPluginArg::TData::e_Array); args.SetConstraint("locs", (*CPluginValueConstraint::CreateSeqMol(), CSeq_inst::eMol_aa)); args.AddDefaultArgument("win_len", "Window length", CPluginArg::eInteger, "28");}void CAlgoPlugin_PredictCoiledCoil::RunCommand(CPluginMessage& msg){ const CPluginCommand& args = msg.GetRequest().GetCommand(); CPluginReply& reply = msg.SetReply(); _TRACE("CAlgoPlugin_PredictCoiledCoil::RunCommand()"); if ( !m_Dialog.get() ) { m_Dialog.reset(new CMultiColDlg()); m_Dialog->SetWindowSize(800, 450); m_Dialog->SetTitle("Predicted Coiled Coil Regions"); m_Dialog->SetColumn(0, "Sequence", FL_ALIGN_LEFT, 0.5f); m_Dialog->SetColumn(1, "Location", FL_ALIGN_LEFT, 0.5f); m_Dialog->SetColumn(2, "Range", FL_ALIGN_CENTER, 0.4f); m_Dialog->SetColumn(3, "Maximum Score", FL_ALIGN_CENTER, 0.5f); m_Dialog->SetColumn(4, "Coiled Coil Prob.", FL_ALIGN_CENTER, 0.5f); } // clear any previous contents m_Dialog->SetRows(0); int row = 0; plugin_args::TLocList locs; GetArgValue(args["locs"], locs); int win_len = args["win_len"].AsInteger(); ITERATE (plugin_args::TLocList, iter, locs) { const CSeq_loc& loc = *iter->second; const IDocument& doc = *iter->first; // find the best ID for this bioseq try { CBioseq_Handle handle = doc.GetScope().GetBioseqHandle(loc); // get sequence vector CSeqVector vec = handle.GetSequenceView(loc, CBioseq_Handle::eViewConstructed, CBioseq_Handle::eCoding_Iupac); string& id_str = m_Dialog->SetCell(row, 0); string& loc_str = m_Dialog->SetCell(row, 1); const CSeq_id& best_id = sequence::GetId(handle, sequence::eGetId_Best); id_str.erase(); best_id.GetLabel(&id_str); loc_str = CPluginUtils::GetLabel(loc, &doc.GetScope()); // a new feature table CRef<CSeq_annot> annot(new CSeq_annot()); // places to store coiled coil regions and their max scores vector<CRef<CSeq_loc> > regions; vector<double> max_scores; // find the regions double top_score = CCoiledCoil:: PredictRegions(vec, regions, max_scores, win_len); _TRACE("Predicted " << regions.size() << " coiled coil regions"); // add description to annot annot->AddName("Predicted coiled coil regions"); string comment = string("Predicted coiled coil regions " "using window length = ") + NStr::IntToString(win_len); annot->AddComment(comment); NON_CONST_ITERATE (vector< CRef<CSeq_loc> >, region, regions) { // must set the ID field (**region).SetId(sequence::GetId(loc)); *region = CSeqUtils::RemapChildToParent(loc, **region); // // add regions to dialog // m_Dialog->SetCell(row, 2) = NStr::IntToString((**region).GetTotalRange().GetFrom() + 1) + "-" + NStr::IntToString((**region).GetTotalRange().GetTo() + 1); m_Dialog->SetCell(row, 3) = NStr::DoubleToString(max_scores[region - regions.begin()], 2); m_Dialog->SetCell(row, 4) = NStr::DoubleToString(CCoiledCoil::ScoreToProb (max_scores[region - regions.begin()])); ++row; // // add features to annot // CRef<CSeq_id> this_id (const_cast<CSeq_id*>(&sequence::GetId(loc))); // create feature CRef<CSeq_feat> feat(new CSeq_feat()); feat->SetExp_ev(CSeq_feat::eExp_ev_not_experimental); // set up the location feat->SetLocation(**region); feat->SetLocation().SetId(*this_id); feat->SetData().SetRegion() = string("Predicted coiled coil: max. score = ") + NStr::DoubleToString(max_scores[region - regions.begin()], 2) + " (probability = " + NStr::DoubleToString(CCoiledCoil::ScoreToProb (max_scores[region - regions.begin()]), 2) + ")"; // save in annot annot->SetData().SetFtable().push_back(feat); } // attach annot to doc //const_cast<IDocument&>(doc).AttachAnnot(*annot); reply.AddObject(doc, *annot); // if no regions found, report max score for the sequence if (regions.size() == 0) { m_Dialog->SetCell(row, 2) = "None"; m_Dialog->SetCell(row, 3) = NStr::DoubleToString(top_score); m_Dialog->SetCell(row, 4) = NStr::DoubleToString(CCoiledCoil::ScoreToProb(top_score)); ++row; } } catch (exception& e) { LOG_POST(Error << e.what()); string str = CPluginUtils::GetLabel(loc, &doc.GetScope()); LOG_POST(Error << "Error processing location " << str); }#ifndef _DEBUG catch (...) { string str = CPluginUtils::GetLabel(loc, &doc.GetScope()); LOG_POST(Error << "Error processing location " << str); }#endif } // update all views //CDocManager::UpdateAllViews(); // // prepare our dialog box // m_Dialog->SetLabel(string("Predicted coiled coil regions" " using a window length of ") + NStr::IntToString(win_len)); m_Dialog->Show(); reply.SetStatus(eMessageStatus_success); reply.AddAction(CPluginReplyAction::e_Add_to_document);}END_NCBI_SCOPE/* * =========================================================================== * $Log: predict_coiled_coil.cpp,v $ * Revision 1000.5 2004/06/01 20:55:30 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.15 * * Revision 1.15 2004/05/21 22:27:47 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.14 2004/05/03 13:05:42 dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.13 2004/03/05 17:35:37 dicuccio * Use sequence::GetId() instead of CSeq_id::GetStringDescr() * * Revision 1.12 2004/01/27 18:38:00 dicuccio * Code clean-up. Use standard names for plugins. Removed unnecessary #includes * * Revision 1.11 2004/01/07 15:50:38 dicuccio * Adjusted for API change in CPluginUtils::GetLabel(). Standardized exception * reporting in algorithms. * * Revision 1.10 2003/11/24 15:45:27 dicuccio * Renamed CVersion to CPluginVersion * * Revision 1.9 2003/11/18 17:48:37 dicuccio * Added standard processing of return values * * Revision 1.8 2003/11/06 20:12:12 dicuccio * Cleaned up handling of USING_SCOPE - removed from all headers * * Revision 1.7 2003/11/04 17:49:23 dicuccio * Changed calling parameters for plugins - pass CPluginMessage instead of paired * CPluginCommand/CPluginReply * * Revision 1.6 2003/10/27 17:46:49 dicuccio * Removed dead #includes * * Revision 1.5 2003/10/15 13:40:26 dicuccio * Mkae sure to set the 'id' for the seq-locs before calling RemapChildToParent() * * Revision 1.4 2003/10/14 16:24:37 dicuccio * Correctly remap new feature locations through the parent location to the master * sequence * * Revision 1.3 2003/10/07 13:47:00 dicuccio * Renamed CPluginURL* to CPluginValue* * * Revision 1.2 2003/09/25 17:21:35 jcherry * Added name to annot * * Revision 1.1 2003/09/08 16:15:13 jcherry * Initial version * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?