Skip to content

Commit

Permalink
Merge pull request #16 from molgenis/feat/format
Browse files Browse the repository at this point in the history
feature: sample details
  • Loading branch information
bartcharbon authored Jun 25, 2020
2 parents ba92863 + 4172f50 commit b8780b8
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 43 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'"
},
"dependencies": {
"@molgenis/vip-report-api": "0.0.6",
"@molgenis/vip-report-api": "0.0.7",
"bootstrap-vue": "^2.15.0",
"core-js": "^3.6.5",
"html-webpack-plugin": "latest",
Expand Down
18 changes: 18 additions & 0 deletions src/components/Anchor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<a :href="href" target="_blank">
{{ text }}
<b-icon-box-arrow-in-up-right class="ml-1"/>
</a>
</template>

<script lang="ts">
// eslint-disable-next-line no-unused-vars
import Vue, {PropType} from 'vue'
export default Vue.extend({
props: {
href: String as PropType<string>,
text: [String, Number, Boolean] as PropType<string | number | boolean>
}
})
</script>
16 changes: 8 additions & 8 deletions src/components/Identifiers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
<div>
<span v-for="(id, index) in identifiers" :key="id">
<!-- dbSNP ID -->
<a v-if="id.startsWith('rs')" :href="'https://www.ncbi.nlm.nih.gov/snp/' + encodeURIComponent(id)" target="_blank">
{{ id }}
<b-icon-box-arrow-in-up-right class="ml-1"/>
</a>
<Anchor v-if="id.startsWith('rs')"
:href="'https://www.ncbi.nlm.nih.gov/snp/' + encodeURIComponent(id)"
:text="id"/>
<!-- dbVar ID -->
<a v-else-if="id.startsWith('esv') || id.startsWith('nsv')" :href="'https://www.ncbi.nlm.nih.gov/dbvar/variants/' + encodeURIComponent(id)" target="_blank">
{{ id }}
<b-icon-box-arrow-in-up-right class="ml-1"/>
</a>
<Anchor v-else-if="id.startsWith('esv') || id.startsWith('nsv')"
:href="'https://www.ncbi.nlm.nih.gov/dbvar/variants/' + encodeURIComponent(id)"
:text="id"/>
<span v-else>{{ id }}</span>
<span v-if="index < identifiers.length - 1">, </span>
</span>
Expand All @@ -20,8 +18,10 @@
<script lang="ts">
// eslint-disable-next-line no-unused-vars
import Vue, {PropType} from 'vue'
import Anchor from '@/components/Anchor.vue'
export default Vue.extend({
components: {Anchor},
props: {
identifiers: Array as PropType<string[]>
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/RecordDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h4>Info</h4>
<RecordInfoDetails :metadata="metadata.info" :info="record.n" />
<h4>Sample</h4>
<RecordSampleDetails :data="record.s[sample.index]" />
<RecordSampleDetails :metadata="metadata.format" :data="record.s[sample.index]" />
</div>
</template>

Expand Down
9 changes: 6 additions & 3 deletions src/components/RecordInfoDetailsItem.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<template>
<div>
<span v-if="metadata.number === undefined">
{{ value }}
<RecordInfoDetailsItemValue v-if="value !== null" :metadataId="metadata.id" :value="value"/>
</span>
<span v-else-if="metadata.number && metadata.number.type === 'NUMBER' && metadata.number.count === 1">
{{ value }}
<RecordInfoDetailsItemValue v-if="value !== null" :metadataId="metadata.id" :value="value"/>
</span>
<span v-else>
<span v-for="(item, index) in value" :key="index">
{{ item }}<span v-if="index < value.length - 1">, </span>
<RecordInfoDetailsItemValue v-if="value !== null" :metadataId="metadata.id" :value="item"/>
<span v-if="index < value.length - 1">, </span>
</span>
</span>
</div>
Expand All @@ -19,8 +20,10 @@
import Vue, {PropType} from 'vue'
// eslint-disable-next-line no-unused-vars
import {InfoMetadata} from '@molgenis/vip-report-api'
import RecordInfoDetailsItemValue from '@/components/RecordInfoDetailsItemValue.vue'
export default Vue.extend({
components: {RecordInfoDetailsItemValue},
props: {
metadata: Object as PropType<InfoMetadata>,
value: [String, Number, Boolean, Array, Object] as PropType<string | number | boolean | object | string[] | number[] | boolean[] | object[]>
Expand Down
27 changes: 27 additions & 0 deletions src/components/RecordInfoDetailsItemValue.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<span v-if="metadataId === 'Consequence'">
<Anchor
:href="'http://www.sequenceontology.org/browser/obob.cgi?rm=term_list&obo_query=' + encodeURIComponent(value) + '&release=current_release'"
:text="value"/>
</span>
<span v-else-if="metadataId === 'SYMBOL'">
<Anchor :href="'https://www.omim.org/search?search=' + encodeURIComponent(value) + '&field=approved_gene_symbol'" :text="value" />
</span>
<span v-else>
{{ value }}
</span>
</template>

<script lang="ts">
// eslint-disable-next-line no-unused-vars
import Vue, {PropType} from 'vue'
import Anchor from '@/components/Anchor.vue'
export default Vue.extend({
components: {Anchor},
props: {
metadataId: String as PropType<String>,
value: [String, Number, Boolean] as PropType<string | number | boolean>
}
})
</script>
18 changes: 5 additions & 13 deletions src/components/RecordInfoNestedDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@
{{ data.label }}
</template>
<template v-slot:cell()="data">
<span v-if="data.field.metadata.number === undefined">
{{ data.item[data.field.index] }}
</span>
<span v-else-if="data.field.metadata.number && data.field.metadata.number.type === 'NUMBER' && data.field.metadata.number.count === 1">
{{ data.item[data.field.index] }}
</span>
<span v-else>
<span v-for="(item, index) in data.item[data.field.index]" :key="index">
{{ item }}<span v-if="index < data.item[data.field.index].length - 1">, </span>
</span>
</span>
<RecordInfoDetailsItem :metadata="data.field.metadata" :value="data.item[data.field.index]"/>
</template>
</b-table>
</div>
Expand All @@ -29,8 +19,10 @@
import Vue, {PropType} from 'vue'
// eslint-disable-next-line no-unused-vars
import {InfoMetadata} from '@molgenis/vip-report-api'
import RecordInfoDetailsItem from '@/components/RecordInfoDetailsItem.vue'
export default Vue.extend({
components: {RecordInfoDetailsItem},
props: {
metadata: Array as PropType<InfoMetadata[]>,
info: Array as PropType<object[]>
Expand All @@ -41,7 +33,7 @@
let index = 0
for (const info of this.metadata) {
// @ts-ignore
if(this.hasData(index)) {
if (this.hasData(index)) {
fields.push({key: info.id, label: info.description, index: index, metadata: info})
}
++index
Expand All @@ -56,7 +48,7 @@
hasData(index: number): boolean {
for (let item of this.info) {
// @ts-ignore
if(!(item[index] === null || (Array.isArray(item[index]) && item[index].length === 0))) {
if (!(item[index] === null || (Array.isArray(item[index]) && item[index].length === 0))) {
return true
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/components/RecordSampleDetails.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
<template>
<div>
<!-- TODO: improve rendering once we have format metadata available -->
{{ data }}
<div>
<span v-for="(alt, index) in data.gt.a" :key="index">
<Allele :allele="alt"/>
<span v-if="index < data.gt.a.length - 1"> {{ data.gt.p ? '|' : '/'}} </span>
</span>
</div>
<RecordInfoDetails :metadata="metadata" :info="data.f" />
</div>
</template>

<script lang="ts">
// eslint-disable-next-line no-unused-vars
import Vue, {PropType} from 'vue'
// eslint-disable-next-line no-unused-vars
import {FormatMetadata} from '@molgenis/vip-report-api'
import RecordInfoDetails from '@/components/RecordInfoDetails.vue'
import Allele from '@/components/Allele.vue'
export default Vue.extend({
components: {Allele, RecordInfoDetails},
props: {
metadata: Array as PropType<FormatMetadata[]>,
data: Object as PropType<object>
}
})
Expand Down
13 changes: 5 additions & 8 deletions src/components/RecordTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,9 @@ f
</b-button>
</template>
<template v-slot:cell(p)="data">
<a v-if="genomeBrowserDb"
:href="'https://genome-euro.ucsc.edu/cgi-bin/hgTracks?db=' + encodeURIComponent(genomeBrowserDb) + '&position=' + encodeURIComponent('chr' + data.item.c + ':' + Math.max(0, (data.item.p - 500)) + '-' + (data.item.p + 500))"
target="_blank">
{{ data.item.c }}:{{ data.item.p | numberWithCommas }}
<b-icon-box-arrow-in-up-right class="ml-1"/>
</a>
<span v-else>{{ data.item.c }}:{{ data.item.p | numberWithCommas }}</span>
<Anchor v-if="genomeBrowserDb"
:href="'https://genome-euro.ucsc.edu/cgi-bin/hgTracks?db=' + encodeURIComponent(genomeBrowserDb) + '&position=' + encodeURIComponent('chr' + data.item.c + ':' + Math.max(0, (data.item.p - 500)) + '-' + (data.item.p + 500))"
:text="data.item.c + ':' + data.item.p | numberWithCommas"/>
</template>
<template v-slot:cell(i)="data">
<Identifiers :identifiers="data.item.i"/>
Expand Down Expand Up @@ -136,9 +132,10 @@ f
import RecordDetails from '@/components/RecordDetails.vue'
import Identifiers from '@/components/Identifiers.vue'
import Allele from '@/components/Allele.vue'
import Anchor from '@/components/Anchor.vue'
export default Vue.extend({
components: {Allele, Identifiers, RecordDetails},
components: {Allele, Anchor, Identifiers, RecordDetails},
props: {
sample: Object as PropType<Sample>
},
Expand Down
14 changes: 7 additions & 7 deletions src/components/SamplePheno.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
<div v-if="phenotypes.items.length === 1 && phenotypes.items[0].phenotypicFeaturesList.length > 0">
<span v-for="(phenotypicFeature, index) in phenotypes.items[0].phenotypicFeaturesList" :key="index">
<span class="mr-1">
<a v-if="phenotypicFeature.type.id.startsWith('HP:')"
:href="'https://hpo.jax.org/app/browse/term/' + phenotypicFeature.type.id" target="_blank">
{{ phenotypicFeature.type.label }}
<b-icon-box-arrow-in-up-right class="ml-1" />
</a>
<Anchor v-if="phenotypicFeature.type.id.startsWith('HP:')"
:href="'https://hpo.jax.org/app/browse/term/' + encodeURIComponent(phenotypicFeature.type.id)"
:text="phenotypicFeature.type.label"/>
<span v-else>
{{ phenotypicFeature.type.label }}
</span>
Expand All @@ -20,7 +18,7 @@
:href="'https://molgenis102.gcc.rug.nl?phenotypes=' + hpoTerms.join(',')"
target="_blank">
{{ $t('vibe') }}
<b-icon-box-arrow-in-up-right class="ml-1" />
<b-icon-box-arrow-in-up-right class="ml-1"/>
</b-button>
</div>
<div v-else>
Expand All @@ -30,16 +28,18 @@

<script lang="ts">
import Vue from 'vue'
import Anchor from '@/components/Anchor.vue'
export default Vue.extend({
components: {Anchor},
props: {
phenotypes: Object
},
computed: {
hpoTerms: function () {
let hpoTerms = []
for (let phenotypicFeature of this.phenotypes.items[0].phenotypicFeaturesList) {
if (phenotypicFeature.type.id.startsWith("HP:")) {
if (phenotypicFeature.type.id.startsWith('HP:')) {
hpoTerms.push(phenotypicFeature.type.id)
}
}
Expand Down

0 comments on commit b8780b8

Please sign in to comment.