NCBI C++ ToolKit
sparse_row_handle.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: sparse_row_handle.cpp 45564 2020-09-08 19:05:27Z shkeda $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrey Yazhuk
27  */
28 
29 #include <ncbi_pch.hpp>
30 
31 #include <corelib/ncbistd.hpp>
32 
34 
37 #include <gui/objutils/utils.hpp>
38 #include <gui/objutils/label.hpp>
39 
42 
43 ///////////////////////////////////////////////////////////////////////////////
44 /// CSparseRowHandle
45 
47 : m_Alignment(aln),
48  m_Row(row)
49 {
50 }
51 
52 
54 {
55 }
56 
57 
59 {
60  return m_Row;
61 }
62 
63 const string& CSparseRowHandle::GetText() const
64 {
65  if (m_Text.empty()) {
66  m_Text = GetSeq_id().GetSeqIdString();
68  m_Text.clear();
70  }
71  }
72  return m_Text;
73 }
74 
76 {
78 }
79 
80 
82 {
84 }
85 
86 
88 {
90 }
91 
92 
94 {
96 }
97 
98 
100 {
102 }
103 
104 
106 {
108 }
109 
110 
113  bool try_reverse_dir) const
114 {
115  return m_Alignment.GetAlnPosFromSeqPos(m_Row, seq_pos, dir, try_reverse_dir);
116 }
117 
118 
121  bool try_reverse_dir) const
122 {
123  return m_Alignment.GetSeqPosFromAlnPos(m_Row, aln_pos, dir, try_reverse_dir);
124 }
125 
126 
130 {
132 }
133 
134 
136 {
137  return true;
138 }
139 
140 
142  const IAlnExplorer::TRange &seq_rng) const
143 {
144  return m_Alignment.GetSeqString(m_Row, buffer, seq_rng);
145 }
146 
147 
149  const IAlnExplorer::TSignedRange &aln_rng) const
150 {
151  return m_Alignment.GetAlnSeqString(m_Row, buffer, aln_rng);
152 }
153 
154 
156 {
157  return true;
158 }
159 
160 
161 const objects::CBioseq_Handle& CSparseRowHandle::GetBioseqHandle() const
162 {
164 }
165 
166 const objects::CSeq_id& CSparseRowHandle::GetSeq_id() const
167 {
168  return m_Alignment.GetSeqId(m_Row);
169 }
170 
171 
172 objects::CScope& CSparseRowHandle::GetScope() const
173 {
174  return *m_Alignment.GetScope();
175 }
176 
178 {
179  return m_Alignment.GetBioseqHandle(m_Row).IsAa();
180 }
181 
183 {
184  TNumrow num_rows = m_Alignment.GetNumRows();
185  if (num_rows <= 1)
186  return false;
187  int base_width = m_Alignment.GetBaseWidth(0);
188  for (TNumrow row = 1; row < num_rows; ++row) {
189  if (base_width != m_Alignment.GetBaseWidth(row))
190  return true;
191  }
192  return false;
193 }
194 
196 {
198 }
199 
201 {
202  if (m_GenCode == -1)
204  return m_GenCode;
205 }
206 
Sparse alignment.
Definition: sparse_aln.hpp:51
TSignedSeqPos GetSeqAlnStart(TNumrow row) const
Definition: sparse_aln.cpp:271
TNumrow GetNumRows(void) const
Synonym of the above.
Definition: sparse_aln.hpp:80
int GetBaseWidth(TNumrow row) const
Get base width for the sequence (1 for nucleotides, 3 for proteins).
Definition: sparse_aln.hpp:225
TSignedSeqPos GetSeqAlnStop(TNumrow row) const
Definition: sparse_aln.cpp:278
TSeqPos GetSeqStop(TNumrow row) const
Definition: sparse_aln.cpp:299
virtual IAlnSegmentIterator * CreateSegmentIterator(TNumrow row, const TSignedRange &range, IAlnSegmentIterator::EFlags flags) const
Create segment iterator.
Definition: sparse_aln.cpp:710
string & GetAlnSeqString(TNumrow row, string &buffer, const TSignedRange &rq_aln_rng, bool force_translation=false) const
Fetch alignment sequence data.
Definition: sparse_aln.cpp:552
TSignedSeqPos GetAlnPosFromSeqPos(TNumrow row, TSeqPos seq_pos, ESearchDirection dir=eNone, bool try_reverse_dir=true) const
Map sequence position to alignment coordinates.
Definition: sparse_aln.cpp:373
TSignedSeqPos GetSeqPosFromAlnPos(TNumrow for_row, TSeqPos aln_pos, ESearchDirection dir=eNone, bool try_reverse_dir=true) const
Definition: sparse_aln.cpp:385
const objects::CBioseq_Handle & GetBioseqHandle(TNumrow row) const
Get bioseq handle for the row.
Definition: sparse_aln.cpp:396
TSeqPos GetSeqStart(TNumrow row) const
Definition: sparse_aln.cpp:292
TSignedRange GetSeqAlnRange(TNumrow row) const
Get sequence range in alignment coords (strand ignored).
Definition: sparse_aln.cpp:285
CRef< objects::CScope > GetScope(void) const
Scope accessor.
Definition: sparse_aln.cpp:250
string & GetSeqString(TNumrow row, string &buffer, TSeqPos seq_from, TSeqPos seq_to, bool force_translation=false) const
Fetch sequence data for the given row and range.
Definition: sparse_aln.cpp:496
bool IsNegativeStrand(TNumrow row) const
Definition: sparse_aln.cpp:321
const objects::CSeq_id & GetSeqId(TNumrow row) const
Get seq-id for the row.
Definition: sparse_aln.cpp:264
virtual size_t GetBaseWidth() const
virtual bool CanGetBioseqHandle() const
virtual TSignedSeqPos GetSeqStart() const
virtual TSignedSeqPos GetSeqAlnStart() const
virtual IAlnExplorer::TSignedRange GetSeqAlnRange() const
virtual TSignedSeqPos GetAlnPosFromSeqPos(TSeqPos seq_pos, IAlnExplorer::ESearchDirection dir=IAlnExplorer::eNone, bool try_reverse_dir=true) const
virtual TSignedSeqPos GetSeqAlnStop() const
virtual TSignedSeqPos GetSeqPosFromAlnPos(TSeqPos aln_pos, IAlnExplorer::ESearchDirection dir=IAlnExplorer::eNone, bool try_reverse_dir=true) const
const string & GetText() const
virtual TSignedSeqPos GetSeqStop() const
virtual string & GetSeqString(string &buffer, const IAlnExplorer::TRange &seq_rng) const
virtual IAlnSegmentIterator * CreateSegmentIterator(const IAlnExplorer::TSignedRange &range, IAlnSegmentIterator::EFlags flag) const
virtual string & GetAlnSeqString(string &buffer, const IAlnExplorer::TSignedRange &aln_rng) const
virtual bool IsNegativeStrand() const
bool UsesAATranslation() const
virtual objects::CScope & GetScope() const
CSparseRowHandle(CSparseAln &aln, TNumrow row)
CSparseRowHandle.
CSparseAln & m_Alignment
virtual const objects::CBioseq_Handle & GetBioseqHandle() const
virtual bool IsNucProtAlignment() const
virtual int GetGenCode() const
virtual TNumrow GetRowNum() const
virtual bool CanGetSeqString() const
virtual const objects::CSeq_id & GetSeq_id() const
IAlnExplorer::TNumrow TNumrow
Definition: alnmulti_ds.hpp:61
ESearchDirection
Position search options.
Alignment segment iterator interface.
EFlags
Iterator options.
Include a standard set of the NCBI C++ Toolkit most basic headers.
static uch flags
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
int TSignedSeqPos
Type for signed sequence position.
Definition: ncbimisc.hpp:887
static bool IsVDBAccession(const string &acc)
Check if string starts with ("SRA", "SRR", "DRR", "ERR")
Definition: utils.cpp:887
static int GetGenCode(const objects::CBioseq_Handle &handle)
Returns Bioseq's Genetic Code.
Definition: utils.cpp:2358
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
@ eDefault
Definition: label.hpp:73
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
range(_Ty, _Ty) -> range< _Ty >
static pcre_uint8 * buffer
Definition: pcretest.c:1051
USING_SCOPE(objects)
Modified on Fri Dec 01 04:51:41 2023 by modify_doxy.py rev. 669887