Skip to content

Commit

Permalink
Jkmarx/dataset2 igv (#1433)
Browse files Browse the repository at this point in the history
* Remove tab buttons.

* Remove other orange button references.

* Refactor, remove style.

* Remove style tag.

* Remove unused states.

* Remove hanging div.

* Add conditional for dataset 2.

* Move analysis tab to it's own partial.

* Move details tab to own partial.

* Move files to own partial.

* Tab views.

* Fix unit test.

* Move display into own component.

* Set default to files.

* Add unit test.

* Remove unused code.

* Render pivotMatrixView call from within directive.

* Unwrap provenance-view-tab watcher.

* Add watchers to directive.

* Remove console.log.

* Correct description.

* Update label.

* New launch analysis component.

* Add disable button conditionals.

* Add unit test.

* Add save directive.

* Move save and reset buttons.

* Add unit tests.

* Move selected nodes text.

* Move file display and config to new layout.

* Add view and remove partial.

* Add comments.

* Adjust popover location.

* Move save funtion to node_group partial.

* Rename reset to better reflect purpose.

* Rename partial.

* Move analyses tab into own feature.

* Column adjustments.

* Parent controller.

* Move file to view folder.

* Keep only table view.

* Fix typo in address.

* Change buttons size.

* Fix hidden popover.

* Add css styling.

* Fix padding.

* Fix padding

* Fix unit test.

* Fix reset button.

* Remove console.

* Fix reset selection count.

* Fix scoping issue.

* Remove console.log

* Fix run analysis ui.

* Update color scheme.

* Add IGV directory.

* Add directive.

* Include partial in tab.

* Add css.

* Disable if no nodes are selected.

* Add error handling and code to accomodate data set2.

* Fix unit test and adjust css.

* Add modal for launching igv

* Add modal script.

* Add visualization directory.

* Add module.

* Update partials.

* Remove unused code.

* Add script to partial and launch modal when igv selected.

* Remove inline script.

* Restructure modals to launch when visualization is selected.

* Remove unused service.

* Remove ununeccessary ctrl.

* Clean up responsibilities.

* Add conditions to launching igv.

* Add factory.

* Add comments.

* Controller unit test.

* Add visualization ctrl test.

* Add directive unit tests.

* Add factory unit test.

* Comments.

* Fix filter bug.

* Fix description.

* Remove duplicate id.

* Add method comment.

* Fix unit test.

* Remove unused dependency.

* Fix logger error message.

* Clafity variable name.
  • Loading branch information
jkmarx committed Oct 4, 2016
1 parent 9e131eb commit d7d3762
Show file tree
Hide file tree
Showing 26 changed files with 721 additions and 41 deletions.
9 changes: 9 additions & 0 deletions refinery/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)

from data_set_manager.models import Node
from data_set_manager.utils import generate_solr_params
from visualization_manager.views import igv_multi_species
from annotation_server.models import GenomeBuild
from file_store.models import FileStoreItem
Expand Down Expand Up @@ -746,6 +747,14 @@ def solr_igv(request):
logger.debug('IGV data query: ' + str(igv_config['query']))
logger.debug('IGV annotation query: ' + str(igv_config['annotation']))

if igv_config['query'] is None:
# generate solr_query method
# assay uuid
solr_query = generate_solr_params({}, igv_config['assay_uuid'])
url_path = '/'.join(["data_set_manager", "select"])
url = urljoin(settings.REFINERY_SOLR_BASE_URL, url_path)
igv_config['query'] = ''.join([url, '/?', solr_query])

# attributes associated with node selection from interface
node_selection_blacklist_mode = igv_config[
'node_selection_blacklist_mode']
Expand Down
4 changes: 3 additions & 1 deletion refinery/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@
<script src="{% static "js/dashboard.js" %}"></script>
<script src="{% static "js/collaboration.js" %}"></script>
<script src="{% static "js/chart.js"%}"></script>
<script src="{% static "js/data-set-about.js" %}"></script>
<script src="{% static "js/data-set-about.js" %}"></script>
<script src="{% static "js/visualization.js" %}"></script>
<script src="{% static "js/igv.js" %}"></script>

<script src="{% static "vendor/ng-file-upload/angular-file-upload.min.js" %}"></script>
<script src="{% static "vendor/angular-ui-grid/ui-grid.min.js" %}"></script>
Expand Down
1 change: 0 additions & 1 deletion refinery/templates/core/data_set2.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ <h1>Data Set <small>{{ data_set.name }}</small></h1>
<rp-assay-files-util-modal-detail></rp-assay-files-util-modal-detail>
</script>


<script type="application/javascript">
setTimeout(function() {
sizing();
Expand Down
4 changes: 3 additions & 1 deletion refinery/ui/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
"file-browser",
"data-set-about",
"globals",
"igv",
"metadata-table-import",
"node-mapping",
"node-relationship",
"statistics",
"workflows"
"workflows",
"visualization"
],
"vendor": {
"css": [
Expand Down
5 changes: 4 additions & 1 deletion refinery/ui/source/js/analysis-monitor/filters/offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
function analysisMonitorOffset () {
return function (input, _start_) {
var start = parseInt(_start_, 10);
return input.slice(start);
if (start) {
return input.slice(start);
}
return input;
};
}

Expand Down
3 changes: 1 addition & 2 deletions refinery/ui/source/js/file-browser/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ angular
'ui.grid.infiniteScroll',
'ui.grid.resizeColumns',
'dndLists',
'ui.select',
'ngSanitize'
'ui.select'
]);
7 changes: 5 additions & 2 deletions refinery/ui/source/js/file-browser/views/files-tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</a>
</span>
</div>
<div class="col-md-6">
<div class="col-md-4">
<span class="align-bottom p-r-1-3">
{{ FBCtrl.selectNodesCount }} of
{{ FBCtrl.assayFilesTotal }} files selected.
Expand All @@ -39,7 +39,10 @@
</a>
<rp-file-browser-node-group></rp-file-browser-node-group>
</div>
<div class="col-md-offset-1 col-md-3 text-right">
<div class="col-md-3 text-right">
<rp-visualization></rp-visualization>
</div>
<div class="col-md-3 text-right">
<rp-select-workflow></rp-select-workflow>
<rp-analysis-launch></rp-analysis-launch>
</div>
Expand Down
103 changes: 103 additions & 0 deletions refinery/ui/source/js/igv/ctrls/ctrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
'use strict';

function IGVCtrl (
$scope,
$window,
$log,
$resource,
$httpParamSerializer,
$uibModalInstance,
selectedNodesService,
IGVFactory
) {
var vm = this;
// includes unused fields to accomodate current igv backend
vm.igvConfig = {
query: null,
annotation: null,
node_selection: [],
node_selection_blacklist_mode: true
};
vm.speciesList = [];
vm.selectedSpecies = { select: vm.speciesList[0] };
vm.message = null;
vm.messageType = 'info';
vm.isLoadingSpecies = true;

// Helper method to set alert message in modal
var generateAlertMessage = function (infoType) {
vm.messageType = infoType;
if (infoType === 'error') {
vm.message = 'Sorry! Unable to configure IGV for the selected file set.';
} else if (vm.speciesList.length === 0) {
vm.message = 'Please select the correct genome and launch IGV.';
} else if (vm.speciesList.length === 1) {
vm.message = null;
vm.selectedSpecies.select = vm.speciesList[0];
} else {
vm.message = 'Multiple species detected. Please select a ' +
'genome and launch IGV. You may repeat this step multiple times.';
}
};

// Helper method set igvConfig based on selected nodes
var setIGVConfig = function () {
if (selectedNodesService.selectedAllFlag) {
vm.igvConfig.node_selection = selectedNodesService.complementSelectedNodesUuids;
vm.igvConfig.node_selection_blacklist_mode = true;
vm.igvConfig.assay_uuid = $window.externalAssayUuid;
} else {
vm.igvConfig.node_selection = selectedNodesService.selectedNodesUuids;
vm.igvConfig.node_selection_blacklist_mode = false;
vm.igvConfig.assay_uuid = $window.externalAssayUuid;
}
};

// Upon launch modal, method retrives species list
vm.retrieveSpecies = function () {
setIGVConfig();

IGVFactory.getSpeciesList(vm.igvConfig).then(function () {
vm.isLoadingSpecies = false;
// update species list
vm.speciesList = IGVFactory.speciesList;
generateAlertMessage('info');
}, function () {
vm.isLoadingSpecies = false;
generateAlertMessage('error');
$log.error('Error creating IGV session URLs.');
});
};

// Launches web based IGV and dismissed modal
vm.launchIgvJs = function () {
var params = $httpParamSerializer({
species: vm.selectedSpecies.select.name,
node_ids: vm.igvConfig.node_selection
});
// close modal
$uibModalInstance.dismiss();
$window.open('/visualize/genome?' + params);
};

// Modal method to cancel
vm.cancel = function () {
$uibModalInstance.dismiss('cancel');
};

vm.retrieveSpecies();
}

angular
.module('refineryIGV')
.controller('IGVCtrl', [
'$scope',
'$window',
'$log',
'$resource',
'$httpParamSerializer',
'$uibModalInstance',
'selectedNodesService',
'IGVFactory',
IGVCtrl
]);
63 changes: 63 additions & 0 deletions refinery/ui/source/js/igv/ctrls/ctrl.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict';

describe('Controller: IGV Ctrl', function () {
var ctrl;
var scope;
var factory;
var $controller;
var $uibModalInstance = { open: function () {}, dismiss: function () {} };

beforeEach(module('refineryApp'));
beforeEach(module('refineryIGV'));
beforeEach(inject(function (
$rootScope,
_$controller_,
_IGVFactory_
) {
scope = $rootScope.$new();
$controller = _$controller_;
ctrl = $controller('IGVCtrl', {
$scope: scope,
$uibModalInstance: $uibModalInstance
});
factory = _IGVFactory_;
}));

it('IGVCtrl ctrl should exist', function () {
expect(ctrl).toBeDefined();
});

it('Data & UI displays variables should exist for views', function () {
expect(ctrl.igvConfig.node_selection).toEqual([]);
expect(ctrl.speciesList).toEqual([]);
expect(ctrl.selectedSpecies.select).toEqual();
expect(ctrl.message).toEqual(null);
expect(ctrl.messageType).toEqual('info');
expect(ctrl.isLoadingSpecies).toEqual(true);
});

it('Helper Methods exist', function () {
expect(angular.isFunction(ctrl.launchIgvJs)).toBe(true);
expect(angular.isFunction(ctrl.cancel)).toBe(true);
});

describe('Test RetrieveSpecies', function () {
it('refreshNodeGroupList is method', function () {
expect(angular.isFunction(ctrl.retrieveSpecies)).toBe(true);
});

it('getSpeciesList calls on correct factory method', function () {
var mockResponse = false;
spyOn(factory, 'getSpeciesList').and.callFake(function () {
return {
then: function () {
mockResponse = true;
}
};
});
expect(mockResponse).toEqual(false);
ctrl.retrieveSpecies();
expect(mockResponse).toEqual(true);
});
});
});
14 changes: 14 additions & 0 deletions refinery/ui/source/js/igv/directives/modal-detail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

function rpIGVLaunchModalDetail () {
return {
restrict: 'AE',
templateUrl: '/static/partials/igv/partials/modal-detail.html'
};
}

angular
.module('refineryIGV')
.directive('rpIGVLaunchModalDetail', [
rpIGVLaunchModalDetail
]);
35 changes: 35 additions & 0 deletions refinery/ui/source/js/igv/directives/modal-detail.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Unit test for visualization spec
'use strict';

describe('rpIGVLaunchModalDetail directive unit test', function () {
beforeEach(module('refineryApp'));
beforeEach(module('refineryVisualization'));

var compile;
var rootScope;
var scope;
var template;
var directiveElement;

beforeEach(inject(function (
_$compile_,
_$rootScope_,
$templateCache
) {
$templateCache.put(
'/static/partials/igv/partials/modal-detail.html',
'<div id="modal-header">igv</div>'
);
compile = _$compile_;
rootScope = _$rootScope_;
scope = rootScope.$new();
template = '<rp-i-g-v-launch-modal-detail></rp-i-g-v-launch-modal-detail>';
directiveElement = compile(template)(scope);
scope.$digest();
}));

it('generates the appropriate HTML', function () {
expect(directiveElement.html()).toContain('modal-header');
expect(directiveElement.html()).toContain('igv');
});
});
4 changes: 4 additions & 0 deletions refinery/ui/source/js/igv/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';

angular
.module('refineryIGV', ['ui.select']);
30 changes: 30 additions & 0 deletions refinery/ui/source/js/igv/module.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

describe('RefineryIGV.module: unit tests', function () {
var module;

beforeEach(function () {
module = angular.module('refineryIGV');
});

describe('Module', function () {
it('should be registered', function () {
expect(!!module).toEqual(true);
});
});

describe('Dependencies:', function () {
var deps;
var hasModule = function (m) {
return deps.indexOf(m) >= 0;
};

beforeEach(function () {
deps = module.value('refineryIGV').requires;
});

it('should have "ui-select" as a dependency', function () {
expect(hasModule('ui.select')).toEqual(true);
});
});
});

0 comments on commit d7d3762

Please sign in to comment.