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

📄 block_multiple_alignment.hpp

📁 ncbi源码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: block_multiple_alignment.hpp,v $ * PRODUCTION Revision 1000.2  2004/04/12 17:30:52  gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.40 * PRODUCTION * =========================================================================== *//*  $Id: block_multiple_alignment.hpp,v 1000.2 2004/04/12 17:30: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:  Paul Thiessen** File Description:*      Classes to hold alignment data** ===========================================================================*/#ifndef CN3D_BLOCK_MULTIPLE_ALIGNMENT__HPP#define CN3D_BLOCK_MULTIPLE_ALIGNMENT__HPP#include <corelib/ncbistl.hpp>#include <objects/cdd/Update_align.hpp>#include <objects/seqalign/Seq_align.hpp>#include <objalign.h>#include <blast.h>#include <blastkar.h>#include <thrdatd.h>#include <thrddecl.h>#include <list>#include <vector>#include <map>#include "vector_math.hpp"#include "style_manager.hpp"BEGIN_SCOPE(Cn3D)class Sequence;class ConservationColorer;class AlignmentManager;class Block;class UngappedAlignedBlock;class UnalignedBlock;class Messenger;class Threader;class BlockMultipleAlignment{public:    typedef std::vector < const Sequence * > SequenceList;    // list will be owned/freed by this object    BlockMultipleAlignment(SequenceList *sequenceList, AlignmentManager *alnMgr);    ~BlockMultipleAlignment(void);    const SequenceList *sequences;    AlignmentManager *alignmentManager;    // create a C-object SeqAlign from this alignment (actually a linked list of pairwise    // SeqAlign's; should be freed with SeqAlignSetFree())    SeqAlignPtr CreateCSeqAlign(void) const;    // to track the origin of this alignment if it came from an update    ncbi::CRef < ncbi::objects::CUpdate_align > updateOrigin;    // add a new aligned block - will be "owned" and deallocated by BlockMultipleAlignment    bool AddAlignedBlockAtEnd(UngappedAlignedBlock *newBlock);    // these two should be called after all aligned blocks have been added; fills out    // unaligned blocks inbetween aligned blocks (and at ends). Also sets length.    bool AddUnalignedBlocks(void);    // Fills out the BlockMap for mapping alignment column -> block+column, special colors,    // and sets up conservation colors (although they're not calculated until needed).    bool UpdateBlockMapAndColors(bool clearRowInfo = true);    // find out if a residue is aligned, by row    bool IsAligned(int row, int seqIndex) const;    // find out if a residue is aligned, by Sequence - only works for non-repeated Sequences!    bool IsAligned(const Sequence *sequence, int seqIndex) const    {        int row = GetRowForSequence(sequence);        if (row < 0) return false;        return IsAligned(row, seqIndex);    }    // stuff regarding master sequence    const Sequence * GetMaster(void) const { return (*sequences)[0]; }    bool IsMaster(const Sequence *sequence) const { return (sequence == (*sequences)[0]); }    // return sequence for given row    const Sequence * GetSequenceOfRow(int row) const    {        if (row >= 0 && row < sequences->size())            return (*sequences)[row];        else            return NULL;    }    // given a sequence, return row number in this alignment (or -1 if not found)    int GetRowForSequence(const Sequence *sequence) const;    // get a color for an aligned residue that's dependent on the entire alignment    // (e.g., for coloring by sequence conservation)    const Vector * GetAlignmentColor(const Sequence *sequence, int seqIndex,        StyleSettings::eColorScheme colorScheme) const;    const Vector * GetAlignmentColor(int row, int seqIndex,        StyleSettings::eColorScheme colorScheme) const;    // will be used to control padding of unaligned blocks    enum eUnalignedJustification {        eLeft,        eRight,        eCenter,        eSplit    };    // return alignment position of left side first aligned block (-1 if no aligned blocks)    int GetFirstAlignedBlockPosition(void) const;    // makes a new copy of itself    BlockMultipleAlignment * Clone(void) const;    // character query interface - "column" must be in alignment range [0 .. totalWidth-1]    bool GetCharacterTraitsAt(int alignmentColumn, int row, eUnalignedJustification justification,        char *character, Vector *color, bool *isHighlighted,        bool *drawBackground, Vector *cellBackgroundColor) const;    // get sequence and index (if any) at given position, and whether that residue is aligned    bool GetSequenceAndIndexAt(int alignmentColumn, int row, eUnalignedJustification justification,        const Sequence **sequence, int *index, bool *isAligned) const;    // given row and sequence index, return alignment index; not the most efficient function - use sparingly    int GetAlignmentIndex(int row, int seqIndex, eUnalignedJustification justification);    // called when user selects some part of a row    void SelectedRange(int row, int from, int to,        eUnalignedJustification justification, bool toggle) const;    // fill in a vector of UngappedAlignedBlocks    typedef std::vector < const UngappedAlignedBlock * > UngappedAlignedBlockList;    void GetUngappedAlignedBlocks(UngappedAlignedBlockList *blocks) const;    // free color storage    void FreeColors(void);    // highlight aligned columns based on master indexes (mainly for alignment annotations);    // returns false if any residue in the range is unaligned (or out of range), true on success    bool HighlightAlignedColumnsOfMasterRange(int from, int to) const;    // PSSM for this alignment (cached)    const BLAST_Matrix * GetPSSM(void) const;    void RemovePSSM(void) const;    ///// editing functions /////    // if in an aligned block, give block column and width of that position; otherwise, -1    void GetAlignedBlockPosition(int alignmentIndex, int *blockColumn, int *blockWidth) const;    // get seqIndex of slave aligned to the given master seqIndex; -1 if master residue unaligned    int GetAlignedSlaveIndex(int masterSeqIndex, int slaveRow) const;    // returns true if any boundary shift actually occurred    bool MoveBlockBoundary(int columnFrom, int columnTo);    // splits a block such that alignmentIndex is the first column of the new block;    // returns false if no split occurred (e.g. if index is not inside aligned block)    bool SplitBlock(int alignmentIndex);    // merges all blocks that overlap specified range - assuming no unaligned blocks    // in that range. Returns true if any merge(s) occurred, false otherwise.    bool MergeBlocks(int fromAlignmentIndex, int toAlignmentIndex);    // creates a block, if given region of an unaligned block in which no gaps    // are present. Returns true if a block is created.    bool CreateBlock(int fromAlignmentIndex, int toAlignmentIndex, eUnalignedJustification justification);    // deletes the block containing this index; returns true if deletion occurred.    bool DeleteBlock(int alignmentIndex);    // deletes all blocks; returns true if there were any blocks to delete    bool DeleteAllBlocks(void);    // shifts (horizontally) the residues in and immediately surrounding an    // aligned block; returns true if any shift occurs.    bool ShiftRow(int row, int fromAlignmentIndex, int toAlignmentIndex, eUnalignedJustification justification);    // delete a row; returns true if successful    bool DeleteRow(int row);    // flag an aligned block for realignment - block will be removed upon ExtractRows; returns true if    // column is in fact an aligned block    bool MarkBlock(int column);    bool ClearMarks(void);  // remove all block flags    // this function does two things: it extracts from a multiple alignment all slave rows listed for    // removal; and if pairwiseAlignments!=NULL, for each slave removed creates a new BlockMultipleAlignment    // that contains the alignment of just that slave with the master, as it was in the original multiple    // (i.e., not according to the corresponding pre-IBM MasterSlaveAlignment)    typedef std::list < BlockMultipleAlignment * > AlignmentList;    bool ExtractRows(const std::vector < int >& slavesToRemove, AlignmentList *pairwiseAlignments);    // merge in the contents of the given alignment (assuming same master, compatible block structure),    // addings its rows to the end of this alignment; returns true if merge successful. Does not change    // block structure - just adds the part of new alignment's aligned blocks that intersect with this    // object's aligned blocks    bool MergeAlignment(const BlockMultipleAlignment *newAlignment);    // turn on/off geometry violations; if param is true, will return # violations found    int ShowGeometryViolations(bool showGeometryViolations);private:    ConservationColorer *conservationColorer;    mutable BLAST_Matrix *pssm;    typedef std::list < Block * > BlockList;    BlockList blocks;    int totalWidth;    typedef struct {        Block *block;        int blockColumn, alignedBlockNum;    } BlockInfo;    typedef std::vector < BlockInfo > BlockMap;    BlockMap blockMap;    // to flag blocks for realignment    typedef std::map < const Block * , bool > MarkBlockMap;    MarkBlockMap markBlocks;    bool CheckAlignedBlock(const Block *newBlock) const;    UnalignedBlock * CreateNewUnalignedBlockBetween(const Block *left, const Block *right);    Block * GetBlockBefore(const Block *block) const;    Block * GetBlockAfter(const Block *block) const;    void InsertBlockBefore(Block *newBlock, const Block *insertAt);    void InsertBlockAfter(const Block *insertAt, Block *newBlock);    void RemoveBlock(Block *block);    // for cacheing of residue->block lookups    mutable int cachePrevRow;    mutable const Block *cachePrevBlock;    mutable BlockList::const_iterator cacheBlockIterator;    void InitCache(void);    // given a row and seqIndex, find block that contains that residue    const Block * GetBlock(int row, int seqIndex) const;

⌨️ 快捷键说明

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