uniprot_id_mapping package
Submodules
uniprot_id_mapping.cache module
Cache management.
- class uniprot_id_mapping.cache.CacheManager(cache_dir=None)[source]
Bases:
object
Cache manager.
- __init__(cache_dir=None)[source]
- Parameters:
cache_dir – An optional path to a cache directory. If None, the standard XDG path will be used.
- get_path(subpath, is_dir=False)[source]
Get the full path to a subdirectory of the cache directory.
- Parameters:
subpath – The subpath within the cache directory.
is_dir – If True, treat the subpath as a directory.
- Returns:
The full path to the given subpath. The parent directory will be created if missing. If is_dir is True, so will the final path component.
uniprot_id_mapping.exception module
Custom exceptions.
uniprot_id_mapping.id_mapper module
Map IDs via the UniProt ID mapping service: https://www.uniprot.org/help/id_mapping
- class uniprot_id_mapping.id_mapper.IdMapper(cache_man: CacheManager = None, timeout: float = 10)[source]
Bases:
object
Wrapper around the UniProt ID mapping service with local caching.
- __init__(cache_man: CacheManager = None, timeout: float = 10)[source]
- Parameters:
cache_man – A configured CacheManager instance.
timeout – Connection timeout for remote requests, in seconds.
- map_ids(db_from, db_to, identifiers, refresh_missing=False)[source]
Map identifiers from one database to another.
- Parameters:
db_from – The database from which to map the identifiers.
db_to – The database to which to map the identifiers.
identifiers – The identifiers in db_from that should be mapped to db_to.
refresh_missing – If True, check the server if previously missing values have been added since the last query.
- Returns:
A dict mapping the found identifiers in db_from to identifiers in db_to.
- Raises:
ValueError – Invalid arguments for db_from or db_to.
- exception uniprot_id_mapping.id_mapper.IdMapperError[source]
Bases:
UniprotIdMappingException
Custom exception raised by IdMapper.
uniprot_id_mapping.main module
Map IDs between databases using UniProt’s ID Mapping service.
Module contents
Package stub.
- class uniprot_id_mapping.IdMapper(cache_man: CacheManager = None, timeout: float = 10)[source]
Bases:
object
Wrapper around the UniProt ID mapping service with local caching.
- __init__(cache_man: CacheManager = None, timeout: float = 10)[source]
- Parameters:
cache_man – A configured CacheManager instance.
timeout – Connection timeout for remote requests, in seconds.
- map_ids(db_from, db_to, identifiers, refresh_missing=False)[source]
Map identifiers from one database to another.
- Parameters:
db_from – The database from which to map the identifiers.
db_to – The database to which to map the identifiers.
identifiers – The identifiers in db_from that should be mapped to db_to.
refresh_missing – If True, check the server if previously missing values have been added since the last query.
- Returns:
A dict mapping the found identifiers in db_from to identifiers in db_to.
- Raises:
ValueError – Invalid arguments for db_from or db_to.