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

Go to the SVN repository for this file.

1 #ifndef SRA__READER__SRA__SRAREAD__HPP
2 #define SRA__READER__SRA__SRAREAD__HPP
3 /* $Id: sraread.hpp 75481 2016-11-18 20:51:27Z 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 SRA files
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
37 #include <sra/readers/sra/sdk.hpp>
38 
40 #include <objects/seq/Seq_inst.hpp>
41 
42 //#include <sra/sradb.h> // for spotid_t, bitsz_t
43 typedef int64_t spotid_t;
44 typedef uint64_t bitsz_t;
45 
46 // SRA SDK structures
47 struct SRAMgr;
48 struct SRAPath;
49 struct SRATable;
50 struct SRAColumn;
51 
54 
55 class CSeq_entry;
56 
57 
58 template<>
59 struct CSraRefTraits<SRAPath>
60 {
61  static rc_t x_Release(const SRAPath* t) { return 0; }
62  static rc_t x_AddRef (const SRAPath* t) { return 0; }
63 };
64 
65 DECLARE_SRA_REF_TRAITS(SRAMgr, const);
66 DECLARE_SRA_REF_TRAITS(SRAColumn, const);
67 DECLARE_SRA_REF_TRAITS(SRATable, const);
68 
69 class CSraPath;
70 class CSraMgr;
71 class CSraRun;
72 class CSraColumn;
73 
75  : public CSraRef<SRAPath>
76 {
77 public:
78  explicit CSraPath(ENull /*null*/)
79  {
80  }
81  CSraPath(void);
82  NCBI_DEPRECATED_CTOR(CSraPath(const string& rep_path,
83  const string& vol_path));
84 
86  static string GetDefaultRepPath(void);
88  static string GetDefaultVolPath(void);
89 
91  void AddRepPath(const string& rep_path);
92 
94  void AddVolPath(const string& vol_path);
95 
96  string FindAccPath(const string& acc) const;
97 };
98 
100  : public CSraRef<const SRAMgr>
101 {
102 public:
103  enum ETrim {
105  eTrim
106  };
107 
108  CSraMgr(ETrim trim = eNoTrim);
109 
111  CSraMgr(const string& rep_path, const string& vol_path,
112  ETrim trim = eNoTrim);
113 
114  spotid_t GetSpotInfo(const string& sra, CSraRun& run);
115 
116  CRef<CSeq_entry> GetSpotEntry(const string& sra);
117  CRef<CSeq_entry> GetSpotEntry(const string& sra, CSraRun& run);
118 
119  CSraPath& GetPath(void) const;
120  string FindAccPath(const string& acc) const;
121 
122  bool GetTrim(void) const
123  {
124  return m_Trim;
125  }
126 
128  static void RegisterFunctions(void);
129 
130 protected:
131  void x_Init(void);
132 
133 private:
134  mutable CSraPath m_Path;
135  bool m_Trim;
136 };
137 
139  : public CSraRef<const SRAColumn>
140 {
141 public:
143  {
144  }
145  CSraColumn(const CSraRun& run, const char* name, const char* type)
146  {
147  Init(run, name, type);
148  }
149 
150  rc_t TryInitRc(const CSraRun& run, const char* name, const char* type);
151  void Init(const CSraRun& run, const char* name, const char* type);
152 };
153 
154 
156  : public CSraRef<const SRATable>
157 {
158 public:
159  CSraRun(void)
160  {
161  }
162  CSraRun(CSraMgr& mgr, const string& acc)
163  {
164  Init(mgr, acc);
165  }
166 
167  void Init(CSraMgr& mgr, const string& acc);
168 
169  const string& GetAccession(void) const
170  {
171  return m_Acc;
172  }
173 
174  CSeq_inst::TMol GetSequenceType(spotid_t spot_id, uint8_t read_id) const;
175  TSeqPos GetSequenceLength(spotid_t spot_id, uint8_t read_id) const;
176  CRef<CSeq_entry> GetSpotEntry(spotid_t spot_id) const;
177 
178 protected:
179  void x_DoInit(CSraMgr& mgr, const string& acc);
180 
181 private:
182  string m_Acc;
183  bool m_Trim;
190 };
191 
192 
194 {
195 public:
196  enum ECheckRc {
198  eNoCheckRc
199  };
200  CSraValue(const CSraColumn& col, spotid_t id,
201  ECheckRc check_rc = eCheckRc);
202 
203  size_t GetLength(void) const
204  {
205  return m_Len;
206  }
207 
208  rc_t GetRC(void) const
209  {
210  return m_Error;
211  }
212 
214 
215 protected:
217  const void* m_Data;
220  size_t m_Len;
221 };
222 
223 
225 {
226 public:
228  ECheckRc check_rc = eCheckRc)
229  : CSraValue(col, id, check_rc)
230  {
231  }
232  const char* data(void) const
233  {
234  return static_cast<const char*>(m_Data);
235  }
236  size_t size(void) const
237  {
238  return GetLength();
239  }
240  operator string(void) const
241  {
242  return string(data(), size());
243  }
244  string Value(void) const
245  {
246  return *this;
247  }
248 };
249 
250 template<class V>
251 class CSraValueFor : public CSraValue
252 {
253 public:
254  typedef V TValue;
257  : CSraValue(col, id, check_rc)
258  {
259  }
260  const TValue& Value(void) const
261  {
262  return *static_cast<const TValue*>(m_Data);
263  }
264  const TValue* operator->(void) const
265  {
266  return &Value();
267  }
268  const TValue& operator[](size_t i) const
269  {
270  return static_cast<const TValue*>(m_Data)[i];
271  }
272 };
273 
276 
277 
280 
281 #endif // SRA__READER__SRA__SRAREAD__HPP
uint32_t rc_t
Definition: Seq_entry.hpp:56
CSraColumn(const CSraRun &run, const char *name, const char *type)
Definition: sraread.hpp:145
CSraColumn(void)
Definition: sraread.hpp:142
bool GetTrim(void) const
Definition: sraread.hpp:122
bool m_Trim
Definition: sraread.hpp:135
CSraPath m_Path
Definition: sraread.hpp:134
@ eNoTrim
Definition: sraread.hpp:104
CSraPath(ENull)
Definition: sraread.hpp:78
Definition: sdk.hpp:85
CSraColumn m_SDesc
Definition: sraread.hpp:187
CSraRun(void)
Definition: sraread.hpp:159
CSraColumn m_Qual
Definition: sraread.hpp:186
bool m_Trim
Definition: sraread.hpp:183
CSraColumn m_Read
Definition: sraread.hpp:185
string m_Acc
Definition: sraread.hpp:182
const string & GetAccession(void) const
Definition: sraread.hpp:169
CSraColumn m_Name
Definition: sraread.hpp:184
CSraColumn m_TrimStart
Definition: sraread.hpp:189
CSraRun(CSraMgr &mgr, const string &acc)
Definition: sraread.hpp:162
CSraColumn m_RDesc
Definition: sraread.hpp:188
CSraStringValue(const CSraColumn &col, spotid_t id, ECheckRc check_rc=eCheckRc)
Definition: sraread.hpp:227
size_t size(void) const
Definition: sraread.hpp:236
const char * data(void) const
Definition: sraread.hpp:232
string Value(void) const
Definition: sraread.hpp:244
const TValue & Value(void) const
Definition: sraread.hpp:260
const TValue & operator[](size_t i) const
Definition: sraread.hpp:268
const TValue * operator->(void) const
Definition: sraread.hpp:264
CSraValueFor(const CSraColumn &col, spotid_t id, CSraValue::ECheckRc check_rc=CSraValue::eCheckRc)
Definition: sraread.hpp:255
bitsz_t m_Bitoffset
Definition: sraread.hpp:218
const void * m_Data
Definition: sraread.hpp:217
bitsz_t m_Bitlen
Definition: sraread.hpp:219
DECLARE_OPERATOR_BOOL(!m_Error)
rc_t GetRC(void) const
Definition: sraread.hpp:208
size_t m_Len
Definition: sraread.hpp:220
size_t GetLength(void) const
Definition: sraread.hpp:203
rc_t m_Error
Definition: sraread.hpp:216
Include a standard set of the NCBI C++ Toolkit most basic headers.
static void Init(void)
Definition: cursor6.c:76
Uint8 uint64_t
Int8 int64_t
unsigned char uint8_t
#define NCBI_DEPRECATED_CTOR(decl)
Macro used to mark a constructor as deprecated.
Definition: ncbimisc.hpp:1209
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
ENull
CNullable –.
Definition: ncbimisc.hpp:645
string
Definition: cgiapp.hpp:690
#define NCBI_DEPRECATED
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_SRAREAD_EXPORT
Definition: ncbi_export.h:1227
EMol
molecule class in living organism
Definition: Seq_inst_.hpp:108
int i
EIPRangeType t
Definition: ncbi_localip.c:101
Uint4 GetSequenceType(const CBioseq_Handle &bsh)
Return a (corrected) set of flags identifying the sequence type.
Definition: sequtils.cpp:42
DECLARE_SRA_REF_TRAITS(SRAMgr, const)
CSraValueFor< uint16_t > CSraUInt16Value
Definition: sraread.hpp:274
int64_t spotid_t
Definition: sraread.hpp:43
uint64_t bitsz_t
Definition: sraread.hpp:44
CSraValueFor< char > CSraBytesValue
Definition: sraread.hpp:275
static rc_t x_Release(const SRAPath *t)
Definition: sraread.hpp:61
static rc_t x_AddRef(const SRAPath *t)
Definition: sraread.hpp:62
Definition: type.c:6
Modified on Fri Sep 20 14:57:43 2024 by modify_doxy.py rev. 669887