src/objtools/blast/gene_info_reader/gene_info_reader.cpp File Reference


Detailed Description

Implementation of reading Gene information from files.

Definition in file gene_info_reader.cpp.

#include <ncbi_pch.hpp>
#include <corelib/env_reg.hpp>
#include <objtools/blast/gene_info_reader/gene_info_reader.hpp>
#include <objtools/blast/gene_info_reader/file_utils.hpp>
#include <algorithm>

Include dependency graph for gene_info_reader.cpp:

Go to the source code of this file.

Functions

int & s_GetField (CGeneInfoFileReader::STwoIntRecord &record, int iField)
 Returns the field of a record given its index.
template<int k_nFields>
int & s_GetField (CGeneInfoFileReader::SMultiIntRecord< k_nFields > &record, int iField)
 Returns the field of a record given its index.
template<typename TRecordType>
bool s_SearchSortedArray (TRecordType *pRecs, int nRecs, int n1, int &iFirstIndex)
 Searches an array of records sorted by the first field.
void s_SortAndFilter (list< int > &listVals, bool bRemoveZeros)
 Sorts and filters a list of integers.
template<typename TRecordType>
static bool s_SearchSortedArray (TRecordType *pRecs, int nRecs, int n1, int iField, list< int > &listFieldVals, bool bRemoveZeros)
 Searches an array of records sorted by the first field.
template<typename TRecordType>
static bool s_GetMemFilePtrAndLength (CMemoryFile *pMemFile, TRecordType *&pRecs, int &nRecs)
 Interprets a memory file as a record array.
static string s_FindPathToGeneInfoFiles (void)
 Find the path to the gene info files, first checking the environment variable GENE_INFO_PATH, then the section BLAST, label GENE_INFO_PATH in the NCBI configuration file.

Variables

static char const rcsid [] = "$Id: gene_info_reader.cpp 140909 2008-09-22 18:25:56Z ucko $"
static const int k_iRNAGiField = 1
 Index of the RNA Gi field in the Gene ID to Gi records.
static const int k_iProteinGiField = 2
 Index of the Protein Gi field in the Gene ID to Gi records.
static const int k_iGenomicGiField = 3
 Index of the Genomic Gi field in the Gene ID to Gi records.


Function Documentation

static string s_FindPathToGeneInfoFiles void   )  [static]
 

Find the path to the gene info files, first checking the environment variable GENE_INFO_PATH, then the section BLAST, label GENE_INFO_PATH in the NCBI configuration file.

If not found in either location, try the $BLASTDB/features directory. If all fails return the current working directory

See also:
s_FindPathToWM

Definition at line 400 of file gene_info_reader.cpp.

References CDirEntry::ConcatPath(), CEnvironmentRegistry::ePriority_Max, CCompoundRWRegistry::ePriority_MaxUser, IRegistry::fWithNcbirc, GENE_INFO_PATH_ENV_VARIABLE, CDir::GetCwd(), kEmptyCStr, kEmptyStr, NStr::ReplaceInPlace(), and NStr::StartsWith().

Referenced by CGeneInfoFileReader::CGeneInfoFileReader().

template<int k_nFields>
int& s_GetField CGeneInfoFileReader::SMultiIntRecord< k_nFields > &  record,
int  iField
 

Returns the field of a record given its index.

Parameters:
record N-integer record.
iField Index of the field in record.
Returns:
Corresponding field of the record.

Definition at line 86 of file gene_info_reader.cpp.

int& s_GetField CGeneInfoFileReader::STwoIntRecord &  record,
int  iField
 

Returns the field of a record given its index.

Parameters:
record Two-integer record.
iField Index of the field in record.
Returns:
Corresponding field of the record.

Definition at line 69 of file gene_info_reader.cpp.

template<typename TRecordType>
static bool s_GetMemFilePtrAndLength CMemoryFile pMemFile,
TRecordType *&  pRecs,
int &  nRecs
[static]
 

Interprets a memory file as a record array.

Parameters:
pMemFile Pointer to a valid and initialized CMemoryFile.
pRecs Set to pointer to the records.
nRecs Set to number of records in the array.
Returns:
True if conversion to a pointer was successful.

Definition at line 207 of file gene_info_reader.cpp.

References CMemoryFile::GetPtr(), and CMemoryFile::GetSize().

Referenced by CGeneInfoFileReader::x_GeneIdToGi(), CGeneInfoFileReader::x_GeneIdToOffset(), CGeneInfoFileReader::x_GiToGeneId(), and CGeneInfoFileReader::x_GiToOffset().

template<typename TRecordType>
static bool s_SearchSortedArray TRecordType *  pRecs,
int  nRecs,
int  n1,
int  iField,
list< int > &  listFieldVals,
bool  bRemoveZeros
[static]
 

Searches an array of records sorted by the first field.

The function returns the list of values of a given field of all the records whose first field matches the key. The list of values is sorted, filtered, and all the zeros are removed (i.e. returns unique sorted positive integers).

Parameters:
pRecs Pointer to the records.
nRecs Number of records in the array.
n1 Key to search for.
iField Return matching records' fields at this index.
listFieldVals List of returned values.
bRemoveZeros Remove zeros from the list of returned values.
Returns:
True if any records were found matching the key.

Definition at line 175 of file gene_info_reader.cpp.

References s_GetField(), s_SearchSortedArray(), and s_SortAndFilter().

template<typename TRecordType>
bool s_SearchSortedArray TRecordType *  pRecs,
int  nRecs,
int  n1,
int &  iFirstIndex
 

Searches an array of records sorted by the first field.

The function implements a variety of binary search that will locate the first record in the array whose first field matches the input key.

Parameters:
pRecs Pointer to the records.
nRecs Number of records in the array.
n1 Key to search for.
iFirstIndex Will be set to the first record matching the key, if any.
Returns:
True if any records were found matching the key.

Definition at line 110 of file gene_info_reader.cpp.

References s_GetField().

Referenced by s_SearchSortedArray(), CGeneInfoFileReader::x_GeneIdToGi(), CGeneInfoFileReader::x_GeneIdToOffset(), CGeneInfoFileReader::x_GiToGeneId(), and CGeneInfoFileReader::x_GiToOffset().

void s_SortAndFilter list< int > &  listVals,
bool  bRemoveZeros
 

Sorts and filters a list of integers.

Parameters:
listVals List of integers to sort and filter.
bRemoveZeros Remove zeros from the list.

Definition at line 139 of file gene_info_reader.cpp.

Referenced by s_SearchSortedArray().


Variable Documentation

const int k_iGenomicGiField = 3 [static]
 

Index of the Genomic Gi field in the Gene ID to Gi records.

Definition at line 57 of file gene_info_reader.cpp.

Referenced by CGeneInfoFileReader::GetGenomicGisForGeneId().

const int k_iProteinGiField = 2 [static]
 

Index of the Protein Gi field in the Gene ID to Gi records.

Definition at line 55 of file gene_info_reader.cpp.

Referenced by CGeneInfoFileReader::GetProteinGisForGeneId().

const int k_iRNAGiField = 1 [static]
 

Index of the RNA Gi field in the Gene ID to Gi records.

Definition at line 53 of file gene_info_reader.cpp.

Referenced by CGeneInfoFileReader::GetRNAGisForGeneId().

char const rcsid[] = "$Id: gene_info_reader.cpp 140909 2008-09-22 18:25:56Z ucko $" [static]
 

Definition at line 34 of file gene_info_reader.cpp.


Generated on Mon Dec 7 09:24:32 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:22:06 2009 by modify_doxy.py rev. 173732