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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_HIT_MATRIX___DENSE_DS__HPP
2 #define GUI_WIDGETS_HIT_MATRIX___DENSE_DS__HPP
3 
4 /* $Id: dense_ds.hpp 46040 2021-01-21 17:33:24Z grichenk $
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 
41 
42 #include <gui/gui_export.h>
43 
51 
52 #include <objmgr/scope.hpp>
53 #include <objmgr/bioseq_handle.hpp>
54 
55 #include <serial/iterator.hpp>
56 
58 
59 
61 
62 
63 ///////////////////////////////////////////////////////////////////////////////
64 /// CHitSeqId
66 {
67 public:
68  CHitSeqId(const objects::CSeq_id& id) : m_SeqId(&id) {}
69  CHitSeqId(const CHitSeqId& id) : m_SeqId(id.m_SeqId) {}
70 
71  virtual bool Equals(const IHitSeqId& id) const;
72  virtual IHitSeqId* Clone() const;
73 
75  { return m_SeqId; }
76 protected:
78 };
79 
80 
81 ///////////////////////////////////////////////////////////////////////////////
82 /// CHitSeqRowId
84 {
85 public:
86  CHitSeqRowId(int row, const objects::CSeq_id& id);
87  CHitSeqRowId(const CHitSeqRowId& id);
88 
89  virtual bool Equals(const IHitSeqId& id) const;
90  virtual IHitSeqId* Clone() const;
91 
92  virtual CConstRef<objects::CSeq_id> GetSeqId() const;
93 
94  int GetRow() const { return m_Row; }
95 protected:
96  int m_Row;
98 };
99 
100 
101 ///////////////////////////////////////////////////////////////////////////////
102 /// CHitMatrixDataSource
104  : public CObject,
105  public IHitMatrixDataSource
106 {
107 public:
109  virtual ~CHitMatrixDataSource();
110 
111  /// @name IHitMatrixDataSource implementation
112  /// @{
113  void Init(objects::CScope& scope, TAlignVector& aligns);
114 
115  virtual bool CanCreateRowBased() const;
116  virtual void SetParams(const SParams& params, bool create_hits);
117  virtual void GetParams(SParams& params) const;
118 
119  virtual bool SelectIds(const IHitSeqId& q_id,
120  const IHitSeqId& s_id);
121 
122  virtual bool SelectDefaultIds();
123  virtual const TIdVector& GetHitSeqIds();
124  virtual void GetHitSeqIdsForParams(TIdVector& ids,
125  const SParams& params) const;
126 
127  virtual void GetAlignedIds(const IHitSeqId& id, TIdVector& aligned);
128 
129  virtual void GetAlignedIdsForParams(const IHitSeqId& id,
130  const TIdVector& ids,
131  TIdVector& aligned,
132  const SParams& params);
133 
134  virtual objects::CScope& GetScope();
135  virtual IHitSeqId& GetQueryId() const;
136  virtual IHitSeqId& GetSubjectId() const;
137  virtual objects::CBioseq_Handle GetQueryHandle();
138  virtual objects::CBioseq_Handle GetSubjectHandle();
139  virtual objects::CBioseq_Handle GetBioseqHandle(const IHitSeqId& id);
140 
141  virtual string GetLabel(const IHitSeqId& id);
142 
143  virtual void GetScoreNames(vector<string>& names) const;
144  TValueRange GetScoreRange(const string& name) const;
145 
146  const THitAdapterCont& GetHits() const;
147 
148  TSeqRange GetQueryHitsRange();
149  TSeqRange GetSubjectHitsRange();
150  /// @}
151 
152 protected:
153  typedef vector<CConstRef<objects::CSeq_id> > TSeqIdRefVector;
154  typedef objects::CSeq_align::TSegs::TStd TStd;
155 
156  typedef vector<const CSeq_align*> TAlnPtrVector;
159 
160  void x_TestAndSelectAligns(TAlignVector& aligns);
161  void x_TestAndSelectAlign(const objects::CSeq_align& align);
162 
163  bool x_GoodSeg(const TStd& std_list);
164 
165  TSeqRange GetStdSegRange(const TStd& std_list, size_t row);
166 
167  void x_Clear();
168  void x_ClearHits();
169 
170  bool x_CanCreateRowBased();
171 
172  void x_UpdateScoreMap();
173  void x_GetSeqAlignIds(const objects::CSeq_align& align,
174  TSeqIdRefVector& ids, bool unique) const;
175  void x_GetAlignedSeqIds(const CSeq_align& align,
176  const IHitSeqId& id,
177  TSeqIdRefVector& ids) const;
178 
179  void x_CreateIds(TIdVector& seq_ids, const SParams& params) const;
180 
181  void x_CreateHits(const objects::CSeq_align& align);
182  void x_CreateHit(const objects::CSeq_align& align,
183  size_t q_index, size_t s_index);
184  void x_CreateHit_Denseg(const objects::CSeq_align& align,
185  size_t q_index, size_t s_index);
186  void x_CreateHit_Std(const objects::CSeq_align& align,
187  size_t q_index, size_t s_index);
188  void x_CreateHits_Diagonal(const objects::CSeq_align& align,
189  size_t q_index, size_t s_index);
190 
191  void x_CalculateHitsRange();
192 
193 protected:
194  typedef map<string, TValueRange> TScoreMap;// symbol name -> [min, max]
196  typedef const CSeq_id* TSeqIdPtr;
197  typedef vector<TSeqIdPtr> TSeqIdVector;
200 
203 
204  unique_ptr<TAlnIdMap> m_AlnIdMap;
206  //TIdToAlnsMap m_IdToAlnsMap;
207 
210 
211  TIdVector m_SeqIds; /// list of Ids for all sequences
214 
215  unique_ptr<IHitSeqId> m_SubjectID;
216  unique_ptr<IHitSeqId> m_QueryID;
217 
218  objects::CBioseq_Handle m_SubjectHandle;
219  objects::CBioseq_Handle m_QueryHandle;
220 
222 
225 };
226 
227 
229 
230 #endif // GUI_WIDGETS_HIT_MATRIX___DENSE_DS__HPP
User-defined methods of the data storage class.
Container mapping seq-aligns to vectors of participating seq-ids.
Definition: aln_tests.hpp:56
IAlnSeqId extracting functor.
Helper class which collects seq-align statistics: seq-ids participating in alignments and rows,...
Definition: aln_stats.hpp:57
CHitMatrixDataSource.
Definition: dense_ds.hpp:106
objects::CBioseq_Handle m_QueryHandle
Definition: dense_ds.hpp:219
vector< const CSeq_align * > TAlnPtrVector
Definition: dense_ds.hpp:156
TAlignVector m_Aligns
Definition: dense_ds.hpp:201
vector< CConstRef< objects::CSeq_id > > TSeqIdRefVector
Definition: dense_ds.hpp:153
TSeqRange m_SubjectHitsRange
Definition: dense_ds.hpp:223
objects::CBioseq_Handle m_SubjectHandle
Definition: dense_ds.hpp:218
map< string, TValueRange > TScoreMap
Definition: dense_ds.hpp:194
THitAdapterCont m_Hits
Definition: dense_ds.hpp:221
THIdToHandleMap m_HIdToHandleMap
list of Ids for all sequences
Definition: dense_ds.hpp:212
unique_ptr< IHitSeqId > m_QueryID
Definition: dense_ds.hpp:216
set< objects::CBioseq_Handle > THIdToHandleMap
Definition: dense_ds.hpp:199
TScoreMap m_ScoreMap
Definition: dense_ds.hpp:213
CAlnIdMap< TAlnPtrVector, TIdExtract > TAlnIdMap
Definition: dense_ds.hpp:158
vector< TSeqIdPtr > TSeqIdVector
Definition: dense_ds.hpp:197
objects::CSeq_align::TSegs::TStd TStd
Definition: dense_ds.hpp:154
CSeq_align::TDim TDim
Definition: dense_ds.hpp:195
const CSeq_id * TSeqIdPtr
Definition: dense_ds.hpp:196
unique_ptr< IHitSeqId > m_SubjectID
Definition: dense_ds.hpp:215
CAlnStats< TAlnIdMap > TAlnStats
Definition: dense_ds.hpp:198
unique_ptr< TAlnIdMap > m_AlnIdMap
Definition: dense_ds.hpp:204
CAlnSeqIdsExtract< CAlnSeqId > TIdExtract
Definition: dense_ds.hpp:157
CRef< objects::CScope > m_Scope
Definition: dense_ds.hpp:202
TSeqRange m_QueryHitsRange
Definition: dense_ds.hpp:224
CRef< TAlnStats > m_AlnStats
Definition: dense_ds.hpp:205
CHitSeqId.
Definition: dense_ds.hpp:66
CConstRef< objects::CSeq_id > m_SeqId
Definition: dense_ds.hpp:77
CHitSeqId(const objects::CSeq_id &id)
Definition: dense_ds.hpp:68
CHitSeqId(const CHitSeqId &id)
Definition: dense_ds.hpp:69
virtual CConstRef< objects::CSeq_id > GetSeqId() const
returns CSeq_id associated with IHitSeqId
Definition: dense_ds.hpp:74
CHitSeqRowId.
Definition: dense_ds.hpp:84
CConstRef< objects::CSeq_id > m_SeqId
Definition: dense_ds.hpp:97
int GetRow() const
Definition: dense_ds.hpp:94
CObject –.
Definition: ncbiobj.hpp:180
IHitMatrixDataSource - abstract Data Source for Hit Matrix Widget.
vector< CConstRef< objects::CSeq_align > > TAlignVector
vector< IHitSeqId * > TIdVector
vector< IHit * > THitAdapterCont
pair< double, double > TValueRange
IHitSeqId - abstract identifier of a sequence in an alignment.
virtual CConstRef< objects::CSeq_id > GetSeqId() const =0
returns CSeq_id associated with IHitSeqId
virtual IHitSeqId * Clone() const =0
virtual bool Equals(const IHitSeqId &id) const =0
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const struct name_t names[]
static void Init(void)
Definition: cursor6.c:76
string GetLabel(const CSeq_id &id)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
virtual void SetParams()
Called at the beginning of Run, before creating thread pool.
#define NCBI_GUIWIDGETS_HIT_MATRIX_EXPORT
Definition: gui_export.h:530
Defines to provide correct exporting from DLLs in Windows.
static CRef< CUser_object > GetParams()
#define row(bind, expected)
Definition: string_bind.c:73
CScope & GetScope()
Modified on Wed Apr 17 13:11:01 2024 by modify_doxy.py rev. 669887