hit_matrix_demo_ui.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:6k
- /*
- * ===========================================================================
- * PRODUCTION $Log: hit_matrix_demo_ui.cpp,v $
- * PRODUCTION Revision 1000.2 2004/06/01 21:11:24 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: hit_matrix_demo_ui.cpp,v 1000.2 2004/06/01 21:11:24 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: Andrey Yazhuk
- *
- * File Description:
- *
- */
- #include <ncbi_pch.hpp>
- #include "hit_matrix_demo_ui.hpp"
- #include <gui/utils/message_box.hpp>
- #include <objtools/data_loaders/genbank/gbloader.hpp>
- #include <serial/objistr.hpp>
- #include <objects/seq/Seq_annot.hpp>
- #include <serial/serial.hpp>
- BEGIN_NCBI_SCOPE
- USING_SCOPE(objects);
- #include "hit_matrix_demo_ui_.cpp"
- DEFINE_MENU(Menu)
- SUBMENU("Zoom")
- MENU_ITEM(eCmdZoomIn, "Zoom In")
- MENU_ITEM(eCmdZoomOut, "Zoom Out")
- MENU_ITEM(eCmdZoomAll, "Zoom All")
- MENU_ITEM(eCmdZoomObjects, "Zoom to Hits")
- MENU_SEPARATOR()
- MENU_ITEM(eCmdZoomSel, "Zoom to Selection")
- MENU_ITEM(eCmdZoomSelObjects, "Zoom to Selected Hits")
- MENU_ITEM(eCmdSetEqualScale, "Make Proportional")
- MENU_SEPARATOR()
- MENU_ITEM(eCmdZoomInX, "Zoom In Subject")
- MENU_ITEM(eCmdZoomOutX, "Zoom Out Subject")
- MENU_ITEM(eCmdZoomAllX, "Zoom All Subject")
- MENU_SEPARATOR()
- MENU_ITEM(eCmdZoomInY, "Zoom In Query")
- MENU_ITEM(eCmdZoomOutY, "Zoom Out Query")
- MENU_ITEM(eCmdZoomAllY, "Zoom All Query")
- END_SUBMENU()
- SUBMENU("View")
- MENU_ITEM(eCmdChooseSeq, "Choose Sequences to Display...")
- MENU_ITEM(eCmdColorByScore, "Color by Score...")
- END_SUBMENU()
- END_MENU()
- CHitMatrixDemoUI::CHitMatrixDemoUI()
- {
- m_Window.reset(x_CreateWindow());
-
- m_MenuBar->SetItems(Menu);
- m_MenuBar->SetCmdTarget(m_MatrixWidget);
- }
- CHitMatrixDemoUI::~CHitMatrixDemoUI()
- {
- // these must be deleted in proper order
- m_DataSource.Reset();
- m_Window.reset();
- m_Scope.Reset();
- m_ObjMgr.Reset();
- }
- void CHitMatrixDemoUI::Show(int argc, char** argv)
- {
- m_Accession->value("gi|");
- m_Accession->redraw();
- m_InputFile->value("E:\Projects\c++\compilers\msvc_prj\gbench\blastres.asn");
- m_InputFile->redraw();
- m_Window->show(argc, argv);
- while (m_Window->shown()) {
- Fl::wait();
- }
- }
- void CHitMatrixDemoUI::x_OnLoadAccession()
- {
- CSeq_id id(m_Accession->value());
- if (id.Which() == CSeq_id::e_not_set) {
- string msg("Accession '");
- msg += m_Accession->value();
- msg += "' not recognized as a valid accession";
- NcbiMessageBox(msg, eDialog_Ok, eIcon_Exclamation,
- "Unhandled Accession");
- return;
- }
- if ( !m_ObjMgr ) {
- m_ObjMgr.Reset(new CObjectManager());
- m_ObjMgr->RegisterDataLoader(*new CGBDataLoader(),
- CObjectManager::eDefault);
- m_Scope.Reset(new CScope(*m_ObjMgr));
- m_Scope->AddDefaults();
- }
- // retrieve our sequence
- CBioseq_Handle handle = m_Scope->GetBioseqHandle(id);
- if ( !handle ) {
- string msg("Can't find sequence for accession '");
- msg += m_Accession->value();
- msg += "'";
- NcbiMessageBox(msg, eDialog_Ok, eIcon_Exclamation,
- "Sequence Not Found");
- return;
- }
- }
- void CHitMatrixDemoUI::x_OnLoadFile()
- {
- string filename(m_InputFile->value());
- auto_ptr<CObjectIStream> is(CObjectIStream::Open(eSerial_AsnText, filename));
- CRef<CSeq_align_set> aset(new CSeq_align_set());
- *is >> *aset;
- if ( !m_ObjMgr ) {
- m_ObjMgr.Reset(new CObjectManager());
- m_ObjMgr->RegisterDataLoader(*new CGBDataLoader(),
- CObjectManager::eDefault);
- m_Scope.Reset(new CScope(*m_ObjMgr));
- m_Scope->AddDefaults();
- }
- m_DataSource.Reset(new CHitMatrixDataSource(*aset, *m_Scope));
- CHitMatrixDataSource::TIdRefCont all_ids = m_DataSource->GetSeqIDs();
- // choosing sequences to display
- if(all_ids.size() >1 ) {
- CHitMatrixDataSource::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_MatrixWidget->SetDataSource(m_DataSource.GetPointer());
- }
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: hit_matrix_demo_ui.cpp,v $
- * Revision 1000.2 2004/06/01 21:11:24 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7
- *
- * Revision 1.7 2004/05/21 22:27:54 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.6 2004/05/17 16:27:24 gorelenk
- * GetObject changed to dereferencin operator
- *
- * Revision 1.5 2004/02/12 21:07:29 yazhuk
- * Reorganized menu and added new commands
- *
- * Revision 1.4 2004/01/15 20:19:31 yazhuk
- * Added menu defintion and menu setup code
- *
- * Revision 1.3 2004/01/05 18:50:29 vasilche
- * Fixed path to include files.
- *
- * Revision 1.2 2003/12/05 17:50:09 yazhuk
- * Fixed viewer initialization code.
- *
- * Revision 1.1 2003/11/17 20:58:56 yazhuk
- * Initial revision
- *
- * ===========================================================================
- */