NCBI C++ ToolKit
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
CIdMapperConfig Class Reference

Search Toolkit Book for CIdMapperConfig

IdMapper implementation using an external configuration file. More...

#include <objtools/readers/idmapper.hpp>

+ Inheritance diagram for CIdMapperConfig:
+ Collaboration diagram for CIdMapperConfig:

Public Member Functions

 CIdMapperConfig (CNcbiIstream &istr, const std::string &strContext="", bool bInvert=false, ILineErrorListener *pErrors=0)
 Constructor specifying the content of the mapping table, mapping context, direction, and error handling. More...
 
 CIdMapperConfig (const std::string &strContext="", bool bInvert=false, ILineErrorListener *pErrors=0)
 
void Initialize (CNcbiIstream &istr)
 
- Public Member Functions inherited from CIdMapper
 CIdMapper (const std::string &strContext="", bool bInvert=false, ILineErrorListener *pErrors=0)
 Constructor specifying the mapping context, direction, and error handling. More...
 
virtual ~CIdMapper ()
 
virtual void AddMapping (const CSeq_id_Handle &from, const CSeq_id_Handle &to)
 Add a mapping to the internal mapping table. More...
 
virtual void AddMapping (const CSeq_loc &loc_from, const CSeq_loc &loc_to)
 
virtual CSeq_id_Handle Map (const CSeq_id_Handle &)
 Map a single given CSeq_id_Handle to another. More...
 
virtual CRef< CSeq_locMap (const CSeq_loc &loc)
 
virtual void MapObject (CSerialObject &)
 Map all embedded IDs in a given object at once. More...
 
- Public Member Functions inherited from IIdMapper
virtual ~IIdMapper ()
 

Static Public Member Functions

static void DescribeContexts (CNcbiIstream &istr, list< SMappingContext > &contexts)
 

Protected Member Functions

void AddMapEntry (const std::string &)
 
void SetCurrentContext (const std::string &, std::string &)
 
CSeq_id_Handle SourceHandle (const std::string &)
 
CSeq_id_Handle TargetHandle (const std::string &)
 

Additional Inherited Members

- Protected Types inherited from CIdMapper
typedef std::map< CSeq_id_Handle, SMapperTMapperCache
 
- Static Protected Member Functions inherited from CIdMapper
static std::string MapErrorString (const CSeq_id_Handle &)
 
static std::string MapErrorString (const CSeq_loc &)
 
- Protected Attributes inherited from CIdMapper
const std::string m_strContext
 
const bool m_bInvert
 
TMapperCache m_Cache
 
ILineErrorListenerm_pErrors
 

Detailed Description

IdMapper implementation using an external configuration file.

The internal mapping table will be initialized during IdMapper construction from a given input stream (typically, an open configuration file).

Definition at line 188 of file idmapper.hpp.

Constructor & Destructor Documentation

◆ CIdMapperConfig() [1/2]

CIdMapperConfig::CIdMapperConfig ( CNcbiIstream istr,
const std::string strContext = "",
bool  bInvert = false,
ILineErrorListener pErrors = 0 
)

Constructor specifying the content of the mapping table, mapping context, direction, and error handling.

The configuration-file-based mapper uses a config file to indicate how mapping should be performed. Configuration-based mapping is suitable for simple id -> id mapping, and cannot generally be used to indicate mapping through a complex location, as would be needed when handling things such as mapping to UCSC chrRandom.

The format of the configuration file is as a standard Windows .ini file, and it should be structured as follows:

[hg18]
map_from = UCSC HG18
map_to = NCBI Human build 36
89161185 = chr1 1
89161199 = chr2 2
89161205 = chr3 3
89161207 = chr4 4
51511721 = chr5 5
NCBI
Definition: static_set.hpp:72

Note that the config file appears backwards! This is intentional, and is structured so as to capture a many-to-one synonymy that we often see in IDs. The snippet above implies:

  • We are mapping from UCSC build HG18 -> NCBI Human build 36
  • The chromosomes are defined by bare integers, which represent gis
  • The primary aliases all begin 'chr', as 'chr1', 'chr2', etc.
  • Each chromosome is represented by multiple input aliases (chr1, 1, etc)
  • We map implicitly from lcl|chr1 -> 89161185, lcl|1 -> 89161185
  • Because of a limitation in processing .ini files, we cannot use a full FASTA representation for the key (the gi). We can use one for the aliases. Since bare integers are interpreted as gis, it is necessary to qualify bare integers as local IDs if you wish to have a representation as something other than a gi
Parameters
istropen input stream containing tabbed data specifying map sources and targets.
strContextthe mapping context or genome source IDs will belong to. Something like "mm6" or "hg18".
bInvertMapping direction. "true" will map in reverse direction.
pErrorsOptional error container. If specified, mapping errors will be passed to the error container for further processing. If not specified, mapping errors result in exceptions that need to be handled.

Definition at line 48 of file idmapper_config.cpp.

References Initialize().

◆ CIdMapperConfig() [2/2]

CIdMapperConfig::CIdMapperConfig ( const std::string strContext = "",
bool  bInvert = false,
ILineErrorListener pErrors = 0 
)

Definition at line 58 of file idmapper_config.cpp.

Member Function Documentation

◆ AddMapEntry()

void CIdMapperConfig::AddMapEntry ( const std::string )
protected

◆ DescribeContexts()

void CIdMapperConfig::DescribeContexts ( CNcbiIstream istr,
list< SMappingContext > &  contexts 
)
static

◆ Initialize()

void CIdMapperConfig::Initialize ( CNcbiIstream istr)

◆ SetCurrentContext()

void CIdMapperConfig::SetCurrentContext ( const std::string ,
std::string  
)
protected

Definition at line 185 of file idmapper_config.cpp.

References columns, NStr::fSplit_MergeDelimiters, and NStr::Split().

Referenced by Initialize().

◆ SourceHandle()

CSeq_id_Handle CIdMapperConfig::SourceHandle ( const std::string )
protected

Definition at line 234 of file idmapper_config.cpp.

References CSeq_id_Base::e_Local, CSeq_id_Handle::GetHandle(), and rapidjson::source.

Referenced by AddMapEntry().

◆ TargetHandle()

CSeq_id_Handle CIdMapperConfig::TargetHandle ( const std::string )
protected

The documentation for this class was generated from the following files:
Modified on Sun Apr 14 05:27:55 2024 by modify_doxy.py rev. 669887