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

Go to the SVN repository for this file.

1 #ifndef SRA__READER__SRA__WGSREAD__HPP
2 #define SRA__READER__SRA__WGSREAD__HPP
3 /* $Id: graphread.hpp 81995 2018-04-23 20:00:53Z vasilche $
4  * ===========================================================================
5  *
6  * PUBLIC DOMAIN NOTICE
7  * National Center for Biotechnology Information
8  *
9  * This software/database is a "United States Government Work" under the
10  * terms of the United States Copyright Act. It was written as part of
11  * the author's official duties as a United States Government employee and
12  * thus cannot be copyrighted. This software/database is freely available
13  * to the public for use. The National Library of Medicine and the U.S.
14  * Government have not placed any restriction on its use or reproduction.
15  *
16  * Although all reasonable efforts have been taken to ensure the accuracy
17  * and reliability of the software and data, the NLM and the U.S.
18  * Government do not and cannot warrant the performance or results that
19  * may be obtained by using this software or data. The NLM and the U.S.
20  * Government disclaim all warranties, express or implied, including
21  * warranties of performance, merchantability or fitness for any particular
22  * purpose.
23  *
24  * Please cite the author in any work or product based on this material.
25  *
26  * ===========================================================================
27  *
28  * Authors: Eugene Vasilchenko
29  *
30  * File Description:
31  * Access to VDB Graph files
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <corelib/ncbimtx.hpp>
37 #include <util/range.hpp>
41 #include <map>
42 #include <list>
43 
46 
47 class CSeq_entry;
48 class CSeq_graph;
49 class CSeq_table;
50 class CUser_object;
51 class CUser_field;
53 
55  enum ELookupType {
59  };
60 };
61 
63 {
64 public:
65  CVDBGraphDb_Impl(CVDBMgr& mgr, CTempString path, ELookupType lookup_type = eLookupDefault);
66  virtual ~CVDBGraphDb_Impl(void);
67 
68  // check if there are graph track of intermediate zoom level
69  bool HasMidZoomGraphs(void);
70 
71  bool LookupIsInVDB() const
72  {
73  return m_LookupIndex;
74  }
75  bool LookupIsInMemory() const
76  {
77  return !m_LookupIndex;
78  }
79  static bool LookupIsInMemory(ELookupType lookup_type);
80 
81 protected:
82  friend class CVDBGraphSeqIterator;
83 
84  // SSeqTableCursor is helper accessor structure for SEQUENCE table
85  struct SGraphTableCursor : public CObject {
87 
89 
90  typedef int64_t TGraphV;
91  typedef int64_t TGraphQ;
92 
109  };
110 
111  const string& GetPath(void) const {
112  return m_Path;
113  }
114 
115  // SSeqInfo holds cached refseq information - ids, len, rows
116  struct SSeqInfo {
118  : m_SeqLength(0),
119  m_RowSize(0),
120  m_RowFirst(0),
121  m_RowLast(0)
122  {
123  }
124 
125  string m_SeqId;
129  TVDBRowId m_RowFirst, m_RowLast;
130  };
131  typedef list<SSeqInfo> TSeqInfoList;
134 
135  const TSeqInfoList& GetSeqInfoList(void) const {
136  return m_SeqList;
137  }
139  return m_SeqMapBySeq_id;
140  }
141 
142  // get table object
143  const CVDBTable& GraphTable(void) {
144  return m_GraphTable;
145  }
146  // get table accessor object for exclusive access
147  CRef<SGraphTableCursor> Graph(void);
148  // return table accessor object for reuse
150  m_Graph.Put(curs);
151  }
152 
153  SSeqInfo GetSeqInfoAtRow(TVDBRowId row);
154  SSeqInfo GetSeqInfo(const CSeq_id_Handle& seq_id);
155 
156 private:
158  string m_Path;
159 
162 
164 
166  TSeqInfoList m_SeqList; // list of cached refseqs' information
167  TSeqInfoMapBySeq_id m_SeqMapBySeq_id; // index for refseq info lookup
168  TSeqInfoMapByFirstRow m_SeqMapByFirstRow; // index for refseq info lookup
169 };
170 
171 
172 class CVDBGraphDb : public CRef<CVDBGraphDb_Impl>, public SVDBGraphDb_Base
173 {
174 public:
176  {
177  }
180  {
181  }
183  : CRef<CVDBGraphDb_Impl>(new CVDBGraphDb_Impl(mgr, path, lookup_type))
184  {
185  }
186 };
187 
188 
190 {
191 public:
194  typedef CVDBGraphDb_Impl::TSeqInfoList::const_iterator TSeqInfoIter;
195 
197  {
198  }
199  explicit CVDBGraphSeqIterator(const CVDBGraphDb& db);
201  const CSeq_id_Handle& seq_id);
202 
203  bool operator!(void) const {
204  return !m_Info.m_RowSize;
205  }
206  operator const void*(void) const {
207  return !*this? 0: this;
208  }
209 
210  const SSeqInfo& GetInfo(void) const;
211  const SSeqInfo& operator*(void) const {
212  return GetInfo();
213  }
214  const SSeqInfo* operator->(void) const {
215  return &GetInfo();
216  }
217 
218  CVDBGraphSeqIterator& operator++(void);
219 
220  const string& GetSeqId(void) const {
221  return GetInfo().m_SeqId;
222  }
223  const CSeq_id_Handle& GetSeq_id_Handle(void) const {
224  return GetInfo().m_Seq_id_Handle;
225  }
226 
227  TSeqPos GetSeqLength(void) const {
228  return GetInfo().m_SeqLength;
229  }
230 
231  // Do not mix graphs of different zoom levels
233  // original detailed graph
234  fGraphMain = 1<<0,
235 
236  // overview graphs (percentiles)
237  fGraphQ0 = 1<<1,
238  fGraphQ10 = 1<<2,
239  fGraphQ50 = 1<<3,
240  fGraphQ90 = 1<<4,
241  fGraphQ100 = 1<<5,
242  fGraphQAll = (fGraphQ0 | fGraphQ10 | fGraphQ50 |
243  fGraphQ90 | fGraphQ100),
244 
245  // main graph representation - either Seq-table or Seq-graph,
246  // set both *As* flags to get more compact representation
247  fGraphMainAsTable = 1<<8,
248  fGraphMainAsGraph = 1<<9,
249  fGraphMainAsBest = (fGraphMainAsTable | fGraphMainAsGraph),
250 
251  // zoom graphs if available (percentiles)
252  fGraphZoomQ0 = 1<<11,
253  fGraphZoomQ10 = 1<<12,
254  fGraphZoomQ50 = 1<<13,
255  fGraphZoomQ90 = 1<<14,
256  fGraphZoomQ100 = 1<<15,
257  fGraphZoomQAll = (fGraphZoomQ0 | fGraphZoomQ10 | fGraphZoomQ50 |
258  fGraphZoomQ90 | fGraphZoomQ100),
259 
260  // overview graphs by default
261  fDefaultContent = fGraphQAll
262  };
263  typedef int TContentFlags;
264 
265  // Returns annot containing graphs over the specified range
266  // (CRange<TSeqPos> or COpenRange<TSeqPos>).
268  const string& annot_name = kEmptyStr,
269  TContentFlags content = fDefaultContent) const;
270 
271  bool SeqTableIsSmaller(COpenRange<TSeqPos> range) const;
272 
273 protected:
274  CVDBGraphDb_Impl& GetDb(void) const {
275  return m_Db.GetNCObject();
276  }
277 
278  CRef<CSeq_graph> x_MakeGraph(const string& annot_name,
279  CSeq_loc& loc,
280  const SSeqInfo& info,
281  const COpenRange<TSeqPos>& range,
282  TSeqPos step,
283  SGraphTableCursor& cursor,
285  int level) const;
286  CRef<CSeq_table> x_MakeTable(const string& annot_name,
287  CSeq_loc& loc,
288  const SSeqInfo& info,
289  const COpenRange<TSeqPos>& range,
290  SGraphTableCursor& cursor) const;
291 
292  bool x_SeqTableIsSmaller(COpenRange<TSeqPos> range,
293  SGraphTableCursor& cursor) const;
294 
295 private:
298 };
299 
300 
303 
304 #endif // SRA__READER__SRA__WGSREAD__HPP
User-defined methods of the data storage class.
CMutex –.
Definition: ncbimtx.hpp:749
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
Definition: Seq_entry.hpp:56
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
CVDBTableIndex m_LookupIndex
Definition: graphread.hpp:161
TSeqInfoList m_SeqList
Definition: graphread.hpp:166
const TSeqInfoList & GetSeqInfoList(void) const
Definition: graphread.hpp:135
CVDBObjectCache< SGraphTableCursor > m_Graph
Definition: graphread.hpp:163
TSeqInfoMapBySeq_id m_SeqMapBySeq_id
Definition: graphread.hpp:167
const string & GetPath(void) const
Definition: graphread.hpp:111
void Put(CRef< SGraphTableCursor > &curs)
Definition: graphread.hpp:149
bool LookupIsInMemory() const
Definition: graphread.hpp:75
CVDBTable m_GraphTable
Definition: graphread.hpp:160
bool LookupIsInVDB() const
Definition: graphread.hpp:71
TSeqInfoMapByFirstRow m_SeqMapByFirstRow
Definition: graphread.hpp:168
CMutex m_SeqInfoMutex
Definition: graphread.hpp:165
const TSeqInfoMapBySeq_id & GetSeqInfoMapBySeq_id(void) const
Definition: graphread.hpp:138
const CVDBTable & GraphTable(void)
Definition: graphread.hpp:143
map< TVDBRowId, TSeqInfoList::iterator > TSeqInfoMapByFirstRow
Definition: graphread.hpp:133
map< CSeq_id_Handle, TSeqInfoList::iterator > TSeqInfoMapBySeq_id
Definition: graphread.hpp:132
list< SSeqInfo > TSeqInfoList
Definition: graphread.hpp:131
CVDBGraphDb(void)
Definition: graphread.hpp:175
CVDBGraphDb(CVDBMgr &mgr, CTempString path, ELookupType lookup_type=eLookupDefault)
Definition: graphread.hpp:182
CVDBGraphDb(CVDBGraphDb_Impl *impl)
Definition: graphread.hpp:178
const string & GetSeqId(void) const
Definition: graphread.hpp:220
CVDBGraphDb_Impl::SSeqInfo m_Info
Definition: graphread.hpp:297
CVDBGraphDb_Impl & GetDb(void) const
Definition: graphread.hpp:274
const SSeqInfo * operator->(void) const
Definition: graphread.hpp:214
TSeqPos GetSeqLength(void) const
Definition: graphread.hpp:227
const SSeqInfo & operator*(void) const
Definition: graphread.hpp:211
CVDBGraphDb_Impl::TSeqInfoList::const_iterator TSeqInfoIter
Definition: graphread.hpp:194
bool operator!(void) const
Definition: graphread.hpp:203
CVDBGraphDb_Impl::SGraphTableCursor SGraphTableCursor
Definition: graphread.hpp:193
CVDBGraphDb_Impl::SSeqInfo SSeqInfo
Definition: graphread.hpp:192
const CSeq_id_Handle & GetSeq_id_Handle(void) const
Definition: graphread.hpp:223
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define LEN(ptr)
static const char * column
Definition: stats.c:23
Int8 int64_t
Uint4 uint32_t
BEGIN_NAMESPACE(objects)
END_NCBI_NAMESPACE
Definition: graphread.hpp:302
END_NAMESPACE(objects)
BEGIN_NCBI_NAMESPACE
Definition: graphread.hpp:44
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define kEmptyStr
Definition: ncbistr.hpp:123
#define NCBI_SRAREAD_EXPORT
Definition: ncbi_export.h:1227
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
static MDB_envinfo info
Definition: mdb_load.c:37
range(_Ty, _Ty) -> range< _Ty >
Multi-threading – mutexes; rw-locks; semaphore.
#define row(bind, expected)
Definition: string_bind.c:73
DECLARE_VDB_COLUMN_AS(TGraphQ, GR_ZOOM_Q0)
DECLARE_VDB_COLUMN_AS(TGraphQ, GR_ZOOM_Q100)
DECLARE_VDB_COLUMN_AS(TGraphQ, GR_ZOOM_Q10)
DECLARE_VDB_COLUMN_AS(TGraphQ, GR_Q100)
DECLARE_VDB_COLUMN_AS(int64_t, NUM_SWITCHES)
DECLARE_VDB_COLUMN_AS(TGraphQ, GR_ZOOM_Q50)
DECLARE_VDB_COLUMN_AS(TGraphQ, GR_ZOOM_Q90)
CSeq_id_Handle m_Seq_id_Handle
Definition: graphread.hpp:126
int64_t TVDBRowId
Definition: vdbread.hpp:80
Modified on Sun Jun 23 05:21:53 2024 by modify_doxy.py rev. 669887