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

Go to the SVN repository for this file.

1 /* $Id: wgsloader.cpp 100507 2023-08-08 16:05:36Z vasilche $
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  * Author: Eugene Vasilchenko
27  *
28  * File Description: WGS file data loader
29  *
30  * ===========================================================================
31  */
32 
33 #include <ncbi_pch.hpp>
34 #include <corelib/ncbistd.hpp>
35 
38 #include <objects/seq/seq__.hpp>
40 
47 
50 
53 
54 class CDataLoader;
55 
56 
58 
60 public:
61  bool IsDataLoaderMatches(CDataLoader& loader) const {
62  return dynamic_cast<CWGSDataLoader*>(&loader) != 0;
63  }
64 };
65 
66 
67 class CRevoker {
68 public:
70  CLoaderFilter filter;
72  }
73 };
77 
79 
80 
81 /////////////////////////////////////////////////////////////////////////////
82 // CWGSDataLoader
83 /////////////////////////////////////////////////////////////////////////////
84 
87  const SLoaderParams& params,
88  CObjectManager::EIsDefault is_default,
90 {
91  TMaker maker(params);
92  CDataLoader::RegisterInObjectManager(om, maker, is_default, priority);
93  return maker.GetRegisterInfo();
94 }
95 
96 
99  CObjectManager::EIsDefault is_default,
100  CObjectManager::TPriority priority)
101 {
102  SLoaderParams params;
103  TMaker maker(params);
104  CDataLoader::RegisterInObjectManager(om, maker, is_default, priority);
105  return maker.GetRegisterInfo();
106 }
107 
108 
111  const string& dir_path,
112  const vector<string>& wgs_files,
113  CObjectManager::EIsDefault is_default,
114  CObjectManager::TPriority priority)
115 {
116  SLoaderParams params;
117  params.m_WGSVolPath = dir_path;
118  params.m_WGSFiles = wgs_files;
119  TMaker maker(params);
120  CDataLoader::RegisterInObjectManager(om, maker, is_default, priority);
121  return maker.GetRegisterInfo();
122 }
123 
124 
126 {
127  return "WGSDataLoader";
128 }
129 
130 
132 {
133  string ret = GetLoaderNameFromArgs();
134  if ( params.m_WGSFiles.empty() ) {
135  if ( !params.m_WGSVolPath.empty() ) {
136  ret += "("+params.m_WGSVolPath+")";
137  }
138  }
139  else {
141  str << ret << ":" << params.m_WGSVolPath << "/";
142  ITERATE ( vector<string>, it, params.m_WGSFiles ) {
143  str << "+" << *it;
144  }
146  }
147  return ret;
148 }
149 
150 
152  const string& dir_path,
153  const vector<string>& wgs_files)
154 {
155  SLoaderParams params;
156  params.m_WGSVolPath = dir_path;
157  params.m_WGSFiles = wgs_files;
158  return GetLoaderNameFromArgs(params);
159 }
160 
161 
162 CWGSDataLoader::CWGSDataLoader(const string& loader_name,
163  const SLoaderParams& params)
164  : CDataLoader(loader_name)
165 {
166  m_Impl.Reset(new CWGSDataLoader_Impl(params));
167 }
168 
169 
171 {
172 }
173 
174 
176 {
177  return TBlobId(m_Impl->GetBlobId(idh).GetPointerOrNull());
178 }
179 
180 
183 {
184  return TBlobId(new CWGSBlobId(str));
185 }
186 
187 
189 {
190  return true;
191 }
192 
193 
196  EChoice choice)
197 {
198  return m_Impl->GetRecords(GetDataSource(), idh, choice);
199 }
200 
201 
204 {
205  // WGS loader doesn't provide external annotations
206  return TTSE_LockSet();
207 }
208 
209 
212  const SAnnotSelector* /*sel*/)
213 {
214  // WGS loader doesn't provide external annotations
215  return TTSE_LockSet();
216 }
217 
218 
221  const SAnnotSelector* /*sel*/)
222 {
223  // WGS loader doesn't provide external annotations
224  return TTSE_LockSet();
225 }
226 
227 
230  const SAnnotSelector* /*sel*/)
231 {
232  // WGS loader doesn't provide orphan annotations
233  return TTSE_LockSet();
234 }
235 
236 
238 {
239  TBlobId blob_id = chunk->GetBlobId();
240  const CWGSBlobId& wgs_id = dynamic_cast<const CWGSBlobId&>(*blob_id);
241  m_Impl->GetChunk(wgs_id, *chunk);
242 }
243 
244 
246 {
247  ITERATE ( TChunkSet, it, chunks ) {
248  GetChunk(*it);
249  }
250 }
251 
252 
255 {
256  return m_Impl->GetBlobById(GetDataSource(),
257  dynamic_cast<const CWGSBlobId&>(*blob_id));
258 }
259 
260 
262 {
263  m_Impl->GetIds(idh, ids);
264 }
265 
266 
269 {
270  return m_Impl->GetAccVer(idh);
271 }
272 
273 
276 {
277  return m_Impl->GetGi(idh);
278 }
279 
280 
282 {
283  return m_Impl->GetTaxId(idh);
284 }
285 
286 
288 {
289  return m_Impl->GetSequenceLength(idh);
290 }
291 
292 
295 {
296  return m_Impl->GetSequenceHash(idh);
297 }
298 
299 
302 {
303  return m_Impl->GetSequenceType(idh);
304 }
305 
306 
308 {
309  return m_Impl->GetAddWGSMasterDescr();
310 }
311 
312 
314 {
316 }
317 
318 
320 {
322 }
323 
324 
326 
327 // ===========================================================================
328 
330 
332 {
333  RegisterEntryPoint<CDataLoader>(NCBI_EntryPoint_DataLoader_WGS);
334 }
335 
336 
337 const char kDataLoader_WGS_DriverName[] = "wgs";
338 
340 {
341 public:
344  virtual ~CWGS_DataLoaderCF(void) {}
345 
346 protected:
349  const TPluginManagerParamTree* params) const;
350 };
351 
352 
355  const TPluginManagerParamTree* params) const
356 {
357  if ( !ValidParams(params) ) {
358  // Use constructor without arguments
360  }
361  // IsDefault and Priority arguments may be specified
363  om,
364  GetIsDefault(params),
365  GetPriority(params)).GetLoader();
366 }
367 
368 
372 {
374 }
375 
376 
380 {
381  NCBI_EntryPoint_DataLoader_WGS(info_list, method);
382 }
383 
384 
CObjectManager::TPriority GetPriority(const TPluginManagerParamTree *params) const
CObjectManager::EIsDefault GetIsDefault(const TPluginManagerParamTree *params) const
bool ValidParams(const TPluginManagerParamTree *params) const
bool IsDataLoaderMatches(CDataLoader &loader) const
Definition: wgsloader.cpp:61
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
CObjectManager –.
CSafeStaticLifeSpan::
@ eLifeLevel_AppMain
Destroyed in CNcbiApplication::AppMain, if possible.
CSafeStatic<>::
TBlobId GetBlobId(void) const
definition of a Culling tree
Definition: ncbi_tree.hpp:100
CDataLoader::SHashFound GetSequenceHash(const CSeq_id_Handle &idh)
CDataLoader::TTSE_LockSet GetRecords(CDataSource *data_source, const CSeq_id_Handle &idh, CDataLoader::EChoice choice)
TTaxId GetTaxId(const CSeq_id_Handle &idh)
CDataLoader::STypeFound GetSequenceType(const CSeq_id_Handle &idh)
CDataLoader::SGiFound GetGi(const CSeq_id_Handle &idh)
CTSE_LoadLock GetBlobById(CDataSource *data_source, const CWGSBlobId &blob_id)
CRef< CWGSBlobId > GetBlobId(const CSeq_id_Handle &idh)
void GetChunk(const CWGSBlobId &blob_id, CTSE_Chunk_Info &chunk)
CDataLoader::SAccVerFound GetAccVer(const CSeq_id_Handle &idh)
void GetIds(const CSeq_id_Handle &idh, TIds &ids)
bool GetAddWGSMasterDescr(void) const
TSeqPos GetSequenceLength(const CSeq_id_Handle &idh)
void SetAddWGSMasterDescr(bool flag)
virtual TSeqPos GetSequenceLength(const CSeq_id_Handle &idh)
Request for a length of a sequence.
Definition: wgsloader.cpp:287
virtual TBlobId GetBlobIdFromString(const string &str) const
Definition: wgsloader.cpp:182
virtual SHashFound GetSequenceHashFound(const CSeq_id_Handle &idh)
Definition: wgsloader.cpp:294
static string GetLoaderNameFromArgs(void)
Definition: wgsloader.cpp:125
CRef< CWGSDataLoader_Impl > m_Impl
Definition: wgsloader.hpp:125
virtual SAccVerFound GetAccVerFound(const CSeq_id_Handle &idh)
Definition: wgsloader.cpp:268
virtual STypeFound GetSequenceTypeFound(const CSeq_id_Handle &idh)
Definition: wgsloader.cpp:301
virtual void GetChunk(TChunk chunk)
Definition: wgsloader.cpp:237
CWGSDataLoader(void)
bool GetAddWGSMasterDescr(void) const
Definition: wgsloader.cpp:307
virtual TTaxId GetTaxId(const CSeq_id_Handle &idh)
Request for a taxonomy id of a sequence.
Definition: wgsloader.cpp:281
virtual TTSE_Lock GetBlobById(const TBlobId &blob_id)
Definition: wgsloader.cpp:254
virtual TTSE_LockSet GetRecords(const CSeq_id_Handle &idh, EChoice choice)
Request from a datasource using handles and ranges instead of seq-loc The TSEs loaded in this call wi...
Definition: wgsloader.cpp:195
virtual TBlobId GetBlobId(const CSeq_id_Handle &idh)
Definition: wgsloader.cpp:175
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, const SLoaderParams &params, CObjectManager::EIsDefault is_default=CObjectManager::eNonDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
Definition: wgsloader.cpp:85
virtual CObjectManager::TPriority GetDefaultPriority(void) const
Definition: wgsloader.cpp:319
virtual void GetChunks(const TChunkSet &chunks)
Definition: wgsloader.cpp:245
~CWGSDataLoader(void)
Definition: wgsloader.cpp:170
virtual TTSE_LockSet GetOrphanAnnotRecords(const CSeq_id_Handle &idh, const SAnnotSelector *sel)
old Get*AnnotRecords() methods
Definition: wgsloader.cpp:229
void SetAddWGSMasterDescr(bool flag)
Definition: wgsloader.cpp:313
virtual bool CanGetBlobById(void) const
Definition: wgsloader.cpp:188
virtual SGiFound GetGiFound(const CSeq_id_Handle &idh)
Definition: wgsloader.cpp:275
virtual TTSE_LockSet GetExternalAnnotRecords(const CSeq_id_Handle &idh, const SAnnotSelector *sel)
Definition: wgsloader.cpp:211
virtual TTSE_LockSet GetExternalRecords(const CBioseq_Info &bioseq)
Request from a datasource set of blobs with external annotations.
Definition: wgsloader.cpp:203
virtual void GetIds(const CSeq_id_Handle &idh, TIds &ids)
Definition: wgsloader.cpp:261
virtual CDataLoader * CreateAndRegister(CObjectManager &om, const TPluginManagerParamTree *params) const
Definition: wgsloader.cpp:353
virtual ~CWGS_DataLoaderCF(void)
Definition: wgsloader.cpp:344
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const char * str(char *buf, int n)
Definition: stats.c:84
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
SStrictId_Tax::TId TTaxId
Taxon id type.
Definition: ncbimisc.hpp:1048
TLoader * GetLoader(void) const
Get pointer to the loader.
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
vector< CSeq_id_Handle > TIds
void RevokeDataLoaders(IDataLoaderFilter &filter)
Revoke data loaders by filter, even if they were still used.
CBlobIdKey TBlobId
CDataSource * GetDataSource(void) const
Definition: data_loader.cpp:92
EChoice
main blob is blob with sequence all other blobs are external and contain external annotations
EIsDefault
Flag defining if the data loader is included in the "default" group.
TRegisterInfo GetRegisterInfo(void)
static void RegisterInObjectManager(CObjectManager &om, CLoaderMaker_Base &loader_maker, CObjectManager::EIsDefault is_default, CObjectManager::TPriority priority)
Register the loader only if the name is not yet registered in the object manager.
Definition: data_loader.cpp:53
vector< TChunk > TChunkSet
set< TTSE_Lock > TTSE_LockSet
@ kPriority_Replace
Default priority for replacement loaders.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
static void NCBI_EntryPointImpl(TDriverInfoList &info_list, EEntryPointRequest method)
Entry point implementation.
list< SDriverInfo > TDriverInfoList
List of driver information.
EEntryPointRequest
Actions performed by the entry point.
#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
Helper classes and templates to implement plugins.
CRef< objects::CObjectManager > om
Better replacement of GetAccVer(), this method should be defined in data loaders, GetAccVer() is left...
Better replacement of GetGi(), this method should be defined in data loaders, GetGi() is left for com...
Better replacement of GetSequenceHash(), this method should be defined in data loaders,...
Better replacement of GetSequenceType(), this method should be defined in data loaders,...
vector< string > m_WGSFiles
Definition: wgsloader.hpp:59
SAnnotSelector –.
SRegisterLoaderInfo –.
void NCBI_EntryPoint_DataLoader_WGS(CPluginManager< CDataLoader >::TDriverInfoList &info_list, CPluginManager< CDataLoader >::EEntryPointRequest method)
Definition: wgsloader.cpp:369
USING_SCOPE(objects)
void NCBI_EntryPoint_xloader_wgs(CPluginManager< objects::CDataLoader >::TDriverInfoList &info_list, CPluginManager< objects::CDataLoader >::EEntryPointRequest method)
Definition: wgsloader.cpp:377
const char kDataLoader_WGS_DriverName[]
Definition: wgsloader.cpp:337
BEGIN_LOCAL_NAMESPACE
Definition: wgsloader.cpp:54
END_LOCAL_NAMESPACE
Definition: wgsloader.cpp:78
void DataLoaders_Register_WGS(void)
Definition: wgsloader.cpp:331
static CSafeStatic< CRevoker > s_Revoker(CSafeStaticLifeSpan(CSafeStaticLifeSpan::eLifeLevel_AppMain, CSafeStaticLifeSpan::eLifeSpan_Long))
Modified on Thu Jul 11 17:54:04 2024 by modify_doxy.py rev. 669887