⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alnvec.hpp

📁 ncbi源码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: alnvec.hpp,v $ * PRODUCTION Revision 1000.1  2004/04/12 17:34:45  gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.33 * PRODUCTION * =========================================================================== */#ifndef OBJECTS_ALNMGR___ALNVEC__HPP#define OBJECTS_ALNMGR___ALNVEC__HPP/*  $Id: alnvec.hpp,v 1000.1 2004/04/12 17:34:45 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. * * =========================================================================== * * Author:  Kamen Todorov, NCBI * * File Description: *   Access to the actual aligned residues * */#include <objtools/alnmgr/alnmap.hpp>#include <objmgr/seq_vector.hpp>BEGIN_NCBI_SCOPEBEGIN_objects_SCOPE// forward declarationsclass CScope;class NCBI_XALNMGR_EXPORT CAlnVec : public CAlnMap{    typedef CAlnMap                         Tparent;    typedef map<TNumrow, CBioseq_Handle>    TBioseqHandleCache;    typedef map<TNumrow, CRef<CSeqVector> > TSeqVectorCache;public:    typedef CSeqVector::TResidue            TResidue;    typedef vector<int>                     TResidueCount;    // constructor    CAlnVec(const CDense_seg& ds, CScope& scope);    CAlnVec(const CDense_seg& ds, TNumrow anchor, CScope& scope);    // destructor    ~CAlnVec(void);    CScope& GetScope(void) const;    // GetSeqString methods:    // raw seq string (in seq coords)    string& GetSeqString   (string& buffer,                            TNumrow row,                            TSeqPos seq_from, TSeqPos seq_to)             const;    string& GetSeqString   (string& buffer,                            TNumrow row,                            const CAlnMap::TRange& seq_rng)               const;    string& GetSegSeqString(string& buffer,                             TNumrow row,                             TNumseg seg, TNumseg offset = 0)              const;    // alignment (seq + gaps) string (in aln coords)    string& GetAlnSeqString(string& buffer,                            TNumrow row,                             const CAlnMap::TSignedRange& aln_rng)         const;    // creates a vertical string of residues for a given aln pos    // optionally, returns a distribution of residues    // optionally, counts the gaps in this distribution    string& GetColumnVector(string& buffer,                            TSeqPos aln_pos,                            TResidueCount * residue_count = 0,                            bool gaps_in_count = false)                   const;    // get the seq string for the whole alignment (seq + gaps)    // optionally, get the inserts and screen limit coords    string& GetWholeAlnSeqString(TNumrow       row,                                 string&       buffer,                                 TSeqPosList * insert_aln_starts = 0,                                 TSeqPosList * insert_starts = 0,                                 TSeqPosList * insert_lens = 0,                                 unsigned int  scrn_width = 0,                                 TSeqPosList * scrn_lefts = 0,                                 TSeqPosList * scrn_rights = 0) const;    const CBioseq_Handle& GetBioseqHandle(TNumrow row)                  const;    TResidue              GetResidue     (TNumrow row, TSeqPos aln_pos) const;    // gap character could be explicitely set otherwise taken from seqvector    void     SetGapChar(TResidue gap_char);    void     UnsetGapChar();    bool     IsSetGapChar()                const;    TResidue GetGapChar(TNumrow row)       const;    // end character is ' ' by default    void     SetEndChar(TResidue gap_char);    bool     IsSetEndChar()                const;    TResidue GetEndChar()                  const;    // functions for manipulating the consensus sequence    CRef<CDense_seg> CreateConsensus(int& consensus_row) const;    // utilities    int CalculateScore          (TNumrow row1, TNumrow row2) const;    int CalculatePercentIdentity(TSeqPos aln_pos)            const;    // static utilities    static void TranslateNAToAA(const string& na, string& aa);    static int  CalculateScore (const string& s1, const string& s2,                                bool s1_is_prot, bool s2_is_prot);        // temporaries for conversion (see note below)    static unsigned char FromIupac(unsigned char c);    static unsigned char ToIupac  (unsigned char c);protected:    CSeqVector& x_GetSeqVector         (TNumrow row)       const;    CSeqVector& x_GetConsensusSeqVector(void)              const;    mutable CRef<CScope>            m_Scope;    mutable TBioseqHandleCache      m_BioseqHandlesCache;    mutable TSeqVectorCache         m_SeqVectorCache;private:    // Prohibit copy constructor and assignment operator    CAlnVec(const CAlnVec&);    CAlnVec& operator=(const CAlnVec&);    TResidue m_GapChar;    bool     m_set_GapChar;    TResidue m_EndChar;    bool     m_set_EndChar;};///////////////////////////////////////////////////////////////////////////////  IMPLEMENTATION of INLINE functions/////////////////////////////////////////////////////////////////////////////inlineCScope& CAlnVec::GetScope(void) const{    return *m_Scope;}inline CSeqVector::TResidue CAlnVec::GetResidue(TNumrow row, TSeqPos aln_pos) const{    if (aln_pos > GetAlnStop()) {        return (TResidue) 0; // out of range    }    TSegTypeFlags type = GetSegType(row, GetSeg(aln_pos));    if (type & fSeq) {        CSeqVector& seq_vec = x_GetSeqVector(row);        TSignedSeqPos pos = GetSeqPosFromAlnPos(row, aln_pos);        if (GetWidth(row) == 3) {            string na_buff, aa_buff;            if (IsPositiveStrand(row)) {                seq_vec.GetSeqData(pos, pos + 3, na_buff);            } else {                TSeqPos size = seq_vec.size();                seq_vec.GetSeqData(size - pos - 3, size - pos, na_buff);            }            TranslateNAToAA(na_buff, aa_buff);            return aa_buff[0];        } else {            return seq_vec[IsPositiveStrand(row) ?                          pos : seq_vec.size() - pos - 1];        }    } else {        if (type & fNoSeqOnLeft  ||  type & fNoSeqOnRight) {            return GetEndChar();        } else {            return GetGapChar(row);        }    }}inlinestring& CAlnVec::GetSeqString(string& buffer,                              TNumrow row,                              TSeqPos seq_from, TSeqPos seq_to) const{    if (GetWidth(row) == 3) {        string buff;        buffer.erase();        if (IsPositiveStrand(row)) {            x_GetSeqVector(row).GetSeqData(seq_from, seq_to + 1, buff);        } else {            CSeqVector& seq_vec = x_GetSeqVector(row);            TSeqPos size = seq_vec.size();            seq_vec.GetSeqData(size - seq_to - 1, size - seq_from, buff);        }        TranslateNAToAA(buff, buffer);    } else {        if (IsPositiveStrand(row)) {            x_GetSeqVector(row).GetSeqData(seq_from, seq_to + 1, buffer);        } else {            CSeqVector& seq_vec = x_GetSeqVector(row);            TSeqPos size = seq_vec.size();            seq_vec.GetSeqData(size - seq_to - 1, size - seq_from, buffer);        }    }    return buffer;}inlinestring& CAlnVec::GetSegSeqString(string& buffer,                                 TNumrow row,                                 TNumseg seg, int offset) const

⌨️ 快捷键说明

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