NCBI C++ ToolKit
sparse_alignment.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___SPARSE_ALIGNMENT__HPP
2 #define GUI_OBJUTILS___SPARSE_ALIGNMENT__HPP
3 
4 /* $Id: sparse_alignment.hpp 25706 2012-04-25 00:21:04Z voronov $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <corelib/ncbiobj.hpp>
37 
38 #include <gui/gui_export.h>
39 
41 
42 #include <util/align_range.hpp>
44 
45 #include <objmgr/scope.hpp>
47 
48 
50 
51 
52 ///////////////////////////////////////////////////////////////////////////////
53 /// CSparseAlignment - an alignment based on CSparse_seg and
54 /// CAlingRangeCollection classes rather than on CDense_seg.
55 /// Assumptions:
56 /// master is always specified in CSparse-seg and has a Seq-id
57 /// we display it always anchored
58 /// chaning anchor is not supported
60 {
61 public:
65 
67 
71 
73  virtual ~CSparseAlignment();
74 
75  void Init(const objects::CSeq_id& master_id,
76  vector<SAlignedSeq*>& aln_seqs,
77  objects::CScope& scope);
78  void Clear();
79 
80  void SetGapChar(TResidue gap_char);
81 
83 
84  TNumrow GetNumRows() const; /// returns number of rows in the alignment
85  TARange GetAlnRange() const;
86 
87  const TAlignColl& GetAlignCollection(TNumrow row);
88 
89  bool IsSetAnchor() const;
90  TNumrow GetAnchor() const;
91 
92  const objects::CSeq_id& GetSeqId(TNumrow row) const;
93 
94  TSignedSeqPos GetSeqAlnStart(TNumrow row) const;
95  TSignedSeqPos GetSeqAlnStop(TNumrow row) const;
96  TSignedRange GetSeqAlnRange (TNumrow row) const;
97  TSeqPos GetSeqStart(TNumrow row) const;
98  TSeqPos GetSeqStop(TNumrow row) const;
99  IAlnExplorer::TRange GetSeqRange(TNumrow row) const;
100 
101  bool IsPositiveStrand(TNumrow row) const;
102  bool IsNegativeStrand(TNumrow row) const;
103 
104  TSignedSeqPos GetAlnPosFromSeqPos(TNumrow row, TSeqPos seq_pos,
106  bool try_reverse_dir = true) const;
107  TSignedSeqPos GetSeqPosFromAlnPos(TNumrow for_row, TSeqPos aln_pos,
109  bool try_reverse_dir = true) const;
110 
111  string& GetSeqString(TNumrow row, string &buffer, TSeqPos seq_from, TSeqPos seq_to) const;
112  string& GetSeqString(TNumrow row, string &buffer, const IAlnExplorer::TRange &seq_rng) const;
113  string& GetAlnSeqString(TNumrow row, string &buffer, const TSignedRange &aln_rng) const;
114 
115  const objects::CBioseq_Handle& GetBioseqHandle(TNumrow row) const;
116 
117  virtual IAlnSegmentIterator*
118  CreateSegmentIterator(TNumrow row, const IAlnExplorer::TSignedRange& range,
120 
121 protected:
122  /// describes a sequence in the alignment
123 
124  struct SRowRec{
126  objects::CBioseq_Handle* m_BioseqHandle;
127 
128  SRowRec();
129  ~SRowRec();
130  };
131 
132  typedef vector<SRowRec*> TRows;
133 
134 protected:
135  void x_AssertRowValid(TNumrow row) const;
136 
137 protected:
140 
141  mutable TRows m_Rows;
142  TARange m_AlnRange; /// the extent of all segments in alignment coords
144 };
145 
146 
148 
149 #endif // GUI_OBJUTILS___SPARSE_ALIGNMENT__HPP
CAlignRange Represents an element of pairwise alignment of two sequences.
Definition: align_range.hpp:63
CObject –.
Definition: ncbiobj.hpp:180
CSparseAlignment - an alignment based on CSparse_seg and CAlingRangeCollection classes rather than on...
CConstRef< objects::CSeq_id > m_MasterId
IAlnExplorer::TSignedRange TSignedRange
vector< SRowRec * > TRows
CRef< objects::CScope > m_Scope
SAlignTools::TAlignColl TAlignColl
IAlnExplorer::TNumrow TNumrow
SAlignTools::TPos TPos
TResidue m_GapChar
the extent of all segments in alignment coords
SAlignTools::TAlignRange TAlignRange
CRange< TPos > TARange
IAlnExplorer::TResidue TResidue
objects::CSeqVector::TResidue TResidue
ESearchDirection
Position search options.
@ eNone
No search.
Alignment segment iterator interface.
EFlags
Iterator options.
Include a standard set of the NCBI C++ Toolkit most basic headers.
static uch flags
static void Init(void)
Definition: cursor6.c:76
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
int TSignedSeqPos
Type for signed sequence position.
Definition: ncbimisc.hpp:887
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIOBJUTILS_EXPORT
Definition: gui_export.h:512
Defines to provide correct exporting from DLLs in Windows.
range(_Ty, _Ty) -> range< _Ty >
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static pcre_uint8 * buffer
Definition: pcretest.c:1051
static bool GetSeqId(const T &d, set< string > &labels, const string name="", bool detect=false, bool found=false)
#define row(bind, expected)
Definition: string_bind.c:73
describes a sequence in the alignment
objects::CBioseq_Handle * m_BioseqHandle
TSignedSeqPos TPos
This is a building block for a Builder represents a Sequence aligned to an Anchor (pairwise alignment...
CScope & GetScope()
Modified on Sun Apr 14 05:24:48 2024 by modify_doxy.py rev. 669887