From b0ed85aabdf8cdd5e8185405fbb611f14755e0c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20W=C3=B6ste?= Date: Fri, 2 Feb 2018 14:52:01 +0100 Subject: [PATCH] Generalize igv image directive Now only dependent on sample, chr and pos instead of variant instance. --- public/viper/igv-image/IgvImageDirective.js | 28 ++++++++++--------- public/viper/igv-image/igv-image.tpl.html | 6 ++-- public/viper/pages/inspector/inspector.html | 12 ++++---- .../viper/visualization/IGVVisualizer.java | 6 ++-- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/public/viper/igv-image/IgvImageDirective.js b/public/viper/igv-image/IgvImageDirective.js index d1ce27f..c738dfd 100644 --- a/public/viper/igv-image/IgvImageDirective.js +++ b/public/viper/igv-image/IgvImageDirective.js @@ -24,9 +24,9 @@ var module = angular.module('de.imi.marw.viper.igv.image', [ Ctrl.sleepMillis = 1000; - Ctrl.variant = null; - Ctrl.chrColumn = null; - Ctrl.bpColumn = null; + Ctrl.sample = null; + Ctrl.chr = null; + Ctrl.pos = null; Ctrl.breakpointImageLink = null; Ctrl.igvConfigurationHash = null; @@ -40,25 +40,27 @@ var module = angular.module('de.imi.marw.viper.igv.image', [ function init () { - $scope.$watch(function () { return { variant: Ctrl.variant, hash: Ctrl.igvConfigurationHash }; }, Ctrl.onUpdate, true); + $scope.$watch(function () { return { sample: Ctrl.sample, chr: Ctrl.chr, pos: Ctrl.pos, hash: Ctrl.igvConfigurationHash }; }, Ctrl.onUpdate, true); } function onUpdate (newVal, oldVal) { - var variant = newVal.variant; + var sample = newVal.sample; + var chr = newVal.chr; + var pos = newVal.pos; var hash = newVal.hash; - if (variant == null || hash == null) return; + if (sample == null || chr == null || pos == null || hash == null) return; - var key = Ctrl.getSnapshotKey(variant, hash); + var key = Ctrl.getSnapshotKey(sample, chr, pos, hash); Ctrl.isSnapshotAvailable(key) .then(function (res) { var isAvailable = res.data; - var currentKey = Ctrl.getSnapshotKey(Ctrl.variant, Ctrl.igvConfigurationHash); + var currentKey = Ctrl.getSnapshotKey(Ctrl.sample, Ctrl.chr, Ctrl.pos, Ctrl.igvConfigurationHash); if (currentKey === key && res.data === 'true') { @@ -88,17 +90,17 @@ var module = angular.module('de.imi.marw.viper.igv.image', [ return promise; } - function getSnapshotKey(variant, hash) { - return variant['sample'] + '-' + variant[Ctrl.chrColumn] + '-' + variant[Ctrl.bpColumn] + "-" + hash; + function getSnapshotKey(sample, chr, pos, hash) { + return sample + '-' + chr + '-' + pos + "-" + hash; } }]) .directive('igvImage', [ function () { return { scope: { - variant: '=variant', - chrColumn: '=chrColumn', - bpColumn: '=bpColumn', + sample: '=sample', + chr: '=chr', + pos: '=pos', igvConfigurationHash: '=igvConfigurationHash' }, restrict: 'E', diff --git a/public/viper/igv-image/igv-image.tpl.html b/public/viper/igv-image/igv-image.tpl.html index 29cbd28..d647aa7 100644 --- a/public/viper/igv-image/igv-image.tpl.html +++ b/public/viper/igv-image/igv-image.tpl.html @@ -20,10 +20,10 @@ -->

Breakpoint: - {{ igvImageController.variant['sample'] }}, - {{ igvImageController.variant[igvImageController.chrColumn] }} + {{ igvImageController.sample }}, + {{ igvImageController.chr }} : - {{ igvImageController.variant[igvImageController.bpColumn] }} + {{ igvImageController.pos }}

diff --git a/public/viper/pages/inspector/inspector.html b/public/viper/pages/inspector/inspector.html index cda6a0d..b91fec4 100644 --- a/public/viper/pages/inspector/inspector.html +++ b/public/viper/pages/inspector/inspector.html @@ -196,18 +196,18 @@

Visualization settings

diff --git a/src/main/java/de/imi/marw/viper/visualization/IGVVisualizer.java b/src/main/java/de/imi/marw/viper/visualization/IGVVisualizer.java index 7da5ea9..ce251ed 100644 --- a/src/main/java/de/imi/marw/viper/visualization/IGVVisualizer.java +++ b/src/main/java/de/imi/marw/viper/visualization/IGVVisualizer.java @@ -206,9 +206,9 @@ public boolean isSnapshotDone(String key) { return this.visualizationProgressMap.getOrDefault(key, false); } - public synchronized void scheduleSnapshot(String sample, String chr, int bp, boolean isUrgent) { + public synchronized void scheduleSnapshot(String sample, String chr, int pos, boolean isUrgent) { - String key = sample + "-" + chr + "-" + bp + "-" + this.getConfigurationHash(); + String key = sample + "-" + chr + "-" + pos + "-" + this.getConfigurationHash(); boolean snapshotAlreadyScheduled = this.visualizationProgressMap.containsKey(key); if (snapshotAlreadyScheduled && (!isUrgent || this.visualizationProgressMap.get(key))) { @@ -227,7 +227,7 @@ public synchronized void scheduleSnapshot(String sample, String chr, int bp, boo "new", "load " + bamName, "collapse", - "goto " + chr + ":" + (bp - configViewRange) + "-" + (bp + configViewRange), + "goto " + chr + ":" + (pos - configViewRange) + "-" + (pos + configViewRange), "snapshot " + imageFileName };