XspecT 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl
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.
Potentially problematic release.
This version of XspecT might be problematic. Click here for more details.
- xspect/classify.py +32 -0
- xspect/file_io.py +3 -9
- xspect/filter_sequences.py +56 -0
- xspect/main.py +52 -30
- xspect/mlst_feature/mlst_helper.py +102 -13
- xspect/mlst_feature/pub_mlst_handler.py +32 -6
- xspect/model_management.py +1 -15
- xspect/models/probabilistic_filter_mlst_model.py +160 -32
- xspect/models/probabilistic_filter_model.py +1 -0
- xspect/models/result.py +18 -6
- xspect/ncbi.py +8 -6
- xspect/train.py +13 -5
- xspect/web.py +173 -0
- xspect/xspect-web/.gitignore +24 -0
- xspect/xspect-web/README.md +54 -0
- xspect/xspect-web/components.json +21 -0
- xspect/xspect-web/dist/assets/index-CMG4V7fZ.js +290 -0
- xspect/xspect-web/dist/assets/index-jIKg1HIy.css +1 -0
- xspect/xspect-web/dist/index.html +14 -0
- xspect/xspect-web/dist/vite.svg +1 -0
- xspect/xspect-web/eslint.config.js +28 -0
- xspect/xspect-web/index.html +13 -0
- xspect/xspect-web/package-lock.json +6865 -0
- xspect/xspect-web/package.json +58 -0
- xspect/xspect-web/pnpm-lock.yaml +4317 -0
- xspect/xspect-web/public/vite.svg +1 -0
- xspect/xspect-web/src/App.tsx +29 -0
- xspect/xspect-web/src/api.tsx +62 -0
- xspect/xspect-web/src/assets/react.svg +1 -0
- xspect/xspect-web/src/components/classification-form.tsx +284 -0
- xspect/xspect-web/src/components/classify.tsx +18 -0
- xspect/xspect-web/src/components/data-table.tsx +78 -0
- xspect/xspect-web/src/components/dropdown-checkboxes.tsx +63 -0
- xspect/xspect-web/src/components/dropdown-slider.tsx +42 -0
- xspect/xspect-web/src/components/filter-form.tsx +423 -0
- xspect/xspect-web/src/components/filter.tsx +15 -0
- xspect/xspect-web/src/components/header.tsx +46 -0
- xspect/xspect-web/src/components/landing.tsx +7 -0
- xspect/xspect-web/src/components/models-details.tsx +138 -0
- xspect/xspect-web/src/components/models.tsx +53 -0
- xspect/xspect-web/src/components/result-chart.tsx +44 -0
- xspect/xspect-web/src/components/result.tsx +155 -0
- xspect/xspect-web/src/components/spinner.tsx +30 -0
- xspect/xspect-web/src/components/ui/accordion.tsx +64 -0
- xspect/xspect-web/src/components/ui/button.tsx +59 -0
- xspect/xspect-web/src/components/ui/card.tsx +92 -0
- xspect/xspect-web/src/components/ui/chart.tsx +351 -0
- xspect/xspect-web/src/components/ui/command.tsx +175 -0
- xspect/xspect-web/src/components/ui/dialog.tsx +135 -0
- xspect/xspect-web/src/components/ui/dropdown-menu.tsx +255 -0
- xspect/xspect-web/src/components/ui/file-upload.tsx +1459 -0
- xspect/xspect-web/src/components/ui/form.tsx +165 -0
- xspect/xspect-web/src/components/ui/input.tsx +21 -0
- xspect/xspect-web/src/components/ui/label.tsx +24 -0
- xspect/xspect-web/src/components/ui/navigation-menu.tsx +168 -0
- xspect/xspect-web/src/components/ui/popover.tsx +46 -0
- xspect/xspect-web/src/components/ui/select.tsx +183 -0
- xspect/xspect-web/src/components/ui/separator.tsx +26 -0
- xspect/xspect-web/src/components/ui/slider.tsx +61 -0
- xspect/xspect-web/src/components/ui/switch.tsx +29 -0
- xspect/xspect-web/src/components/ui/table.tsx +113 -0
- xspect/xspect-web/src/components/ui/tabs.tsx +64 -0
- xspect/xspect-web/src/index.css +120 -0
- xspect/xspect-web/src/lib/utils.ts +6 -0
- xspect/xspect-web/src/main.tsx +10 -0
- xspect/xspect-web/src/types.tsx +34 -0
- xspect/xspect-web/src/utils.tsx +6 -0
- xspect/xspect-web/src/vite-env.d.ts +1 -0
- xspect/xspect-web/tsconfig.app.json +32 -0
- xspect/xspect-web/tsconfig.json +13 -0
- xspect/xspect-web/tsconfig.node.json +24 -0
- xspect/xspect-web/vite.config.ts +24 -0
- {xspect-0.4.0.dist-info → xspect-0.5.0.dist-info}/METADATA +7 -8
- xspect-0.5.0.dist-info/RECORD +85 -0
- {xspect-0.4.0.dist-info → xspect-0.5.0.dist-info}/WHEEL +1 -1
- xspect/fastapi.py +0 -102
- xspect-0.4.0.dist-info/RECORD +0 -24
- {xspect-0.4.0.dist-info → xspect-0.5.0.dist-info}/entry_points.txt +0 -0
- {xspect-0.4.0.dist-info → xspect-0.5.0.dist-info}/licenses/LICENSE +0 -0
- {xspect-0.4.0.dist-info → xspect-0.5.0.dist-info}/top_level.txt +0 -0
xspect/fastapi.py
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"""FastAPI application for XspecT."""
|
|
2
|
-
|
|
3
|
-
from uuid import uuid4
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
from shutil import copyfileobj
|
|
6
|
-
from fastapi import FastAPI, UploadFile, BackgroundTasks
|
|
7
|
-
from xspect.definitions import get_xspect_runs_path, get_xspect_upload_path
|
|
8
|
-
from xspect.download_models import download_test_models
|
|
9
|
-
from xspect.file_io import filter_sequences
|
|
10
|
-
import xspect.model_management as mm
|
|
11
|
-
from xspect.train import train_from_ncbi
|
|
12
|
-
|
|
13
|
-
app = FastAPI()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@app.get("/download-filters")
|
|
17
|
-
def download_filters():
|
|
18
|
-
"""Download filters."""
|
|
19
|
-
download_test_models("http://assets.adrianromberg.com/xspect-models.zip")
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@app.get("/classify")
|
|
23
|
-
def classify(genus: str, file: str, meta: bool = False, step: int = 500):
|
|
24
|
-
"""Classify uploaded sample."""
|
|
25
|
-
|
|
26
|
-
input_path = get_xspect_upload_path() / file
|
|
27
|
-
|
|
28
|
-
uuid = str(uuid4())
|
|
29
|
-
|
|
30
|
-
if meta:
|
|
31
|
-
genus_model = mm.get_genus_model(genus)
|
|
32
|
-
genus_result = genus_model.predict(input_path, step=step)
|
|
33
|
-
included_ids = genus_result.get_filtered_subsequence_labels(genus)
|
|
34
|
-
if not included_ids:
|
|
35
|
-
return {"message": "No sequences found for the given genus."}
|
|
36
|
-
filtered_path = get_xspect_runs_path() / f"filtered_{uuid}.fasta"
|
|
37
|
-
filter_sequences(
|
|
38
|
-
Path(input_path),
|
|
39
|
-
Path(filtered_path),
|
|
40
|
-
included_ids=included_ids,
|
|
41
|
-
)
|
|
42
|
-
input_path = filtered_path
|
|
43
|
-
|
|
44
|
-
species_model = mm.get_species_model(genus)
|
|
45
|
-
species_result = species_model.predict(input_path, step=step)
|
|
46
|
-
species_result.save(get_xspect_runs_path() / f"result_{uuid}.json")
|
|
47
|
-
return species_result.to_dict()
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@app.post("/train")
|
|
51
|
-
def train(genus: str, background_tasks: BackgroundTasks, svm_steps: int = 1):
|
|
52
|
-
"""Train NCBI model."""
|
|
53
|
-
background_tasks.add_task(train_from_ncbi, genus, svm_steps)
|
|
54
|
-
|
|
55
|
-
return {"message": "Training started."}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
@app.get("/list-models")
|
|
59
|
-
def list_models():
|
|
60
|
-
"""List available models."""
|
|
61
|
-
return mm.get_models()
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@app.get("/model-metadata")
|
|
65
|
-
def get_model_metadata(model_slug: str):
|
|
66
|
-
"""Get metadata of a model."""
|
|
67
|
-
return mm.get_model_metadata(model_slug)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
@app.post("/model-metadata")
|
|
71
|
-
def post_model_metadata(model_slug: str, author: str, author_email: str):
|
|
72
|
-
"""Update metadata of a model."""
|
|
73
|
-
try:
|
|
74
|
-
mm.update_model_metadata(model_slug, author, author_email)
|
|
75
|
-
except ValueError as e:
|
|
76
|
-
return {"error": str(e)}
|
|
77
|
-
return {"message": "Metadata updated."}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
@app.post("/model-display-name")
|
|
81
|
-
def post_model_display_name(model_slug: str, filter_id: str, display_name: str):
|
|
82
|
-
"""Update display name of a filter in a model."""
|
|
83
|
-
try:
|
|
84
|
-
mm.update_model_display_name(model_slug, filter_id, display_name)
|
|
85
|
-
except ValueError as e:
|
|
86
|
-
return {"error": str(e)}
|
|
87
|
-
return {"message": "Display name updated."}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
@app.post("/upload-file")
|
|
91
|
-
def upload_file(file: UploadFile):
|
|
92
|
-
"""Upload file to the server."""
|
|
93
|
-
upload_path = get_xspect_upload_path() / file.filename
|
|
94
|
-
|
|
95
|
-
if not upload_path.exists():
|
|
96
|
-
try:
|
|
97
|
-
with upload_path.open("wb") as buffer:
|
|
98
|
-
copyfileobj(file.file, buffer)
|
|
99
|
-
finally:
|
|
100
|
-
file.file.close()
|
|
101
|
-
|
|
102
|
-
return {"filename": file.filename}
|
xspect-0.4.0.dist-info/RECORD
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
xspect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
xspect/definitions.py,sha256=fVn_li_s2hriOSGJ69o_H8H-vkw1znvkryhBj7WMnF4,1219
|
|
3
|
-
xspect/download_models.py,sha256=y1wFJZa1xOJfvUP78zKkRs46O-WqKBL90vmo5AYUio0,853
|
|
4
|
-
xspect/fastapi.py,sha256=DOef3MqWPdBmdYBo8Z9SPmWrbJHOsQxQe3GrC4f__Rc,3165
|
|
5
|
-
xspect/file_io.py,sha256=YmfoKEQdHHEi8dO2G5Kt4tSNi5LuWW0VZ74pyYRHiTo,5937
|
|
6
|
-
xspect/main.py,sha256=uVj1fooDU5WW8sMug5YPwuAphb8zd3PDpNFNlTIyXBw,11155
|
|
7
|
-
xspect/model_management.py,sha256=LItMidbfxZfttEZHa8da_nnkwkH7XVLWDM0uVrFUZ0Q,3753
|
|
8
|
-
xspect/ncbi.py,sha256=sSJO3g8n89Qw6UJjAy13bpjOcIGSquTKNKVHNUMbDeM,10072
|
|
9
|
-
xspect/train.py,sha256=7I7-inWGJe_VDzII9dLZ8U-8SUCZDIrhb-eNOZEyfss,10703
|
|
10
|
-
xspect/mlst_feature/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
xspect/mlst_feature/mlst_helper.py,sha256=3zhhEomkk-qiObbQ82TM_YHuyVCJ7_XgyzsYM_4TS0E,5760
|
|
12
|
-
xspect/mlst_feature/pub_mlst_handler.py,sha256=oss3CkJNt6041p3qnMdOfoX8ZgUfpB93CUim-Yakc9A,5031
|
|
13
|
-
xspect/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
xspect/models/probabilistic_filter_mlst_model.py,sha256=JMc0yBJPo7J9b-GpvhDmzhwWPIKOwatAq0edDgM72PE,11735
|
|
15
|
-
xspect/models/probabilistic_filter_model.py,sha256=l8mhcRgHPso7qIgI56buCnE3ZleO3gPWOZEpgrycOBA,10029
|
|
16
|
-
xspect/models/probabilistic_filter_svm_model.py,sha256=xXimcv3iWnG1JiFyrk6UqkP9hFIxWGDdb__fRdQYwro,6245
|
|
17
|
-
xspect/models/probabilistic_single_filter_model.py,sha256=yxWnCt4IP-3ZRLP4pRA3f2VTHc0_4g17PDCyOFayDDg,4090
|
|
18
|
-
xspect/models/result.py,sha256=fhTS43XYAIkNiiAMyNpaif0kM4Ab3xLBnVJnutkOuFU,3400
|
|
19
|
-
xspect-0.4.0.dist-info/licenses/LICENSE,sha256=bhBGDKIRUVwYIHGOGO5hshzuVHyqFJajvSOA3XXOLKI,1094
|
|
20
|
-
xspect-0.4.0.dist-info/METADATA,sha256=mmsNmdiRqOC0RCBe7yW6oofue2OctwErCWVyiJD86nI,4439
|
|
21
|
-
xspect-0.4.0.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
|
22
|
-
xspect-0.4.0.dist-info/entry_points.txt,sha256=L7qliX3pIuwupQxpuOSsrBJCSHYPOPNEzH8KZKQGGUw,43
|
|
23
|
-
xspect-0.4.0.dist-info/top_level.txt,sha256=hdoa4cnBv6OVzpyhMmyxpJxEydH5n2lDciy8urc1paE,7
|
|
24
|
-
xspect-0.4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|