Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display Target Categories in a User Friendly Way #315

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/ScoreSetTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import $ from "jquery";
import _ from "lodash";

import { textForTargetGeneCategory } from "@/lib/target-genes"
import useFormatters from "@/composition/formatters";
import FlexDataTable from "@/components/common/FlexDataTable";

Expand All @@ -25,6 +26,7 @@ export default {
setup: () => {
return {
...useFormatters(),
textForTargetGeneCategory: textForTargetGeneCategory
};
},

Expand Down Expand Up @@ -79,7 +81,7 @@ export default {
title: "Target",
},
{
data: (x) => _.get(x, "targetGenes[0].category", "null category"),
data: (x) => textForTargetGeneCategory(_.get(x, "targetGenes[0].category", undefined)) || "null category",
title: "Target type",
},
{
Expand Down
8 changes: 6 additions & 2 deletions src/components/common/SelectList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<div class="mavedb-listbox-controls">
</div>
</template>
<template #option="slotProps">
<template #option="slotProps">
<div>
<span>{{slotProps.option.title || slotProps.option.value}}</span>
<span>{{ optionLabel ? optionLabel(slotProps.option.value) : slotProps.option.title || optionLabel ? optionLabel(slotProps.option.value) : slotProps.option.value }}</span>
<Badge v-if="slotProps.option.badge" :value="slotProps.option.badge" class="badge"></Badge>
</div>
</template>
Expand All @@ -39,6 +39,10 @@ export default {
type: Array,
default: () => []
},
optionLabel: {
type: Function,
default: null
},
order: {
type: Array,
default: () => ['value', 'asc']
Expand Down
6 changes: 4 additions & 2 deletions src/components/screens/ExperimentView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
}}</router-link>
<div v-for="targetGene of scoreSet.targetGenes" :key="targetGene">
<div v-if="targetGene.name"><strong>Name:</strong> {{ targetGene.name }}</div>
<div v-if="targetGene.category"><strong>Type:</strong> {{ targetGene.category }}</div>
<div v-if="targetGene.category"><strong>Type:</strong> {{ textForTargetGeneCategory(targetGene.category) }}</div>

<div v-if="targetGene.targetAccession?.accession" style="word-break: break-word">
<div v-if="targetGene.targetAccession?.assembly"><strong>Assembly:</strong>
Expand Down Expand Up @@ -227,6 +227,7 @@ import PageLoading from '@/components/common/PageLoading'
import { PrimeIcons } from 'primevue/api'
import ItemNotFound from '@/components/common/ItemNotFound'
import useAuth from '@/composition/auth'
import { textForTargetGeneCategory } from '@/lib/target-genes'
import useItem from '@/composition/item'
import useFormatters from '@/composition/formatters'
import config from '@/config'
Expand All @@ -243,7 +244,8 @@ export default {

...useFormatters(),
...useItem({ itemTypeName: 'experiment' }),
userIsAuthenticated
userIsAuthenticated,
textForTargetGeneCategory: textForTargetGeneCategory
}
},

Expand Down
16 changes: 7 additions & 9 deletions src/components/screens/ScoreSetCreator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@
<template #item="slotProps">
<div>
<div>Name: {{ slotProps.item.name }}</div>
<div>Category: {{ slotProps.item.category }}</div>
<div>Category: {{ textForTargetGeneCategory(slotProps.item.category) }}</div>
<div v-for="externalIdentifier of slotProps.item.externalIdentifiers" :key=externalIdentifier.identifier>
{{ externalIdentifier.identifier.dbName }}: {{ externalIdentifier.identifier.identifier }}, Offset: {{ externalIdentifier.offset }}
</div>
Expand Down Expand Up @@ -649,7 +649,7 @@
<span class="p-float-label">
<span class="p-float-label">
<SelectButton v-model="createdTargetGenes[targetIdx].targetGene.category" :id="$scopedId('input-targetGeneCategory')"
:options="targetGeneCategories" />
:options="targetGeneCategories" :optionLabel="textForTargetGeneCategory" />
</span>
</span>
<span v-if="validationErrors[`targetGene.${targetIdx}.category`]" class="mave-field-error">{{ validationErrors[`targetGene.${targetIdx}.category`] }}</span>
Expand Down Expand Up @@ -839,7 +839,7 @@
<span class="p-float-label">
<span class="p-float-label">
<SelectButton v-model="createdTargetGenes[targetIdx].targetGene.category" :id="$scopedId('input-targetGeneCategoryLabel')"
:options="targetGeneCategories" />
:options="targetGeneCategories" :optionLabel="textForTargetGeneCategory" />
</span>
</span>
<span v-if="validationErrors[`targetGene.${targetIdx}.category`]" class="mave-field-error">{{ validationErrors[`targetGene.${targetIdx}.category`] }}</span>
Expand Down Expand Up @@ -1123,6 +1123,7 @@ import EmailPrompt from '@/components/common/EmailPrompt'
import useItem from '@/composition/item'
import useItems from '@/composition/items'
import config from '@/config'
import { TARGET_GENE_CATEGORIES, textForTargetGeneCategory } from '@/lib/target-genes'
import {ORCID_ID_REGEX} from '@/lib/orcid'
import { normalizeDoi, validateDoi} from '@/lib/identifiers'
import useFormatters from '@/composition/formatters'
Expand Down Expand Up @@ -1254,7 +1255,8 @@ export default {
taxonomySuggestions: taxonomySuggestions.items,
setTaxonomySearch: (text) => taxonomySuggestions.setRequestBody({text}),
assemblies: assemblies.items,
geneNames: geneNames.items
geneNames: geneNames.items,
textForTargetGeneCategory: textForTargetGeneCategory
}
},

Expand Down Expand Up @@ -1310,11 +1312,7 @@ export default {
'DNA',
'protein'
],
targetGeneCategories: [
'Protein coding',
'Regulatory',
'Other noncoding'
],
targetGeneCategories: TARGET_GENE_CATEGORIES,
rangeClassifications: [
'Normal',
'Abnormal'
Expand Down
16 changes: 7 additions & 9 deletions src/components/screens/ScoreSetEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@
<template #item="slotProps">
<div>
<div>Name: {{ slotProps.item.name }}</div>
<div>Category: {{ slotProps.item.category }}</div>
<div>Category: {{ textForTargetGeneCategory(slotProps.item.category) }}</div>
<div v-for="externalIdentifier of slotProps.item.externalIdentifiers" :key=externalIdentifier.identifier>
{{ externalIdentifier.identifier.dbName }}: {{ externalIdentifier.identifier.identifier }}, Offset: {{ externalIdentifier.offset }}
</div>
Expand All @@ -402,7 +402,7 @@
<div class="field">
<span class="p-float-label">
<SelectButton v-model="targetGene.category" :id="$scopedId('input-targetGeneCategory')"
:options="targetGeneCategories" />
:options="targetGeneCategories" :optionLabel="textForTargetGeneCategory" />
</span>
</div>
<div v-for="dbName of externalGeneDatabases" class="field field-columns" :key="dbName">
Expand Down Expand Up @@ -516,7 +516,7 @@
<div class="field">
<span class="p-float-label">
<SelectButton v-model="targetGene.category" :id="$scopedId('input-targetGeneCategory')"
:options="targetGeneCategories" />
:options="targetGeneCategories" :optionLabel="textForTargetGeneCategory" />
</span>
</div>
<div>
Expand Down Expand Up @@ -732,6 +732,7 @@
import {normalizeDoi, normalizeIdentifier, normalizePubmedId, validateDoi, validateIdentifier, validatePubmedId} from '@/lib/identifiers'
import {ORCID_ID_REGEX} from '@/lib/orcid'
import useFormatters from '@/composition/formatters'
import { TARGET_GENE_CATEGORIES, textForTargetGeneCategory } from '@/lib/target-genes'

const externalGeneDatabases = ['UniProt', 'Ensembl', 'RefSeq']

Expand Down Expand Up @@ -826,7 +827,8 @@
setTaxonomySearch: (text) => taxonomySuggestions.setRequestBody({text}),
assemblies: assemblies.items,
geneNames: geneNames.items,
expandedTargetGeneRows
expandedTargetGeneRows,
textForTargetGeneCategory: textForTargetGeneCategory
}
},

Expand Down Expand Up @@ -880,11 +882,7 @@
'DNA',
'protein'
],
targetGeneCategories: [
'Protein coding',
'Regulatory',
'Other noncoding'
],
targetGeneCategories: TARGET_GENE_CATEGORIES,
rangeClassifications: [
'normal',
'abnormal'
Expand Down
4 changes: 3 additions & 1 deletion src/components/screens/ScoreSetView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
<div class="mave-score-set-section-title">Targets</div>
<div v-for="targetGene of item.targetGenes" :key="targetGene">
<div v-if="targetGene.name"><strong>Name:</strong> {{ targetGene.name }}</div>
<div v-if="targetGene.category"><strong>Type:</strong> {{ targetGene.category }}</div>
<div v-if="targetGene.category"><strong>Type:</strong> {{ textForTargetGeneCategory(targetGene.category) }}</div>

<div v-if="targetGene.targetAccession?.accession" style="word-break: break-word">
<div v-if="targetGene.targetAccession?.assembly"><strong>Assembly:</strong>
Expand Down Expand Up @@ -422,6 +422,7 @@ import useFormatters from '@/composition/formatters'
import useItem from '@/composition/item'
import useRemoteData from '@/composition/remote-data'
import config from '@/config'
import { textForTargetGeneCategory } from '@/lib/target-genes';
import {saveChartAsFile} from '@/lib/chart-export'
import { parseScoresOrCounts } from '@/lib/scores'
import { variantNotNullOrNA } from '@/lib/mave-hgvs';
Expand Down Expand Up @@ -481,6 +482,7 @@ export default {
setScoresDataUrl: scoresRemoteData.setDataUrl,
ensureScoresDataLoaded: scoresRemoteData.ensureDataLoaded,
variantSearchSuggestions,
textForTargetGeneCategory: textForTargetGeneCategory
}
},
props: {
Expand Down
4 changes: 3 additions & 1 deletion src/components/screens/SearchView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<TabPanel header="Target filters">
<div class="mavedb-search-filters">
<SelectList v-model="filterTargetNames" :options="targetNameFilterOptions" class="mavedb-search-filter-option-picker" title="Target name" />
<SelectList v-model="filterTargetTypes" :options="targetTypeFilterOptions" class="mavedb-search-filter-option-picker" title="Target type" />
<SelectList v-model="filterTargetTypes" :options="targetTypeFilterOptions" :optionLabel="textForTargetGeneCategory" class="mavedb-search-filter-option-picker" title="Target type" />
<SelectList v-model="filterTargetOrganismNames" :options="targetOrganismFilterOptions" class="mavedb-search-filter-option-picker mavedb-organism-picker" title="Target organism" />
<SelectList v-model="filterTargetAccession" :options="targetAccessionFilterOptions" class="mavedb-search-filter-option-picker mavedb-organism-picker" title="Target accession" />
</div>
Expand Down Expand Up @@ -59,6 +59,7 @@ import { defineComponent } from 'vue'
import { paths, components } from '@/schema/openapi'

import type {LocationQueryValue} from "vue-router";
import { textForTargetGeneCategory } from '@/lib/target-genes'

type ShortScoreSet = components['schemas']['ShortScoreSet']
type ShortTargetGene = components['schemas']['ShortTargetGene']
Expand Down Expand Up @@ -131,6 +132,7 @@ export default defineComponent({
language: {
emptyTable: 'Type in the search box above or use the filters to find a data set.'
},
textForTargetGeneCategory: textForTargetGeneCategory,
}
},
computed: {
Expand Down
20 changes: 20 additions & 0 deletions src/lib/target-genes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export type TargetGeneCategory = "protein_coding" | "regulatory" | "other_noncoding"

export const TARGET_GENE_CATEGORIES: TargetGeneCategory[] = [
'protein_coding',
'regulatory',
'other_noncoding'
]

export function textForTargetGeneCategory(cat: TargetGeneCategory): string | undefined {
switch (cat) {
case "protein_coding":
return "Protein Coding"
case "regulatory":
return "Regulatory"
case "other_noncoding":
return "Other noncoding"
default:
return undefined
}
}