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

Go to the SVN repository for this file.

1 /* $Id: gene_info_reader.cpp 100101 2023-06-15 14:10:29Z merezhuk $
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: Vahram Avagyan
27  *
28  */
29 
30 /// @file gene_info_reader.cpp
31 /// Implementation of reading Gene information from files.
32 //==========================================================================//
33 
34 #include <ncbi_pch.hpp>
35 #include <corelib/env_reg.hpp>
36 
39 
40 #include <algorithm>
41 
43 
44 //==========================================================================//
45 // Constants
46 
47 /// Index of the RNA Gi field in the Gene ID to Gi records.
48 static const int k_iRNAGiField = 1;
49 /// Index of the Protein Gi field in the Gene ID to Gi records.
50 static const int k_iProteinGiField = 2;
51 /// Index of the Genomic Gi field in the Gene ID to Gi records.
52 static const int k_iGenomicGiField = 3;
53 
54 //==========================================================================//
55 
56 /// Returns the field of a record given its index.
57 ///
58 /// @param record
59 /// Two-integer record.
60 /// @param iField
61 /// Index of the field in record.
62 /// @return
63 /// Corresponding field of the record.
65  int iField)
66 {
67  if (iField == 0)
68  return record.n1;
69  return record.n2;
70 }
71 
72 /// Returns the field of a record given its index.
73 ///
74 /// @param record
75 /// N-integer record.
76 /// @param iField
77 /// Index of the field in record.
78 /// @return
79 /// Corresponding field of the record.
80 template<int k_nFields>
81 /* static */ int& s_GetField(CGeneInfoFileReader::
82  SMultiIntRecord<k_nFields>& record,
83  int iField)
84 {
85  return record.n[iField];
86 }
87 
88 /// Searches an array of records sorted by the first field.
89 ///
90 /// The function implements a variety of binary search that
91 /// will locate the first record in the array whose first
92 /// field matches the input key.
93 ///
94 /// @param pRecs
95 /// Pointer to the records.
96 /// @param nRecs
97 /// Number of records in the array.
98 /// @param n1
99 /// Key to search for.
100 /// @param iFirstIndex
101 /// Will be set to the first record matching the key, if any.
102 /// @return
103 /// True if any records were found matching the key.
104 template <typename TRecordType>
105 /* static */ bool s_SearchSortedArray(TRecordType* pRecs, int nRecs,
106  int n1, int& iFirstIndex)
107 {
108  int iRecBeg = 0, iRecEnd = nRecs;
109  int iRecMid, n1Mid;
110  while (iRecBeg < iRecEnd)
111  {
112  iRecMid = (iRecBeg + iRecEnd) / 2;
113  n1Mid = s_GetField(pRecs[iRecMid], 0);
114  if (n1Mid < n1)
115  iRecBeg = iRecMid + 1;
116  else
117  iRecEnd = iRecMid;
118  }
119  if (iRecEnd < nRecs)
120  if (s_GetField(pRecs[iRecEnd], 0) == n1)
121  {
122  iFirstIndex = iRecEnd;
123  return true;
124  }
125  return false;
126 }
127 
128 /// Sorts and filters a list of integers.
129 ///
130 /// @param listVals
131 /// List of integers to sort and filter.
132 /// @param bRemoveZeros
133 /// Remove zeros from the list.
134 /* static */ void s_SortAndFilter(list<int>& listVals, bool bRemoveZeros)
135 {
136  listVals.sort();
137  listVals.unique();
138  if (bRemoveZeros)
139  {
140  while (!listVals.empty() &&
141  listVals.front() == 0)
142  {
143  listVals.pop_front();
144  }
145  }
146 }
147 
148 /* static */ void s_SortAndFilterGis(list<TGi>& listVals, bool bRemoveZeros)
149 {
150  listVals.sort();
151  listVals.unique();
152  if (bRemoveZeros)
153  {
154  while (!listVals.empty() &&
155  listVals.front() == ZERO_GI)
156  {
157  listVals.pop_front();
158  }
159  }
160 }
161 
162 /// Searches an array of records sorted by the first field.
163 ///
164 /// The function returns the list of values of a given field
165 /// of all the records whose first field matches the key. The
166 /// list of values is sorted, filtered, and all the zeros are
167 /// removed (i.e. returns unique sorted positive integers).
168 ///
169 /// @param pRecs
170 /// Pointer to the records.
171 /// @param nRecs
172 /// Number of records in the array.
173 /// @param n1
174 /// Key to search for.
175 /// @param iField
176 /// Return matching records' fields at this index.
177 /// @param listFieldVals
178 /// List of returned values.
179 /// @param bRemoveZeros
180 /// Remove zeros from the list of returned values.
181 /// @return
182 /// True if any records were found matching the key.
183 template <typename TRecordType>
184 static bool s_SearchSortedArray(TRecordType* pRecs, int nRecs,
185  int n1, int iField,
186  list<int>& listFieldVals,
187  bool bRemoveZeros)
188 {
189  int iFirstIndex = -1;
190  if (s_SearchSortedArray(pRecs, nRecs, n1, iFirstIndex))
191  {
192  while (iFirstIndex < nRecs &&
193  s_GetField(pRecs[iFirstIndex], 0) == n1)
194  {
195  listFieldVals.push_back(
196  s_GetField(pRecs[iFirstIndex], iField));
197  iFirstIndex++;
198  }
199  s_SortAndFilter(listFieldVals, bRemoveZeros);
200  return true;
201  }
202  return false;
203 }
204 
205 template <typename TRecordType>
206 static bool s_SearchSortedArrayGis(TRecordType* pRecs, int nRecs,
207  int n1, int iField,
208  list<TGi>& listFieldVals,
209  bool bRemoveZeros)
210 {
211  int iFirstIndex = -1;
212  if (s_SearchSortedArray(pRecs, nRecs, n1, iFirstIndex))
213  {
214  while (iFirstIndex < nRecs &&
215  s_GetField(pRecs[iFirstIndex], 0) == n1)
216  {
217  listFieldVals.push_back(
218  GI_FROM(int, s_GetField(pRecs[iFirstIndex], iField)));
219  iFirstIndex++;
220  }
221  s_SortAndFilterGis(listFieldVals, bRemoveZeros);
222  return true;
223  }
224  return false;
225 }
226 
227 /// Interprets a memory file as a record array.
228 ///
229 /// @param pMemFile
230 /// Pointer to a valid and initialized CMemoryFile.
231 /// @param pRecs
232 /// Set to pointer to the records.
233 /// @param nRecs
234 /// Set to number of records in the array.
235 /// @return
236 /// True if conversion to a pointer was successful.
237 template <typename TRecordType>
238 static bool s_GetMemFilePtrAndLength(CMemoryFile* pMemFile,
239  TRecordType*& pRecs, int& nRecs)
240 {
241  if (pMemFile != 0)
242  {
243  nRecs = static_cast<int>(pMemFile->GetSize() / (sizeof(TRecordType)));
244  if (nRecs > 0)
245  {
246  pRecs = (TRecordType*)(pMemFile->GetPtr());
247  return pRecs != 0;
248  }
249  }
250  return false;
251 }
252 
253 //==========================================================================//
254 
256 {
258  NCBI_THROW(CGeneInfoException, eFileNotFoundError,
259  "Gi->GeneId processed file not found: " + m_strGi2GeneFile);
261 
263  NCBI_THROW(CGeneInfoException, eFileNotFoundError,
264  "GeneId->Offset processed file not found: " + m_strGene2OffsetFile);
266 
268  {
270  NCBI_THROW(CGeneInfoException, eFileNotFoundError,
271  "Gi->Offset processed file not found: " + m_strGi2OffsetFile);
273  }
274 
276  NCBI_THROW(CGeneInfoException, eFileNotFoundError,
277  "Gene->Gi processed file not found: " + m_strGene2GiFile);
279 }
280 
282 {
283  if (m_memGi2GeneFile.get() != 0)
284  m_memGi2GeneFile->Unmap();
285 
286  if (m_memGene2OffsetFile.get() != 0)
287  m_memGene2OffsetFile->Unmap();
288 
289  if (m_memGi2OffsetFile.get() != 0)
290  m_memGi2OffsetFile->Unmap();
291 
292  if (m_memGene2GiFile.get() != 0)
293  m_memGene2GiFile->Unmap();
294 }
295 
296 bool CGeneInfoFileReader::x_GiToGeneId(TGi gi, list<int>& listGeneIds)
297 {
298  STwoIntRecord* pRecs;
299  int nRecs;
300  bool retval = false;
302  pRecs, nRecs))
303  {
304  retval = s_SearchSortedArray(pRecs, nRecs,
305  GI_TO(int, gi), 1, listGeneIds, false);
306  }
307  else
308  {
309  NCBI_THROW(CGeneInfoException, eFileNotFoundError,
310  "Cannot access the memory-mapped file for "
311  "Gi to Gene ID conversion.");
312  }
313 
314  return retval;
315 }
316 
317 bool CGeneInfoFileReader::x_GeneIdToOffset(int geneId, int& nOffset)
318 {
319  STwoIntRecord* pRecs;
320  int nRecs;
322  pRecs, nRecs))
323  {
324  int iIndex = -1;
325  if (s_SearchSortedArray(pRecs, nRecs,
326  geneId, iIndex))
327  {
328  nOffset = s_GetField(pRecs[iIndex], 1);
329  return true;
330  }
331  }
332  else
333  {
334  NCBI_THROW(CGeneInfoException, eFileNotFoundError,
335  "Cannot access the memory-mapped file for "
336  "Gene ID to Gene Info Offset conversion.");
337  }
338 
339  return false;
340 }
341 
342 bool CGeneInfoFileReader::x_GiToOffset(TGi gi, list<int>& listOffsets)
343 {
344  if (!m_bGiToOffsetLookup)
345  {
346  NCBI_THROW(CGeneInfoException, eInternalError,
347  "Gi to offset lookup is disabled.");
348  }
349 
350  STwoIntRecord* pRecs;
351  int nRecs;
352  bool retval = false;
354  pRecs, nRecs))
355  {
356  retval = s_SearchSortedArray(pRecs, nRecs,
357  GI_TO(int, gi), 1, listOffsets, false);
358  }
359  else
360  {
361  NCBI_THROW(CGeneInfoException, eFileNotFoundError,
362  "Cannot access the memory-mapped file for "
363  "Gi to Gene Info Offset conversion.");
364  }
365 
366  return retval;
367 }
368 
369 bool CGeneInfoFileReader::x_GeneIdToGi(int geneId, int iGiField,
370  list<TGi>& listGis)
371 {
372  SMultiIntRecord<4>* pRecs;
373  int nRecs;
374  bool retval = false;
376  pRecs, nRecs))
377  {
378  retval = s_SearchSortedArrayGis(pRecs, nRecs,
379  geneId, iGiField, listGis, true);
380  }
381  else
382  {
383  NCBI_THROW(CGeneInfoException, eFileNotFoundError,
384  "Cannot access the memory-mapped file for "
385  "Gene ID to Gi conversion.");
386  }
387 
388  return retval;
389 }
390 
391 
393 {
394  // read the line at nOffset from the gene data file
395  ReadGeneInfo(m_inAllData, nOffset, info);
396  return true;
397 }
398 
399 //==========================================================================//
400 
401 CGeneInfoFileReader::CGeneInfoFileReader(const string& strGi2GeneFile,
402  const string& strGene2OffsetFile,
403  const string& strGi2OffsetFile,
404  const string& strAllGeneDataFile,
405  const string& strGene2GiFile,
406  bool bGiToOffsetLookup)
407  : m_strGi2GeneFile(strGi2GeneFile),
408  m_strGene2OffsetFile(strGene2OffsetFile),
409  m_strGi2OffsetFile(strGi2OffsetFile),
410  m_strGene2GiFile(strGene2GiFile),
411  m_strAllGeneDataFile(strAllGeneDataFile),
412  m_bGiToOffsetLookup(bGiToOffsetLookup)
413 {
415  {
416  NCBI_THROW(CGeneInfoException, eFileNotFoundError,
417  "Cannot open the Gene Data file for reading: " +
419  }
420 
421  x_MapMemFiles();
422 }
423 
424 /// Find the path to the gene info files, first checking the environment
425 /// variable GENE_INFO_PATH, then the section BLAST, label
426 /// GENE_INFO_PATH in the NCBI configuration file. If not found in either
427 /// location, try the $BLASTDB/gene_info directory. If all fails return the
428 /// current working directory
429 /// @sa s_FindPathToWM
430 static string
432 {
433  string retval = kEmptyStr;
434  const string kSection("BLAST");
435  CNcbiIstrstream empty_stream(kEmptyStr);
436  CRef<CNcbiRegistry> reg(new CNcbiRegistry(empty_stream,
439  kEmptyStr));
442  reg->Add(*env_reg, CNcbiRegistry::ePriority_MaxUser);
443  retval = reg->Get(kSection, GENE_INFO_PATH_ENV_VARIABLE);
444 
445  // Try the features subdirectory in the BLAST database storage location
446  if (retval == kEmptyStr) {
447  if ( (retval = reg->Get(kSection, "BLASTDB")) != kEmptyStr) {
448  retval = CDirEntry::ConcatPath(retval, "gene_info");
449  if ( !CDir(retval).Exists() ) {
450  retval = kEmptyStr;
451  }
452  }
453  }
454 
455  if (retval == kEmptyStr) {
456  retval = CDir::GetCwd();
457  }
458 #if defined(NCBI_OS_MSWIN)
459  // We address this here otherwise CDirEntry::IsAbsolutePath() fails
460  if (NStr::StartsWith(retval, "//")) {
461  NStr::ReplaceInPlace(retval, "//", "\\\\");
462  }
463 #endif
464  return retval;
465 }
466 
468  : m_bGiToOffsetLookup(bGiToOffsetLookup)
469 {
470  string strDirPath = s_FindPathToGeneInfoFiles();
471  if (strDirPath.length() == 0 ||
472  !CheckDirExistence(strDirPath))
473  {
474  NCBI_THROW(CGeneInfoException, eFileNotFoundError,
475  "Invalid path to Gene info directory: " +
476  strDirPath);
477  }
478  strDirPath = CDirEntry::AddTrailingPathSeparator(strDirPath);
479 
485 
487  {
488  NCBI_THROW(CGeneInfoException, eFileNotFoundError,
489  "Cannot open the Gene Data file for reading: " +
491  }
492 
493  x_MapMemFiles();
494 }
495 
496 
498 {
499  x_UnmapMemFiles();
500 }
501 
503  GetGeneIdsForGi(TGi gi, TGeneIdList& geneIdList)
504 {
505  return x_GiToGeneId(gi, geneIdList);
506 }
507 
509  GetRNAGisForGeneId(int geneId, TGiList& giList)
510 {
511  return x_GeneIdToGi(geneId, k_iRNAGiField, giList);
512 }
513 
515  GetProteinGisForGeneId(int geneId, TGiList& giList)
516 {
517  return x_GeneIdToGi(geneId, k_iProteinGiField, giList);
518 }
519 
521  GetGenomicGisForGeneId(int geneId, TGiList& giList)
522 {
523  return x_GeneIdToGi(geneId, k_iGenomicGiField, giList);
524 }
525 
527 {
528  bool bSuccess = false;
530  {
531  int nOffset = 0;
533  list<int> listOffsets;
534  if (x_GiToOffset(gi, listOffsets))
535  {
536  list<int>::const_iterator itOffset = listOffsets.begin();
537  for (; itOffset != listOffsets.end(); itOffset++)
538  {
539  nOffset = *itOffset;
540  if (x_OffsetToInfo(nOffset, info))
541  {
542  infoList.push_back(info);
543  bSuccess = true;
544  }
545  }
546  }
547  }
548  else
549  {
550  list<int> listGeneIds;
551  if (x_GiToGeneId(gi, listGeneIds))
552  {
553  list<int>::const_iterator itId = listGeneIds.begin();
554  for (; itId != listGeneIds.end(); itId++)
555  {
556  if (GetGeneInfoForId(*itId, infoList))
557  bSuccess = true;
558  else
559  {
560  NCBI_THROW(CGeneInfoException, eDataFormatError,
561  "Gene info not found for Gene ID:" +
562  NStr::IntToString(*itId) +
563  " linked from valid Gi:" +
565  }
566  }
567  }
568  }
569  return bSuccess;
570 }
571 
573 {
574  bool bSuccess = false;
575  if (m_mapIdToInfo.find(geneId) != m_mapIdToInfo.end())
576  {
577  infoList.push_back(m_mapIdToInfo[geneId]);
578  bSuccess = true;
579  }
580  else
581  {
582  int nOffset = 0;
584 
585  if (x_GeneIdToOffset(geneId, nOffset))
586  {
587  if (x_OffsetToInfo(nOffset, info))
588  {
589  infoList.push_back(info);
590  m_mapIdToInfo.insert(make_pair(geneId, info));
591  bSuccess = true;
592  }
593  else
594  {
595  NCBI_THROW(CGeneInfoException, eDataFormatError,
596  "Invalid Offset:" +
597  NStr::IntToString(nOffset) +
598  " for Gene ID:" +
599  NStr::IntToString(geneId));
600  }
601  }
602  }
603  return bSuccess;
604 }
605 
606 //==========================================================================//
607 
CDir –.
Definition: ncbifile.hpp:1695
CEnvironmentRegistry –.
Definition: env_reg.hpp:87
static bool CheckDirExistence(const string &strDir)
Check if a directory exists, given its name.
Definition: file_utils.cpp:54
static bool OpenBinaryInputFile(const string &strFileName, CNcbiIfstream &in)
Open the given binary file for reading.
Definition: file_utils.cpp:88
static void ReadGeneInfo(CNcbiIfstream &in, int nOffset, CRef< CGeneInfo > &info)
Read a Gene info object from the file.
Definition: file_utils.cpp:137
static bool CheckExistence(const string &strFile)
Check if a file exists, given its name.
Definition: file_utils.cpp:60
CGeneInfoException.
Definition: gene_info.hpp:63
CGeneInfoFileReader.
virtual bool GetGeneInfoForId(int geneId, TGeneInfoList &infoList)
GetGeneInfoForId implementation, see IGeneInfoInput.
bool x_GeneIdToOffset(int geneId, int &nOffset)
Set the offset value given a Gene ID.
string m_strGi2OffsetFile
Path to the Gi to Offset file.
bool x_GeneIdToGi(int geneId, int iGiField, list< TGi > &listGis)
Fill the Gi list given a Gene ID, and the Gi field index, which represents the Gi type to be read fro...
CNcbiIfstream m_inAllData
Input stream for the Gene data file.
virtual ~CGeneInfoFileReader()
Destructor.
unique_ptr< CMemoryFile > m_memGi2GeneFile
Memory-mapped Gi to Gene ID file.
bool m_bGiToOffsetLookup
Perform Gi to Offset lookups directly.
CGeneInfoFileReader(const string &strGi2GeneFile, const string &strGene2OffsetFile, const string &strGi2OffsetFile, const string &strAllGeneDataFile, const string &strGene2GiFile, bool bGiToOffsetLookup=true)
Construct using direct paths.
virtual bool GetGenomicGisForGeneId(int geneId, TGiList &giList)
GetGenomicGisForGeneId implementation, see IGeneInfoInput.
virtual bool GetGeneIdsForGi(TGi gi, TGeneIdList &geneIdList)
GetGeneIdsForGi implementation, see IGeneInfoInput.
void x_MapMemFiles()
Memory-map all the files.
unique_ptr< CMemoryFile > m_memGi2OffsetFile
Memory-mapped Gi to Offset file.
TGeneIdToGeneInfoMap m_mapIdToInfo
Cached map of looked up Gene Info objects.
unique_ptr< CMemoryFile > m_memGene2GiFile
Memory-mapped Gene ID to Gi file.
string m_strGene2GiFile
Path to the Gene ID to Gi file.
void x_UnmapMemFiles()
Unmap all the memory-mapped files.
string m_strGene2OffsetFile
Path to the Gene ID to Offset file.
string m_strGi2GeneFile
Path to the Gi to Gene ID file.
bool x_GiToGeneId(TGi gi, list< int > &listGeneIds)
Fill the Gene ID list given a Gi.
virtual bool GetGeneInfoForGi(TGi gi, TGeneInfoList &infoList)
GetGeneInfoForGi implementation, see IGeneInfoInput.
unique_ptr< CMemoryFile > m_memGene2OffsetFile
Memory-mapped Gene ID to Offset file.
bool x_GiToOffset(TGi gi, list< int > &listOffsets)
Set the offset value given a Gi.
virtual bool GetProteinGisForGeneId(int geneId, TGiList &giList)
GetProteinGisForGeneId implementation, see IGeneInfoInput.
virtual bool GetRNAGisForGeneId(int geneId, TGiList &giList)
GetRNAGisForGeneId implementation, see IGeneInfoInput.
bool x_OffsetToInfo(int nOffset, CRef< CGeneInfo > &info)
Read Gene data at the given offset and create the info object.
string m_strAllGeneDataFile
Path to the file containing all the Gene data.
CMemoryFile –.
Definition: ncbifile.hpp:2860
CNcbiRegistry –.
Definition: ncbireg.hpp:913
CRef –.
Definition: ncbiobj.hpp:618
CSimpleEnvRegMapper –.
Definition: env_reg.hpp:157
vector< CRef< CGeneInfo > > TGeneInfoList
List of Gene Information objects.
Definition: gene_info.hpp:252
list< int > TGeneIdList
List of Gene IDs.
Definition: gene_info.hpp:246
list< TGi > TGiList
List of Gis.
Definition: gene_info.hpp:243
const_iterator end() const
Definition: map.hpp:152
iterator_bool insert(const value_type &val)
Definition: map.hpp:165
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Classes to support using environment variables as a backend for the registry framework.
General file processing routines and structures.
static const int k_iGenomicGiField
Index of the Genomic Gi field in the Gene ID to Gi records.
static bool s_SearchSortedArrayGis(TRecordType *pRecs, int nRecs, int n1, int iField, list< TGi > &listFieldVals, bool bRemoveZeros)
static bool s_GetMemFilePtrAndLength(CMemoryFile *pMemFile, TRecordType *&pRecs, int &nRecs)
Interprets a memory file as a record array.
static const int k_iRNAGiField
Index of the RNA Gi field in the Gene ID to Gi records.
static const int k_iProteinGiField
Index of the Protein Gi field in the Gene ID to Gi records.
bool s_SearchSortedArray(TRecordType *pRecs, int nRecs, int n1, int &iFirstIndex)
Searches an array of records sorted by the first field.
int & s_GetField(CGeneInfoFileReader::STwoIntRecord &record, int iField)
Returns the field of a record given its index.
void s_SortAndFilter(list< int > &listVals, bool bRemoveZeros)
Sorts and filters a list of integers.
static string s_FindPathToGeneInfoFiles(void)
Find the path to the gene info files, first checking the environment variable GENE_INFO_PATH,...
void s_SortAndFilterGis(list< TGi > &listVals, bool bRemoveZeros)
Defines a class for reading Gene information from files.
#define GENE_GENE2OFFSET_FILE_NAME
Name of the processed "GeneID to Offset" file.
#define GENE_INFO_PATH_ENV_VARIABLE
Name of the environment variable holding the path to Gene info files.
#define GENE_GI2GENE_FILE_NAME
Name of the processed "Gi to GeneID" file.
#define GENE_ALL_GENE_DATA_FILE_NAME
Name of the combined "Gene Data" file.
#define GENE_GI2OFFSET_FILE_NAME
Name of the processed "Gi to Offset" file.
#define GENE_GENE2GI_FILE_NAME
Name of the processed "Gene ID to Gi" file.
#define GI_FROM(T, value)
Definition: ncbimisc.hpp:1086
#define ZERO_GI
Definition: ncbimisc.hpp:1088
#define GI_TO(T, gi)
Definition: ncbimisc.hpp:1085
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
size_t GetSize(void) const
Get length of the mapped region.
Definition: ncbifile.hpp:4287
void * GetPtr(void) const
Get pointer to beginning of data.
Definition: ncbifile.hpp:4281
static string AddTrailingPathSeparator(const string &path)
Add trailing path separator, if needed.
Definition: ncbifile.cpp:455
static string ConcatPath(const string &first, const string &second)
Concatenate two parts of the path for the current OS.
Definition: ncbifile.cpp:776
static string GetCwd(void)
Get the current working directory.
Definition: ncbifile.cpp:3708
virtual const string & Get(const string &section, const string &name, TFlags flags=0) const
Get the parameter value.
Definition: ncbireg.cpp:262
void Add(const IRegistry &reg, TPriority prio=ePriority_Default, const string &name=kEmptyStr)
Non-empty names must be unique within each compound registry, but there is no limit to the number of ...
Definition: ncbireg.cpp:1779
void AddMapper(const IEnvRegMapper &mapper, TPriority prio=ePriority_Default)
Definition: env_reg.cpp:71
@ fWithNcbirc
Include .ncbirc (used only by CNcbiReg.)
Definition: ncbireg.hpp:93
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3405
static MDB_envinfo info
Definition: mdb_load.c:37
const char *const kSection
Definition: snpptis.cpp:56
SMultiIntRecord - an n-tuple of integers.
Definition: file_utils.hpp:84
STwoIntRecord - a pair of integers.
Definition: file_utils.hpp:70
int n1
First integer field of the record.
Definition: file_utils.hpp:72
int n2
Second integer field of the record.
Definition: file_utils.hpp:75
Modified on Sat Apr 20 12:18:43 2024 by modify_doxy.py rev. 669887