XspecT 0.4.1__tar.gz → 0.5.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.

Potentially problematic release.


This version of XspecT might be problematic. Click here for more details.

Files changed (156) hide show
  1. xspect-0.5.0/.github/workflows/docs.yml +28 -0
  2. {xspect-0.4.1 → xspect-0.5.0}/.github/workflows/pypi.yml +11 -0
  3. {xspect-0.4.1 → xspect-0.5.0}/.github/workflows/test.yml +12 -1
  4. {xspect-0.4.1 → xspect-0.5.0}/.gitignore +0 -1
  5. {xspect-0.4.1 → xspect-0.5.0}/PKG-INFO +6 -8
  6. {xspect-0.4.1 → xspect-0.5.0}/README.md +2 -2
  7. xspect-0.5.0/docs/cli.md +146 -0
  8. xspect-0.5.0/docs/contributing.md +3 -0
  9. xspect-0.5.0/docs/index.md +7 -0
  10. xspect-0.5.0/docs/quickstart.md +6 -0
  11. xspect-0.5.0/docs/understanding.md +3 -0
  12. xspect-0.5.0/docs/web.md +17 -0
  13. xspect-0.5.0/mkdocs.yml +19 -0
  14. {xspect-0.4.1 → xspect-0.5.0}/pyproject.toml +6 -3
  15. {xspect-0.4.1 → xspect-0.5.0}/src/XspecT.egg-info/PKG-INFO +6 -8
  16. xspect-0.5.0/src/XspecT.egg-info/SOURCES.txt +115 -0
  17. {xspect-0.4.1 → xspect-0.5.0}/src/XspecT.egg-info/requires.txt +3 -5
  18. xspect-0.5.0/src/xspect/classify.py +32 -0
  19. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/file_io.py +3 -9
  20. xspect-0.5.0/src/xspect/filter_sequences.py +56 -0
  21. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/main.py +13 -18
  22. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/mlst_feature/mlst_helper.py +102 -13
  23. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/mlst_feature/pub_mlst_handler.py +32 -6
  24. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/models/probabilistic_filter_mlst_model.py +160 -32
  25. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/models/probabilistic_filter_model.py +1 -0
  26. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/ncbi.py +8 -6
  27. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/train.py +13 -5
  28. xspect-0.5.0/src/xspect/web.py +173 -0
  29. xspect-0.5.0/src/xspect/xspect-web/.gitignore +24 -0
  30. xspect-0.5.0/src/xspect/xspect-web/README.md +54 -0
  31. xspect-0.5.0/src/xspect/xspect-web/components.json +21 -0
  32. xspect-0.5.0/src/xspect/xspect-web/dist/assets/index-CMG4V7fZ.js +290 -0
  33. xspect-0.5.0/src/xspect/xspect-web/dist/assets/index-jIKg1HIy.css +1 -0
  34. xspect-0.5.0/src/xspect/xspect-web/dist/index.html +14 -0
  35. xspect-0.5.0/src/xspect/xspect-web/dist/vite.svg +1 -0
  36. xspect-0.5.0/src/xspect/xspect-web/eslint.config.js +28 -0
  37. xspect-0.5.0/src/xspect/xspect-web/index.html +13 -0
  38. xspect-0.5.0/src/xspect/xspect-web/package-lock.json +6865 -0
  39. xspect-0.5.0/src/xspect/xspect-web/package.json +58 -0
  40. xspect-0.5.0/src/xspect/xspect-web/pnpm-lock.yaml +4317 -0
  41. xspect-0.5.0/src/xspect/xspect-web/public/vite.svg +1 -0
  42. xspect-0.5.0/src/xspect/xspect-web/src/App.tsx +29 -0
  43. xspect-0.5.0/src/xspect/xspect-web/src/api.tsx +62 -0
  44. xspect-0.5.0/src/xspect/xspect-web/src/assets/react.svg +1 -0
  45. xspect-0.5.0/src/xspect/xspect-web/src/components/classification-form.tsx +284 -0
  46. xspect-0.5.0/src/xspect/xspect-web/src/components/classify.tsx +18 -0
  47. xspect-0.5.0/src/xspect/xspect-web/src/components/data-table.tsx +78 -0
  48. xspect-0.5.0/src/xspect/xspect-web/src/components/dropdown-checkboxes.tsx +63 -0
  49. xspect-0.5.0/src/xspect/xspect-web/src/components/dropdown-slider.tsx +42 -0
  50. xspect-0.5.0/src/xspect/xspect-web/src/components/filter-form.tsx +423 -0
  51. xspect-0.5.0/src/xspect/xspect-web/src/components/filter.tsx +15 -0
  52. xspect-0.5.0/src/xspect/xspect-web/src/components/header.tsx +46 -0
  53. xspect-0.5.0/src/xspect/xspect-web/src/components/landing.tsx +7 -0
  54. xspect-0.5.0/src/xspect/xspect-web/src/components/models-details.tsx +138 -0
  55. xspect-0.5.0/src/xspect/xspect-web/src/components/models.tsx +53 -0
  56. xspect-0.5.0/src/xspect/xspect-web/src/components/result-chart.tsx +44 -0
  57. xspect-0.5.0/src/xspect/xspect-web/src/components/result.tsx +155 -0
  58. xspect-0.5.0/src/xspect/xspect-web/src/components/spinner.tsx +30 -0
  59. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/accordion.tsx +64 -0
  60. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/button.tsx +59 -0
  61. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/card.tsx +92 -0
  62. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/chart.tsx +351 -0
  63. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/command.tsx +175 -0
  64. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/dialog.tsx +135 -0
  65. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/dropdown-menu.tsx +255 -0
  66. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/file-upload.tsx +1459 -0
  67. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/form.tsx +165 -0
  68. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/input.tsx +21 -0
  69. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/label.tsx +24 -0
  70. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/navigation-menu.tsx +168 -0
  71. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/popover.tsx +46 -0
  72. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/select.tsx +183 -0
  73. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/separator.tsx +26 -0
  74. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/slider.tsx +61 -0
  75. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/switch.tsx +29 -0
  76. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/table.tsx +113 -0
  77. xspect-0.5.0/src/xspect/xspect-web/src/components/ui/tabs.tsx +64 -0
  78. xspect-0.5.0/src/xspect/xspect-web/src/index.css +120 -0
  79. xspect-0.5.0/src/xspect/xspect-web/src/lib/utils.ts +6 -0
  80. xspect-0.5.0/src/xspect/xspect-web/src/main.tsx +10 -0
  81. xspect-0.5.0/src/xspect/xspect-web/src/types.tsx +34 -0
  82. xspect-0.5.0/src/xspect/xspect-web/src/utils.tsx +6 -0
  83. xspect-0.5.0/src/xspect/xspect-web/src/vite-env.d.ts +1 -0
  84. xspect-0.5.0/src/xspect/xspect-web/tsconfig.app.json +32 -0
  85. xspect-0.5.0/src/xspect/xspect-web/tsconfig.json +13 -0
  86. xspect-0.5.0/src/xspect/xspect-web/tsconfig.node.json +24 -0
  87. xspect-0.5.0/src/xspect/xspect-web/vite.config.ts +24 -0
  88. {xspect-0.4.1 → xspect-0.5.0}/tests/test_ncbi.py +1 -1
  89. {xspect-0.4.1 → xspect-0.5.0}/tests/test_probabilisitc_filter_mlst_model.py +4 -3
  90. xspect-0.4.1/tests/test_fastapi.py → xspect-0.5.0/tests/test_web.py +25 -12
  91. xspect-0.4.1/.github/workflows/docs.yml +0 -33
  92. xspect-0.4.1/docs/Instructions/pictures/About.png +0 -0
  93. xspect-0.4.1/docs/Instructions/pictures/AddFilter.png +0 -0
  94. xspect-0.4.1/docs/Instructions/pictures/AddSpecies1.png +0 -0
  95. xspect-0.4.1/docs/Instructions/pictures/AddSpecies2.png +0 -0
  96. xspect-0.4.1/docs/Instructions/pictures/BF.png +0 -0
  97. xspect-0.4.1/docs/Instructions/pictures/ClAssT_Ergebnis1.png +0 -0
  98. xspect-0.4.1/docs/Instructions/pictures/ClAssT_Ergebnis2.png +0 -0
  99. xspect-0.4.1/docs/Instructions/pictures/ClAssT_Ergebnis3.png +0 -0
  100. xspect-0.4.1/docs/Instructions/pictures/ClAssT_Hauptseite.png +0 -0
  101. xspect-0.4.1/docs/Instructions/pictures/CommandLine_Input.png +0 -0
  102. xspect-0.4.1/docs/Instructions/pictures/CommandLine_results.png +0 -0
  103. xspect-0.4.1/docs/Instructions/pictures/CommandLine_whole.png +0 -0
  104. xspect-0.4.1/docs/Instructions/pictures/How2Use.png +0 -0
  105. xspect-0.4.1/docs/Instructions/pictures/HowtouseAspecT.png +0 -0
  106. xspect-0.4.1/docs/Instructions/pictures/XspecT_Ergebnis1.png +0 -0
  107. xspect-0.4.1/docs/Instructions/pictures/XspecT_Ergebnis2.png +0 -0
  108. xspect-0.4.1/docs/Instructions/pictures/XspecT_Ergebnis3.png +0 -0
  109. xspect-0.4.1/docs/Instructions/pictures/XspecT_Ergebnis4.png +0 -0
  110. xspect-0.4.1/docs/Instructions/pictures/XspecT_Hauptseite.png +0 -0
  111. xspect-0.4.1/docs/Instructions/pictures/XspecT_Runtime.png +0 -0
  112. xspect-0.4.1/docs/Instructions/pictures/XspecT_Runtime_Oxa.png +0 -0
  113. xspect-0.4.1/docs/Instructions/pictures/XspecT_Startseite.png +0 -0
  114. xspect-0.4.1/docs/Instructions/pictures/change_pw.png +0 -0
  115. xspect-0.4.1/docs/Instructions/pictures/modify_vecs.png +0 -0
  116. xspect-0.4.1/docs/Instructions/pictures/secretkey.png +0 -0
  117. xspect-0.4.1/docs/Makefile +0 -20
  118. xspect-0.4.1/docs/cli.md +0 -80
  119. xspect-0.4.1/docs/conf.py +0 -29
  120. xspect-0.4.1/docs/diagrams/probabilistic_filter_models.md +0 -52
  121. xspect-0.4.1/docs/img/logo.png +0 -0
  122. xspect-0.4.1/docs/index.md +0 -20
  123. xspect-0.4.1/docs/input_data.md +0 -2
  124. xspect-0.4.1/docs/installation.md +0 -35
  125. xspect-0.4.1/docs/make.bat +0 -35
  126. xspect-0.4.1/docs/quickstart.md +0 -6
  127. xspect-0.4.1/docs/web.md +0 -3
  128. xspect-0.4.1/src/XspecT.egg-info/SOURCES.txt +0 -83
  129. xspect-0.4.1/src/xspect/fastapi.py +0 -102
  130. {xspect-0.4.1 → xspect-0.5.0}/.github/workflows/black.yml +0 -0
  131. {xspect-0.4.1 → xspect-0.5.0}/.github/workflows/pylint.yml +0 -0
  132. {xspect-0.4.1 → xspect-0.5.0}/LICENSE +0 -0
  133. {xspect-0.4.1 → xspect-0.5.0}/setup.cfg +0 -0
  134. {xspect-0.4.1 → xspect-0.5.0}/src/XspecT.egg-info/dependency_links.txt +0 -0
  135. {xspect-0.4.1 → xspect-0.5.0}/src/XspecT.egg-info/entry_points.txt +0 -0
  136. {xspect-0.4.1 → xspect-0.5.0}/src/XspecT.egg-info/top_level.txt +0 -0
  137. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/__init__.py +0 -0
  138. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/definitions.py +0 -0
  139. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/download_models.py +0 -0
  140. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/mlst_feature/__init__.py +0 -0
  141. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/model_management.py +0 -0
  142. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/models/__init__.py +0 -0
  143. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/models/probabilistic_filter_svm_model.py +0 -0
  144. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/models/probabilistic_single_filter_model.py +0 -0
  145. {xspect-0.4.1 → xspect-0.5.0}/src/xspect/models/result.py +0 -0
  146. {xspect-0.4.1 → xspect-0.5.0}/tests/__init__.py +0 -0
  147. {xspect-0.4.1 → xspect-0.5.0}/tests/conftest.py +0 -0
  148. {xspect-0.4.1 → xspect-0.5.0}/tests/test_cli.py +0 -0
  149. {xspect-0.4.1 → xspect-0.5.0}/tests/test_file_io.py +0 -0
  150. {xspect-0.4.1 → xspect-0.5.0}/tests/test_model_management.py +0 -0
  151. {xspect-0.4.1 → xspect-0.5.0}/tests/test_model_result.py +0 -0
  152. {xspect-0.4.1 → xspect-0.5.0}/tests/test_probabilistic_filter_model.py +0 -0
  153. {xspect-0.4.1 → xspect-0.5.0}/tests/test_probabilistic_filter_svm_model.py +0 -0
  154. {xspect-0.4.1 → xspect-0.5.0}/tests/test_probabilistic_single_filter_model.py +0 -0
  155. {xspect-0.4.1 → xspect-0.5.0}/tests/test_pub_mlst_handler.py +0 -0
  156. {xspect-0.4.1 → xspect-0.5.0}/tests/test_train.py +0 -0
@@ -0,0 +1,28 @@
1
+ name: mkdocs
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ permissions:
7
+ contents: write
8
+ jobs:
9
+ mkdocs:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - name: Configure Git Credentials
14
+ run: |
15
+ git config user.name github-actions[bot]
16
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: 3.x
20
+ - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
21
+ - uses: actions/cache@v4
22
+ with:
23
+ key: mkdocs-material-${{ env.cache_id }}
24
+ path: .cache
25
+ restore-keys: |
26
+ mkdocs-material-
27
+ - run: pip install '.[docs]'
28
+ - run: mkdocs gh-deploy --force
@@ -12,6 +12,17 @@ jobs:
12
12
  steps:
13
13
  - uses: actions/checkout@v4
14
14
 
15
+ - name: Set up Node.js
16
+ uses: actions/setup-node@v4
17
+ with:
18
+ node-version: "23"
19
+ - name: Build XspecT web dist
20
+ run: |
21
+ cd src/xspect/xspect-web
22
+ npm install
23
+ npx vite build
24
+ cd ../../..
25
+
15
26
  - uses: actions/setup-python@v5
16
27
  with:
17
28
  python-version: "3.x"
@@ -2,9 +2,20 @@ name: test
2
2
  on: [push]
3
3
  jobs:
4
4
  pytest:
5
+ name: Run pytest
5
6
  runs-on: ubuntu-latest
6
7
  steps:
7
8
  - uses: actions/checkout@v4
9
+ - name: Set up Node.js
10
+ uses: actions/setup-node@v4
11
+ with:
12
+ node-version: "23"
13
+ - name: Build dist
14
+ run: |
15
+ cd src/xspect/xspect-web
16
+ npm install
17
+ npx vite build
18
+ cd ../../..
8
19
  - name: Set up Python
9
20
  uses: actions/setup-python@v4
10
21
  with:
@@ -18,7 +29,7 @@ jobs:
18
29
  xspect models download
19
30
  - name: Test with pytest
20
31
  run: |
21
- pytest --cov
32
+ pytest --cov --retries 2 --retry-delay 5
22
33
  - name: Upload coverage reports to Codecov
23
34
  uses: codecov/codecov-action@v4
24
35
  env:
@@ -14,7 +14,6 @@ dist/
14
14
  downloads/
15
15
  eggs/
16
16
  .eggs/
17
- lib/
18
17
  lib64/
19
18
  parts/
20
19
  sdist/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: XspecT
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: Tool to monitor and characterize pathogens using Bloom filters.
5
5
  License: MIT License
6
6
 
@@ -46,14 +46,12 @@ Requires-Dist: fastapi
46
46
  Requires-Dist: uvicorn
47
47
  Requires-Dist: python-multipart
48
48
  Provides-Extra: docs
49
- Requires-Dist: sphinx; extra == "docs"
50
- Requires-Dist: furo; extra == "docs"
51
- Requires-Dist: myst-parser; extra == "docs"
52
- Requires-Dist: sphinx-copybutton; extra == "docs"
53
- Requires-Dist: sphinx-autobuild; extra == "docs"
49
+ Requires-Dist: mkdocs-material; extra == "docs"
50
+ Requires-Dist: mkdocs-include-markdown-plugin; extra == "docs"
54
51
  Provides-Extra: test
55
52
  Requires-Dist: pytest; extra == "test"
56
53
  Requires-Dist: pytest-cov; extra == "test"
54
+ Requires-Dist: pytest-retry; extra == "test"
57
55
  Requires-Dist: httpx; extra == "test"
58
56
  Dynamic: license-file
59
57
 
@@ -79,7 +77,7 @@ To install XspecT, please download the lastest 64 bit Python version and install
79
77
  ```
80
78
  pip install xspect
81
79
  ```
82
- Please note that Windows and Alpine Linux is currently not supported.
80
+ Please note that Windows and Alpine Linux are currently not supported.
83
81
 
84
82
  ## Usage
85
83
  ### Get the models
@@ -107,5 +105,5 @@ For further instructions on how to use the command line interface, please refer
107
105
  ```
108
106
  xspect --help
109
107
  ```
110
- [documentation]: https://bionf.github.io/XspecT2/cli.html
108
+ [documentation]: https://bionf.github.io/XspecT2/cli/index.html
111
109
  <!-- end quickstart -->
@@ -20,7 +20,7 @@ To install XspecT, please download the lastest 64 bit Python version and install
20
20
  ```
21
21
  pip install xspect
22
22
  ```
23
- Please note that Windows and Alpine Linux is currently not supported.
23
+ Please note that Windows and Alpine Linux are currently not supported.
24
24
 
25
25
  ## Usage
26
26
  ### Get the models
@@ -48,5 +48,5 @@ For further instructions on how to use the command line interface, please refer
48
48
  ```
49
49
  xspect --help
50
50
  ```
51
- [documentation]: https://bionf.github.io/XspecT2/cli.html
51
+ [documentation]: https://bionf.github.io/XspecT2/cli/index.html
52
52
  <!-- end quickstart -->
@@ -0,0 +1,146 @@
1
+ # How to use the CLI
2
+
3
+ XspecT comes with a built-in command line interface (CLI), which enables quick classifications without the need to use the web interface. The command line interface can also be used to download and train models.
4
+
5
+ After installing XspecT, a list of available commands can be viewed by running:
6
+
7
+ ```bash
8
+ xspect --help
9
+ ```
10
+
11
+ In general, XspecT commands will prompt you for parameters if they are not provided. However, you can also provide them directly in the command line, for example when using scripts or tools such as Slurm. Simply run the command with the `--help` option to see all available parameters.
12
+
13
+ ## Model Management
14
+
15
+ At its core, XspecT uses models to classify and filter samples. These models are based on kmer indices trained on publicly availabel genomes as well as, possibly, a support vector machine (SVM) classifier.
16
+
17
+ To manage models, the `xspect models` command can be used. This command allows you to download, train, and view available models.
18
+
19
+ ### Viewing Available Models
20
+
21
+ To view a list of available models, run:
22
+
23
+ ```bash
24
+ xspect models list
25
+ ```
26
+ This will show a list of all available models, separated by their type (species, genus, MLST).
27
+
28
+ ### Downloading Models
29
+
30
+ To download a basic set of pre-trained models (Acinetobacter and Salonella), run:
31
+
32
+ ```bash
33
+ xspect models download
34
+ ```
35
+
36
+ ### Model Training
37
+
38
+ Models can be trained based on data from NCBI, which is automatically downloaded and processed by XspecT.
39
+
40
+ To train a model with NCBI data, run the following command:
41
+
42
+ ```bash
43
+ xspect models train ncbi
44
+ ```
45
+
46
+ If you would like to train models with manually curated data from a directory, you can use:
47
+
48
+ ```bash
49
+ xspect models train directory
50
+ ```
51
+
52
+ Your directory should have the following structure:
53
+ ```
54
+ your-directory/
55
+ ├── cobs
56
+ │ ├── species1
57
+ │ │ ├── genome1.fna
58
+ │ │ ├── genome2.fna
59
+ │ │ └── ...
60
+ │ ├── species2
61
+ │ │ ├── genome1.fna
62
+ │ │ ├── genome2.fna
63
+ │ │ └── ...
64
+ │ └── ...
65
+ ├── svm
66
+ │ ├── species1
67
+ │ │ ├── genome1.fna
68
+ │ │ ├── genome2.fna
69
+ │ │ └── ...
70
+ │ ├── species2
71
+ │ │ ├── genome1.fna
72
+ │ │ ├── genome2.fna
73
+ │ │ └── ...
74
+ │ └── ...
75
+ ```
76
+
77
+ To train models for MLST classifications, run:
78
+
79
+ ```bash
80
+ xspect models train mlst
81
+ ```
82
+
83
+ ## Classification
84
+
85
+ To classify samples, the command `xspect classify` can be used. This command will classify the sample based on the models available in your XspecT installation.
86
+
87
+ ### Genus Classification
88
+
89
+ To classify a sample based on its genus, run the following command:
90
+
91
+ ```bash
92
+ xspect classify genus
93
+ ```
94
+
95
+ XspecT will prompt you for the genus and path to your sample directory.
96
+
97
+ ### Species Classification
98
+
99
+ To classify a sample based on its species, run the following command:
100
+
101
+ ```bash
102
+ xspect classify species
103
+ ```
104
+
105
+ XspecT will prompt you for the genus and path to your sample directory.
106
+
107
+ ### Sparse Sampling
108
+ XspecT uses a kmer-based approach to classify samples. This means that the entire sample is analyzed, which can be time-consuming for large samples. To speed up the analysis, you can use the `--sparse-sampling-step` option to only consider every nth kmer:
109
+
110
+ **Example**:
111
+ ```bash
112
+ xspect classify species --sparse-sampling-step 10 Acinetobacter path
113
+ ```
114
+
115
+ This will only consider every 10th kmer in the sample.
116
+
117
+ ### MLST Classification
118
+
119
+ Samples can also be classified based on Multi-locus sequence type schemas. To MLST-classify a sample, run:
120
+
121
+ ```bash
122
+ xspect classify-mlst -p path
123
+ ```
124
+
125
+ ## Filtering
126
+ XspecT can also be used to filter samples based on their classification results. This is useful when analyzing metagenome samples, for example when looking at genomic bycatch.
127
+
128
+ To filter samples, the command `xspect filter` can be used. This command will filter the samples based on the specified criteria.
129
+
130
+ ### Filtering by Genus
131
+
132
+ To filter samples by genus, run the following command:
133
+
134
+ ```bash
135
+ xspect filter genus
136
+ ```
137
+ XspecT will prompt you for the genus and path to your sample directory, as well as for a threshold to use for filtering.
138
+
139
+ ### Filtering by Species
140
+ To filter samples by species, run the following command:
141
+
142
+ ```bash
143
+ xspect filter species
144
+ ```
145
+
146
+ You will be prompted for the genus and path to your sample directory, as well for the species to filter by and for a threshold to use for filtering. Next to normal threshold-based filtering, you can also enter a threshold of `-1` to only include contigs if the selected species is the maximum scoring species.
@@ -0,0 +1,3 @@
1
+ # Contributing to XspecT
2
+
3
+ Coming soon...
@@ -0,0 +1,7 @@
1
+ # Home
2
+ {%
3
+ include-markdown "../README.md"
4
+ start="<!-- start intro -->"
5
+ end="<!-- end intro -->"
6
+ %}
7
+ [Get started](quickstart.md){ .md-button .md-button--primary}
@@ -0,0 +1,6 @@
1
+ # Quickstart
2
+ {%
3
+ include-markdown "../README.md"
4
+ start="<!-- start quickstart -->"
5
+ end="<!-- end quickstart -->"
6
+ %}
@@ -0,0 +1,3 @@
1
+ # Understanding XspecT
2
+
3
+ Coming soon...
@@ -0,0 +1,17 @@
1
+ # How to use the Web app
2
+
3
+ To run XspecT in a web browser, you can use the following command:
4
+
5
+ ```bash
6
+ xspect web
7
+ ```
8
+ This will start a web server running on port 8000. You can access the web app by navigating to [http://localhost:8000](http://localhost:8000) in your web browser.
9
+
10
+ ## Web App Features
11
+
12
+ Within the web app, you can perform the following tasks:
13
+
14
+ - Upload samples for classification
15
+ - Submit samples for classification and view results
16
+ - Submit samples for filtering and view results
17
+ - Manage models
@@ -0,0 +1,19 @@
1
+ site_name: XspecT Documentation
2
+ theme:
3
+ name: material
4
+ features:
5
+ - navigation.tabs
6
+ - content.code.copy
7
+ plugins:
8
+ - include-markdown
9
+ - search
10
+ repo_url: https://github.com/BIONF/XspecT2
11
+ markdown_extensions:
12
+ - attr_list
13
+ nav:
14
+ - Home: index.md
15
+ - Quickstart: quickstart.md
16
+ - CLI: cli.md
17
+ - "Web App": web.md
18
+ - "Understanding XspecT": understanding.md
19
+ - Contributing: contributing.md
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "XspecT"
3
- version = "0.4.1"
3
+ version = "0.5.0"
4
4
  description = "Tool to monitor and characterize pathogens using Bloom filters."
5
5
  readme = {file = "README.md", content-type = "text/markdown"}
6
6
  license = {file = "LICENSE"}
@@ -44,11 +44,14 @@ where = ["src"]
44
44
  include = ["xspect"]
45
45
  namespaces = false
46
46
 
47
+ [tool.setuptools.package-data]
48
+ xspect = ["xspect-web/dist/**/*"]
49
+
47
50
  [tool.pytest.ini_options]
48
51
  pythonpath = [
49
52
  "src"
50
53
  ]
51
54
 
52
55
  [project.optional-dependencies]
53
- docs = ["sphinx", "furo", "myst-parser", "sphinx-copybutton", "sphinx-autobuild"]
54
- test = ["pytest", "pytest-cov", "httpx"]
56
+ docs = ["mkdocs-material", "mkdocs-include-markdown-plugin"]
57
+ test = ["pytest", "pytest-cov", "pytest-retry", "httpx"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: XspecT
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: Tool to monitor and characterize pathogens using Bloom filters.
5
5
  License: MIT License
6
6
 
@@ -46,14 +46,12 @@ Requires-Dist: fastapi
46
46
  Requires-Dist: uvicorn
47
47
  Requires-Dist: python-multipart
48
48
  Provides-Extra: docs
49
- Requires-Dist: sphinx; extra == "docs"
50
- Requires-Dist: furo; extra == "docs"
51
- Requires-Dist: myst-parser; extra == "docs"
52
- Requires-Dist: sphinx-copybutton; extra == "docs"
53
- Requires-Dist: sphinx-autobuild; extra == "docs"
49
+ Requires-Dist: mkdocs-material; extra == "docs"
50
+ Requires-Dist: mkdocs-include-markdown-plugin; extra == "docs"
54
51
  Provides-Extra: test
55
52
  Requires-Dist: pytest; extra == "test"
56
53
  Requires-Dist: pytest-cov; extra == "test"
54
+ Requires-Dist: pytest-retry; extra == "test"
57
55
  Requires-Dist: httpx; extra == "test"
58
56
  Dynamic: license-file
59
57
 
@@ -79,7 +77,7 @@ To install XspecT, please download the lastest 64 bit Python version and install
79
77
  ```
80
78
  pip install xspect
81
79
  ```
82
- Please note that Windows and Alpine Linux is currently not supported.
80
+ Please note that Windows and Alpine Linux are currently not supported.
83
81
 
84
82
  ## Usage
85
83
  ### Get the models
@@ -107,5 +105,5 @@ For further instructions on how to use the command line interface, please refer
107
105
  ```
108
106
  xspect --help
109
107
  ```
110
- [documentation]: https://bionf.github.io/XspecT2/cli.html
108
+ [documentation]: https://bionf.github.io/XspecT2/cli/index.html
111
109
  <!-- end quickstart -->
@@ -0,0 +1,115 @@
1
+ .gitignore
2
+ LICENSE
3
+ README.md
4
+ mkdocs.yml
5
+ pyproject.toml
6
+ .github/workflows/black.yml
7
+ .github/workflows/docs.yml
8
+ .github/workflows/pylint.yml
9
+ .github/workflows/pypi.yml
10
+ .github/workflows/test.yml
11
+ docs/cli.md
12
+ docs/contributing.md
13
+ docs/index.md
14
+ docs/quickstart.md
15
+ docs/understanding.md
16
+ docs/web.md
17
+ src/XspecT.egg-info/PKG-INFO
18
+ src/XspecT.egg-info/SOURCES.txt
19
+ src/XspecT.egg-info/dependency_links.txt
20
+ src/XspecT.egg-info/entry_points.txt
21
+ src/XspecT.egg-info/requires.txt
22
+ src/XspecT.egg-info/top_level.txt
23
+ src/xspect/__init__.py
24
+ src/xspect/classify.py
25
+ src/xspect/definitions.py
26
+ src/xspect/download_models.py
27
+ src/xspect/file_io.py
28
+ src/xspect/filter_sequences.py
29
+ src/xspect/main.py
30
+ src/xspect/model_management.py
31
+ src/xspect/ncbi.py
32
+ src/xspect/train.py
33
+ src/xspect/web.py
34
+ src/xspect/mlst_feature/__init__.py
35
+ src/xspect/mlst_feature/mlst_helper.py
36
+ src/xspect/mlst_feature/pub_mlst_handler.py
37
+ src/xspect/models/__init__.py
38
+ src/xspect/models/probabilistic_filter_mlst_model.py
39
+ src/xspect/models/probabilistic_filter_model.py
40
+ src/xspect/models/probabilistic_filter_svm_model.py
41
+ src/xspect/models/probabilistic_single_filter_model.py
42
+ src/xspect/models/result.py
43
+ src/xspect/xspect-web/.gitignore
44
+ src/xspect/xspect-web/README.md
45
+ src/xspect/xspect-web/components.json
46
+ src/xspect/xspect-web/eslint.config.js
47
+ src/xspect/xspect-web/index.html
48
+ src/xspect/xspect-web/package-lock.json
49
+ src/xspect/xspect-web/package.json
50
+ src/xspect/xspect-web/pnpm-lock.yaml
51
+ src/xspect/xspect-web/tsconfig.app.json
52
+ src/xspect/xspect-web/tsconfig.json
53
+ src/xspect/xspect-web/tsconfig.node.json
54
+ src/xspect/xspect-web/vite.config.ts
55
+ src/xspect/xspect-web/dist/index.html
56
+ src/xspect/xspect-web/dist/vite.svg
57
+ src/xspect/xspect-web/dist/assets/index-CMG4V7fZ.js
58
+ src/xspect/xspect-web/dist/assets/index-jIKg1HIy.css
59
+ src/xspect/xspect-web/public/vite.svg
60
+ src/xspect/xspect-web/src/App.tsx
61
+ src/xspect/xspect-web/src/api.tsx
62
+ src/xspect/xspect-web/src/index.css
63
+ src/xspect/xspect-web/src/main.tsx
64
+ src/xspect/xspect-web/src/types.tsx
65
+ src/xspect/xspect-web/src/utils.tsx
66
+ src/xspect/xspect-web/src/vite-env.d.ts
67
+ src/xspect/xspect-web/src/assets/react.svg
68
+ src/xspect/xspect-web/src/components/classification-form.tsx
69
+ src/xspect/xspect-web/src/components/classify.tsx
70
+ src/xspect/xspect-web/src/components/data-table.tsx
71
+ src/xspect/xspect-web/src/components/dropdown-checkboxes.tsx
72
+ src/xspect/xspect-web/src/components/dropdown-slider.tsx
73
+ src/xspect/xspect-web/src/components/filter-form.tsx
74
+ src/xspect/xspect-web/src/components/filter.tsx
75
+ src/xspect/xspect-web/src/components/header.tsx
76
+ src/xspect/xspect-web/src/components/landing.tsx
77
+ src/xspect/xspect-web/src/components/models-details.tsx
78
+ src/xspect/xspect-web/src/components/models.tsx
79
+ src/xspect/xspect-web/src/components/result-chart.tsx
80
+ src/xspect/xspect-web/src/components/result.tsx
81
+ src/xspect/xspect-web/src/components/spinner.tsx
82
+ src/xspect/xspect-web/src/components/ui/accordion.tsx
83
+ src/xspect/xspect-web/src/components/ui/button.tsx
84
+ src/xspect/xspect-web/src/components/ui/card.tsx
85
+ src/xspect/xspect-web/src/components/ui/chart.tsx
86
+ src/xspect/xspect-web/src/components/ui/command.tsx
87
+ src/xspect/xspect-web/src/components/ui/dialog.tsx
88
+ src/xspect/xspect-web/src/components/ui/dropdown-menu.tsx
89
+ src/xspect/xspect-web/src/components/ui/file-upload.tsx
90
+ src/xspect/xspect-web/src/components/ui/form.tsx
91
+ src/xspect/xspect-web/src/components/ui/input.tsx
92
+ src/xspect/xspect-web/src/components/ui/label.tsx
93
+ src/xspect/xspect-web/src/components/ui/navigation-menu.tsx
94
+ src/xspect/xspect-web/src/components/ui/popover.tsx
95
+ src/xspect/xspect-web/src/components/ui/select.tsx
96
+ src/xspect/xspect-web/src/components/ui/separator.tsx
97
+ src/xspect/xspect-web/src/components/ui/slider.tsx
98
+ src/xspect/xspect-web/src/components/ui/switch.tsx
99
+ src/xspect/xspect-web/src/components/ui/table.tsx
100
+ src/xspect/xspect-web/src/components/ui/tabs.tsx
101
+ src/xspect/xspect-web/src/lib/utils.ts
102
+ tests/__init__.py
103
+ tests/conftest.py
104
+ tests/test_cli.py
105
+ tests/test_file_io.py
106
+ tests/test_model_management.py
107
+ tests/test_model_result.py
108
+ tests/test_ncbi.py
109
+ tests/test_probabilisitc_filter_mlst_model.py
110
+ tests/test_probabilistic_filter_model.py
111
+ tests/test_probabilistic_filter_svm_model.py
112
+ tests/test_probabilistic_single_filter_model.py
113
+ tests/test_pub_mlst_handler.py
114
+ tests/test_train.py
115
+ tests/test_web.py
@@ -13,13 +13,11 @@ uvicorn
13
13
  python-multipart
14
14
 
15
15
  [docs]
16
- sphinx
17
- furo
18
- myst-parser
19
- sphinx-copybutton
20
- sphinx-autobuild
16
+ mkdocs-material
17
+ mkdocs-include-markdown-plugin
21
18
 
22
19
  [test]
23
20
  pytest
24
21
  pytest-cov
22
+ pytest-retry
25
23
  httpx
@@ -0,0 +1,32 @@
1
+ from pathlib import Path
2
+ from xspect.mlst_feature.mlst_helper import pick_scheme_from_models_dir
3
+ import xspect.model_management as mm
4
+ from xspect.models.probabilistic_filter_mlst_model import (
5
+ ProbabilisticFilterMlstSchemeModel,
6
+ )
7
+
8
+
9
+ def classify_genus(
10
+ model_genus: str, input_path: Path, output_path: Path, step: int = 1
11
+ ):
12
+ """Classify the input file using the genus model."""
13
+ model = mm.get_genus_model(model_genus)
14
+ result = model.predict(input_path, step=step)
15
+ result.input_source = input_path.name
16
+ result.save(output_path)
17
+
18
+
19
+ def classify_species(model_genus, input_path, output_path, step=1):
20
+ """Classify the input file using the species model."""
21
+ model = mm.get_species_model(model_genus)
22
+ result = model.predict(input_path, step=step)
23
+ result.input_source = input_path.name
24
+ result.save(output_path)
25
+
26
+
27
+ def classify_mlst(input_path, output_path):
28
+ """Classify the input file using the MLST model."""
29
+ scheme_path = pick_scheme_from_models_dir()
30
+ model = ProbabilisticFilterMlstSchemeModel.load(scheme_path)
31
+ result = model.predict(scheme_path, input_path)
32
+ result.save(output_path)
@@ -20,17 +20,11 @@ def delete_zip_files(dir_path):
20
20
 
21
21
 
22
22
  def extract_zip(zip_path: Path, unzipped_path: Path):
23
- """Extracts all files from a directory with zip files."""
24
- # Make new directory.
23
+ """Extracts all files from a zip file."""
25
24
  unzipped_path.mkdir(parents=True, exist_ok=True)
26
25
 
27
- file_names = os.listdir(zip_path)
28
- for file in file_names:
29
- file_path = zip_path / file
30
- if zipfile.is_zipfile(file_path):
31
- with zipfile.ZipFile(file_path) as item:
32
- directory = unzipped_path / file.replace(".zip", "")
33
- item.extractall(directory)
26
+ with zipfile.ZipFile(zip_path) as item:
27
+ item.extractall(unzipped_path)
34
28
 
35
29
 
36
30
  def concatenate_meta(path: Path, genus: str):
@@ -0,0 +1,56 @@
1
+ from pathlib import Path
2
+ from xspect.model_management import get_genus_model, get_species_model
3
+ from xspect.file_io import filter_sequences
4
+
5
+
6
+ def filter_species(
7
+ model_genus: str,
8
+ model_species: str,
9
+ input_path: Path,
10
+ output_path: Path,
11
+ threshold: float,
12
+ ):
13
+ """Filter sequences by species.
14
+ This function filters sequences from the input file based on the species model.
15
+ It uses the genus model to identify the genus of the sequences and then applies
16
+ the species model to filter the sequences.
17
+
18
+ Args:
19
+ model_genus (str): The genus model slug.
20
+ model_species (str): The species model slug.
21
+ input_path (Path): The path to the input file containing sequences.
22
+ output_path (Path): The path to the output file where filtered sequences will be saved.
23
+ threshold (float): The threshold for filtering sequences. Only sequences with a score
24
+ above this threshold will be included in the output file.
25
+ """
26
+ species_model = get_species_model(model_genus)
27
+ result = species_model.predict(input_path)
28
+ included_ids = result.get_filtered_subsequence_labels(model_species, threshold)
29
+ if not included_ids:
30
+ print("No sequences found for the given species.")
31
+ return
32
+ filter_sequences(
33
+ input_path,
34
+ output_path,
35
+ included_ids,
36
+ )
37
+
38
+
39
+ def filter_genus(
40
+ model_genus: str,
41
+ input_path: Path,
42
+ output_path: Path,
43
+ threshold: float,
44
+ ):
45
+ genus_model = get_genus_model(model_genus)
46
+ result = genus_model.predict(Path(input_path))
47
+ included_ids = result.get_filtered_subsequence_labels(model_genus, threshold)
48
+ if not included_ids:
49
+ print("No sequences found for the given genus.")
50
+ return
51
+
52
+ filter_sequences(
53
+ input_path,
54
+ output_path,
55
+ included_ids,
56
+ )