Skip to content
Snippets Groups Projects
Commit 6de644c3 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Copy paste sequence

parent fbc19185
No related branches found
No related tags found
1 merge request!21Copy paste sequence
...@@ -97,6 +97,37 @@ def add( ...@@ -97,6 +97,37 @@ def add(
return analysis return analysis
@router.post("add-example", response={200: AnalysisOutSchema, 503: Error})
def add_example(
request,
):
request.session.set_expiry(session_expiry)
if request.session.session_key:
session_key = request.session.session_key
else:
request.session.create()
request.session.set_expiry(session_expiry)
session_key = request.session.session_key
session = Session.objects.get(session_key=session_key)
aw = AnalysisWorkflow.objects.get(galaxy_id=settings.GALAXY_WORKFLOW_ID)
# check if Galaxy online
is_galaxy_online = aw.analysis_owner.galaxy_instance.is_online()
if not is_galaxy_online:
return 503, {"message": "The Galaxy instance is offline"}
print(settings.BASE_DIR)
input_files = [
f"{settings.BASE_DIR}/analysis/data/GCF_000005845.faa",
]
params = {}
analysis = aw.invoke(session, input_files, params, "GCF_000005845.faa")
return analysis
@router.get("/", response={200: list[AnalysisOutSchema], 503: Error}) @router.get("/", response={200: list[AnalysisOutSchema], 503: Error})
def list(request): def list(request):
session_key = request.session.session_key session_key = request.session.session_key
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { useField, useForm } from 'vee-validate'
import { useField, useForm } from "vee-validate"; import { useCsrfToken } from "@/composables/useCsrfToken"
const router = useRouter();
const uppyComponentRef = ref(null)
const { meta, handleSubmit } = useForm({ const uppyComponentRef = ref(null)
const tab = ref<"local" | "paste">("null")
const maxSequenceLength = ref(10000)
const { csrfToken } = await useCsrfToken()
const { handleSubmit } = useForm({
validationSchema: { validationSchema: {
files(value) { // files(value) {
if (value?.length > 0) return true // if (value?.length > 0) return true
// return "You need to pass at least one file"
// },
sequence(value: string) {
const seqLength = value?.length
if (seqLength <= maxSequenceLength.value) return true
return `Sequences needs to be less than ${maxSequenceLength.value} characters.`
} }
} }
}); });
const files = useField("files"); const files = useField("files")
const { value: sequence, errorMessage: sequenceErrorMessage } = useField("sequence");
const { data } = await useAPI<{ is_online: boolean }>("/analysis/is-galaxy-online")
if (data.value !== null && !data.value.is_online) {
throw createError("The galaxy instance is offline")
}
const loading = ref(false)
async function addExample() {
loading.value = true
try {
await $fetch('/dfapi/analysis/add-example', {
method: 'POST',
headers: { "X-CSRFToken": csrfToken.value }
})
await navigateTo("/analyses/")
} catch (error) {
throw createError("Cannot upload the pasted sequence")
} finally {
loading.value = false
const { data, error } = await useAPI<{ is_online: boolean }>("/analysis/is-galaxy-online", {
onRequest({ request }) {
} }
})
if (data.value !== null && !data.value.is_online) {
throw createError("The galaxy instance is offline")
} }
const submit = handleSubmit(async (values) => {
loading.value = true
const formData = new FormData();
const blob = new Blob([toValue(sequence)], { type: 'text/plain' })
formData.append('genomefile', blob, 'pasted-sequence.fasta')
try {
await $fetch('/dfapi/analysis/add', {
method: 'POST',
body: formData,
headers: { "X-CSRFToken": csrfToken.value }
})
await navigateTo("/analyses/")
} catch (error) {
throw createError("Cannot upload the pasted sequence")
} finally {
loading.value = false
}
})
</script> </script>
<template> <template>
<v-card flat color="transparent"> <v-card flat color="transparent">
<v-form id="form-upload-genome"> <v-form id="form-upload-genome">
<v-card-text> <v-card-text>
<UppyGenomeUpload v-model="files.value.value" ref="uppyComponentRef" class="mb-2" /> <v-card>
<v-tabs v-model="tab" align-tabs="start">
<v-tab value="local" :rounded="false">Local fasta files</v-tab>
<v-tab value="paste" :rounded="false">Paste fasta sequences</v-tab>
<v-tab value="example" :rounded="false">Example</v-tab>
</v-tabs>
<v-card-text>
<v-window v-model="tab">
<v-window-item value="local">
<UppyGenomeUpload v-model="files.value.value" ref="uppyComponentRef" class="mb-2" />
</v-window-item>
<v-window-item value="paste">
<v-form @submit.prevent="submit">
<v-textarea v-model="sequence" :error-messages="sequenceErrorMessage" :count="maxSequenceLength"
label="Fasta sequences" variant="filled" auto-grow></v-textarea>
<v-btn type="submit" :loading="loading">Submit</v-btn>
</v-form>
</v-window-item>
<v-window-item value="example">
<v-card flat color="transparent">
<v-card-text>
You can try an example with Escherichia coli str. K-12 substr. MG1655 proteins (<a target="_blank"
href="https://www.ncbi.nlm.nih.gov/datasets/genome/GCF_000005845.2">GCF_000005845.2</a>)
</v-card-text>
<v-card-actions>
<v-btn variant="elevated" density="default" size="default" :slim="false" rounded="xl"
:loading="loading" @click="addExample()">Run
analysis for GCF_000005845.2</v-btn>
</v-card-actions>
</v-card>
</v-window-item>
</v-window>
</v-card-text>
</v-card>
</v-card-text> </v-card-text>
</v-form> </v-form>
</v-card> </v-card>
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -37,6 +37,6 @@ ...@@ -37,6 +37,6 @@
"@vue-flow/minimap": "^1.1.1", "@vue-flow/minimap": "^1.1.1",
"@vueuse/core": "^10.7.2", "@vueuse/core": "^10.7.2",
"d3": "^7.8.5", "d3": "^7.8.5",
"vee-validate": "^4.12.4" "vee-validate": "^4.12.6"
} }
} }
...@@ -78,6 +78,12 @@ function resetError(error) { ...@@ -78,6 +78,12 @@ function resetError(error) {
title="MacSyFinder v2: Improved modelling and search engine to identify molecular systems in genomes" title="MacSyFinder v2: Improved modelling and search engine to identify molecular systems in genomes"
subtitle="Néron, B; Denise, R; Coluzzi, C; Touchon, M; Rocha, E.P.C.; Abby, S.S., Peer Community Journal, 2023"> subtitle="Néron, B; Denise, R; Coluzzi, C; Touchon, M; Rocha, E.P.C.; Abby, S.S., Peer Community Journal, 2023">
</v-list-item> </v-list-item>
<v-list-item href="https://doi.org/10.1101/2024.01.25.577194" target="_blank"
title="A Comprehensive Resource for Exploring Antiphage Defense: DefenseFinder Webservice, Wiki and Databases"
subtitle="Tesson, F., Planel, R., Egorov, A., Georjon, H., Vaysset, H., Brancotte, B., Néron, B., Mordret, E., Bernheim, A., Atkinson, G., & Cury, J., Preprint, 2024
">
</v-list-item>
</v-list> </v-list>
</v-card> </v-card>
</v-col></v-row> </v-col></v-row>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment