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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Header from "@/components/header"
|
|
2
|
+
import Landing from "@/components/landing";
|
|
3
|
+
import Classify from "@/components/classify"
|
|
4
|
+
import Filter from "@/components/filter"
|
|
5
|
+
import Models from "@/components/models"
|
|
6
|
+
import Result from "@/components/result"
|
|
7
|
+
import { BrowserRouter as Router, Routes, Route } from "react-router-dom"
|
|
8
|
+
import ModelDetails from "./components/models-details";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function App() {
|
|
12
|
+
return (
|
|
13
|
+
<Router basename="/xspect-web">
|
|
14
|
+
<div className="min-h-screen flex flex-col">
|
|
15
|
+
<Header />
|
|
16
|
+
<Routes>
|
|
17
|
+
<Route path="/classify" element={<Classify />} />
|
|
18
|
+
<Route path="/filter" element={<Filter />} />
|
|
19
|
+
<Route path="/models" element={<Models />} />
|
|
20
|
+
<Route path="/models/:model_slug" element={<ModelDetails />} />
|
|
21
|
+
<Route path="/result/:classification_uuid" element={<Result />} />
|
|
22
|
+
<Route path="*" element={<Landing />} />
|
|
23
|
+
</Routes>
|
|
24
|
+
</div>
|
|
25
|
+
</Router>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default App
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { Models, ClassificationResult, ModelMetadata } from '@/types';
|
|
3
|
+
|
|
4
|
+
export async function getModels(): Promise<Models> {
|
|
5
|
+
try {
|
|
6
|
+
const response = await axios.get('/api/list-models');
|
|
7
|
+
return response.data as Models;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error('Error fetching models:', error);
|
|
10
|
+
throw new Error('Failed to fetch models');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function uploadFile(file: File): Promise<{ filename: string }> {
|
|
15
|
+
try {
|
|
16
|
+
const formData = new FormData();
|
|
17
|
+
formData.append('file', file);
|
|
18
|
+
const response = await axios.post('/api/upload-file', formData, {
|
|
19
|
+
headers: {
|
|
20
|
+
'Content-Type': 'multipart/form-data',
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
return response.data as { filename: string };
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error('Error uploading file:', error);
|
|
26
|
+
throw new Error('Failed to upload file');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function classify(filename: string, classification_type: string, model: string, step: number): Promise<any> {
|
|
31
|
+
try {
|
|
32
|
+
const response = await axios.post(`/api/classify?classification_type=${classification_type}&model=${model}&file=${filename}&step=${step}`);
|
|
33
|
+
return response.data;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error('Error classifying file:', error);
|
|
36
|
+
throw new Error('Failed to classify file');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function getClassificationResult(classification_uuid: string): Promise<ClassificationResult> {
|
|
41
|
+
try {
|
|
42
|
+
const response = await axios.get(`/api/classification-result`, {
|
|
43
|
+
params: { uuid: classification_uuid },
|
|
44
|
+
});
|
|
45
|
+
return response.data as ClassificationResult;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('Error fetching classification result:', error);
|
|
48
|
+
throw new Error('Failed to fetch classification result');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function getModelMetadata(modelSlug: string): Promise<ModelMetadata> {
|
|
53
|
+
try {
|
|
54
|
+
const response = await axios.get(`/api/model-metadata`, {
|
|
55
|
+
params: { model_slug: modelSlug },
|
|
56
|
+
});
|
|
57
|
+
return response.data as ModelMetadata;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error('Error fetching model metadata:', error);
|
|
60
|
+
throw new Error('Failed to fetch model metadata');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { zodResolver } from "@hookform/resolvers/zod"
|
|
2
|
+
import { useForm } from "react-hook-form"
|
|
3
|
+
import { z } from "zod"
|
|
4
|
+
import { Button } from "@/components/ui/button"
|
|
5
|
+
import { Switch } from "@/components/ui/switch"
|
|
6
|
+
import { Input } from "@/components/ui/input"
|
|
7
|
+
import {
|
|
8
|
+
Form,
|
|
9
|
+
FormControl,
|
|
10
|
+
FormDescription,
|
|
11
|
+
FormField,
|
|
12
|
+
FormItem,
|
|
13
|
+
FormLabel,
|
|
14
|
+
FormMessage,
|
|
15
|
+
} from "@/components/ui/form"
|
|
16
|
+
import {
|
|
17
|
+
Select,
|
|
18
|
+
SelectContent,
|
|
19
|
+
SelectItem,
|
|
20
|
+
SelectTrigger,
|
|
21
|
+
SelectValue,
|
|
22
|
+
} from "@/components/ui/select"
|
|
23
|
+
import { classify, getModels, uploadFile } from "../api"
|
|
24
|
+
import {
|
|
25
|
+
FileUpload,
|
|
26
|
+
FileUploadDropzone,
|
|
27
|
+
FileUploadItem,
|
|
28
|
+
FileUploadItemDelete,
|
|
29
|
+
FileUploadItemMetadata,
|
|
30
|
+
FileUploadItemPreview,
|
|
31
|
+
FileUploadItemProgress,
|
|
32
|
+
FileUploadList,
|
|
33
|
+
FileUploadTrigger,
|
|
34
|
+
} from "@/components/ui/file-upload";
|
|
35
|
+
import { Upload, X } from "lucide-react";
|
|
36
|
+
import { useState, useCallback, useEffect } from "react"
|
|
37
|
+
import { useNavigate } from "react-router-dom"
|
|
38
|
+
|
|
39
|
+
const FormSchema = z.object({
|
|
40
|
+
input_file: z.string().min(1, "Please upload a file"),
|
|
41
|
+
classification_type: z.enum([
|
|
42
|
+
"Genus",
|
|
43
|
+
"Species",
|
|
44
|
+
"MLST",
|
|
45
|
+
]),
|
|
46
|
+
model: z.string(),
|
|
47
|
+
sparse_sampling: z.boolean(),
|
|
48
|
+
sparse_sampling_step: z.number().min(1).max(500)
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export default function ClassificationForm() {
|
|
52
|
+
|
|
53
|
+
const [models, setModels] = useState<Record<string, string[]>>({});
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
getModels()
|
|
57
|
+
.then((data) => {
|
|
58
|
+
setModels(data);
|
|
59
|
+
})
|
|
60
|
+
.catch((error) => {
|
|
61
|
+
console.error("Error fetching models:", error);
|
|
62
|
+
});
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
const navigate = useNavigate()
|
|
66
|
+
|
|
67
|
+
const form = useForm<z.infer<typeof FormSchema>>({
|
|
68
|
+
resolver: zodResolver(FormSchema),
|
|
69
|
+
defaultValues: {
|
|
70
|
+
classification_type: "Species",
|
|
71
|
+
model: undefined,
|
|
72
|
+
sparse_sampling: false,
|
|
73
|
+
sparse_sampling_step: 1,
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
const onUpload = useCallback(
|
|
80
|
+
async (
|
|
81
|
+
files: File[],
|
|
82
|
+
{
|
|
83
|
+
onSuccess,
|
|
84
|
+
onError,
|
|
85
|
+
}: {
|
|
86
|
+
onSuccess: (file: File) => void;
|
|
87
|
+
onError: (file: File, error: Error) => void;
|
|
88
|
+
},
|
|
89
|
+
) => {
|
|
90
|
+
const file = files[0]
|
|
91
|
+
try {
|
|
92
|
+
const { filename } = await uploadFile(file)
|
|
93
|
+
onSuccess(file)
|
|
94
|
+
console.log("File uploaded successfully:", filename)
|
|
95
|
+
form.setValue("input_file", filename)
|
|
96
|
+
} catch (error) {
|
|
97
|
+
onError(file, error as Error)
|
|
98
|
+
console.error("Error uploading file:", error)
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
[form]
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const onFileReject = useCallback((file: File, message: string) => {
|
|
105
|
+
console.log(message, {
|
|
106
|
+
description: `"${file.name.length > 20 ? `${file.name.slice(0, 20)}...` : file.name}" has been rejected`,
|
|
107
|
+
});
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
function onSubmit(data: z.infer<typeof FormSchema>) {
|
|
111
|
+
classify(data.input_file, data.classification_type, data.model, data.sparse_sampling_step)
|
|
112
|
+
.then((response) => {
|
|
113
|
+
console.log("Classification response:", response)
|
|
114
|
+
navigate(`/result/${response.uuid}`)
|
|
115
|
+
})
|
|
116
|
+
.catch((error) => {
|
|
117
|
+
console.error("Error during classification:", error)
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
|
|
123
|
+
<Form {...form}>
|
|
124
|
+
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
|
|
125
|
+
<FormField
|
|
126
|
+
control={form.control}
|
|
127
|
+
name="input_file"
|
|
128
|
+
render={({ field }) => (
|
|
129
|
+
<FormItem>
|
|
130
|
+
<FormLabel>Input File</FormLabel>
|
|
131
|
+
<FormControl>
|
|
132
|
+
<FileUpload
|
|
133
|
+
value={files}
|
|
134
|
+
onValueChange={setFiles}
|
|
135
|
+
onUpload={onUpload}
|
|
136
|
+
onFileReject={onFileReject}
|
|
137
|
+
maxFiles={1}
|
|
138
|
+
multiple
|
|
139
|
+
>
|
|
140
|
+
{files.length === 0 && (
|
|
141
|
+
<FileUploadDropzone>
|
|
142
|
+
<div className="flex flex-col items-center gap-1 text-center">
|
|
143
|
+
<div className="flex items-center justify-center rounded-full border p-2.5">
|
|
144
|
+
<Upload className="size-6 text-muted-foreground" />
|
|
145
|
+
</div>
|
|
146
|
+
<p className="font-medium text-sm">Drag & drop file here</p>
|
|
147
|
+
<p className="text-muted-foreground text-xs">
|
|
148
|
+
Or click to browse
|
|
149
|
+
</p>
|
|
150
|
+
</div>
|
|
151
|
+
<FileUploadTrigger asChild>
|
|
152
|
+
<Button variant="outline" size="sm" className="mt-2 w-fit">
|
|
153
|
+
Browse files
|
|
154
|
+
</Button>
|
|
155
|
+
</FileUploadTrigger>
|
|
156
|
+
</FileUploadDropzone>
|
|
157
|
+
)}
|
|
158
|
+
<FileUploadList>
|
|
159
|
+
{files.map((file, index) => (
|
|
160
|
+
<FileUploadItem key={index} value={file} className="flex-col">
|
|
161
|
+
<div className="flex w-full items-center gap-2">
|
|
162
|
+
<FileUploadItemPreview />
|
|
163
|
+
<FileUploadItemMetadata />
|
|
164
|
+
<FileUploadItemDelete asChild>
|
|
165
|
+
<Button variant="ghost" size="icon" className="size-7" onClick={() => {
|
|
166
|
+
setFiles((prev) => prev.filter((_, i) => i !== index));
|
|
167
|
+
form.setValue("input_file", "")
|
|
168
|
+
}}>
|
|
169
|
+
<X />
|
|
170
|
+
</Button>
|
|
171
|
+
</FileUploadItemDelete>
|
|
172
|
+
</div>
|
|
173
|
+
<FileUploadItemProgress />
|
|
174
|
+
</FileUploadItem>
|
|
175
|
+
))}
|
|
176
|
+
</FileUploadList>
|
|
177
|
+
</FileUpload>
|
|
178
|
+
</FormControl>
|
|
179
|
+
<FormDescription>
|
|
180
|
+
Upload the file you would like to classify.
|
|
181
|
+
</FormDescription>
|
|
182
|
+
<FormMessage />
|
|
183
|
+
</FormItem>
|
|
184
|
+
)}
|
|
185
|
+
/>
|
|
186
|
+
<FormField
|
|
187
|
+
control={form.control}
|
|
188
|
+
name="classification_type"
|
|
189
|
+
render={({ field }) => (
|
|
190
|
+
<FormItem>
|
|
191
|
+
<FormLabel>Classification Type</FormLabel>
|
|
192
|
+
<FormControl>
|
|
193
|
+
<Select defaultValue="Species" onValueChange={(value) => field.onChange(value)}>
|
|
194
|
+
<SelectTrigger className="w-full">
|
|
195
|
+
<SelectValue />
|
|
196
|
+
</SelectTrigger>
|
|
197
|
+
<SelectContent>
|
|
198
|
+
<SelectItem value="Genus">Genus</SelectItem>
|
|
199
|
+
<SelectItem value="Species">Species</SelectItem>
|
|
200
|
+
<SelectItem value="MLST">MLST</SelectItem>
|
|
201
|
+
</SelectContent>
|
|
202
|
+
</Select>
|
|
203
|
+
</FormControl>
|
|
204
|
+
<FormDescription>
|
|
205
|
+
Select the type of classification you would like to perform.
|
|
206
|
+
</FormDescription>
|
|
207
|
+
<FormMessage />
|
|
208
|
+
</FormItem>
|
|
209
|
+
)}
|
|
210
|
+
/>
|
|
211
|
+
<FormField
|
|
212
|
+
control={form.control}
|
|
213
|
+
name="model"
|
|
214
|
+
render={({ field }) => (
|
|
215
|
+
<FormItem>
|
|
216
|
+
<FormLabel>Model</FormLabel>
|
|
217
|
+
<FormControl>
|
|
218
|
+
<Select onValueChange={field.onChange}>
|
|
219
|
+
<SelectTrigger className="w-full">
|
|
220
|
+
<SelectValue />
|
|
221
|
+
</SelectTrigger>
|
|
222
|
+
<SelectContent>
|
|
223
|
+
{models[form.watch("classification_type")]?.map((model: string) => (
|
|
224
|
+
<SelectItem key={model} value={model}>
|
|
225
|
+
{model}
|
|
226
|
+
</SelectItem>
|
|
227
|
+
))}
|
|
228
|
+
</SelectContent>
|
|
229
|
+
</Select>
|
|
230
|
+
</FormControl>
|
|
231
|
+
<FormDescription>
|
|
232
|
+
Select the model you would like to use for classification.
|
|
233
|
+
</FormDescription>
|
|
234
|
+
<FormMessage />
|
|
235
|
+
</FormItem>
|
|
236
|
+
)}
|
|
237
|
+
/>
|
|
238
|
+
<FormField
|
|
239
|
+
control={form.control}
|
|
240
|
+
name="sparse_sampling"
|
|
241
|
+
render={({ field }) => (
|
|
242
|
+
<FormItem className="flex flex-row items-center justify-between pr-2">
|
|
243
|
+
<div className="space-y-0.5">
|
|
244
|
+
<FormLabel>Sparse Sampling</FormLabel>
|
|
245
|
+
<FormDescription>
|
|
246
|
+
Enable sparse sampling for classification.
|
|
247
|
+
</FormDescription>
|
|
248
|
+
</div>
|
|
249
|
+
<FormControl>
|
|
250
|
+
<Switch
|
|
251
|
+
checked={field.value}
|
|
252
|
+
onCheckedChange={field.onChange}
|
|
253
|
+
/>
|
|
254
|
+
</FormControl>
|
|
255
|
+
</FormItem>
|
|
256
|
+
)}
|
|
257
|
+
/>
|
|
258
|
+
{form.watch("sparse_sampling") && (
|
|
259
|
+
<FormField
|
|
260
|
+
control={form.control}
|
|
261
|
+
name="sparse_sampling_step"
|
|
262
|
+
render={({ field }) => (
|
|
263
|
+
<FormItem>
|
|
264
|
+
<FormLabel>Sparse Sampling Step</FormLabel>
|
|
265
|
+
<FormControl>
|
|
266
|
+
<Input
|
|
267
|
+
type="number"
|
|
268
|
+
value={field.value}
|
|
269
|
+
onChange={(e) => field.onChange(Number(e.target.value))}
|
|
270
|
+
/>
|
|
271
|
+
</FormControl>
|
|
272
|
+
<FormDescription>
|
|
273
|
+
Set the step size for sparse sampling.
|
|
274
|
+
</FormDescription>
|
|
275
|
+
<FormMessage />
|
|
276
|
+
</FormItem>
|
|
277
|
+
)}
|
|
278
|
+
/>
|
|
279
|
+
)}
|
|
280
|
+
<Button type="submit">Classify</Button>
|
|
281
|
+
</form>
|
|
282
|
+
</Form>
|
|
283
|
+
)
|
|
284
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ClassificationForm from "./classification-form";
|
|
2
|
+
import { Separator } from "@/components/ui/separator"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default function Classify() {
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<main className="flex-1 flex flex-col items-center justify-center p-4">
|
|
10
|
+
<div className="w-1/2">
|
|
11
|
+
<h1 className="text-xl font-bold">Classify your data</h1>
|
|
12
|
+
<p>Upload your data and select a model to classify it.</p>
|
|
13
|
+
<Separator className="my-4" />
|
|
14
|
+
<ClassificationForm />
|
|
15
|
+
</div>
|
|
16
|
+
</main>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ColumnDef,
|
|
3
|
+
flexRender,
|
|
4
|
+
getCoreRowModel,
|
|
5
|
+
useReactTable,
|
|
6
|
+
} from "@tanstack/react-table"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Table,
|
|
10
|
+
TableBody,
|
|
11
|
+
TableCell,
|
|
12
|
+
TableHead,
|
|
13
|
+
TableHeader,
|
|
14
|
+
TableRow,
|
|
15
|
+
} from "@/components/ui/table"
|
|
16
|
+
|
|
17
|
+
interface DataTableProps<TData, TValue> {
|
|
18
|
+
columns: ColumnDef<TData, TValue>[]
|
|
19
|
+
data: TData[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function DataTable<TData, TValue>({
|
|
23
|
+
columns,
|
|
24
|
+
data,
|
|
25
|
+
}: DataTableProps<TData, TValue>) {
|
|
26
|
+
const table = useReactTable({
|
|
27
|
+
data,
|
|
28
|
+
columns,
|
|
29
|
+
getCoreRowModel: getCoreRowModel(),
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className="rounded-md border">
|
|
34
|
+
<Table>
|
|
35
|
+
<TableHeader>
|
|
36
|
+
{table.getHeaderGroups().map((headerGroup) => (
|
|
37
|
+
<TableRow key={headerGroup.id}>
|
|
38
|
+
{headerGroup.headers.map((header) => {
|
|
39
|
+
return (
|
|
40
|
+
<TableHead key={header.id}>
|
|
41
|
+
{header.isPlaceholder
|
|
42
|
+
? null
|
|
43
|
+
: flexRender(
|
|
44
|
+
header.column.columnDef.header,
|
|
45
|
+
header.getContext()
|
|
46
|
+
)}
|
|
47
|
+
</TableHead>
|
|
48
|
+
)
|
|
49
|
+
})}
|
|
50
|
+
</TableRow>
|
|
51
|
+
))}
|
|
52
|
+
</TableHeader>
|
|
53
|
+
<TableBody>
|
|
54
|
+
{table.getRowModel().rows?.length ? (
|
|
55
|
+
table.getRowModel().rows.map((row) => (
|
|
56
|
+
<TableRow
|
|
57
|
+
key={row.id}
|
|
58
|
+
data-state={row.getIsSelected() && "selected"}
|
|
59
|
+
>
|
|
60
|
+
{row.getVisibleCells().map((cell) => (
|
|
61
|
+
<TableCell key={cell.id}>
|
|
62
|
+
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
63
|
+
</TableCell>
|
|
64
|
+
))}
|
|
65
|
+
</TableRow>
|
|
66
|
+
))
|
|
67
|
+
) : (
|
|
68
|
+
<TableRow>
|
|
69
|
+
<TableCell colSpan={columns.length} className="h-24 text-center">
|
|
70
|
+
No results.
|
|
71
|
+
</TableCell>
|
|
72
|
+
</TableRow>
|
|
73
|
+
)}
|
|
74
|
+
</TableBody>
|
|
75
|
+
</Table>
|
|
76
|
+
</div>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { DropdownMenuCheckboxItemProps } from "@radix-ui/react-dropdown-menu"
|
|
3
|
+
|
|
4
|
+
import { Button } from "@/components/ui/button"
|
|
5
|
+
import {
|
|
6
|
+
DropdownMenu,
|
|
7
|
+
DropdownMenuCheckboxItem,
|
|
8
|
+
DropdownMenuContent,
|
|
9
|
+
DropdownMenuLabel,
|
|
10
|
+
DropdownMenuSeparator,
|
|
11
|
+
DropdownMenuTrigger,
|
|
12
|
+
} from "@/components/ui/dropdown-menu"
|
|
13
|
+
import { ChevronDown } from "lucide-react"
|
|
14
|
+
|
|
15
|
+
type Checked = DropdownMenuCheckboxItemProps["checked"]
|
|
16
|
+
|
|
17
|
+
interface DropdownCheckboxItem {
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
checked: Checked;
|
|
21
|
+
onCheckedChange: (checked: Checked) => void;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface DropdownMenuCheckboxesProps {
|
|
26
|
+
triggerButtonText?: string;
|
|
27
|
+
labelText?: string;
|
|
28
|
+
items: DropdownCheckboxItem[];
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function DropdownMenuCheckboxes({
|
|
33
|
+
triggerButtonText,
|
|
34
|
+
labelText,
|
|
35
|
+
items,
|
|
36
|
+
disabled = false,
|
|
37
|
+
}: DropdownMenuCheckboxesProps) {
|
|
38
|
+
return (
|
|
39
|
+
<DropdownMenu>
|
|
40
|
+
<DropdownMenuTrigger asChild>
|
|
41
|
+
<Button variant="ghost" disabled={disabled}>{triggerButtonText}<ChevronDown /></Button>
|
|
42
|
+
</DropdownMenuTrigger>
|
|
43
|
+
<DropdownMenuContent className="w-56">
|
|
44
|
+
{labelText && (
|
|
45
|
+
<>
|
|
46
|
+
<DropdownMenuLabel>{labelText}</DropdownMenuLabel>
|
|
47
|
+
<DropdownMenuSeparator />
|
|
48
|
+
</>
|
|
49
|
+
)}
|
|
50
|
+
{items.map((item) => (
|
|
51
|
+
<DropdownMenuCheckboxItem
|
|
52
|
+
key={item.id}
|
|
53
|
+
checked={item.checked}
|
|
54
|
+
onCheckedChange={item.onCheckedChange}
|
|
55
|
+
disabled={item.disabled}
|
|
56
|
+
>
|
|
57
|
+
{item.label}
|
|
58
|
+
</DropdownMenuCheckboxItem>
|
|
59
|
+
))}
|
|
60
|
+
</DropdownMenuContent>
|
|
61
|
+
</DropdownMenu>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { DropdownMenuCheckboxItemProps } from "@radix-ui/react-dropdown-menu"
|
|
5
|
+
|
|
6
|
+
import { Button } from "@/components/ui/button"
|
|
7
|
+
import {
|
|
8
|
+
DropdownMenu,
|
|
9
|
+
DropdownMenuContent,
|
|
10
|
+
DropdownMenuTrigger,
|
|
11
|
+
} from "@/components/ui/dropdown-menu"
|
|
12
|
+
import { Slider } from "@/components/ui/slider"
|
|
13
|
+
import { ChevronDown } from "lucide-react"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
interface DropdownMenuSlider {
|
|
17
|
+
triggerButtonText?: string;
|
|
18
|
+
value: number;
|
|
19
|
+
max?: number;
|
|
20
|
+
step?: number;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function DropdownMenuSlider({
|
|
25
|
+
triggerButtonText,
|
|
26
|
+
value,
|
|
27
|
+
onValueChange,
|
|
28
|
+
max,
|
|
29
|
+
step,
|
|
30
|
+
disabled = false,
|
|
31
|
+
}: DropdownMenuSlider) {
|
|
32
|
+
return (
|
|
33
|
+
<DropdownMenu>
|
|
34
|
+
<DropdownMenuTrigger asChild>
|
|
35
|
+
<Button variant="ghost" disabled={disabled}>{triggerButtonText}<ChevronDown /></Button>
|
|
36
|
+
</DropdownMenuTrigger>
|
|
37
|
+
<DropdownMenuContent className="w-56">
|
|
38
|
+
<Slider value={[value]} onValueChange={onValueChange} max={max} step={step} className="my-3" />
|
|
39
|
+
</DropdownMenuContent>
|
|
40
|
+
</DropdownMenu>
|
|
41
|
+
)
|
|
42
|
+
}
|