Datasets
shedding_hub.load_dataset(dataset, *, repo='shedding-hub/shedding-hub', ref=None, pr=None, local=None)
Load a dataset from GitHub or a local directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Dataset identifier, e.g., :code: |
required |
repo
|
str
|
GitHub repository to load data from. |
'shedding-hub/shedding-hub'
|
ref
|
Optional[str]
|
Git reference to load. Defaults to the most recent data on the :code: |
None
|
pr
|
Optional[int]
|
Pull request to fetch data from. |
None
|
local
|
Optional[str]
|
Local directory to load data from. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Loaded dataset. |
Examples:
>>> import shedding_hub as sh
>>> data = sh.load_dataset('woelfel2020virological', local='./data')
>>> sorted(data.keys())
['analytes', 'dataset_id', 'description', 'doi', 'participants', 'title']
>>> data['dataset_id']
'woelfel2020virological'
shedding_hub.check_dataset(*, doi=None, title=None, local=None, similarity_threshold=0.6)
Check whether a paper is in the curated datasets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doi
|
Optional[str]
|
DOI of the paper to check. |
None
|
title
|
Optional[str]
|
Title of the paper to check. |
None
|
local
|
Optional[str]
|
Local directory containing datasets. Defaults to the |
None
|
similarity_threshold
|
float
|
Minimum similarity ratio (0 to 1) for reporting near-matches when no exact title match is found. |
0.6
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the paper is found (exact DOI or exact title match), False |
bool
|
otherwise. When a title is provided and no exact match is found, a |
bool
|
warning is issued for the most similar dataset above the threshold. |
Examples:
>>> import shedding_hub as sh
>>> sh.check_dataset(doi='10.1038/s41586-020-2196-x', local='./data')
True
>>> sh.check_dataset(doi='10.1000/nonexistent-doi', local='./data')
False
shedding_hub.normalize_str(value, *, dedent=True, strip=True, unwrap=True)
Normalize a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
String to normalize. |
required |
dedent
|
bool
|
Remove any common leading whitespace. |
True
|
strip
|
bool
|
Remove leading and trailing whitespace. |
True
|
unwrap
|
bool
|
Unwrap lines separated by a single line break. |
True
|
Examples:
>>> import shedding_hub as sh
>>> sh.normalize_str("\n line one\n line two\n")
'line one line two'
shedding_hub.folded_str
Bases: str
Folded string in yaml representation.
Examples:
>>> import yaml
>>> import shedding_hub as sh
>>> print(yaml.dump({"description": sh.folded_str("This is a long description that will be wrapped nicely.")}))
description: >-
This is a long description that will be wrapped nicely.
shedding_hub.literal_str
Bases: str
Literal string in yaml representation.
Examples:
>>> import yaml
>>> import shedding_hub as sh
>>> print(yaml.dump({"description": sh.literal_str("Line one.\nLine two.\n")}))
description: |
Line one.
Line two.