Skip to content

Commit

Permalink
Implement upload warnings...
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Aug 17, 2023
1 parent 636af05 commit a104a9a
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 10 deletions.
12 changes: 5 additions & 7 deletions client/src/components/Upload/DefaultBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { COLLECTION_TYPES, DEFAULT_FILE_NAME, hasBrowserSupport } from "./utils"
import DefaultRow from "./DefaultRow.vue";
import UploadBox from "./UploadBox.vue";
import UploadExtension from "./UploadExtension.vue";
import UploadSelect from "./UploadSelect.vue";
import UploadSelectExtension from "./UploadSelectExtension.vue";
library.add(faCopy, faEdit, faFolderOpen, faLaptop);
Expand Down Expand Up @@ -392,15 +392,13 @@ defineExpose({
placeholder="Select Type"
@input="updateCollectionType" />
<span class="upload-footer-title">Type (set all):</span>
<UploadSelect
<UploadSelectExtension
class="upload-footer-extension"
:value="extension"
:disabled="isRunning"
:options="listExtensions"
what="file type"
placeholder="Select Type"
@input="updateExtension" />
<UploadExtension :extension="extension" :list-extensions="listExtensions" />
:list-extensions="listExtensions"
@input="updateExtension">
</UploadSelectExtension>
<span class="upload-footer-title">Reference (set all):</span>
<UploadSelect
class="upload-footer-genome"
Expand Down
14 changes: 11 additions & 3 deletions client/src/components/Upload/UploadSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const props = defineProps({
type: Boolean,
default: true,
},
warn: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(["input"]);
Expand All @@ -59,9 +63,10 @@ const currentValue = computed({
select-label=""
selected-label=""
track-by="id">
<template
><span slot="noResult" v-localize>No matching {{ what }}s found.</span></template
>
<span slot="noResult" v-localize>No matching {{ what }}s found.</span>
<span slot="singleLabel" slot-scope="{ option }" :class="{ 'selection-warning': warn }">
{{ option.text }}
</span>
</Multiselect>
</template>

Expand All @@ -71,6 +76,9 @@ const currentValue = computed({
display: inline-block;
min-height: unset;
width: 150px;
.selection-warning {
color: $brand-warning;
}
.multiselect__content-wrapper {
.multiselect__content {
width: inherit;
Expand Down
63 changes: 63 additions & 0 deletions client/src/components/Upload/UploadSelectExtension.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<script setup>
import { library } from "@fortawesome/fontawesome-svg-core";
import { faExclamationCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { computed } from "vue";
import { findExtension } from "./utils";
import UploadExtension from "./UploadExtension.vue";
import UploadSelect from "./UploadSelect.vue";
import Popper from "@/components/Popper/Popper.vue";
library.add(faExclamationCircle);
const props = defineProps({
disabled: {
type: Boolean,
default: false,
},
listExtensions: {
type: Array,
required: true,
},
value: {
type: String,
default: null,
},
});
const emit = defineEmits(["input"]);
const details = computed(() => findExtension(props.listExtensions, props.value));
const warnText = computed(() => details.value.upload_warning);
</script>

<template>
<span title="">
<UploadSelect
:value="value"
:disabled="disabled"
:options="listExtensions"
what="file type"
placeholder="Select Type"
:warn="warnText ? true : false"
@input="(newValue) => emit('input', newValue)" />
<Popper v-if="warnText" placement="bottom" mode="light">
<template v-slot:reference>
<FontAwesomeIcon icon="fa-exclamation-circle" class="selection-warning" />
</template>
<div class="p-2">
{{ warnText }}
</div>
</Popper>
<UploadExtension :extension="value" :list-extensions="listExtensions" />
</span>
</template>

<style lang="scss" scoped>
@import "theme/blue.scss";
.selection-warning {
color: $brand-warning;
}
</style>
1 change: 1 addition & 0 deletions client/src/components/Upload/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ async function loadUploadDatatypes() {
description: datatypes[key].description,
description_url: datatypes[key].description_url,
composite_files: datatypes[key].composite_files,
upload_warning: datatypes[key].upload_warning,
});
}
listExtensions.sort((a, b) => {
Expand Down
5 changes: 5 additions & 0 deletions client/src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3631,6 +3631,11 @@ export interface components {
* @example bed
*/
extension: string;
/**
* Upload warning
* @description End-user information regarding potential pitfalls with this upload type.
*/
upload_warning?: string;
};
/** DatatypeEDAMDetails */
DatatypeEDAMDetails: {
Expand Down
6 changes: 6 additions & 0 deletions lib/galaxy/config/sample/datatypes_conf.xml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
</datatype>
<datatype extension="fastg" type="galaxy.datatypes.sequence:Fastg" display_in_upload="true" description="fastg format faithfully represents genome assemblies in the face of allelic polymorphism and assembly uncertainty" description_url="http://fastg.sourceforge.net/FASTG_Spec_v1.00.pdf"/>
<datatype extension="fastq" auto_compressed_types="gz,bz2" type="galaxy.datatypes.sequence:Fastq" display_in_upload="true" description="FASTQ format is a text-based format for storing both a biological sequence (usually nucleotide sequence) and its corresponding quality scores." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Fastq">
<upload_warning>
Generally a more specific fastq datatype should be specified, please consider selecting fastqsanger${auto_compressed_type} instead.
</upload_warning>
<converter file="fastq_to_fqtoc.xml" target_datatype="fqtoc"/>
</datatype>
<datatype extension="fastqsanger" auto_compressed_types="gz,bz2" type="galaxy.datatypes.sequence:FastqSanger" display_in_upload="true" description="Sanger variant of the FASTQ format: phred+33">
Expand All @@ -147,6 +150,9 @@
<converter file="fastq_to_fqtoc.xml" target_datatype="fqtoc"/>
</datatype>
<datatype extension="fastqcssanger" auto_compressed_types="gz,bz2" type="galaxy.datatypes.sequence:FastqCSSanger" display_in_upload="true" description="sequence in in color space phred scored quality values 0:93 represented by ASCII 33:126">
<upload_warning>
Color space data is rarely used in modern analyses, please consider selecting fastqsanger${auto_compressed_type} instead.
</upload_warning>
<converter file="fastq_to_fqtoc.xml" target_datatype="fqtoc"/>
</datatype>
<datatype extension="fastqillumina" auto_compressed_types="gz,bz2" type="galaxy.datatypes.sequence:FastqIllumina" display_in_upload="true" description="Sanger variant of the FASTQ format: phred+64">
Expand Down
5 changes: 5 additions & 0 deletions lib/galaxy/datatypes/_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class DatatypeDetails(BaseModel):
composite_files: Optional[List[CompositeFileInfo]] = Field(
default=None, title="Composite files", description="A collection of files composing this data type"
)
upload_warning: Optional[str] = Field(
default=None,
title="Upload warning",
description="End-user information regarding potential pitfalls with this upload type.",
)


class DatatypesMap(BaseModel):
Expand Down
17 changes: 17 additions & 0 deletions lib/galaxy/datatypes/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,14 @@ def __import_module(full_path: str, datatype_module: str):
datatype_class.is_subclass = make_subclass
description = elem.get("description", None)
description_url = elem.get("description_url", None)

# process as a list, in the future handle grabbing extensions here
upload_warning_els = elem.findall("upload_warning")
upload_warning_template = None
for upload_warning_el in upload_warning_els:
if upload_warning_template is not None:
raise NotImplementedError("Multiple upload_warnings not implemented")
upload_warning_template = Template(upload_warning_el.text)
datatype_instance = datatype_class()
self.datatypes_by_extension[extension] = datatype_instance
if mimetype is None:
Expand Down Expand Up @@ -303,6 +311,7 @@ def __import_module(full_path: str, datatype_module: str):
"extension": extension,
"description": description,
"description_url": description_url,
"upload_warning": upload_warning(upload_warning_template),
}
composite_files = datatype_instance.get_composite_files()
if composite_files:
Expand Down Expand Up @@ -353,6 +362,7 @@ def __import_module(full_path: str, datatype_module: str):
"extension": compressed_extension,
"description": description,
"description_url": description_url,
"upload_warning": upload_warning(upload_warning_template, auto_compressed_type),
}
)
if auto_compressed_type == "gz":
Expand Down Expand Up @@ -965,6 +975,13 @@ def __getstate__(self):
return state


def upload_warning(template: Optional[Template], auto_compressed_type: Optional[str] = None) -> Optional[str]:
if template is None:
return None
template_args = {"auto_compressed_type": "" if auto_compressed_type is None else f".{auto_compressed_type}"}
return template.safe_substitute(template_args)


def example_datatype_registry_for_sample(sniff_compressed_dynamic_datatypes_default=True):
galaxy_dir = galaxy.util.galaxy_directory()
sample_conf = os.path.join(galaxy_dir, "lib", "galaxy", "config", "sample", "datatypes_conf.xml.sample")
Expand Down

0 comments on commit a104a9a

Please sign in to comment.