Skip to content

Commit

Permalink
Merge pull request #118 from molgenis/feat/depthCheckbox
Browse files Browse the repository at this point in the history
Add checkbox to filter on read depth > 20
  • Loading branch information
marikaris authored Feb 1, 2021
2 parents 25934c7 + 74b5c3b commit 6e00ca0
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 9 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.6.0",
"@molgenis/vip-report-api": "0.7.0",
"bootstrap-vue": "^2.15.0",
"core-js": "^3.6.5",
"file-saver": "^2.0.2",
Expand Down
20 changes: 19 additions & 1 deletion src/components/RecordTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export default Vue.extend({
'isRecordsContainPhenotypes',
'isSamplesContainInheritance',
'isSamplesContainDenovo',
'isSamplesContainDepth',
'sampleMaternal',
'samplePaternal'
]),
Expand All @@ -302,7 +303,8 @@ export default Vue.extend({
'selectedSamplePhenotypes',
'filterRecordsByPhenotype',
'filterRecordsByInheritance',
'filterRecordsByDenovo'
'filterRecordsByDenovo',
'filterRecordsByDepth'
]),
genomeAssembly(): string {
return this.metadata.htsFile.genomeAssembly;
Expand Down Expand Up @@ -392,6 +394,11 @@ export default Vue.extend({
if (this.isSamplesContainDenovo && this.filterRecordsByDenovo) {
queries.push(this.createSampleDenovoQuery());
}
if (this.isSamplesContainDepth && this.filterRecordsByDepth) {
queries.push(this.createSampleReadDepthQuery());
}
// todo: translate ctx filter param to query
let query: Query | ComposedQuery | undefined;
Expand Down Expand Up @@ -448,6 +455,13 @@ export default Vue.extend({
args: 1
};
},
createSampleReadDepthQuery(): Query {
return {
selector: ['s', this.sample.index, 'f', 'DP'],
operator: '>=',
args: 20
};
},
hasSamplePhenotypes(): boolean {
return this.selectedSamplePhenotypes !== null && this.selectedSamplePhenotypes.page.totalElements > 0;
},
Expand Down Expand Up @@ -575,6 +589,10 @@ export default Vue.extend({
'$store.state.filterRecordsByDenovo'() {
this.page.currentPage = 1;
(this.$refs.table as BTable).refresh();
},
'$store.state.filterRecordsByDepth'() {
this.page.currentPage = 1;
(this.$refs.table as BTable).refresh();
}
}
});
Expand Down
12 changes: 9 additions & 3 deletions src/components/RecordTableControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
@change="this.setFilterRecordsByDenovo"
>{{ $t('matchDenovo') }}
</b-form-checkbox>
<b-form-checkbox
v-if="isSamplesContainDepth"
:checked="filterRecordsByDepth"
@change="this.setFilterRecordsByDepth"
>{{ $t('matchDepth') }}
</b-form-checkbox>
</div>
</template>

Expand All @@ -27,11 +33,11 @@ import { mapActions, mapGetters, mapState } from 'vuex';
export default Vue.extend({
computed: {
...mapGetters(['isRecordsContainPhenotypes', 'isSamplesContainInheritance', 'isSamplesContainDenovo']),
...mapState(['filterRecordsByPhenotype', 'filterRecordsByInheritance', 'filterRecordsByDenovo'])
...mapGetters(['isRecordsContainPhenotypes', 'isSamplesContainInheritance', 'isSamplesContainDenovo', 'isSamplesContainDepth']),
...mapState(['filterRecordsByPhenotype', 'filterRecordsByInheritance', 'filterRecordsByDenovo', 'filterRecordsByDepth'])
},
methods: {
...mapActions(['setFilterRecordsByPhenotype', 'setFilterRecordsByInheritance', 'setFilterRecordsByDenovo'])
...mapActions(['setFilterRecordsByPhenotype', 'setFilterRecordsByInheritance', 'setFilterRecordsByDenovo', 'setFilterRecordsByDepth'])
}
});
</script>
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"matchPhenotype": "Only display records that match sample phenotype(s)",
"matchInheritance": "Only display records that match inheritance",
"matchDenovo": "Only display records that are denovo",
"matchDepth": "Only display records that have a read depth of 20 or higher",
"maleAffected": "Male, Affected.",
"maleUnaffected": "Male, Unaffected.",
"maleUnknown": "Male, Unknown affected status.",
Expand Down
3 changes: 3 additions & 0 deletions src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export default {
},
setFilterRecordsByDenovo({ commit }: ActionContext<State, State>, value: boolean) {
commit('setFilterRecordsByDenovo', value);
},
setFilterRecordsByDepth({ commit }: ActionContext<State, State>, value: boolean) {
commit('setFilterRecordsByDepth', value);
}
};

Expand Down
13 changes: 13 additions & 0 deletions src/store/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,18 @@ export default {
hasSampleInheritance = vimFormat !== undefined;
}
return hasSampleInheritance;
},
/**
* Returns whether records contain read depth information.
*/
isSamplesContainDepth: (state: State): boolean => {
let hasReadDepth;
if (state.metadata === null) {
hasReadDepth = false;
} else {
const dpFormat = state.metadata.records.format.find(item => item.id === 'DP');
hasReadDepth = dpFormat !== undefined;
}
return hasReadDepth;
}
};
3 changes: 3 additions & 0 deletions src/store/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ export default {
},
setFilterRecordsByDenovo(state: State, value: boolean) {
state.filterRecordsByDenovo = value;
},
setFilterRecordsByDepth(state: State, value: boolean) {
state.filterRecordsByDepth = value;
}
};
1 change: 1 addition & 0 deletions src/store/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const state: State = {
filterRecordsByPhenotype: true,
filterRecordsByInheritance: true,
filterRecordsByDenovo: false,
filterRecordsByDepth: false,
annotations: null
};

Expand Down
1 change: 1 addition & 0 deletions src/types/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export type State = {
filterRecordsByPhenotype: boolean;
filterRecordsByInheritance: boolean;
filterRecordsByDenovo: boolean;
filterRecordsByDepth: boolean;
annotations: Annotations | null;
};
2 changes: 1 addition & 1 deletion src/views/Samples.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default Vue.extend({
components: { SampleNavigation, SampleReport },
computed: {
...mapGetters(['samples', 'getSampleById']),
...mapState(['selectedSample', 'selectedSamplePhenotypes', 'selectedSampleInheritance', 'selectedSampleDenovo'])
...mapState(['selectedSample', 'selectedSamplePhenotypes'])
},
methods: {
...mapActions(['loadMetadata', 'loadSamples', 'selectSample']),
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/store/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,11 @@ test('set filter records by denovo status', async done => {
expect(commit).toHaveBeenCalledWith('setFilterRecordsByDenovo', true);
done();
});


test('set filter records by read depth', async done => {
const commit = jest.fn() as Commit;
actions.setFilterRecordsByDepth({ commit } as ActionContext<State, State>, true);
expect(commit).toHaveBeenCalledWith('setFilterRecordsByDepth', true);
done();
});
10 changes: 10 additions & 0 deletions tests/unit/store/getters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,13 @@ test('whether records contain denovo information. null.', () => {
};
expect(getters.isSamplesContainDenovo(testState)).toEqual(false);
});

test('whether records contain read depth information. null.', () => {
const metadata = null;

const testState: State = {
...initialState,
metadata: metadata
};
expect(getters.isSamplesContainDepth(testState)).toEqual(false);
});
6 changes: 6 additions & 0 deletions tests/unit/store/mutations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ test('set filter records by denovo', () => {
mutations.setFilterRecordsByDenovo(testState, false);
expect(testState.filterRecordsByDenovo).toBe(false);
});

test('set filter records by read depth', () => {
const testState: State = { ...initialState };
mutations.setFilterRecordsByDepth(testState, false);
expect(testState.filterRecordsByDepth).toBe(false);
});

0 comments on commit 6e00ca0

Please sign in to comment.