align_ds.cpp

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

CPP
252
字号
/* * =========================================================================== * PRODUCTION $Log: align_ds.cpp,v $ * PRODUCTION Revision 1000.2  2004/06/01 21:06:52  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * PRODUCTION * =========================================================================== *//*  $Id: align_ds.cpp,v 1000.2 2004/06/01 21:06:52 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 <gui/widgets/aln_data/align_ds.hpp>#include <objtools/alnmgr/alnmix.hpp>#include <objmgr/align_ci.hpp>#include <objects/seqalign/Dense_seg.hpp>#include <objects/seqalign/Seq_align.hpp>#include <objects/seq/Seq_annot.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(ncbi::objects);//// CAlignDataSourceException is a trivial exception class for trapping// exceptions during initialization.//class CAlignDataSourceException : EXCEPTION_VIRTUAL_BASE public CException{public:    // Enumerated list of document management errors    enum EErrCode {        eInvalidAnnot    };    // Translate the specific error code into a string representations of    // that error code.    virtual const char* GetErrCodeString(void) const    {        switch (GetErrCode()) {        case eInvalidAnnot:         return "eInvalidAnnot";        default:                    return CException::GetErrCodeString();        }    }    NCBI_EXCEPTION_DEFAULT(CAlignDataSourceException, CException);};//// constructors//CAlignDataSource::CAlignDataSource(): m_ConsRowIndex(-1){}void    CAlignDataSource::Init(CAlnVec& mgr){    m_ConsRowIndex = -1;    x_ClearHandles();    m_AlnMgr = &mgr;    x_CreateHandles();}void CAlignDataSource::Init(CAlign_CI& iter, CScope& scope){     CAlnMix mix(scope);    for ( ;  iter;  ++iter) {        mix.Add(*iter);    }    x_Init(mix);}void CAlignDataSource::Init(const CSeq_align& align, CScope& scope){    CAlnMix mix(scope);    mix.Add(align);    x_Init(mix);}void CAlignDataSource::Init(const CSeq_annot& annot, CScope& scope){    if ( !annot.GetData().IsAlign() ) {        NCBI_THROW(CAlignDataSourceException, eInvalidAnnot,                   "Annotation is not an alignment");    }    CAlnMix mix(scope);    ITERATE (CSeq_annot::TData::TAlign, iter, annot.GetData().GetAlign()) {        mix.Add(**iter);    }    x_Init(mix);}void CAlignDataSource::Init(const CDense_seg& seg, CScope& scope){    CAlnMix mix(scope);    mix.Add(seg);    x_Init(mix);}void CAlignDataSource::Init(const CBioseq_Handle& handle, CScope& scope){    CAlnMix Mix(scope);    // iterate all alignments on this bioseq handle    SAnnotSelector sel(CSeq_annot::TData::e_Align);    CAlign_CI iter(handle, 0, 0, sel);        CAlnMix mix(scope);    for ( ;  iter;  ++iter) {        mix.Add(*iter);    }    x_Init(mix);}void CAlignDataSource::x_Init(CAlnMix& mix){    m_ConsRowIndex = -1;    x_ClearHandles();    try {        mix.Merge(CAlnMix::fGen2EST |                  CAlnMix::fTryOtherMethodOnFail |                  CAlnMix::fGapJoin);        m_AlnMgr.Reset(new CAlnVec(mix.GetDenseg(), mix.GetScope()));        m_AlnMgr->SetGapChar('-');    }    catch (CException& e) {        LOG_POST(Error << "CAlignDataSource::x_Init(): caught exception: "                 << e.what());        throw;    }    x_CreateHandles();}void CAlignDataSource::x_ClearHandles(){}void CAlignDataSource::x_CreateHandles(){}CAlnVec& CAlignDataSource::SetAlnMgr(void){    return *m_AlnMgr;}const CAlnVec& CAlignDataSource::GetAlnMgr(void) const{    return *m_AlnMgr;}void    CAlignDataSource::CreateConsensus(){    if(m_AlnMgr.NotEmpty()  &&  m_ConsRowIndex == -1)    {        x_ClearHandles();        CRef<CDense_seg> ds = m_AlnMgr->CreateConsensus(m_ConsRowIndex);             m_AlnMgr.Reset(new CAlnVec(*ds, m_AlnMgr->GetScope()));            x_CreateHandles();    }}    int     CAlignDataSource::x_GetConsensusRow() const{    return m_ConsRowIndex;}END_NCBI_SCOPE/* * =========================================================================== * $Log: align_ds.cpp,v $ * Revision 1000.2  2004/06/01 21:06:52  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * * Revision 1.9  2004/05/21 22:27:52  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.8  2004/02/11 15:08:59  yazhuk * Replaced constructors with Init() functions; removed x_Init() * * Revision 1.7  2003/10/29 23:14:19  yazhuk * Moved CAlnVecRowHandle to widgets/aln_multiple. Moved implementation of interface for CAlnMultiWidget to CAlnVecMutliDataSource * * Revision 1.6  2003/10/20 15:44:25  yazhuk * Clean-up. * * Revision 1.5  2003/10/15 21:17:44  yazhuk * Add to CAlignDataSource functions for providing API to "generic" alignments. * Added IAlignRowHandle and CAlnVecRowHandle classes. * * Revision 1.4  2003/10/07 13:44:40  dicuccio * Deleted commented lines * * Revision 1.3  2003/10/06 16:21:05  dicuccio * Disable alignment truncation on mix - fixes crash in multiple alignment viewer * * Revision 1.2  2003/09/25 20:51:50  yazhuk * Added support for consensus row * * Revision 1.1  2003/09/23 20:17:06  dicuccio * Initial revision (not built by default) * * =========================================================================== */

⌨️ 快捷键说明

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