ariadnepy 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.
- ariadnepy-0.1.0/.github/workflows/build.yml +48 -0
- ariadnepy-0.1.0/.github/workflows/test.yml +35 -0
- ariadnepy-0.1.0/.gitignore +41 -0
- ariadnepy-0.1.0/PKG-INFO +138 -0
- ariadnepy-0.1.0/README.md +101 -0
- ariadnepy-0.1.0/pyproject.toml +71 -0
- ariadnepy-0.1.0/src/ariadnepy/__init__.py +49 -0
- ariadnepy-0.1.0/src/ariadnepy/_version.py +1 -0
- ariadnepy-0.1.0/src/ariadnepy/anndata/__init__.py +6 -0
- ariadnepy-0.1.0/src/ariadnepy/anndata/_humann.py +102 -0
- ariadnepy-0.1.0/src/ariadnepy/anndata/_modules.py +235 -0
- ariadnepy-0.1.0/src/ariadnepy/core/__init__.py +4 -0
- ariadnepy-0.1.0/src/ariadnepy/core/_download.py +78 -0
- ariadnepy-0.1.0/src/ariadnepy/core/_graph.py +118 -0
- ariadnepy-0.1.0/src/ariadnepy/core/_versions.py +186 -0
- ariadnepy-0.1.0/src/ariadnepy/core/versions.json +42 -0
- ariadnepy-0.1.0/src/ariadnepy/exceptions.py +25 -0
- ariadnepy-0.1.0/src/ariadnepy/graph/__init__.py +4 -0
- ariadnepy-0.1.0/src/ariadnepy/graph/_names.py +248 -0
- ariadnepy-0.1.0/src/ariadnepy/graph/_search.py +3 -0
- ariadnepy-0.1.0/src/ariadnepy/graph/_weave.py +1095 -0
- ariadnepy-0.1.0/src/ariadnepy/io/__init__.py +4 -0
- ariadnepy-0.1.0/src/ariadnepy/io/_ott.py +181 -0
- ariadnepy-0.1.0/src/ariadnepy/io/_sparql.py +235 -0
- ariadnepy-0.1.0/src/ariadnepy/plot/__init__.py +4 -0
- ariadnepy-0.1.0/src/ariadnepy/plot/_custom.py +137 -0
- ariadnepy-0.1.0/src/ariadnepy/plot/_draw.py +163 -0
- ariadnepy-0.1.0/src/ariadnepy/plot/_utils.py +39 -0
- ariadnepy-0.1.0/src/ariadnepy/plot/exceptions.py +8 -0
- ariadnepy-0.1.0/src/ariadnepy/resources/__init__.py +4 -0
- ariadnepy-0.1.0/src/ariadnepy/resources/_cache.py +187 -0
- ariadnepy-0.1.0/src/ariadnepy/resources/_data.py +30 -0
- ariadnepy-0.1.0/src/ariadnepy/resources/_parsers.py +106 -0
- ariadnepy-0.1.0/src/ariadnepy/resources/_rds.py +103 -0
- ariadnepy-0.1.0/src/ariadnepy/resources/data/butyrate.csv +17 -0
- ariadnepy-0.1.0/tests/conftest.py +0 -0
- ariadnepy-0.1.0/tests/test.py +15 -0
- ariadnepy-0.1.0/tests/test_anndata/__init__.py +0 -0
- ariadnepy-0.1.0/tests/test_anndata/test_modules.py +350 -0
- ariadnepy-0.1.0/tests/test_core/test_download.py +120 -0
- ariadnepy-0.1.0/tests/test_core/test_graph/test_add_resource.py +130 -0
- ariadnepy-0.1.0/tests/test_core/test_graph/test_names.py +158 -0
- ariadnepy-0.1.0/tests/test_core/test_graph/test_plot.py +108 -0
- ariadnepy-0.1.0/tests/test_core/test_graph/test_search.py +142 -0
- ariadnepy-0.1.0/tests/test_core/test_graph/test_weave.py +501 -0
- ariadnepy-0.1.0/tests/test_core/test_graph.py +154 -0
- ariadnepy-0.1.0/tests/test_core/test_versions.py +157 -0
- ariadnepy-0.1.0/tests/test_utils.py +77 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*" # triggers on version tags like v0.1.0, v1.2.3
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build distribution
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Set up Python
|
|
16
|
+
uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
|
|
20
|
+
- name: Install build tool
|
|
21
|
+
run: pip install build
|
|
22
|
+
|
|
23
|
+
- name: Build wheel and source distribution
|
|
24
|
+
run: python -m build
|
|
25
|
+
|
|
26
|
+
- name: Upload distributions as artifact
|
|
27
|
+
uses: actions/upload-artifact@v4
|
|
28
|
+
with:
|
|
29
|
+
name: dist
|
|
30
|
+
path: dist/
|
|
31
|
+
|
|
32
|
+
publish:
|
|
33
|
+
name: Publish to PyPI
|
|
34
|
+
needs: build
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
environment: pypi
|
|
37
|
+
permissions:
|
|
38
|
+
id-token: write # required for Trusted Publisher (OIDC) — no API token needed
|
|
39
|
+
|
|
40
|
+
steps:
|
|
41
|
+
- name: Download distributions
|
|
42
|
+
uses: actions/download-artifact@v4
|
|
43
|
+
with:
|
|
44
|
+
name: dist
|
|
45
|
+
path: dist/
|
|
46
|
+
|
|
47
|
+
- name: Publish to PyPI
|
|
48
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: ${{ matrix.os }} / Python ${{ matrix.python-version }}
|
|
12
|
+
runs-on: ${{ matrix.os }}
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
17
|
+
python-version: ["3.12"]
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: ${{ matrix.python-version }}
|
|
26
|
+
cache: pip
|
|
27
|
+
|
|
28
|
+
- name: Install package and dev dependencies
|
|
29
|
+
run: pip install -e ".[dev]"
|
|
30
|
+
|
|
31
|
+
- name: Lint with ruff
|
|
32
|
+
run: ruff check src/
|
|
33
|
+
|
|
34
|
+
- name: Run tests
|
|
35
|
+
run: pytest --tb=short -q
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.pyo
|
|
5
|
+
*.pyd
|
|
6
|
+
*.so
|
|
7
|
+
*.egg
|
|
8
|
+
*.egg-info/
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
.eggs/
|
|
12
|
+
|
|
13
|
+
# Virtual environments
|
|
14
|
+
.venv/
|
|
15
|
+
venv/
|
|
16
|
+
env/
|
|
17
|
+
|
|
18
|
+
# Testing & coverage
|
|
19
|
+
.pytest_cache/
|
|
20
|
+
.coverage
|
|
21
|
+
htmlcov/
|
|
22
|
+
.tox/
|
|
23
|
+
|
|
24
|
+
# Type checkers
|
|
25
|
+
.mypy_cache/
|
|
26
|
+
.ruff_cache/
|
|
27
|
+
|
|
28
|
+
# ariadne cache
|
|
29
|
+
.ariadne_cache/
|
|
30
|
+
|
|
31
|
+
# Jupyter
|
|
32
|
+
.ipynb_checkpoints/
|
|
33
|
+
*.ipynb
|
|
34
|
+
|
|
35
|
+
# IDE
|
|
36
|
+
.vscode/
|
|
37
|
+
.idea/
|
|
38
|
+
|
|
39
|
+
# OS
|
|
40
|
+
.DS_Store
|
|
41
|
+
Thumbs.db
|
ariadnepy-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ariadnepy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python interface to the ariadne multi-omic knowledge graph
|
|
5
|
+
Project-URL: Homepage, https://github.com/Minotau-R/ariadne
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/Minotau-R/ariadne/issues
|
|
7
|
+
Author-email: Aditi <abhiyan@analyticsandsociety.com>
|
|
8
|
+
License: Artistic-2.0
|
|
9
|
+
Keywords: bioinformatics,graph,knowledge-graph,microbiome,multi-omics
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: Artistic License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Requires-Dist: igraph>=0.11
|
|
20
|
+
Requires-Dist: matplotlib>=3.7
|
|
21
|
+
Requires-Dist: pandas>=2.0
|
|
22
|
+
Requires-Dist: platformdirs>=3.0
|
|
23
|
+
Requires-Dist: pyarrow>=14.0
|
|
24
|
+
Requires-Dist: pyreadr>=0.5
|
|
25
|
+
Requires-Dist: requests>=2.28
|
|
26
|
+
Requires-Dist: scipy>=1.10
|
|
27
|
+
Provides-Extra: anndata
|
|
28
|
+
Requires-Dist: anndata>=0.10; extra == 'anndata'
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
31
|
+
Requires-Dist: pandas-stubs; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: responses>=0.25; extra == 'dev'
|
|
35
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
# ariadnePy
|
|
39
|
+
|
|
40
|
+
Python interface to the [ariadne](https://github.com/Minotau-R/ariadne) multi-omic knowledge graph.
|
|
41
|
+
|
|
42
|
+
ariadnePy brings the biological database integration and graph-theory tools of the R package **ariadne** to Python users. It downloads biological resources (Gene Ontology, KEGG, UniProt, BugSigDB, ChocoPhlAn, and more) from [Zenodo](https://zenodo.org) and assembles them into a single [NetworkX](https://networkx.org) `MultiDiGraph` that can be queried, filtered, and visualised directly in Python.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install ariadnepy
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
To also read RDS files (required for MSigDB):
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install "ariadnepy[rds]"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
For development:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/Minotau-R/ariadnePy
|
|
62
|
+
cd ariadnePy
|
|
63
|
+
pip install -e ".[dev]"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Quick start
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
import ariadnepy
|
|
72
|
+
|
|
73
|
+
# Build the knowledge graph using default resource versions
|
|
74
|
+
# (downloads GML files from Zenodo on first run; cached locally afterwards)
|
|
75
|
+
g = ariadnepy.ariadne()
|
|
76
|
+
|
|
77
|
+
print(g)
|
|
78
|
+
# MultiDiGraph with N nodes and M edges
|
|
79
|
+
|
|
80
|
+
# List all available resource versions
|
|
81
|
+
df = ariadnepy.list_resource_versions()
|
|
82
|
+
print(df.head())
|
|
83
|
+
|
|
84
|
+
# Select specific versions
|
|
85
|
+
g = ariadnepy.ariadne(versions={"GO": "2026-01-23", "KEGG": "latest"})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
<!-- ## Supported resources
|
|
91
|
+
|
|
92
|
+
| Resource | Description |
|
|
93
|
+
|---|---|
|
|
94
|
+
| GO | Gene Ontology |
|
|
95
|
+
| KEGG | KEGG Pathways & Modules |
|
|
96
|
+
| UniProt | UniProt protein database |
|
|
97
|
+
| OTT | Open Tree of Life Taxonomy |
|
|
98
|
+
| Rhea | Rhea biochemical reactions |
|
|
99
|
+
| WoL | Web of Life phylogenetic tree |
|
|
100
|
+
| TIGRFAMs | TIGRFAM protein families |
|
|
101
|
+
| GM | Gut Metabolome modules |
|
|
102
|
+
| BugSigDB | Bug Signatures Database |
|
|
103
|
+
| ChocoPhlAn | MetaPhlAn gene families |
|
|
104
|
+
| MSigDB | Molecular Signatures Database |
|
|
105
|
+
|
|
106
|
+
--- -->
|
|
107
|
+
|
|
108
|
+
## Project structure
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
ariadnePy/
|
|
112
|
+
├── src/
|
|
113
|
+
│ └── ariadnepy/
|
|
114
|
+
│ ├── __init__.py # public API
|
|
115
|
+
│ ├── _core.py # ariadne() graph builder
|
|
116
|
+
│ ├── _cache.py # resource downloading & caching
|
|
117
|
+
│ ├── _utils.py # utility functions
|
|
118
|
+
│ └── _custom.py # custom resource support
|
|
119
|
+
├── tests/
|
|
120
|
+
│ ├── test_core.py
|
|
121
|
+
│ ├── test_cache.py
|
|
122
|
+
│ └── test_utils.py
|
|
123
|
+
├── pyproject.toml
|
|
124
|
+
└── README.md
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Running tests
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
pytest
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# ariadnePy
|
|
2
|
+
|
|
3
|
+
Python interface to the [ariadne](https://github.com/Minotau-R/ariadne) multi-omic knowledge graph.
|
|
4
|
+
|
|
5
|
+
ariadnePy brings the biological database integration and graph-theory tools of the R package **ariadne** to Python users. It downloads biological resources (Gene Ontology, KEGG, UniProt, BugSigDB, ChocoPhlAn, and more) from [Zenodo](https://zenodo.org) and assembles them into a single [NetworkX](https://networkx.org) `MultiDiGraph` that can be queried, filtered, and visualised directly in Python.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install ariadnepy
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
To also read RDS files (required for MSigDB):
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install "ariadnepy[rds]"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For development:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
git clone https://github.com/Minotau-R/ariadnePy
|
|
25
|
+
cd ariadnePy
|
|
26
|
+
pip install -e ".[dev]"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Quick start
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import ariadnepy
|
|
35
|
+
|
|
36
|
+
# Build the knowledge graph using default resource versions
|
|
37
|
+
# (downloads GML files from Zenodo on first run; cached locally afterwards)
|
|
38
|
+
g = ariadnepy.ariadne()
|
|
39
|
+
|
|
40
|
+
print(g)
|
|
41
|
+
# MultiDiGraph with N nodes and M edges
|
|
42
|
+
|
|
43
|
+
# List all available resource versions
|
|
44
|
+
df = ariadnepy.list_resource_versions()
|
|
45
|
+
print(df.head())
|
|
46
|
+
|
|
47
|
+
# Select specific versions
|
|
48
|
+
g = ariadnepy.ariadne(versions={"GO": "2026-01-23", "KEGG": "latest"})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
<!-- ## Supported resources
|
|
54
|
+
|
|
55
|
+
| Resource | Description |
|
|
56
|
+
|---|---|
|
|
57
|
+
| GO | Gene Ontology |
|
|
58
|
+
| KEGG | KEGG Pathways & Modules |
|
|
59
|
+
| UniProt | UniProt protein database |
|
|
60
|
+
| OTT | Open Tree of Life Taxonomy |
|
|
61
|
+
| Rhea | Rhea biochemical reactions |
|
|
62
|
+
| WoL | Web of Life phylogenetic tree |
|
|
63
|
+
| TIGRFAMs | TIGRFAM protein families |
|
|
64
|
+
| GM | Gut Metabolome modules |
|
|
65
|
+
| BugSigDB | Bug Signatures Database |
|
|
66
|
+
| ChocoPhlAn | MetaPhlAn gene families |
|
|
67
|
+
| MSigDB | Molecular Signatures Database |
|
|
68
|
+
|
|
69
|
+
--- -->
|
|
70
|
+
|
|
71
|
+
## Project structure
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
ariadnePy/
|
|
75
|
+
├── src/
|
|
76
|
+
│ └── ariadnepy/
|
|
77
|
+
│ ├── __init__.py # public API
|
|
78
|
+
│ ├── _core.py # ariadne() graph builder
|
|
79
|
+
│ ├── _cache.py # resource downloading & caching
|
|
80
|
+
│ ├── _utils.py # utility functions
|
|
81
|
+
│ └── _custom.py # custom resource support
|
|
82
|
+
├── tests/
|
|
83
|
+
│ ├── test_core.py
|
|
84
|
+
│ ├── test_cache.py
|
|
85
|
+
│ └── test_utils.py
|
|
86
|
+
├── pyproject.toml
|
|
87
|
+
└── README.md
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Running tests
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pytest
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ariadnepy"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python interface to the ariadne multi-omic knowledge graph"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "Artistic-2.0" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Aditi", email = "abhiyan@analyticsandsociety.com" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["bioinformatics", "multi-omics", "graph", "knowledge-graph", "microbiome"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"License :: OSI Approved :: Artistic License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Bio-Informatics",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"igraph>=0.11",
|
|
28
|
+
"pandas>=2.0",
|
|
29
|
+
"requests>=2.28",
|
|
30
|
+
"platformdirs>=3.0",
|
|
31
|
+
"pyarrow>=14.0",
|
|
32
|
+
"pyreadr>=0.5",
|
|
33
|
+
"scipy>=1.10",
|
|
34
|
+
"matplotlib>=3.7",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
anndata = ["anndata>=0.10"]
|
|
39
|
+
dev = [
|
|
40
|
+
"pytest>=8.0",
|
|
41
|
+
"pytest-cov>=5.0",
|
|
42
|
+
"responses>=0.25",
|
|
43
|
+
"ruff>=0.4",
|
|
44
|
+
"mypy>=1.10",
|
|
45
|
+
"pandas-stubs",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
Homepage = "https://github.com/Minotau-R/ariadne"
|
|
50
|
+
"Bug Tracker" = "https://github.com/Minotau-R/ariadne/issues"
|
|
51
|
+
|
|
52
|
+
[tool.hatch.build.targets.wheel]
|
|
53
|
+
packages = ["src/ariadnepy"]
|
|
54
|
+
|
|
55
|
+
[tool.pytest.ini_options]
|
|
56
|
+
testpaths = ["tests"]
|
|
57
|
+
addopts = "--tb=short -q"
|
|
58
|
+
|
|
59
|
+
[tool.ruff]
|
|
60
|
+
src = ["src"]
|
|
61
|
+
line-length = 100
|
|
62
|
+
target-version = "py310"
|
|
63
|
+
|
|
64
|
+
[tool.ruff.lint]
|
|
65
|
+
select = ["E", "F", "W", "I", "UP", "B", "C4", "PT"]
|
|
66
|
+
ignore = ["B008"]
|
|
67
|
+
|
|
68
|
+
[tool.mypy]
|
|
69
|
+
python_version = "3.10"
|
|
70
|
+
strict = true
|
|
71
|
+
warn_unused_ignores = true
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""ariadnepy — Python extension of the ariadne multi-omic graph package."""
|
|
2
|
+
|
|
3
|
+
from ariadnepy._version import __version__
|
|
4
|
+
from ariadnepy.anndata._humann import process_gene_families
|
|
5
|
+
from ariadnepy.anndata._modules import add_modules, get_modules
|
|
6
|
+
from ariadnepy.core._graph import ariadne
|
|
7
|
+
from ariadnepy.core._versions import list_resource_versions
|
|
8
|
+
from ariadnepy.exceptions import (
|
|
9
|
+
AriadneCacheError,
|
|
10
|
+
AriadneDownloadError,
|
|
11
|
+
AriadneError,
|
|
12
|
+
AriadneParseError,
|
|
13
|
+
AriadnePathError,
|
|
14
|
+
AriadneVersionError,
|
|
15
|
+
)
|
|
16
|
+
from ariadnepy.graph._names import link_names
|
|
17
|
+
from ariadnepy.graph._weave import draw_path, search_path, weave_complex, weave_path
|
|
18
|
+
from ariadnepy.plot._custom import add_resource
|
|
19
|
+
from ariadnepy.plot._draw import plot_path
|
|
20
|
+
from ariadnepy.resources._data import load_butyrate
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"__version__",
|
|
24
|
+
# exceptions
|
|
25
|
+
"AriadneError",
|
|
26
|
+
"AriadneDownloadError",
|
|
27
|
+
"AriadneVersionError",
|
|
28
|
+
"AriadneParseError",
|
|
29
|
+
"AriadnePathError",
|
|
30
|
+
"AriadneCacheError",
|
|
31
|
+
# core
|
|
32
|
+
"ariadne",
|
|
33
|
+
"list_resource_versions",
|
|
34
|
+
# graph traversal
|
|
35
|
+
"weave_path",
|
|
36
|
+
"weave_complex",
|
|
37
|
+
"draw_path",
|
|
38
|
+
"search_path",
|
|
39
|
+
"link_names",
|
|
40
|
+
# plot
|
|
41
|
+
"plot_path",
|
|
42
|
+
"add_resource",
|
|
43
|
+
# data
|
|
44
|
+
"load_butyrate",
|
|
45
|
+
# anndata integration
|
|
46
|
+
"add_modules",
|
|
47
|
+
"get_modules",
|
|
48
|
+
"process_gene_families",
|
|
49
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""AnnData integration — Python equivalent of R's SummarizedExperiment helpers."""
|
|
2
|
+
|
|
3
|
+
from ariadnepy.anndata._humann import process_gene_families
|
|
4
|
+
from ariadnepy.anndata._modules import add_modules, get_modules
|
|
5
|
+
|
|
6
|
+
__all__ = ["add_modules", "get_modules", "process_gene_families"]
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""process_gene_families — mirrors R's processGeneFamilies in ariadne.
|
|
2
|
+
|
|
3
|
+
Prepares an AnnData object containing HUMAnN gene families by parsing
|
|
4
|
+
the feature names into uniref90, taxname, genus, and species columns
|
|
5
|
+
and adding them to adata.var.
|
|
6
|
+
|
|
7
|
+
R equivalent:
|
|
8
|
+
processGeneFamilies(genes)
|
|
9
|
+
|
|
10
|
+
HUMAnN feature name format:
|
|
11
|
+
UniRef90_XXXXXX|g__Genus.s__species
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from typing import TYPE_CHECKING
|
|
16
|
+
|
|
17
|
+
import pandas as pd
|
|
18
|
+
|
|
19
|
+
from ariadnepy.exceptions import AriadneError
|
|
20
|
+
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
from anndata import AnnData
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _require_anndata() -> None:
|
|
26
|
+
try:
|
|
27
|
+
import anndata # noqa: F401
|
|
28
|
+
except ImportError:
|
|
29
|
+
raise AriadneError(
|
|
30
|
+
"'anndata' is required for process_gene_families. "
|
|
31
|
+
"Install with: pip install anndata"
|
|
32
|
+
) from None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def process_gene_families(adata: AnnData) -> AnnData:
|
|
36
|
+
"""Parse HUMAnN gene family feature names and add metadata to adata.var.
|
|
37
|
+
|
|
38
|
+
Filters to features that contain a ``|`` separator and do not contain
|
|
39
|
+
``"unclassified"``, then splits the name into four columns:
|
|
40
|
+
``uniref90``, ``taxname``, ``genus``, and ``species``.
|
|
41
|
+
|
|
42
|
+
Equivalent to R's ``processGeneFamilies(genes)``.
|
|
43
|
+
|
|
44
|
+
Parameters
|
|
45
|
+
----------
|
|
46
|
+
adata:
|
|
47
|
+
AnnData object whose ``var_names`` follow the HUMAnN format
|
|
48
|
+
``UniRef90_XXXXXX|g__Genus.s__species``.
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
-------
|
|
52
|
+
AnnData
|
|
53
|
+
Filtered AnnData (unclassified and non-stratified rows removed)
|
|
54
|
+
with four new columns in ``adata.var``:
|
|
55
|
+
``uniref90``, ``taxname``, ``genus``, ``species``.
|
|
56
|
+
|
|
57
|
+
Examples
|
|
58
|
+
--------
|
|
59
|
+
>>> from ariadnepy import process_gene_families
|
|
60
|
+
>>> genes = process_gene_families(genes)
|
|
61
|
+
>>> genes.var.head()
|
|
62
|
+
"""
|
|
63
|
+
_require_anndata()
|
|
64
|
+
|
|
65
|
+
names = pd.Series(adata.var_names, index=adata.var_names)
|
|
66
|
+
|
|
67
|
+
# Keep only stratified (contains |) and classified features
|
|
68
|
+
mask = names.str.contains("|", regex=False) & ~names.str.contains(
|
|
69
|
+
"unclassified", case=False, regex=False
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
if not mask.any():
|
|
73
|
+
raise AriadneError(
|
|
74
|
+
"No valid HUMAnN gene family features found. "
|
|
75
|
+
"Expected feature names like 'UniRef90_XXXXX|g__Genus.s__species'."
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
adata = adata[:, mask].copy()
|
|
79
|
+
names = pd.Series(adata.var_names, index=adata.var_names)
|
|
80
|
+
|
|
81
|
+
# Split on | to get uniref90 and taxname
|
|
82
|
+
split_gene = names.str.split("|", n=1, expand=True)
|
|
83
|
+
split_gene.columns = ["uniref90", "taxname"]
|
|
84
|
+
split_gene.index = adata.var_names
|
|
85
|
+
|
|
86
|
+
# Split taxname on . to get genus and species
|
|
87
|
+
split_tax = split_gene["taxname"].str.split(".", n=1, expand=True)
|
|
88
|
+
split_tax.columns = ["genus", "species"]
|
|
89
|
+
split_tax.index = adata.var_names
|
|
90
|
+
|
|
91
|
+
# Append to existing var
|
|
92
|
+
for col in ["uniref90", "taxname", "genus", "species"]:
|
|
93
|
+
if col in adata.var.columns:
|
|
94
|
+
import warnings
|
|
95
|
+
warnings.warn(f"Column '{col}' in adata.var was replaced.", UserWarning, stacklevel=2)
|
|
96
|
+
|
|
97
|
+
adata.var = pd.concat(
|
|
98
|
+
[adata.var, split_gene[["uniref90", "taxname"]], split_tax],
|
|
99
|
+
axis=1,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
return adata
|