cross_aln_demo_ui.cpp

来自「ncbi源码」· C++ 代码 · 共 211 行

CPP
211
字号
/* * =========================================================================== * PRODUCTION $Log: cross_aln_demo_ui.cpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 21:06:44  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3 * PRODUCTION * =========================================================================== *//*  $Id: cross_aln_demo_ui.cpp,v 1000.1 2004/06/01 21:06:44 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: * */#include <ncbi_pch.hpp>#include "cross_aln_demo_ui.hpp"#include <gui/utils/message_box.hpp>#include <gui/utils/fltk_utils.hpp>#include <objtools/data_loaders/genbank/gbloader.hpp>#include <serial/objistr.hpp>#include <objects/seq/Seq_annot.hpp>#include <serial/serial.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);#include "cross_aln_demo_ui_.cpp"CCrossAlnDemoUI::CCrossAlnDemoUI(){    m_Window.reset(x_CreateWindow());    CFltkEvent::SetOSDefaults();}CCrossAlnDemoUI::~CCrossAlnDemoUI(){    // these must be deleted in proper order    m_DataSource.Reset();    m_Window.reset();    m_Scope.Reset();    m_ObjMgr.Reset();}void CCrossAlnDemoUI::Show(int argc, char** argv){    m_Accession->value("gi|");    m_Accession->redraw();    m_InputFile->value("/Users/lebedev/align2.asn");    m_InputFile->redraw();    m_Window->show(argc, argv);    while (m_Window->shown()) {        Fl::wait();    }}void CCrossAlnDemoUI::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;    }    /*CRef<CSeq_align_set> aset(new CSeq_align_set());    CAlign_CI iter(handle, 0, 0, SAnnotSelector());    for ( ;  iter;  ++iter) {        const CSeq_align& align = *iter;        aset.insert(align);    }*/    //m_DataSource.Reset(new CCrossAlnDataSource(aset.GetObject(), m_Scope.GetObject()));}void CCrossAlnDemoUI::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;    CRef<CSeq_annot> annot(new CSeq_annot());    *is >> *annot;    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 CCrossAlnDataSource(aset.GetObject(), m_Scope.GetObject()));zzzzz    m_DataSource.Reset(new CCrossAlnDataSource(annot.GetObject(), m_Scope.GetObject()));    CCrossAlnDataSource::TIdRefCont all_ids =  m_DataSource->GetSeqIDs();    // choosing sequences to display    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());            x_FillLists();    }}void CCrossAlnDemoUI::x_FillLists(){    m_Idx1->clear();    m_Idx2->clear();    const CCrossAlnDataSource::TIdRefCont& ids = m_DataSource->GetSeqIDs();      ITERATE(CCrossAlnDataSource::TIdRefCont, iter, ids) {        CNcbiOstrstream oss;        (*iter)->WriteAsFasta(oss);        string tmp = (string)CNcbiOstrstreamToString(oss);        m_Idx1->add( tmp.c_str() );        m_Idx2->add( tmp.c_str() );    }    m_Idx1->select(1);    m_Idx2->select(2);}void CCrossAlnDemoUI::x_QuitApp(){    delete m_MainWindow;}END_NCBI_SCOPE/* * =========================================================================== * $Log: cross_aln_demo_ui.cpp,v $ * Revision 1000.1  2004/06/01 21:06:44  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3 * * Revision 1.3  2004/05/21 22:27:52  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.2  2004/01/05 18:50:29  vasilche * Fixed path to include files. * * Revision 1.1  2003/12/22 13:09:17  lebedev * Initial revision * * =========================================================================== */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?