microcafe 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.
- microcafe-0.1.0/.vscode/settings.json +3 -0
- microcafe-0.1.0/PKG-INFO +197 -0
- microcafe-0.1.0/README.md +166 -0
- microcafe-0.1.0/pyproject.toml +59 -0
- microcafe-0.1.0/src/microcafe/__init__.py +54 -0
- microcafe-0.1.0/src/microcafe/cli.py +354 -0
- microcafe-0.1.0/src/microcafe/client.py +396 -0
- microcafe-0.1.0/src/microcafe/exceptions.py +49 -0
- microcafe-0.1.0/src/microcafe/models.py +145 -0
- microcafe-0.1.0/src/microcafe/test_api.py +68 -0
- microcafe-0.1.0/src/microcafe/test_sdk.py +345 -0
microcafe-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: microcafe
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for microCafe - AI-powered microbiome analysis
|
|
5
|
+
Project-URL: Homepage, https://microcafe.ai
|
|
6
|
+
Project-URL: Documentation, https://docs.microcafe.ai
|
|
7
|
+
Project-URL: Repository, https://github.com/microcafe/microcafe-python
|
|
8
|
+
Project-URL: Issues, https://github.com/microcafe/microcafe-python/issues
|
|
9
|
+
Author-email: microCafe <support@microcafe.ai>
|
|
10
|
+
License: MIT
|
|
11
|
+
Keywords: 16S,api,bioinformatics,genomics,metagenomics,microbiome
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Requires-Dist: click>=8.0.0
|
|
24
|
+
Requires-Dist: requests>=2.28.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# microCafe Python SDK
|
|
33
|
+
|
|
34
|
+
Official Python SDK for [microCafe](https://microcafe.ai) — AI-powered microbiome analysis.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install microcafe
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from microcafe import Client
|
|
46
|
+
|
|
47
|
+
# Auto-reads API key from env var or ~/.microcafe/config.json
|
|
48
|
+
client = Client()
|
|
49
|
+
|
|
50
|
+
# Or pass explicitly
|
|
51
|
+
client = Client(api_key="mc_your_key_here")
|
|
52
|
+
|
|
53
|
+
# Classify a single sequence
|
|
54
|
+
result = client.classify("ATCGATCGATCG...")
|
|
55
|
+
print(result.predictions[0].genus) # "Bacteroides"
|
|
56
|
+
print(result.predictions[0].confidence) # 0.95
|
|
57
|
+
|
|
58
|
+
# Classify a file (submits, polls, returns abundance)
|
|
59
|
+
summary = client.classify_file("sequences.fq")
|
|
60
|
+
print(summary.summary.raw_counts) # {"Bacteroides": 150, "Prevotella": 80}
|
|
61
|
+
print(summary.summary.relative_abundance) # {"Bacteroides": 65.2, "Prevotella": 34.8}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## CLI Usage
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Save API key (stored in ~/.microcafe/config.json)
|
|
68
|
+
microcafe configure mc_your_key_here
|
|
69
|
+
|
|
70
|
+
# Classify a single sequence
|
|
71
|
+
microcafe classify "ATCGATCGATCG..."
|
|
72
|
+
microcafe classify "ATCGATCG..." --format json
|
|
73
|
+
|
|
74
|
+
# Classify a file (submits, shows progress bar, returns abundance)
|
|
75
|
+
microcafe classify-file sequences.fq
|
|
76
|
+
microcafe classify-file sequences.fq --output results.json
|
|
77
|
+
microcafe classify-file sequences.fq --format json
|
|
78
|
+
|
|
79
|
+
# Check job status
|
|
80
|
+
microcafe status <job_id>
|
|
81
|
+
microcafe status <job_id> --wait # poll until complete
|
|
82
|
+
|
|
83
|
+
# Get abundance table
|
|
84
|
+
microcafe abundance <job_id>
|
|
85
|
+
microcafe abundance <job_id> --top 20 # show top 20 genera
|
|
86
|
+
microcafe abundance <job_id> --output abundance.json
|
|
87
|
+
|
|
88
|
+
# Get per-sequence predictions
|
|
89
|
+
microcafe predictions <job_id>
|
|
90
|
+
microcafe predictions <job_id> --output predictions.json
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Python API Reference
|
|
94
|
+
|
|
95
|
+
### Client
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from microcafe import Client
|
|
99
|
+
|
|
100
|
+
# Auto-resolves API key from env var or config file
|
|
101
|
+
client = Client()
|
|
102
|
+
|
|
103
|
+
# Or configure explicitly
|
|
104
|
+
client = Client(
|
|
105
|
+
api_key="mc_xxx", # Optional if env var or config file is set
|
|
106
|
+
base_url="https://...", # Optional, default: https://microcafe.ai/api
|
|
107
|
+
timeout=300 # Optional, request timeout in seconds
|
|
108
|
+
)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Single Sequence Classification
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
result = client.classify(
|
|
115
|
+
sequence="ATCGATCG...",
|
|
116
|
+
top_k=5 # Number of top predictions
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
print(result.sequence_length)
|
|
120
|
+
for pred in result.predictions:
|
|
121
|
+
print(f"{pred.genus}: {pred.confidence}")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### File Classification
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
# Submits file, polls for progress, returns abundance summary
|
|
128
|
+
summary = client.classify_file(
|
|
129
|
+
file_path="sequences.fq",
|
|
130
|
+
top_k=5,
|
|
131
|
+
poll_interval=2.0, # Seconds between status checks
|
|
132
|
+
on_progress=lambda s: print(f"{s.progress}%") # Optional callback
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
print(summary.summary.raw_counts)
|
|
136
|
+
print(summary.summary.relative_abundance)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Job Management
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
# Submit file (returns immediately)
|
|
143
|
+
job = client.classify_file_async("sequences.fq")
|
|
144
|
+
print(job.job_id)
|
|
145
|
+
|
|
146
|
+
# Check status
|
|
147
|
+
status = client.get_job_status(job.job_id)
|
|
148
|
+
print(f"{status.progress}% — {status.sequences_processed}/{status.total_sequences}")
|
|
149
|
+
|
|
150
|
+
# Wait for completion
|
|
151
|
+
final_status = client.wait_for_job(job.job_id)
|
|
152
|
+
|
|
153
|
+
# Get results
|
|
154
|
+
abundance = client.get_job_summary(job.job_id) # abundance table
|
|
155
|
+
predictions = client.get_job_results(job.job_id) # per-sequence predictions
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Environment Variables
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
export MICROCAFE_API_KEY=mc_your_key_here
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
# No need to pass api_key if env var is set
|
|
166
|
+
client = Client()
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Error Handling
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
from microcafe import Client, MicroCafeError, RateLimitError, AuthenticationError
|
|
173
|
+
|
|
174
|
+
try:
|
|
175
|
+
result = client.classify("ATCG...")
|
|
176
|
+
except RateLimitError as e:
|
|
177
|
+
print(f"Rate limited. Retry after {e.retry_after} seconds")
|
|
178
|
+
except AuthenticationError:
|
|
179
|
+
print("Invalid API key")
|
|
180
|
+
except MicroCafeError as e:
|
|
181
|
+
print(f"Error: {e.message}")
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Supported File Formats
|
|
185
|
+
|
|
186
|
+
- FASTA (`.fasta`, `.fa`)
|
|
187
|
+
- FASTQ (`.fastq`, `.fq`)
|
|
188
|
+
|
|
189
|
+
## Links
|
|
190
|
+
|
|
191
|
+
- [microCafe Website](https://microcafe.ai)
|
|
192
|
+
- [API Documentation](https://microcafe.ai/api/docs)
|
|
193
|
+
- [Get API Key](https://microcafe.ai/dashboard/api-console)
|
|
194
|
+
|
|
195
|
+
## License
|
|
196
|
+
|
|
197
|
+
MIT
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# microCafe Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [microCafe](https://microcafe.ai) — AI-powered microbiome analysis.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install microcafe
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from microcafe import Client
|
|
15
|
+
|
|
16
|
+
# Auto-reads API key from env var or ~/.microcafe/config.json
|
|
17
|
+
client = Client()
|
|
18
|
+
|
|
19
|
+
# Or pass explicitly
|
|
20
|
+
client = Client(api_key="mc_your_key_here")
|
|
21
|
+
|
|
22
|
+
# Classify a single sequence
|
|
23
|
+
result = client.classify("ATCGATCGATCG...")
|
|
24
|
+
print(result.predictions[0].genus) # "Bacteroides"
|
|
25
|
+
print(result.predictions[0].confidence) # 0.95
|
|
26
|
+
|
|
27
|
+
# Classify a file (submits, polls, returns abundance)
|
|
28
|
+
summary = client.classify_file("sequences.fq")
|
|
29
|
+
print(summary.summary.raw_counts) # {"Bacteroides": 150, "Prevotella": 80}
|
|
30
|
+
print(summary.summary.relative_abundance) # {"Bacteroides": 65.2, "Prevotella": 34.8}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## CLI Usage
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Save API key (stored in ~/.microcafe/config.json)
|
|
37
|
+
microcafe configure mc_your_key_here
|
|
38
|
+
|
|
39
|
+
# Classify a single sequence
|
|
40
|
+
microcafe classify "ATCGATCGATCG..."
|
|
41
|
+
microcafe classify "ATCGATCG..." --format json
|
|
42
|
+
|
|
43
|
+
# Classify a file (submits, shows progress bar, returns abundance)
|
|
44
|
+
microcafe classify-file sequences.fq
|
|
45
|
+
microcafe classify-file sequences.fq --output results.json
|
|
46
|
+
microcafe classify-file sequences.fq --format json
|
|
47
|
+
|
|
48
|
+
# Check job status
|
|
49
|
+
microcafe status <job_id>
|
|
50
|
+
microcafe status <job_id> --wait # poll until complete
|
|
51
|
+
|
|
52
|
+
# Get abundance table
|
|
53
|
+
microcafe abundance <job_id>
|
|
54
|
+
microcafe abundance <job_id> --top 20 # show top 20 genera
|
|
55
|
+
microcafe abundance <job_id> --output abundance.json
|
|
56
|
+
|
|
57
|
+
# Get per-sequence predictions
|
|
58
|
+
microcafe predictions <job_id>
|
|
59
|
+
microcafe predictions <job_id> --output predictions.json
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Python API Reference
|
|
63
|
+
|
|
64
|
+
### Client
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from microcafe import Client
|
|
68
|
+
|
|
69
|
+
# Auto-resolves API key from env var or config file
|
|
70
|
+
client = Client()
|
|
71
|
+
|
|
72
|
+
# Or configure explicitly
|
|
73
|
+
client = Client(
|
|
74
|
+
api_key="mc_xxx", # Optional if env var or config file is set
|
|
75
|
+
base_url="https://...", # Optional, default: https://microcafe.ai/api
|
|
76
|
+
timeout=300 # Optional, request timeout in seconds
|
|
77
|
+
)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Single Sequence Classification
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
result = client.classify(
|
|
84
|
+
sequence="ATCGATCG...",
|
|
85
|
+
top_k=5 # Number of top predictions
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
print(result.sequence_length)
|
|
89
|
+
for pred in result.predictions:
|
|
90
|
+
print(f"{pred.genus}: {pred.confidence}")
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### File Classification
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
# Submits file, polls for progress, returns abundance summary
|
|
97
|
+
summary = client.classify_file(
|
|
98
|
+
file_path="sequences.fq",
|
|
99
|
+
top_k=5,
|
|
100
|
+
poll_interval=2.0, # Seconds between status checks
|
|
101
|
+
on_progress=lambda s: print(f"{s.progress}%") # Optional callback
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
print(summary.summary.raw_counts)
|
|
105
|
+
print(summary.summary.relative_abundance)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Job Management
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
# Submit file (returns immediately)
|
|
112
|
+
job = client.classify_file_async("sequences.fq")
|
|
113
|
+
print(job.job_id)
|
|
114
|
+
|
|
115
|
+
# Check status
|
|
116
|
+
status = client.get_job_status(job.job_id)
|
|
117
|
+
print(f"{status.progress}% — {status.sequences_processed}/{status.total_sequences}")
|
|
118
|
+
|
|
119
|
+
# Wait for completion
|
|
120
|
+
final_status = client.wait_for_job(job.job_id)
|
|
121
|
+
|
|
122
|
+
# Get results
|
|
123
|
+
abundance = client.get_job_summary(job.job_id) # abundance table
|
|
124
|
+
predictions = client.get_job_results(job.job_id) # per-sequence predictions
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Environment Variables
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
export MICROCAFE_API_KEY=mc_your_key_here
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
# No need to pass api_key if env var is set
|
|
135
|
+
client = Client()
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Error Handling
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from microcafe import Client, MicroCafeError, RateLimitError, AuthenticationError
|
|
142
|
+
|
|
143
|
+
try:
|
|
144
|
+
result = client.classify("ATCG...")
|
|
145
|
+
except RateLimitError as e:
|
|
146
|
+
print(f"Rate limited. Retry after {e.retry_after} seconds")
|
|
147
|
+
except AuthenticationError:
|
|
148
|
+
print("Invalid API key")
|
|
149
|
+
except MicroCafeError as e:
|
|
150
|
+
print(f"Error: {e.message}")
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Supported File Formats
|
|
154
|
+
|
|
155
|
+
- FASTA (`.fasta`, `.fa`)
|
|
156
|
+
- FASTQ (`.fastq`, `.fq`)
|
|
157
|
+
|
|
158
|
+
## Links
|
|
159
|
+
|
|
160
|
+
- [microCafe Website](https://microcafe.ai)
|
|
161
|
+
- [API Documentation](https://microcafe.ai/api/docs)
|
|
162
|
+
- [Get API Key](https://microcafe.ai/dashboard/api-console)
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "microcafe"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python SDK for microCafe - AI-powered microbiome analysis"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "microCafe", email = "support@microcafe.ai"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["microbiome", "bioinformatics", "genomics", "16S", "metagenomics", "api"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.8",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Topic :: Scientific/Engineering :: Bio-Informatics",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"requests>=2.28.0",
|
|
30
|
+
"click>=8.0.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = [
|
|
35
|
+
"pytest>=7.0.0",
|
|
36
|
+
"pytest-cov>=4.0.0",
|
|
37
|
+
"black>=23.0.0",
|
|
38
|
+
"ruff>=0.1.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.scripts]
|
|
42
|
+
microcafe = "microcafe.cli:main"
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Homepage = "https://microcafe.ai"
|
|
46
|
+
Documentation = "https://docs.microcafe.ai"
|
|
47
|
+
Repository = "https://github.com/microcafe/microcafe-python"
|
|
48
|
+
Issues = "https://github.com/microcafe/microcafe-python/issues"
|
|
49
|
+
|
|
50
|
+
[tool.hatch.build.targets.wheel]
|
|
51
|
+
packages = ["src/microcafe"]
|
|
52
|
+
|
|
53
|
+
[tool.black]
|
|
54
|
+
line-length = 100
|
|
55
|
+
target-version = ["py38"]
|
|
56
|
+
|
|
57
|
+
[tool.ruff]
|
|
58
|
+
line-length = 100
|
|
59
|
+
select = ["E", "F", "I"]
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# src/microcafe/__init__.py
|
|
2
|
+
"""
|
|
3
|
+
microCafe Python SDK - AI-powered microbiome analysis.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
from microcafe import Client
|
|
7
|
+
|
|
8
|
+
client = Client(api_key="mc_your_key_here")
|
|
9
|
+
|
|
10
|
+
# Single sequence
|
|
11
|
+
result = client.classify("ATCGATCG...")
|
|
12
|
+
print(result.predictions[0].genus)
|
|
13
|
+
|
|
14
|
+
# File classification
|
|
15
|
+
summary = client.classify_file("sequences.fq")
|
|
16
|
+
print(summary.summary.raw_counts)
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from .client import Client
|
|
20
|
+
from .exceptions import (
|
|
21
|
+
MicroCafeError,
|
|
22
|
+
AuthenticationError,
|
|
23
|
+
RateLimitError,
|
|
24
|
+
ValidationError,
|
|
25
|
+
JobNotFoundError,
|
|
26
|
+
JobNotCompletedError,
|
|
27
|
+
ServerError,
|
|
28
|
+
)
|
|
29
|
+
from .models import (
|
|
30
|
+
Prediction,
|
|
31
|
+
ClassificationResult,
|
|
32
|
+
Summary,
|
|
33
|
+
JobStatus,
|
|
34
|
+
JobResults,
|
|
35
|
+
JobSummary,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
__version__ = "0.1.0"
|
|
39
|
+
__all__ = [
|
|
40
|
+
"Client",
|
|
41
|
+
"MicroCafeError",
|
|
42
|
+
"AuthenticationError",
|
|
43
|
+
"RateLimitError",
|
|
44
|
+
"ValidationError",
|
|
45
|
+
"JobNotFoundError",
|
|
46
|
+
"JobNotCompletedError",
|
|
47
|
+
"ServerError",
|
|
48
|
+
"Prediction",
|
|
49
|
+
"ClassificationResult",
|
|
50
|
+
"Summary",
|
|
51
|
+
"JobStatus",
|
|
52
|
+
"JobResults",
|
|
53
|
+
"JobSummary",
|
|
54
|
+
]
|