Skip to content

Commit

Permalink
Merge pull request #1131 from bgruening/IE_iobio
Browse files Browse the repository at this point in the history
Add BAM iobio visualisation as Interactive Environment
  • Loading branch information
hexylena committed Nov 19, 2015
2 parents 5191c21 + 5188b41 commit 81f8427
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[main]
# Following options are ignored if using the Galaxy dynamic proxy but
# are useful if mapping a range of ports for environment consumption.
#password_auth = False
#ssl = False

[docker]
# Command to launch docker container. For example `sudo docker` or `docker-lxc`.
# If you need to use a command like `sg` you can do that here, just be sure to
# wrap all of the docker portion in single quotes. E.g. `sg 'docker' 'docker {docker_args}'`
#
# It is recommended that you use command_inject if you need to inject
# additional parameters. This command string is re-used for a `docker inspect`
# command and will likely cause errors if it is extensively modified, past the
# usual group/sudo changes.
#command = docker {docker_args}

# The docker image name that should be started.
image = qiaoy/iobio-bundle.bam-iobio:1.0-ondemand

# Additional arguments that are passed to the `docker run` command.
#command_inject = --sig-proxy=true -e DEBUG=false

# URL to access the Galaxy API with from the spawn Docker containter, if empty
# this falls back to galaxy.ini's galaxy_infrastructure_url and finally to the
# Docker host of the spawned container if that is also not set.
#galaxy_url =

# The Docker hostname. It can be useful to run the Docker daemon on a different
# host than Galaxy.
#docker_hostname = localhost

# Try to set the tempdirectory to world execute - this can fix the issue
# where 'sudo docker' is not able to mount the folder otherwise.
# "finalize namespace chdir to /import permission denied"
#wx_tempdir = False

# Overwride the IE tempdirectory. This can be useful if you regular tempdir is
# located on an NFS share, which does not work well as Docker volume. In this case
# you can have a shared sshfs share which you can use as temporary directory to
# share data between the IE and Galaxy.
#docker_galaxy_temp_dir = None

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE interactive_environment SYSTEM "../../interactive_environments.dtd">
<interactive_environment name="BAM iobio">
<data_sources>
<data_source>
<model_class>HistoryDatasetAssociation</model_class>
<test type="isinstance" test_attr="datatype" result_type="datatype">binary.Bam</test>
<to_param param_attr="id">dataset_id</to_param>
</data_source>
</data_sources>
<params>
<param type="dataset" var_name_in_template="hda" required="true">dataset_id</param>
</params>
<entry_point entry_point_type="mako">bam_iobio.mako</entry_point>
</interactive_environment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
function message_failed_auth(password){
toastr.info(
"Automatic authorization failed.",
"Please login manually",
{'closeButton': true, 'timeOut': 100000, 'tapToDismiss': false}
);
}

function message_failed_connection(){
toastr.error(
"Could not connect to BAM iobio. Please contact your administrator.",
"Security warning",
{'closeButton': true, 'timeOut': 20000, 'tapToDismiss': true}
);
}

/**
* Load an interactive environment (IE) from a remote URL
* @param {String} password: password used to authenticate to the remote resource
* @param {String} notebook_login_url: URL that should be POSTed to for login
* @param {String} notebook_access_url: the URL embeded in the page and loaded
*
*/
function load_notebook(notebook_access_url){
$( document ).ready(function() {
// Test notebook_login_url for accessibility, executing the login+load function whenever
// we've successfully connected to the IE.
test_ie_availability(notebook_access_url, function(){
_handle_notebook_loading(notebook_access_url);
});
});
}

/**
* Must be implemented by IEs
*/
function _handle_notebook_loading(notebook_access_url){
append_notebook(notebook_access_url);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<%namespace name="ie" file="ie.mako" />

<%
import subprocess
from galaxy.util import sockets
# Sets ID and sets up a lot of other variables
ie_request.load_deploy_config()
ie_request.attr.docker_port = 80
ie_request.attr.import_volume = False
bam = ie_request.volume(hda.file_name, '/input/bamfile.bam', how='ro')
bam_index = ie_request.volume(hda.metadata.bam_index.file_name, '/input/bamfile.bam.bai', how='ro')
ie_request.launch(volumes=[bam, bam_index], env_override={
'PUB_HTTP_PORT': ie_request.attr.galaxy_config.dynamic_proxy_bind_port,
'PUB_HOSTNAME': ie_request.attr.HOST,
})
notebook_access_url = ie_request.url_template('${PROXY_URL}/?bam=http://localhost/tmp/bamfile.bam')
root = h.url_for( '/' )
%>
<html>
<head>
${ ie.load_default_js() }
</head>
<body>

<script type="text/javascript">
${ ie.default_javascript_variables() }
var notebook_access_url = '${ notebook_access_url }';
${ ie.plugin_require_config() }
requirejs(['interactive_environments', 'plugin/bam_iobio'], function(){
display_spinner();
});
toastr.info(
"BAM io.bio is starting up!",
"transferring data ...",
{'closeButton': true, 'timeOut': 5000, 'tapToDismiss': false}
);
var startup = function(){
// Load notebook
requirejs(['interactive_environments', 'plugin/bam_iobio'], function(){
load_notebook(notebook_access_url);
});
};
// sleep 5 seconds
// this is currently needed to get the vis right
// plans exists to move this spinner into the container
setTimeout(startup, 5000);
</script>
<div id="main">
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// Following three are for older-style IE proxies, newer dynamic Galaxy proxy
// does not use these.
ie_password_auth = ${ ie_request.javascript_boolean(ie_request.attr.PASSWORD_AUTH) };
ie_apache_urls = ${ ie_request.javascript_boolean(ie_request.attr.APACHE_URLS) };
ie_password = '${ ie_request.notebook_pw }';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[main]
# Following options are ignored if using the Galaxy dynamic proxy but
# are useful if mapping a range of ports for environment consumption.
#apache_urls = False
#password_auth = False
#ssl = False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function _handle_notebook_loading(password, notebook_login_url, notebook_access_
append_notebook(notebook_access_url);
},
error: function(jqxhr, status, error){
if(ie_password_auth && !ie_apache_urls){
if(ie_password_auth){
// Failure happens due to CORS
message_failed_auth(password);
append_notebook(notebook_access_url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function _handle_notebook_loading(password, notebook_login_url, notebook_access_
append_notebook(notebook_access_url);
},
error: function(jqxhr, status, error){
if(ie_password_auth && !ie_apache_urls){
if(ie_password_auth){
// Failure now happens because the redirect that RStudio gives us includes the
// port internal to nginx. (E.g. localhost:NNNN/rstudio/NNNN/)
// so disabling the message here makes sense as long as it's working correctly
Expand Down
5 changes: 1 addition & 4 deletions lib/galaxy/web/base/interactive_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
class InteractiveEnviornmentRequest(object):

def __init__(self, trans, plugin):
plugin_config = plugin.config

self.trans = trans
self.log = log

self.attr = Bunch()
self.attr.viz_id = plugin_config["name"].lower()
self.attr.viz_id = plugin.name
self.attr.history_id = trans.security.encode_id( trans.history.id )
self.attr.galaxy_config = trans.app.config
self.attr.galaxy_root_dir = os.path.abspath(self.attr.galaxy_config.root)
Expand Down Expand Up @@ -100,7 +98,6 @@ def _boolean_option(option, default=False):
# we always assume use of Galaxy dynamic proxy? None of these need to be specified
# if using the Galaxy dynamic proxy.
self.attr.PASSWORD_AUTH = _boolean_option("password_auth")
self.attr.APACHE_URLS = _boolean_option("apache_urls")
self.attr.SSL_URLS = _boolean_option("ssl")

def get_conf_dict(self):
Expand Down

0 comments on commit 81f8427

Please sign in to comment.