ubuntu-bio 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ubuntu_bio-0.1.0/.github/workflows/ci.yml +44 -0
- ubuntu_bio-0.1.0/.github/workflows/publish.yml +50 -0
- ubuntu_bio-0.1.0/.gitignore +25 -0
- ubuntu_bio-0.1.0/LICENSE +21 -0
- ubuntu_bio-0.1.0/PKG-INFO +198 -0
- ubuntu_bio-0.1.0/README.md +169 -0
- ubuntu_bio-0.1.0/pyproject.toml +119 -0
- ubuntu_bio-0.1.0/src/ubuntu_bio/__init__.py +56 -0
- ubuntu_bio-0.1.0/src/ubuntu_bio/auth.py +342 -0
- ubuntu_bio-0.1.0/src/ubuntu_bio/cli.py +704 -0
- ubuntu_bio-0.1.0/src/ubuntu_bio/config.py +84 -0
- ubuntu_bio-0.1.0/src/ubuntu_bio/download.py +223 -0
- ubuntu_bio-0.1.0/src/ubuntu_bio/exceptions.py +35 -0
- ubuntu_bio-0.1.0/src/ubuntu_bio/hub.py +204 -0
- ubuntu_bio-0.1.0/src/ubuntu_bio/search.py +65 -0
- ubuntu_bio-0.1.0/src/ubuntu_bio/upload.py +285 -0
- ubuntu_bio-0.1.0/src/ubuntubio/__init__.py +61 -0
- ubuntu_bio-0.1.0/tests/test_auth.py +120 -0
- ubuntu_bio-0.1.0/tests/test_cli.py +120 -0
- ubuntu_bio-0.1.0/tests/test_config_and_token.py +43 -0
- ubuntu_bio-0.1.0/tests/test_device_auth.py +79 -0
- ubuntu_bio-0.1.0/tests/test_download.py +130 -0
- ubuntu_bio-0.1.0/tests/test_hub.py +100 -0
- ubuntu_bio-0.1.0/tests/test_search.py +49 -0
- ubuntu_bio-0.1.0/tests/test_upload.py +101 -0
- ubuntu_bio-0.1.0/uv.lock +855 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: Lint, Type Check & Test Suite
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout repository
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Install uv
|
|
23
|
+
uses: astral-sh/setup-uv@v5
|
|
24
|
+
with:
|
|
25
|
+
version: "latest"
|
|
26
|
+
enable-cache: true
|
|
27
|
+
|
|
28
|
+
- name: Set up Python 3.12
|
|
29
|
+
run: uv python install 3.12
|
|
30
|
+
|
|
31
|
+
- name: Install dependencies
|
|
32
|
+
run: uv sync --all-extras
|
|
33
|
+
|
|
34
|
+
- name: Lint with Ruff
|
|
35
|
+
run: uv run ruff check .
|
|
36
|
+
|
|
37
|
+
- name: Check formatting with Ruff
|
|
38
|
+
run: uv run ruff format --check .
|
|
39
|
+
|
|
40
|
+
- name: Type check with Mypy
|
|
41
|
+
run: uv run mypy src tests
|
|
42
|
+
|
|
43
|
+
- name: Run Pytest test suite
|
|
44
|
+
run: uv run pytest --cov=src --cov-report=xml
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*.*.*"
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build-and-publish:
|
|
13
|
+
name: Build & Publish to PyPI
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
environment:
|
|
16
|
+
name: pypi
|
|
17
|
+
url: https://pypi.org/project/ubuntu-bio/
|
|
18
|
+
permissions:
|
|
19
|
+
id-token: write # Mandatory for PyPI Trusted Publishing (OIDC)
|
|
20
|
+
contents: read
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- name: Checkout repository
|
|
24
|
+
uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- name: Install uv
|
|
27
|
+
uses: astral-sh/setup-uv@v5
|
|
28
|
+
with:
|
|
29
|
+
version: "latest"
|
|
30
|
+
enable-cache: true
|
|
31
|
+
|
|
32
|
+
- name: Set up Python 3.12
|
|
33
|
+
run: uv python install 3.12
|
|
34
|
+
|
|
35
|
+
- name: Install dependencies
|
|
36
|
+
run: uv sync --all-extras
|
|
37
|
+
|
|
38
|
+
- name: Run test suite verification
|
|
39
|
+
run: uv run pytest
|
|
40
|
+
|
|
41
|
+
- name: Build sdist and wheel
|
|
42
|
+
run: uv build
|
|
43
|
+
|
|
44
|
+
- name: Publish package distributions to PyPI
|
|
45
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
46
|
+
with:
|
|
47
|
+
packages-dir: dist/
|
|
48
|
+
# If using OIDC Trusted Publishing, no token is needed.
|
|
49
|
+
# If using an API token, set the secret PYPI_API_TOKEN in GitHub repository settings.
|
|
50
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
|
|
11
|
+
# Virtual environments
|
|
12
|
+
.venv/
|
|
13
|
+
venv/
|
|
14
|
+
env/
|
|
15
|
+
|
|
16
|
+
# Testing & linting
|
|
17
|
+
.pytest_cache/
|
|
18
|
+
.coverage
|
|
19
|
+
htmlcov/
|
|
20
|
+
.mypy_cache/
|
|
21
|
+
.ruff_cache/
|
|
22
|
+
.hypothesis/
|
|
23
|
+
|
|
24
|
+
# OS artifacts
|
|
25
|
+
.DS_Store
|
ubuntu_bio-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 UbuntuBio Community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ubuntu-bio
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python client and CLI for UbuntuBio - African Bioinformatics Data Hub
|
|
5
|
+
Author-email: UbuntuBio Community <dev@ubuntubio.org>
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: africa,bioinformatics,datasets,genomics,open-science,openxet
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Requires-Dist: httpx>=0.27.2
|
|
17
|
+
Requires-Dist: pydantic>=2.9.0
|
|
18
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
19
|
+
Requires-Dist: rich>=13.9.0
|
|
20
|
+
Requires-Dist: typer>=0.12.5
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: mypy>=1.13.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest>=8.3.3; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff>=0.7.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: types-pyyaml>=6.0.12.20240917; extra == 'dev'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# ubuntu-bio
|
|
31
|
+
|
|
32
|
+
[](https://pypi.org/project/ubuntu-bio/)
|
|
33
|
+
[](https://pypi.org/project/ubuntu-bio/)
|
|
34
|
+
[](https://opensource.org/licenses/MIT)
|
|
35
|
+
[](https://github.com/Sredeemer/ubuntu-bio-pypi/actions/workflows/ci.yml)
|
|
36
|
+
|
|
37
|
+
The official Python client and command-line interface (`ubio`) for **UbuntuBio** — the African Bioinformatics Data Hub.
|
|
38
|
+
|
|
39
|
+
`ubuntu-bio` enables researchers across the African continent and globally to publish, discover, stream, and version bioinformatics datasets (pathogen genomics, AMR surveillance, agriculture, biodiversity, and metagenomics) with chunk-level deduplication and Git versioning.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Key Features
|
|
44
|
+
|
|
45
|
+
- **Researcher Identity & Namespaces**: Seamless ORCID-authenticated login via browser loopback or RFC 8628 device flow with personal namespace resolution (`@username/dataset-name`).
|
|
46
|
+
- **Genomic Deduplication**: Powered by OpenXet Content-Addressed Storage (CAS) using 64 KiB Content-Defined Chunking (CDC) and Blake3 Merkle trees—identical sequence chunks are stored only once.
|
|
47
|
+
- **Git Versioning**: Every dataset is backed by standard Git commit histories, tags, and branches.
|
|
48
|
+
- **Metadata Standards & Data Governance**: Built-in MIxS checklist validation and African Union ISO-3166 country code verification. Non-human genomics strictly enforced in v1.
|
|
49
|
+
- **Dual Interface**: Full-featured command-line interface (`ubio` or `ubuntu-bio`) and ergonomic Python SDK (`import ubuntu_bio as ub`).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
Install using `pip`:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install ubuntu-bio
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or using `uv`:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
uv add ubuntu-bio
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## CLI Quickstart
|
|
70
|
+
|
|
71
|
+
The package installs two identical CLI entrypoints: `ubio` and `ubuntu-bio`.
|
|
72
|
+
|
|
73
|
+
### 1. Authenticate with ORCID
|
|
74
|
+
Connect your ORCID iD. Opens an interactive browser authorization or falls back to an RFC 8628 device verification code:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
ubio login
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Verify your authenticated researcher profile:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
ubio whoami
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
✓ Authenticated with UbuntuBio Hub
|
|
88
|
+
Name: Dr. Ada Lovelace
|
|
89
|
+
Username: @ada-lovelace
|
|
90
|
+
ORCID: 0000-0002-1825-0097
|
|
91
|
+
Role: researcher
|
|
92
|
+
Server: https://hub.ubuntubio.org
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 2. Create a Dataset Repository
|
|
96
|
+
Create a new dataset repository. If you provide a bare slug, `ubio` automatically prefixes your verified researcher handle:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Automatically creates @ada-lovelace/lassa-surveillance-2024
|
|
100
|
+
ubio create lassa-surveillance-2024 --domain virus --access public
|
|
101
|
+
|
|
102
|
+
# Or specify an institutional / organization namespace
|
|
103
|
+
ubio create pasteur-dakar/lassa-2024 --domain virus --access public
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Supported biological domains:
|
|
107
|
+
`bacteria`, `virus`, `parasite`, `fungus`, `plant`, `animal`, `vector`, `metagenome`, `environmental`.
|
|
108
|
+
|
|
109
|
+
### 3. Upload Datasets
|
|
110
|
+
Upload an entire directory of sequences, alignments, and metadata:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
ubio upload lassa-surveillance-2024 ./my-data --message "Initial release of Lineage II FASTA assemblies"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 4. Search Public Datasets
|
|
117
|
+
Search the catalog using full-text search across pathogen titles, descriptions, and AU member states:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Search for cholera surveillance in Kenya
|
|
121
|
+
ubio search "cholera" --country KE
|
|
122
|
+
|
|
123
|
+
# Search for antimicrobial resistance studies
|
|
124
|
+
ubio search "antimicrobial resistance" --domain bacteria
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 5. Download Datasets & Remote Files
|
|
128
|
+
Download a snapshot of a dataset repository:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
ubio download lassa-surveillance-2024 --output-dir ./local-data
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Download external assets listed in a `remote_files.tsv` manifest with parallel MD5 verification:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
ubio download-remote ./remote_files.tsv --output-dir ./downloads --workers 8
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Python SDK Quickstart
|
|
143
|
+
|
|
144
|
+
Use `ubuntu_bio` directly in your Python analysis pipelines and Jupyter notebooks:
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
import ubuntu_bio as ub
|
|
148
|
+
|
|
149
|
+
# 1. Authenticate (using a Personal Access Token or environment variable)
|
|
150
|
+
ub.login(token="ubp_your_personal_access_token")
|
|
151
|
+
|
|
152
|
+
# 2. Check profile
|
|
153
|
+
profile = ub.whoami()
|
|
154
|
+
print(f"Logged in as: @{profile.get('username')}")
|
|
155
|
+
|
|
156
|
+
# 3. Create a repository
|
|
157
|
+
repo = ub.create_repo(
|
|
158
|
+
repo_id="lassa-surveillance-2024",
|
|
159
|
+
domain="virus",
|
|
160
|
+
access="public",
|
|
161
|
+
description="Lassa virus genomic surveillance in West Africa",
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
# 4. Upload an entire folder of genomic files
|
|
165
|
+
ub.upload_folder(
|
|
166
|
+
repo_id="lassa-surveillance-2024",
|
|
167
|
+
folder_path="./data",
|
|
168
|
+
message="Add consensus FASTA and GFF annotations",
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
# 5. Download a single file or complete snapshot
|
|
172
|
+
fasta_path = ub.download_file("pasteur-dakar/cholera-2024", "assemblies/sample_01.fasta")
|
|
173
|
+
dataset_dir = ub.snapshot_download("pasteur-dakar/cholera-2024", revision="main")
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Configuration & Environment Variables
|
|
179
|
+
|
|
180
|
+
| Variable | Description | Default |
|
|
181
|
+
| :--- | :--- | :--- |
|
|
182
|
+
| `UBUNTUBIO_SERVER_URL` | UbuntuBio Hub API server URL | `https://hub.ubuntubio.org` |
|
|
183
|
+
| `UBUNTUBIO_API_TOKEN` | Personal Access Token (`ubp_...`) for non-interactive environments / CI | `None` |
|
|
184
|
+
| `UBUNTUBIO_CONFIG_DIR` | Directory storing local credentials cache | `~/.config/ubuntubio` |
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Security & Biological Data Ethics
|
|
189
|
+
|
|
190
|
+
- **Non-Human Data Only**: In compliance with UbuntuBio v1 data governance rules, human genomic data (NCBI Taxon ID 9606) is strictly prohibited.
|
|
191
|
+
- **African Union Member States**: Metadata validation strictly enforces the 54 AU member state ISO-3166-1 alpha-2 country codes.
|
|
192
|
+
- **Token Security**: Tokens are stored locally with restrictive file permissions (`0600`) and validated via short-lived cryptographic tokens against the Hub.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
Distributed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# ubuntu-bio
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/ubuntu-bio/)
|
|
4
|
+
[](https://pypi.org/project/ubuntu-bio/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://github.com/Sredeemer/ubuntu-bio-pypi/actions/workflows/ci.yml)
|
|
7
|
+
|
|
8
|
+
The official Python client and command-line interface (`ubio`) for **UbuntuBio** — the African Bioinformatics Data Hub.
|
|
9
|
+
|
|
10
|
+
`ubuntu-bio` enables researchers across the African continent and globally to publish, discover, stream, and version bioinformatics datasets (pathogen genomics, AMR surveillance, agriculture, biodiversity, and metagenomics) with chunk-level deduplication and Git versioning.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Key Features
|
|
15
|
+
|
|
16
|
+
- **Researcher Identity & Namespaces**: Seamless ORCID-authenticated login via browser loopback or RFC 8628 device flow with personal namespace resolution (`@username/dataset-name`).
|
|
17
|
+
- **Genomic Deduplication**: Powered by OpenXet Content-Addressed Storage (CAS) using 64 KiB Content-Defined Chunking (CDC) and Blake3 Merkle trees—identical sequence chunks are stored only once.
|
|
18
|
+
- **Git Versioning**: Every dataset is backed by standard Git commit histories, tags, and branches.
|
|
19
|
+
- **Metadata Standards & Data Governance**: Built-in MIxS checklist validation and African Union ISO-3166 country code verification. Non-human genomics strictly enforced in v1.
|
|
20
|
+
- **Dual Interface**: Full-featured command-line interface (`ubio` or `ubuntu-bio`) and ergonomic Python SDK (`import ubuntu_bio as ub`).
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Install using `pip`:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install ubuntu-bio
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or using `uv`:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
uv add ubuntu-bio
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## CLI Quickstart
|
|
41
|
+
|
|
42
|
+
The package installs two identical CLI entrypoints: `ubio` and `ubuntu-bio`.
|
|
43
|
+
|
|
44
|
+
### 1. Authenticate with ORCID
|
|
45
|
+
Connect your ORCID iD. Opens an interactive browser authorization or falls back to an RFC 8628 device verification code:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
ubio login
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Verify your authenticated researcher profile:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
ubio whoami
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
✓ Authenticated with UbuntuBio Hub
|
|
59
|
+
Name: Dr. Ada Lovelace
|
|
60
|
+
Username: @ada-lovelace
|
|
61
|
+
ORCID: 0000-0002-1825-0097
|
|
62
|
+
Role: researcher
|
|
63
|
+
Server: https://hub.ubuntubio.org
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 2. Create a Dataset Repository
|
|
67
|
+
Create a new dataset repository. If you provide a bare slug, `ubio` automatically prefixes your verified researcher handle:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Automatically creates @ada-lovelace/lassa-surveillance-2024
|
|
71
|
+
ubio create lassa-surveillance-2024 --domain virus --access public
|
|
72
|
+
|
|
73
|
+
# Or specify an institutional / organization namespace
|
|
74
|
+
ubio create pasteur-dakar/lassa-2024 --domain virus --access public
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Supported biological domains:
|
|
78
|
+
`bacteria`, `virus`, `parasite`, `fungus`, `plant`, `animal`, `vector`, `metagenome`, `environmental`.
|
|
79
|
+
|
|
80
|
+
### 3. Upload Datasets
|
|
81
|
+
Upload an entire directory of sequences, alignments, and metadata:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
ubio upload lassa-surveillance-2024 ./my-data --message "Initial release of Lineage II FASTA assemblies"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 4. Search Public Datasets
|
|
88
|
+
Search the catalog using full-text search across pathogen titles, descriptions, and AU member states:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Search for cholera surveillance in Kenya
|
|
92
|
+
ubio search "cholera" --country KE
|
|
93
|
+
|
|
94
|
+
# Search for antimicrobial resistance studies
|
|
95
|
+
ubio search "antimicrobial resistance" --domain bacteria
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 5. Download Datasets & Remote Files
|
|
99
|
+
Download a snapshot of a dataset repository:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
ubio download lassa-surveillance-2024 --output-dir ./local-data
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Download external assets listed in a `remote_files.tsv` manifest with parallel MD5 verification:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
ubio download-remote ./remote_files.tsv --output-dir ./downloads --workers 8
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Python SDK Quickstart
|
|
114
|
+
|
|
115
|
+
Use `ubuntu_bio` directly in your Python analysis pipelines and Jupyter notebooks:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
import ubuntu_bio as ub
|
|
119
|
+
|
|
120
|
+
# 1. Authenticate (using a Personal Access Token or environment variable)
|
|
121
|
+
ub.login(token="ubp_your_personal_access_token")
|
|
122
|
+
|
|
123
|
+
# 2. Check profile
|
|
124
|
+
profile = ub.whoami()
|
|
125
|
+
print(f"Logged in as: @{profile.get('username')}")
|
|
126
|
+
|
|
127
|
+
# 3. Create a repository
|
|
128
|
+
repo = ub.create_repo(
|
|
129
|
+
repo_id="lassa-surveillance-2024",
|
|
130
|
+
domain="virus",
|
|
131
|
+
access="public",
|
|
132
|
+
description="Lassa virus genomic surveillance in West Africa",
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# 4. Upload an entire folder of genomic files
|
|
136
|
+
ub.upload_folder(
|
|
137
|
+
repo_id="lassa-surveillance-2024",
|
|
138
|
+
folder_path="./data",
|
|
139
|
+
message="Add consensus FASTA and GFF annotations",
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
# 5. Download a single file or complete snapshot
|
|
143
|
+
fasta_path = ub.download_file("pasteur-dakar/cholera-2024", "assemblies/sample_01.fasta")
|
|
144
|
+
dataset_dir = ub.snapshot_download("pasteur-dakar/cholera-2024", revision="main")
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Configuration & Environment Variables
|
|
150
|
+
|
|
151
|
+
| Variable | Description | Default |
|
|
152
|
+
| :--- | :--- | :--- |
|
|
153
|
+
| `UBUNTUBIO_SERVER_URL` | UbuntuBio Hub API server URL | `https://hub.ubuntubio.org` |
|
|
154
|
+
| `UBUNTUBIO_API_TOKEN` | Personal Access Token (`ubp_...`) for non-interactive environments / CI | `None` |
|
|
155
|
+
| `UBUNTUBIO_CONFIG_DIR` | Directory storing local credentials cache | `~/.config/ubuntubio` |
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Security & Biological Data Ethics
|
|
160
|
+
|
|
161
|
+
- **Non-Human Data Only**: In compliance with UbuntuBio v1 data governance rules, human genomic data (NCBI Taxon ID 9606) is strictly prohibited.
|
|
162
|
+
- **African Union Member States**: Metadata validation strictly enforces the 54 AU member state ISO-3166-1 alpha-2 country codes.
|
|
163
|
+
- **Token Security**: Tokens are stored locally with restrictive file permissions (`0600`) and validated via short-lived cryptographic tokens against the Hub.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
Distributed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ubuntu-bio"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python client and CLI for UbuntuBio - African Bioinformatics Data Hub"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "UbuntuBio Community", email = "dev@ubuntubio.org" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"bioinformatics",
|
|
17
|
+
"africa",
|
|
18
|
+
"genomics",
|
|
19
|
+
"datasets",
|
|
20
|
+
"open-science",
|
|
21
|
+
"openxet",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 4 - Beta",
|
|
25
|
+
"Intended Audience :: Science/Research",
|
|
26
|
+
"License :: OSI Approved :: MIT License",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.12",
|
|
29
|
+
"Topic :: Scientific/Engineering :: Bio-Informatics",
|
|
30
|
+
]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"httpx>=0.27.2",
|
|
33
|
+
"typer>=0.12.5",
|
|
34
|
+
"rich>=13.9.0",
|
|
35
|
+
"pydantic>=2.9.0",
|
|
36
|
+
"pyyaml>=6.0.2",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
dev = [
|
|
41
|
+
"pytest>=8.3.3",
|
|
42
|
+
"pytest-asyncio>=0.24.0",
|
|
43
|
+
"pytest-cov>=5.0.0",
|
|
44
|
+
"ruff>=0.7.0",
|
|
45
|
+
"mypy>=1.13.0",
|
|
46
|
+
"types-pyyaml>=6.0.12.20240917",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[dependency-groups]
|
|
50
|
+
dev = [
|
|
51
|
+
"pytest>=8.3.3",
|
|
52
|
+
"pytest-asyncio>=0.24.0",
|
|
53
|
+
"pytest-cov>=5.0.0",
|
|
54
|
+
"ruff>=0.7.0",
|
|
55
|
+
"mypy>=1.13.0",
|
|
56
|
+
"types-pyyaml>=6.0.12.20240917",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
[project.scripts]
|
|
61
|
+
ubio = "ubuntu_bio.cli:main"
|
|
62
|
+
ubuntu-bio = "ubuntu_bio.cli:main"
|
|
63
|
+
|
|
64
|
+
[tool.hatch.build.targets.wheel]
|
|
65
|
+
packages = ["src/ubuntu_bio", "src/ubuntubio"]
|
|
66
|
+
|
|
67
|
+
[tool.ruff]
|
|
68
|
+
target-version = "py312"
|
|
69
|
+
line-length = 100
|
|
70
|
+
src = ["src", "tests"]
|
|
71
|
+
|
|
72
|
+
[tool.ruff.lint]
|
|
73
|
+
select = [
|
|
74
|
+
"E", # pycodestyle errors
|
|
75
|
+
"W", # pycodestyle warnings
|
|
76
|
+
"F", # pyflakes
|
|
77
|
+
"I", # isort
|
|
78
|
+
"B", # flake8-bugbear
|
|
79
|
+
"UP", # pyupgrade
|
|
80
|
+
"S", # flake8-bandit
|
|
81
|
+
"C4", # flake8-comprehensions
|
|
82
|
+
"SIM", # flake8-simplify
|
|
83
|
+
"RUF", # Ruff-specific rules
|
|
84
|
+
]
|
|
85
|
+
ignore = [
|
|
86
|
+
"S101", # Allow assert in tests
|
|
87
|
+
"S105", # Possible hardcoded password
|
|
88
|
+
"S106", # Possible hardcoded password
|
|
89
|
+
"S603", # Subprocess calls
|
|
90
|
+
"S607", # Partial executable paths
|
|
91
|
+
"B008", # Function call in argument defaults
|
|
92
|
+
"S324", # MD5 used for remote_files.tsv checksums
|
|
93
|
+
"SIM117", # Allow nested with statements in tests
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
[tool.ruff.format]
|
|
98
|
+
quote-style = "double"
|
|
99
|
+
indent-style = "space"
|
|
100
|
+
|
|
101
|
+
[tool.mypy]
|
|
102
|
+
python_version = "3.12"
|
|
103
|
+
strict = true
|
|
104
|
+
warn_unused_configs = true
|
|
105
|
+
disallow_untyped_defs = true
|
|
106
|
+
disallow_incomplete_defs = true
|
|
107
|
+
check_untyped_defs = true
|
|
108
|
+
no_implicit_optional = true
|
|
109
|
+
warn_redundant_casts = true
|
|
110
|
+
warn_unused_ignores = true
|
|
111
|
+
warn_return_any = true
|
|
112
|
+
show_error_codes = true
|
|
113
|
+
|
|
114
|
+
[tool.pytest.ini_options]
|
|
115
|
+
minversion = "8.0"
|
|
116
|
+
addopts = "-ra -q --strict-markers"
|
|
117
|
+
testpaths = ["tests"]
|
|
118
|
+
asyncio_mode = "auto"
|
|
119
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""UbuntuBio Python Client Library (ubuntu-bio).
|
|
2
|
+
|
|
3
|
+
African Bioinformatics Data Hub client for discovering, downloading,
|
|
4
|
+
publishing, and versioning genomic datasets.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from ubuntu_bio.auth import login, logout, poll_device_token, request_device_code, whoami
|
|
10
|
+
from ubuntu_bio.config import get_cache_dir, get_config_dir, get_hub_url
|
|
11
|
+
from ubuntu_bio.download import download_file, download_remote_files, snapshot_download
|
|
12
|
+
from ubuntu_bio.exceptions import (
|
|
13
|
+
AuthenticationError,
|
|
14
|
+
AuthorizationError,
|
|
15
|
+
ClientValidationError,
|
|
16
|
+
DownloadError,
|
|
17
|
+
RepositoryAlreadyExistsError,
|
|
18
|
+
RepositoryNotFoundError,
|
|
19
|
+
UbuntuBioError,
|
|
20
|
+
UploadError,
|
|
21
|
+
)
|
|
22
|
+
from ubuntu_bio.hub import create_repo, get_commits, get_repo, get_tree, list_repos
|
|
23
|
+
from ubuntu_bio.search import search
|
|
24
|
+
from ubuntu_bio.upload import upload_file, upload_folder
|
|
25
|
+
|
|
26
|
+
__version__ = "0.1.0"
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"AuthenticationError",
|
|
30
|
+
"AuthorizationError",
|
|
31
|
+
"ClientValidationError",
|
|
32
|
+
"DownloadError",
|
|
33
|
+
"RepositoryAlreadyExistsError",
|
|
34
|
+
"RepositoryNotFoundError",
|
|
35
|
+
"UbuntuBioError",
|
|
36
|
+
"UploadError",
|
|
37
|
+
"create_repo",
|
|
38
|
+
"download_file",
|
|
39
|
+
"download_remote_files",
|
|
40
|
+
"get_cache_dir",
|
|
41
|
+
"get_commits",
|
|
42
|
+
"get_config_dir",
|
|
43
|
+
"get_hub_url",
|
|
44
|
+
"get_repo",
|
|
45
|
+
"get_tree",
|
|
46
|
+
"list_repos",
|
|
47
|
+
"login",
|
|
48
|
+
"logout",
|
|
49
|
+
"poll_device_token",
|
|
50
|
+
"request_device_code",
|
|
51
|
+
"search",
|
|
52
|
+
"snapshot_download",
|
|
53
|
+
"upload_file",
|
|
54
|
+
"upload_folder",
|
|
55
|
+
"whoami",
|
|
56
|
+
]
|