📄 su_block_multiple_alignment.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: su_block_multiple_alignment.hpp,v $ * PRODUCTION Revision 1000.0 2004/06/01 18:14:33 gouriano * PRODUCTION PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.7 * PRODUCTION * =========================================================================== *//* $Id: su_block_multiple_alignment.hpp,v 1000.0 2004/06/01 18:14:33 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 SU_BLOCK_MULTIPLE_ALIGNMENT__HPP#define SU_BLOCK_MULTIPLE_ALIGNMENT__HPP#include <corelib/ncbistl.hpp>#include <corelib/ncbiobj.hpp>#include <objects/seqalign/Seq_align.hpp>#include <list>#include <vector>#include <map>// forward declaration of BLAST_Matrixstruct _blast_matrix;typedef struct _blast_matrix BLAST_Matrix_;BEGIN_SCOPE(struct_util)class Sequence;class Block;class UngappedAlignedBlock;class UnalignedBlock;class BlockMultipleAlignment : public ncbi::CObject{public: enum { eUndefined = kMax_UInt }; typedef std::vector < const Sequence * > SequenceList; BlockMultipleAlignment(const SequenceList& sequenceList); // first sequence is master ~BlockMultipleAlignment(void); // 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 UpdateBlockMap(bool clearRowInfo = true); // find out if a residue is aligned, by row bool IsAligned(unsigned int row, unsigned int seqIndex) const; // stuff regarding master sequence const Sequence * GetMaster(void) const { return m_sequences[0]; } bool IsMaster(const Sequence *sequence) const { return (sequence == m_sequences[0]); } // return sequence for given row const Sequence * GetSequenceOfRow(unsigned int row) const { if (row < m_sequences.size()) return m_sequences[row]; else return NULL; } // will be used to control padding of unaligned blocks enum eUnalignedJustification { eLeft, eRight, eCenter, eSplit }; // return alignment position of left side first aligned block (eUndefined if no aligned blocks) unsigned int GetFirstAlignedBlockPosition(void) const; // makes a new copy of itself BlockMultipleAlignment * Clone(void) const; // character query interface - "column" must be in alignment range [0 .. AlignmentWidth()-1] bool GetCharacterAt(unsigned int alignmentColumn, unsigned int row, eUnalignedJustification justification, char *character) const; // get sequence and index (if any) at given position, and whether that residue is aligned bool GetSequenceAndIndexAt(unsigned int alignmentColumn, unsigned int row, eUnalignedJustification justification, const Sequence **sequence, unsigned int *index, bool *isAligned) const; // given row and sequence index, return alignment index; not the most efficient function - use sparingly unsigned int GetAlignmentIndex(unsigned int row, unsigned int seqIndex, eUnalignedJustification justification); // fill in a vector of UngappedAlignedBlocks typedef std::vector < const UngappedAlignedBlock * > UngappedAlignedBlockList; void GetUngappedAlignedBlocks(UngappedAlignedBlockList *blocks) const; typedef std::vector < UngappedAlignedBlock * > ModifiableUngappedAlignedBlockList; void GetModifiableUngappedAlignedBlocks(ModifiableUngappedAlignedBlockList *blocks); // PSSM for this alignment (cached) const BLAST_Matrix_ * GetPSSM(void) const; void RemovePSSM(void) const; // NULL if block before is aligned; if NULL passed, retrieves last block (if unaligned; else NULL) const UnalignedBlock * GetUnalignedBlockBefore(const UngappedAlignedBlock *aBlock) const; unsigned int NBlocks(void) const { return m_blocks.size(); } unsigned int NAlignedBlocks(void) const; unsigned int NRows(void) const { return m_sequences.size(); } unsigned int AlignmentWidth(void) const { return m_totalWidth; } // return a number from 1..n for aligned blocks, eUndefined for unaligned unsigned int GetAlignedBlockNumber(unsigned int alignmentIndex) const { return m_blockMap[alignmentIndex].alignedBlockNum; } // for storing/querying info double GetRowDouble(unsigned int row) const { return m_rowDoubles[row]; } void SetRowDouble(unsigned int row, double value) const { m_rowDoubles[row] = value; } const std::string& GetRowStatusLine(unsigned int row) const { return m_rowStrings[row]; } void SetRowStatusLine(unsigned int row, const std::string& value) const { m_rowStrings[row] = value; } // empties all rows' infos void ClearRowInfo(void) const { for (unsigned int r=0; r<NRows(); ++r) { m_rowDoubles[r] = 0.0; m_rowStrings[r].erase(); } } ///// editing functions ///// // if in an aligned block, give block column and width of that position; otherwise eUndefined void GetAlignedBlockPosition(unsigned int alignmentIndex, unsigned int *blockColumn, unsigned int *blockWidth) const; // get seqIndex of slave aligned to the given master seqIndex; eUndefined if master residue unaligned unsigned int GetAlignedSlaveIndex(unsigned int masterSeqIndex, unsigned int slaveRow) const; // returns true if any boundary shift actually occurred bool MoveBlockBoundary(unsigned int columnFrom, unsigned 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(unsigned 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(unsigned int fromAlignmentIndex, unsigned 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(unsigned int fromAlignmentIndex, unsigned int toAlignmentIndex, eUnalignedJustification justification); // deletes the block containing this index; returns true if deletion occurred. bool DeleteBlock(unsigned 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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -