BBClient Module
bbclient
Classes
BBClient
BBClient(cache_folder=DEFAULT_CACHE_FOLDER, bedbase_api=DEFAULT_BEDBASE_API)
Bases: BedCacheManager
BBClient to deal with download files from bedbase and caching them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cache_folder
|
Union[str, PathLike]
|
path to local folder as cache of files from bedbase, if not given it will be the environment variable |
DEFAULT_CACHE_FOLDER
|
bedbase_api
|
str
|
url to bedbase |
DEFAULT_BEDBASE_API
|
Functions
load_bedset
load_bedset(bedset_id)
Load a BEDset from cache, or download and add it to the cache with its BED files
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bedset_id
|
str
|
unique identifier of a BED set |
required |
Returns:
Type | Description |
---|---|
BedSet
|
the BedSet object |
load_bed
load_bed(bed_id)
Loads a BED file from cache, or downloads and caches it if it doesn't exist
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bed_id
|
str
|
unique identifier of a BED file |
required |
Returns:
Type | Description |
---|---|
RegionSet
|
the RegionSet object |
add_bedset_to_cache
add_bedset_to_cache(bedset)
Add a BED set to the cache
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bedset
|
BedSet
|
the BED set to be added, a BedSet class |
required |
Returns:
Type | Description |
---|---|
str
|
the identifier if the BedSet object |
add_bed_to_cache
add_bed_to_cache(bedfile, force=False)
Add a BED file to the cache
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bedfile
|
Union[RegionSet, str]
|
a RegionSet object or a path or url to the BED file |
required |
force
|
bool
|
whether to overwrite the existing file in cache |
False
|
Returns:
Type | Description |
---|---|
RegionSet
|
the RegionSet identifier |
add_bed_tokens_to_cache
add_bed_tokens_to_cache(bed_id, universe_id)
Add a tokenized BED file to the cache
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bed_id
|
str
|
the identifier of the BED file |
required |
universe_id
|
str
|
the identifier of the universe |
required |
Returns:
Type | Description |
---|---|
None
|
the identifier of the tokenized BED file |
load_bed_tokens
load_bed_tokens(bed_id, universe_id)
Load a tokenized BED file from cache, or download and cache it if it doesn't exist
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bed_id
|
str
|
the identifier of the BED file |
required |
universe_id
|
str
|
the identifier of the universe |
required |
Returns:
Type | Description |
---|---|
Array
|
the zarr array of tokens |
remove_tokens
remove_tokens(bed_id, universe_id)
Remove all tokenized BED files from cache
cache_tokens
cache_tokens(bed_id, universe_id, tokens)
Cache tokenized BED file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bed_id
|
str
|
the identifier of the BED file |
required |
universe_id
|
str
|
the identifier of the universe |
required |
tokens
|
Union[list, Array]
|
the list of tokens |
required |
Returns:
Type | Description |
---|---|
None
|
None |
add_bed_to_s3
add_bed_to_s3(identifier, bucket=DEFAULT_BUCKET_NAME, endpoint_url=None, aws_access_key_id=None, aws_secret_access_key=None, s3_path=DEFAULT_BUCKET_FOLDER)
Add a cached BED file to S3
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str
|
the unique identifier of the BED file |
required |
bucket
|
str
|
the name of the bucket |
DEFAULT_BUCKET_NAME
|
endpoint_url
|
str
|
the URL of the S3 endpoint [Default: set up by the environment vars] |
None
|
aws_access_key_id
|
str
|
the access key of the AWS account [Default: set up by the environment vars] |
None
|
aws_secret_access_key
|
str
|
the secret access key of the AWS account [Default: set up by the environment vars] |
None
|
s3_path
|
str
|
the path on S3 |
DEFAULT_BUCKET_FOLDER
|
Returns:
Type | Description |
---|---|
str
|
full path on S3 |
get_bed_from_s3
get_bed_from_s3(identifier, bucket=DEFAULT_BUCKET_NAME, endpoint_url=None, aws_access_key_id=None, aws_secret_access_key=None, s3_path=DEFAULT_BUCKET_FOLDER)
Get a cached BED file from S3 and cache it locally
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str
|
the unique identifier of the BED file |
required |
bucket
|
str
|
the name of the bucket |
DEFAULT_BUCKET_NAME
|
endpoint_url
|
str
|
the URL of the S3 endpoint [Default: set up by the environment vars] |
None
|
aws_access_key_id
|
str
|
the access key of the AWS account [Default: set up by the environment vars] |
None
|
aws_secret_access_key
|
str
|
the secret access key of the AWS account [Default: set up by the environment vars] |
None
|
s3_path
|
str
|
the path on S3 |
DEFAULT_BUCKET_FOLDER
|
Returns:
Type | Description |
---|---|
str
|
bed file id |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
if the identifier does not exist in cache |
seek
seek(identifier)
Get local path to BED file or BED set with specific identifier
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str
|
the unique identifier |
required |
Returns:
Type | Description |
---|---|
str
|
the local path of the file |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
if the identifier does not exist in cache |
remove_bedset_from_cache
remove_bedset_from_cache(bedset_id, remove_bed_files=False)
Remove a BED set from cache
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bedset_id
|
str
|
the identifier of BED set |
required |
remove_bed_files
|
bool
|
whether also remove BED files in the BED set |
False
|
Raises:
Type | Description |
---|---|
FileNotFoundError
|
if the BED set does not exist in cache |
list_beds
list_beds()
List all BED files in cache
Returns:
Type | Description |
---|---|
Dict[str, str]
|
the list of identifiers of BED files |
list_bedsets
list_bedsets()
List all BED sets in cache
Returns:
Type | Description |
---|---|
Dict[str, str]
|
the list of identifiers of BED sets |
remove_bedfile_from_cache
remove_bedfile_from_cache(bedfile_id)
Remove a BED file from cache
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bedfile_id
|
str
|
the identifier of BED file |
required |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
if the BED set does not exist in cache |