view_crossalign.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:12k
- /*
- * ===========================================================================
- * PRODUCTION $Log: view_crossalign.cpp,v $
- * PRODUCTION Revision 1000.5 2004/06/01 20:59:09 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.36
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: view_crossalign.cpp,v 1000.5 2004/06/01 20:59:09 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: Vlad Lebedev
- *
- * File Description:
- * User-modifiable implementation file for extension
- * of Cross Alignment viewer
- */
- #include <ncbi_pch.hpp>
- #include "view_crossalign.hpp"
- #include <gui/core/plugin_utils.hpp>
- #include <gui/core/version.hpp>
- #include <gui/plugin/PluginRequest.hpp>
- #include <gui/plugin/PluginCommand.hpp>
- #include <gui/plugin/PluginCommandSet.hpp>
- #include <gui/plugin/PluginInfo.hpp>
- #include <gui/plugin/PluginValue.hpp>
- #include <gui/objutils/utils.hpp>
- #include <objmgr/util/sequence.hpp>
- BEGIN_NCBI_SCOPE
- // We include the generated _.cpp file here. This avoids a nasty bug in some
- // versions of gcc in which inline functions are not intantiated.
- #include "view_crossalign_.cpp"
- void CAlnCrossAlignView::GetInfo(CPluginInfo& info)
- {
- info.Reset();
- // version info macro
- info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,
- string(__DATE__) + " " + string(__TIME__),
- "CAlnCrossAlignView",
- "Cross Alignment Viewer",
- "Cross Alignment Viewer", "");
- // command info
- CPluginCommandSet& cmds = info.SetCommands();
- CPluginCommand& args = cmds.AddViewCommand(eViewCommand_new_view);
- args.AddArgument("alignments", "Alignments to merge and render",
- CSeq_annot::GetTypeInfo(),
- CPluginArg::TData::e_Single);
- args.SetConstraint("alignments",
- *CPluginValueConstraint::CreateAnnotType
- (CSeq_annot::TData::e_Align));
- }
- CAlnCrossAlignView::CAlnCrossAlignView(const CPluginMessage& msg,
- const string& pool_name)
- : CAlnView()
- {
- m_Window.reset(x_CreateWindow());
- // set our core components
- const CPluginCommand& args = msg.GetRequest().GetCommand();
- const CPluginArg& arg = args["alignments"];
- // extract the alignments from the argument
- const CSeq_annot* annot =
- dynamic_cast<const CSeq_annot*>(arg.GetObject());
- const IDocument* doc = arg.GetDocument();
- if (annot && doc) {
- m_AnnotData.Reset(annot);
- x_SetDocument(*doc);
- }
- }
- void CAlnCrossAlignView::OnDocumentChanged()
- {
- if (!m_Document) {
- return;
- }
- SetTitle(m_Document->GetShortTitle() + ": " + GetTitle());
- // create our datasource
- m_DataSource.Reset(
- new CCrossAlnDataSource(*m_AnnotData, m_Document->GetScope()));
- CCrossAlnDataSource::TIdRefCont all_ids = m_DataSource->GetSeqIDs();
- // choosing sequences to display
- m_SeqChoice1->clear();
- m_SeqChoice2->clear();
-
- if(all_ids.size() >1 ) {
- CCrossAlnDataSource::TIdRefCont::const_iterator it = all_ids.begin();
- CConstRef<CSeq_id> s_id(*it);
- CConstRef<CSeq_id> q_id(*(++it));
- m_DataSource->SelectIds(s_id, q_id);
- m_AlnWidget->SetDataSource(m_DataSource.GetPointer());
-
- int i_q = -1, i_s = -1;
- for(unsigned int i = 0; i < all_ids.size(); i++ ) {
- CConstRef<CSeq_id> id = all_ids[i];
- if(id->Match(*q_id)) {
- i_q = i;
- }
- if(id->Match(*s_id)) {
- i_s = i;
- }
-
- CBioseq_Handle handle = m_Document->GetScope().GetBioseqHandle(*id);
- const CSeq_id& best_id =
- sequence::GetId(handle, sequence::eGetId_Best);
- string str;
- best_id.GetLabel(&str);
- m_SeqChoice1->add(str.c_str());
- m_SeqChoice2->add(str.c_str());
- }
- m_SeqChoice1->value(i_q);
- m_SeqChoice2->value(i_s);
- }
- }
- void CAlnCrossAlignView::x_OnSelectionChanged()
- {
- int idx1 = m_SeqChoice1->value();
- int idx2 = m_SeqChoice2->value();
-
- CCrossAlnDataSource::TIdRefCont all_ids = m_DataSource->GetSeqIDs();
- m_DataSource->SelectIds(all_ids[idx1], all_ids[idx2]);
- m_AlnWidget->Update();
- }
- void CAlnCrossAlignView::x_OnFitToWindow()
- {
- m_AlnWidget->FitToWindow();
- }
- void CAlnCrossAlignView::x_OnZoomToSequence()
- {
- m_AlnWidget->ZoomToSequence();
- }
- void CAlnCrossAlignView::x_OnShowMismatches()
- {
- //bool show = m_Menu->mvalue()->value() ? true : false;
- //m_AlnWidget->ShowSequenceAsDots(show);
- }
- const string& CAlnCrossAlignView::GetTitle(void) const
- {
- static string s_str("Cross Alignment View");
- return s_str;
- }
- void CAlnCrossAlignView::x_OnFileClose()
- {
- Hide();
- }
- void CAlnCrossAlignView::x_OnHelp()
- {
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: view_crossalign.cpp,v $
- * Revision 1000.5 2004/06/01 20:59:09 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.36
- *
- * Revision 1.36 2004/05/21 22:27:49 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.35 2004/05/03 13:30:17 dicuccio
- * gui/utils --> gui/objutils where needed
- *
- * Revision 1.34 2004/04/07 13:05:10 dicuccio
- * Changed view API - require CPluginMessage instead of CPluginArgSet
- *
- * Revision 1.33 2004/03/05 17:37:11 dicuccio
- * Use sequence::GetId() instead of CSeq_id::GetStringDescr()
- *
- * Revision 1.32 2003/12/22 19:33:13 dicuccio
- * Lots of changes. Changed to match new APIs in IView. Added better handling of messages received from other views
- *
- * Revision 1.31 2003/12/22 16:50:07 lebedev
- * Do not use ViewMenuManager (no menu present)
- *
- * Revision 1.30 2003/12/22 13:28:21 lebedev
- * Plugin updated to use new CrossAlignment Widget
- *
- * Revision 1.29 2003/11/24 15:45:42 dicuccio
- * Renamed CVersion to CPluginVersion
- *
- * Revision 1.28 2003/11/19 20:45:26 friedman
- * Added handling a visible range change event
- *
- * Revision 1.27 2003/11/04 12:51:27 friedman
- * Added event message pool callbacks for the document all-view message pool.
- *
- * Revision 1.26 2003/10/27 20:03:26 dicuccio
- * Rearranged Update() to be consistent
- *
- * Revision 1.25 2003/10/07 13:47:06 dicuccio
- * Renamed CPluginURL* to CPluginValue*
- *
- * Revision 1.24 2003/09/24 18:26:46 dicuccio
- * Large clean-ups to alignment viewers. Reimplemented data sources and alignment
- * generation mechanism to be more generic.
- *
- * Revision 1.23 2003/09/04 14:54:21 dicuccio
- * Use IDocument instead of CDocument. Changed APIs to match changes in IView
- *
- * Revision 1.22 2003/07/22 15:32:16 dicuccio
- * Changed to make use of new API in plugin_utils.hpp - GetArgValue()
- *
- * Revision 1.21 2003/06/26 15:33:41 dicuccio
- * Moved GetURLValue() from PluginURL.hpp to plugin_utils.hpp. Fixed compilation
- * errors relating to missing #includes
- *
- * Revision 1.20 2003/06/25 17:02:59 dicuccio
- * Split CPluginHandle into a handle (pointer-to-implementation) and
- * implementation file. Lots of #include file clean-ups.
- *
- * Revision 1.19 2003/06/23 13:23:13 dicuccio
- * Deprecated seq_utils.[h,c]pp - moved functions into gui.utils/utils.hpp
- *
- * Revision 1.18 2003/06/20 14:53:52 dicuccio
- * Revised plugin registration - moved GetInfo() into the plugin handler
- *
- * Revision 1.17 2003/06/02 16:06:22 dicuccio
- * Rearranged src/objects/ subtree. This includes the following shifts:
- * - src/objects/asn2asn --> arc/app/asn2asn
- * - src/objects/testmedline --> src/objects/ncbimime/test
- * - src/objects/objmgr --> src/objmgr
- * - src/objects/util --> src/objmgr/util
- * - src/objects/alnmgr --> src/objtools/alnmgr
- * - src/objects/flat --> src/objtools/flat
- * - src/objects/validator --> src/objtools/validator
- * - src/objects/cddalignview --> src/objtools/cddalignview
- * In addition, libseq now includes six of the objects/seq... libs, and libmmdb
- * replaces the three libmmdb? libs.
- *
- * Revision 1.16 2003/05/22 18:50:04 dicuccio
- * Standardized construction, argument specification for all alignment views
- *
- * Revision 1.15 2003/05/19 13:43:32 dicuccio
- * Moved gui/core/plugin --> gui/plugin/. Merged core libraries into libgui_core
- *
- * Revision 1.14 2003/04/24 16:40:38 dicuccio
- * Updated to reflect changes in plugin API. Added new common alignment view base
- * class - handles notions of creating alignment manager in a standard way
- *
- * Revision 1.13 2003/03/17 14:54:14 dicuccio
- * Changed base class CView - added member variable for FLTK gui component for
- * child windows, which is now maintained via an auto_ptr<>. Eliminated
- * Show()/Hide() as a pure virtual requirement.
- *
- * Revision 1.12 2003/03/07 13:35:59 dicuccio
- * Fixed titles in drop-down menu for sequence selection
- *
- * Revision 1.11 2003/03/04 20:08:36 lebedev
- * Prepare Cross Alignment Viewer for MDI
- *
- * Revision 1.10 2003/03/03 18:31:22 dicuccio
- * Deprecated CAlnUtils::GetTitle() in favor of sequence::GetTitle()
- *
- * Revision 1.9 2003/02/20 19:49:58 dicuccio
- * Created new plugin architecture, based on ASN.1 spec. Moved GBENCH frameowrk
- * over to use new plugin architecture.
- *
- * Revision 1.8 2003/01/17 18:38:49 lebedev
- * Menu item to hide matching sequence letters added
- *
- * Revision 1.7 2003/01/15 21:35:43 lebedev
- * Zoom to Sequence menu item added
- *
- * Revision 1.6 2003/01/13 13:10:08 dicuccio
- * Namespace clean-up. Retired namespace gui -> converted all to namespace ncbi.
- * Moved all FLUID-generated code into namespace ncbi.
- *
- * Revision 1.5 2003/01/09 14:50:41 dicuccio
- * Use 'const CBioseq_Handle&' instead of 'CBioseq_Handle&'
- *
- * Revision 1.4 2002/12/20 19:52:21 dicuccio
- * Cnaged TRange::SetFrom()/TRange::SetTo() --> TRange::Set()
- *
- * Revision 1.3 2002/12/20 19:22:51 dicuccio
- * Lots of changes to the menus. Standardized the menu syntax across all views.
- * Changed to use new dynamic menu managers.
- *
- * Revision 1.2 2002/12/13 13:18:52 dicuccio
- * Added work-around for inlining problems in some versions of gcc: directly
- * include a FLUID-generated '*_.cpp' file in the corresponding '*.cpp' and
- * remove this file from the build. Thanks Aaron!
- *
- * Revision 1.1 2002/12/05 19:07:20 lebedev
- * Initial revision
- *
- * ===========================================================================
- */