Locked History Actions

Diff for "Events/GCC2014/TrainingDay/AdminWalkthrough"

Differences between revisions 1 and 6 (spanning 5 versions)
Revision 1 as of 2014-06-25 23:40:45
Size: 60
Editor: JohnChilton
Comment:
Revision 6 as of 2014-06-26 01:42:16
Size: 32970
Editor: JohnChilton
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Describe Events/GCC2014/TrainingDay/AdminWalkthrough here. <<div(title)>>Tutorial: Galaxy Installation and Administration<<div>>

[[nate|Nate Coraor]] and [[JohnChilton|John Chilton]]

<<BR>>
{{https://dev.twitter.com/sites/default/files/images_documentation/bird_blue_16.png}} #usegalaxy

This this follow-along page assumes you have already installed and started a [[https://wiki.galaxyproject.org/Events/GCC2014/TrainingDay/VMs|Training Day VM]] - please do this before arriving.

<<TableOfContents>>

'''Please use Firefox or Chrome for this tutorial.''' Galaxy is compatible with all modern versions of Firefox, Chrome, Safari, and Internet Explorer. However, for the purposes of this tutorial it will help us when assisting people encountering problems if only Firefox or Chrome are used.

= Setting up a Local Galaxy Tutorial (Part I) =

== Clone (download) Galaxy ==

The Galaxy distribution is found at [[https://bitbucket.org/galaxy/galaxy-dist/]], but for the purposes of this tutorial, we'll use a trimmed version to decrease the time it takes to clone.

Trying again:

{{{
#!highlight console
galaxy@gcc2014:~$ hg clone /home/galaxy/galaxy-central galaxy-dist
requesting all changes
adding changesets
adding manifests
adding file changes
added 8 changesets with 3443 changes to 3443 files
updating to branch default
3443 files updated, 0 files merged, 0 files removed, 0 files unresolved
galaxy@gcc2014:~$ cd galaxy-dist
galaxy@gcc2014:~/galaxy-dist$
}}}


=== References ===

 * [[http://getgalaxy.org|getgalaxy.org]]
 * [[https://wiki.galaxyproject.org|Galaxy Wiki/documentation]]

== Update to the stable branch ==

TODO: Replace console.

{{{
#!highlight console
ubuntu@bioit:~$ cd galaxy-dist
ubuntu@bioit:~/galaxy-dist$ hg update stable
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
ubuntu@bioit:~/galaxy-dist$
}}}

== Start Galaxy ==

TODO: Replace console.

{{{
#!highlight console
ubuntu@bioit:~/galaxy-dist$ sh run.sh
Initializing datatypes_conf.xml from datatypes_conf.xml.sample
  ...
Some eggs are out of date, attempting to fetch...
Fetched http://scofield.galaxyproject.org/eggs/Mako/Mako-0.4.1-py2.7.egg
  ...
Fetch successful.
python path is: /home/ubuntu/galaxy-dist/eggs/mercurial-2...
  ...
Starting server in PID 3091.
serving on http://127.0.0.1:8080
}}}

== Serve over public interface ==

Stop Galaxy by hitting `CTRL-c`:

TODO: Replace console.
{{{
#!highlight console
serving on http://127.0.0.1:8080
^Cgalaxy.jobs.handler INFO 2014-04-23 13:27:59,203 sending stop signal to worker thread
galaxy.jobs.handler INFO 2014-04-23 13:27:59,204 job handler queue stopped
galaxy.jobs.runners INFO 2014-04-23 13:27:59,204 LWRRunner: Sending stop signal to monitor thread
galaxy.jobs.runners INFO 2014-04-23 13:27:59,204 LWRRunner: Sending stop signal to 3 worker threads
galaxy.jobs.runners INFO 2014-04-23 13:27:59,204 LocalRunner: Sending stop signal to 5 worker threads
galaxy.jobs.handler INFO 2014-04-23 13:27:59,205 sending stop signal to worker thread
galaxy.jobs.handler INFO 2014-04-23 13:27:59,205 job handler stop queue stopped
ubuntu@bioit:~/galaxy-dist$
}}}

Edit the primary Galaxy configuration file, `universe_wsgi.ini`. If you are not familiar with `vi`, consider using `nano` instead.

TODO: Replace console.
{{{
#!highlight console
ubuntu@bioit:~/galaxy-dist$ vi universe_wsgi.ini
}}}

In the `[server:main]` section, uncomment `#host = 127.0.0.1` and set:

{{{
#!highlight ini
host = 0.0.0.0
}}}

While we are in the config, we should set two options necessary for the next section. The file is large and it's easiest to search for these (`/<pattern>` in vi, `CTRL-w` `<pattern>` in nano):

TODO: Replace tool_dependency_dir.
{{{
#!highlight ini
[app:main]
admin_users = nate@bx.psu.edu
tool_dependency_dir = /home/ubuntu/tool_deps
}}}

Then save and quit (`CTRL-x` `y` `ENTER` in nano). Start Galaxy again:

TODO: Replace console.
{{{
#!highlight console
ubuntu@bioit:~/galaxy-dist$ sh run.sh
  ...
Starting server in PID 3298.
serving on 0.0.0.0:8080 view at http://127.0.0.1:8080
}}}

The message `view at http://127.0.0.1:8080` is generated by the embedded webserver and cannot be changed so it is not entirely accurate, but `serving on 0.0.0.0:8080` reveals that the server is now listening on public interfaces.

== Installing tools from the Tool Shed ==

=== Topics for this section ===

 * What is a Galaxy tool?
  * Basic: An XML description of the tool's interface, allowing Galaxy to render a UI (tool form), as well as the command line to execute.
  * Complex: XML + wrapper scripts and interfaces to external dependencies
 * Exploring preinstalled tools and filesystem layout
  * `galaxy-dist/tool_conf.xml`
  * `galaxy-dist/tools/`
  * Example simple tool: `galaxy-dist/tools/filters/sorter.xml` (tool xml), `galaxy-dist/tools/filters/sorter.py` (tool code)
  * Example tool with unmet dependencies: `galaxy-dist/tools/sr_mapping/mosaik.xml`
 * The Tool Shed
  * Installing tools from the Tool Shed
  * Exploring the filesystem layout of tools installed from the Tool Shed

=== Install a tool from the Tool Shed ===

{{{#!wiki blue/solid/light
'''You will need to enable 3rd-party cookies in your browser for Tool Shed installations to work:'''

 * Chrome: Settings -> Show advanced settings... -> Privacy -> Content Settings... -> Block third-party cookies and site data -> ''uncheck''
 * Firefox: Settings -> Privacy -> History -> Firefox will: ''Remember history'' '''or''' Firefox will: ''Use custom settings for history'' -> Accept third-party cookies: ''Always''

Reload the Galaxy interface if your 3rd party cookies were not previously enabled.}}}

TODO: Replace paths below if needed.
<<BR>>
 * Register an account that matches the address you set in `admin_users`
 * Follow the [[Admin/Tools/AddToolFromToolShedTutorial|tutorial on installing tools from the Tool Shed]]. In brief:
  * Click '''Admin''' from the masthead
  * Click '''Search and browse tool sheds''' from the left panel
  * Click the popup icon for '''Galaxy main tool shed''' and select '''Search for valid tools'''
  * Search for '''Tool name'''s that contain the name `bwa`
  * Click the popup icon for '''bwa_wrappers''' and select '''Install to Galaxy'''
  * Select the '''NGS: Mapping''' section and click '''Install to Galaxy'''
 * Tools (XML, wrapper scripts) are installed in `/home/ubuntu/shed_tools`
 * Tool dependencies (binaries) are installed in `/home/ubuntu/tool_deps`

=== References ===

 * [[Admin/Tools|Tools hub page]]
 * [[Admin/Tools/AddToolTutorial|Tutorial on adding custom tools]]
 * [[Admin/Tools/AddToolFromToolShedTutorial|Tutorial on installing tools from the Tool Shed]]
 * [[https://bitbucket.org/galaxy/galaxy-central/src/3b42725359224832317a066d95dff596f93ab33f/tools?at=stable|Current tools/ directory]]
 * [[ToolShed|Tool Shed hub page]]
 * [[ToolShedTour|Tool Shed tour]]
 * [[http://toolshed.g2.bx.psu.edu/|Galaxy Main Tool Shed]]

== Managing local data ==

=== Topics for this section ===

 * What is local data?
 * Manual data inclusion
  * Building indexes on the command line
  * `.loc` files
  * `tool_data_table_conf.xml`
  * Example of the above with bwa and S. cerevisiae (sacCer2) [[#Adding local data by hand|transcript]]
 * Galaxy Data Managers

=== Adding local data with a Galaxy Data Manager ===

Install data managers for fetching the reference genome and building BWA indexes:

 * Click '''Admin''' from the masthead
 * Click '''Search and browse tool sheds''' from the left panel
 * Click the popup icon for '''Galaxy main tool shed''' and select '''Search for valid tools'''
 * Search for '''Tool id'''s that contain the name `manager`
 * Check '''data_manager_fetch_genome_all_fasta''' and '''data_manager_bwa_index_builder''', then click '''Install to Galaxy''' (at the bottom of the page)
 * Click '''Install'''

Fetch reference genome (fasta):

 * Click '''Manage local data (beta)''' from the left panel
 * Click '''Reference Genome - fetching'''
 * In the '''DBKEY to assign to data:''' field, type `sacCer2`
 * In the '''UCSC's DBKEY for source FASTA:''' field, type `sacCer2`
 * Click '''Execute'''

Build BWA indexes:

 * Click '''Manage local data (beta)''' from the left panel
 * Click '''BWA index - builder'''
 * Click '''Execute'''

Upon completion:

 * `galaxy-dist/tool-data/sacCer2/seq/sacCer2.fa` has been created from chromosome fastas fetched from UCSC
 * `galaxy-dist/tool-data/sacCer2/bwa_index/sacCer2.fa.*` indexes have been generated with `bwa index`
 * `galaxy-dist/tool-data/toolshed.g2.bx.psu.edu/repos/devteam/data_manager_fetch_genome_all_fasta/2ebc856bce29/all_fasta.loc` contains a reference to the newly created `sacCer2.fa`
 * `galaxy-dist/tool-data/toolshed.g2.bx.psu.edu/repos/devteam/data_manager_bwa_index_builder/367878cb3698/bwa_index.loc` contains a reference to the newly built bwa indexes
 * `galaxy-dist/shed_tool_data_table_conf.xml` includes entries for the `all_fasta` and `bwa_indexes` data tables

=== References ===

 * [[Admin/DataPreparation|(Manual) index building]]
 * [[Admin/DataIntegration|(Manual) data integration]]
 * [[Admin/Tools/DataManagers|Automated data management with Data Managers]]

= Setting up a Local Galaxy Tutorial (Part II) =

Documentation for the features used in this section can be found at [[https://usegalaxy.org/production|usegalaxy.org/production]] (forwards to [[Admin/Config/Performance/ProductionServer]])

== Install and configure PostgreSQL ==

TODO: Replace console.
{{{#!hightlight console
ubuntu@bioit:~$ sudo apt-get install postgresql
  ...
After this operation, 15.5 MB of additional disk space will be used.
Do you want to continue? [Y/n]
  ...
Creating new cluster 9.3/main ...
  config /etc/postgresql/9.3/main
  data /var/lib/postgresql/9.3/main
  locale en_US.UTF-8
  port 5432
 * Starting PostgreSQL 9.3 database server
   ...done.
ubuntu@bioit:~$ sudo -u postgres createuser galaxy
ubuntu@bioit:~$ sudo -u postgres createdb -O galaxy galaxy
}}}

== Create a new user for Galaxy ==

TODO: Replace console.
{{{#!highlight console
ubuntu@bioit:~$ sudo useradd -m -s /bin/bash galaxy
ubuntu@bioit:~$
}}}

== Create a Python virtual environment ==

TODO: Replace console.
{{{#!highlight console
ubuntu@bioit:~$ sudo apt-get install python-virtualenv
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  ...
Do you want to continue? [Y/n]
  ...
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libasan0 amd64 4.8.2-19ubuntu1 [63.0 kB]
  ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
ubuntu@bioit:~$ sudo -iu galaxy
galaxy@bioit:~$ virtualenv venv
New python executable in venv/bin/python
Installing setuptools, pip...done.
galaxy@bioit:~$ source ./venv/bin/activate
(venv)galaxy@bioit:~$
}}}

== Clone (download) Galaxy ==

TODO: Replace console.
{{{#!highlight console
galaxy@bioit:~$ hg clone https://bitbucket.org/natefoo/galaxy-bioit galaxy-dist
requesting all changes
adding changesets
adding manifests
adding file changes
added 8 changesets with 3443 changes to 3443 files
updating to branch default
3443 files updated, 0 files merged, 0 files removed, 0 files unresolved
galaxy@bioit:~$ cd galaxy-dist
galaxy@bioit:~/galaxy-dist$ hg update stable
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
galaxy@bioit:~/galaxy-dist$
}}}

== Configure Galaxy ==

TODO: Replace console.
{{{#!highlight console
galaxy@bioit:~/galaxy-dist$ cp universe_wsgi.ini.sample universe_wsgi.ini
galaxy@bioit:~/galaxy-dist$ vi universe_wsgi.ini
}}}

Add the following section for uWSGI's configuration and the job handler processes

{{{#!highlight ini
[uwsgi]
socket = 127.0.0.1:4001
stats = 127.0.0.1:9191
processes = 2
threads = 4
master = True
logto = /home/galaxy/uwsgi.log
pythonpath = lib

[server:handler0]
use = egg:Paste#http
port = 9010
use_threadpool = True
threadpool_workers = 10

[server:handler1]
use = egg:Paste#http
port = 9011
use_threadpool = True
threadpool_workers = 10
}}}

Set the following settings in the `[app:main]` section:

{{{#!highlight ini
database_connection = postgresql:///galaxy?host=/var/run/postgresql
database_engine_option_server_side_cursors = True
database_engine_option_strategy = threadlocal
tool_dependency_dir = /home/galaxy/tool_deps
static_enabled = False
nginx_x_accel_redirect_base = /_x_accel_redirect
nginx_upload_store = /home/galaxy/uploads
nginx_upload_path = /_upload
log_events = False
log_actions = False
debug = False
use_interactive = False
id_secret = <random text>
admin_users = nate@bx.psu.edu
}}}

Explanations of these options:

 * `database_connection = postgresql:///galaxy?host=/var/run/postgresql` - Use a PostgreSQL database via a local UNIX domain socket (the socket is in `/var/run/postgresql`). [[Admin/Config/Performance/ProductionServer#Switching_to_a_database_server|documentation]]
 * `database_engine_option_server_side_cursors = True` - Keep large SQL query results on the PostgreSQL server, rather the transferring the entire result set to the Galaxy processes.
 * `database_engine_option_strategy = threadlocal` - Only use one database connection per thread
 * `tool_dependency_dir = /home/galaxy/tool_deps` - The directory that will house tool dependencies
 * `static_enabled = False` - Static content will be served by the proxy server
 * `nginx_x_accel_redirect_base = /_x_accel_redirect` - Delegate dataset downloads to nginx
 * `nginx_upload_store = /home/galaxy/uploads` - Delegate uploads to nginx, set temporary directory
 * `nginx_upload_path = /_upload` - Special path configured in nginx where uploads will be POSTed
 * `log_events = False` - Don't log events in the database (faster)
 * `log_actions = False` - Don't log actions in the database (faster)
 * `debug = False` - Disables debugging middleware that loads server responses in to memory (can crash the server when handling large files)
 * `use_interactive = False` - Disables live client browser debugging (insecure).
 * `id_secret = <random text>` - Ensures that the encoded IDs used by Galaxy (especially session IDs) are unique. One simple way to generate a value for this is with a shell command like `$ date | md5sum`
 * `admin_users = nate@bx.psu.edu` - Make nate@example.org an administrator. Galaxy's Admin UI is only accessible if you define administrators here!

Honorable mentions for features we won't use today but that are common in big setups:

 * `ftp_upload_dir` and `ftp_upload_site` - Allow users to upload data to the server using FTP
 * `use_remote_user` and `remote_user_maildomain` - Use your institution's existing authentication system to log in to Galaxy. [[Admin/Config/ExternalUserDatbases|Apache documentation]] or [[Admin/Config/nginxProxy#External_user_authentication|nginx documentation]]
 * `allow_user_impersonation` - Users configured as administrators (with `admin_users`) can "become" other users to view Galaxy exactly as the impersonated user does. Useful for providing support.
 * `library_import_dir` - Administrators can directly import datasets from this directory on the server to Data Libraries. This includes an option that allows an effective "symlink" to the data, rather than copying it in to Galaxy's `file_path` directory. [[Admin/DataLibraries/UploadingLibraryFiles|documentation]]
 * `user_library_import_dir` - Non-administrators can directly import datasets from this directory on this server to Data Libraries from which they have been given write permission. [[Admin/DataLibraries/UploadingLibraryFiles|documentation]]
 * `allow_library_path_paste` - Administrators can import datasets from anywhere on the server's filesystem(s) by entering their paths in to a text box
 * `object_store_config_file` - Configure Galaxy's "object storage" layer to store data in multiple filesystems, Amazon S3, iRODS, etc.
 * `error_email_to` (with `smtp_server`) - Allow users to send bug reports directly to you
 * `user_activation_on` and related options - Require new users to verify their email address
 * `allow_user_dataset_purge = True` - Allow users to forcibly remove their datasets from disk (note that the data is only actually removed if all versions of a shared dataset are purged by all users who are sharing the dataset). By default, Galaxy does not remove data, as this is done at a later time by the dataset cleanup scripts.
 * `enable_quotas = True` - Enable Galaxy's quota system. Quotas are configured by administrators in the Galaxy Admin UI

Create a job system configuration:

TODO: Replace console.
{{{#!highlight console
galaxy@bioit:~/galaxy-dist$ vi job_conf.xml
}}}

In the editor, paste:

{{{#!highlight xml
<?xml version="1.0"?>
<job_conf>
    <plugins workers="2">
        <plugin id="gridengine" type="runner" load="galaxy.jobs.runners.drmaa:DRMAAJobRunner"/>
    </plugins>
    <handlers default="handlers">
        <handler id="handler0" tags="handlers"/>
        <handler id="handler1" tags="handlers"/>
    </handlers>
    <destinations default="gridengine">
        <destination id="gridengine" runner="gridengine"/>
    </destinations>
    <limits>
        <limit type="registered_user_concurrent_jobs">2</limit>
        <limit type="unregistered_user_concurrent_jobs">1</limit>
        <limit type="job_walltime">24:00:00</limit>
    </limits>
</job_conf>
}}}

== Start a Galaxy server to complete first run setup ==

TODO: Replace console.
{{{#!highlight console
galaxy@bioit:~/galaxy-dist$ sh run.sh
Initializing datatypes_conf.xml from datatypes_conf.xml.sample
  ...
serving on http://127.0.0.1:8080
^C
  ...
galaxy@bioit:~/galaxy-dist$ logout
ubuntu@bioit:~$
}}}

== Install and configure Grid Engine ==

{{{#!highlight console
ubuntu@bioit:~$ sudo apt-get install gridengine-master gridengine-exec gridengine-client gridengine-drmaa1.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  bsd-mailx gridengine-common postfix tcsh
Suggested packages:
  gridengine-qmon procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin dovecot-common postfix-cdb mail-reader postfix-doc
The following NEW packages will be installed:
  bsd-mailx gridengine-client gridengine-common gridengine-drmaa1.0 gridengine-exec gridengine-master postfix tcsh
0 upgraded, 8 newly installed, 0 to remove and 5 not upgraded.
Need to get 9,172 kB of archives.
After this operation, 51.6 MB of additional disk space will be used.
Do you want to continue? [Y/n]
  ...
Preconfiguring packages ...
}}}

You'll be asked a series of configuration questions for Postfix and Grid Engine at this point. The following answers are suitable for this tutorial:

 * General type of mail configuration: Local only
 * System mail name: bioit
 * Configure SGE automatically?: Yes
 * SGE cell name: default
 * SGE master hostname: bioit

TODO: Replace console.
{{{#!highlight console
ubuntu@bioit:~$ sudo vi /var/lib/gridengine/default/common/host_aliases
  ...
localhost bioit
  ...
ubuntu@bioit:~$ sudo service gridengine-master restart
ubuntu@bioit:~$ sudo pkill sge_execd && sudo service gridengine-exec restart
ubuntu@bioit:~$ sudo qconf -aq all.q
  ...
hostlist localhost
shell /bin/bash
  ...
ubuntu@bioit:~$ sudo qconf -as localhost
localhost added to submit host list
ubuntu@bioit:~$
}}}

== Install nginx, uWSGI, and supervisord ==

TODO: Replace console.
{{{#!highlight console
ubuntu@bioit:~$ sudo add-apt-repository ppa:natefoo/bioit2014
 Provides a rebuilt nginx-extras with the upload module for the workshop @
 Bio-IT World Expo 2014
 More info: https://launchpad.net/~natefoo/+archive/bioit2014
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmp71rhd5g3/secring.gpg' created
gpg: keyring `/tmp/tmp71rhd5g3/pubring.gpg' created
gpg: requesting key 12788738 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp71rhd5g3/trustdb.gpg: trustdb created
gpg: key 12788738: public key "Launchpad PPA for Nate Coraor" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
ubuntu@bioit:~$ sudo apt-get update
  ...
Fetched 141 kB in 4s (34.0 kB/s)
Reading package lists... Done
ubuntu@bioit:~$ sudo apt-get install nginx-extras uwsgi uwsgi-plugin-python supervisor
  ...
After this operation, 10.4 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://ppa.launchpad.net/natefoo/bioit2014/ubuntu/ trusty/main nginx-common all 1.4.6-1ubuntu3ppa1 [81.5 kB]
Get:2 http://ppa.launchpad.net/natefoo/bioit2014/ubuntu/ trusty/main nginx-extras amd64 1.4.6-1ubuntu3ppa1 [570 kB]
  ...
ubuntu@bioit:~$ sudo /etc/init.d/nginx stop
ubuntu@bioit:~$ sudo update-rc.d -f nginx remove
 Removing any system startup links for /etc/init.d/nginx ...
   /etc/rc0.d/K20nginx
   /etc/rc1.d/K20nginx
   /etc/rc2.d/S20nginx
   /etc/rc3.d/S20nginx
   /etc/rc4.d/S20nginx
   /etc/rc5.d/S20nginx
   /etc/rc6.d/K20nginx
ubuntu@bioit:~$ sudo update-rc.d -f uwsgi remove
 Removing any system startup links for /etc/init.d/uwsgi ...
   /etc/rc0.d/K20uwsgi
   /etc/rc1.d/K20uwsgi
   /etc/rc2.d/S20uwsgi
   /etc/rc3.d/S20uwsgi
   /etc/rc4.d/S20uwsgi
   /etc/rc5.d/S20uwsgi
   /etc/rc6.d/K20uwsgi
ubuntu@bioit:~$
}}}

== Configure nginx ==

TODO: Replace console.
{{{#!highlight console
ubuntu@bioit:~$ cd /etc/nginx
ubuntu@bioit:/etc/nginx$ sudo vi nginx.conf
  ...
  user galaxy;
  daemon off;
  http {
      gzip_vary on;
      gzip_proxied any;
      gzip_comp_level 6;
      gzip_buffers 16 8k;
      gzip_http_version 1.1;
      gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  }
  ...
ubuntu@bioit:/etc/nginx$ cd sites-available
ubuntu@bioit:/etc/nginx/sites-available$ sudo vi galaxy
}}}

In the editor, paste:

{{{#!highlight nginx

client_max_body_size 50g;
uwsgi_read_timeout 300;

server {
    listen 80 default_server;
    server_name bioit.galaxyproject.org;

    # pass to uWSGI by default
    location / {
        uwsgi_pass 127.0.0.1:4001;
        include uwsgi_params;
    }

    # serve static content
    location /static {
        alias /home/galaxy/galaxy-dist/static;
        gzip on;
        gzip_types text/plain text/xml text/javascript text/css application/x-javascript;
        expires 24h;
    }
    location /static/style {
        alias /home/galaxy/galaxy-dist/static/style/blue;
        gzip on;
        gzip_types text/plain text/xml text/javascript text/css application/x-javascript;
        expires 24h;
    }
    location /static/scripts {
        alias /home/galaxy/galaxy-dist/static/scripts/packed;
        gzip on;
        gzip_types text/plain text/javascript application/x-javascript;
        expires 24h;
    }
    location ~ ^/plugins/visualizations/(?<vis_name>.+?)/static/(?<static_file>.*?)$ {
        alias /home/galaxy/galaxy-dist/config/plugins/visualizations/$vis_name/static/$static_file;
    }

    # delegated downloads
    location /_x_accel_redirect {
        internal;
        alias /;
    }

    # delegated uploads
    location /_upload {
        upload_store /home/galaxy/uploads;
        upload_store_access user:rw;
        upload_pass_form_field "";
        upload_set_form_field "__${upload_field_name}__is_composite" "true";
        upload_set_form_field "__${upload_field_name}__keys" "name path";
        upload_set_form_field "${upload_field_name}_name" "$upload_file_name";
        upload_set_form_field "${upload_field_name}_path" "$upload_tmp_path";
        upload_pass_args on;
        upload_pass /_upload_done;
    }
    location /_upload_done {
        set $dst /api/tools;
        if ($args ~ nginx_redir=([^&]+)) {
            set $dst $1;
        }
        rewrite "" $dst;
    }
}
}}}

{{{#!highlight console
ubuntu@bioit:/etc/nginx/sites-available$ cd ../sites-enabled/
ubuntu@bioit:/etc/nginx/sites-enabled$ sudo rm default
ubuntu@bioit:/etc/nginx/sites-enabled$ sudo ln -s ../sites-available/galaxy
ubuntu@bioit:/etc/nginx/sites-enabled$
}}}

== Configure supervisord ==

{{{#!highlight console
ubuntu@bioit:~$ cd /etc/supervisor/conf.d
ubuntu@bioit:/etc/supervisor/conf.d$ sudo vi galaxy.conf
}}}

In the editor, paste:

{{{#!highlight ini
[program:nginx]
command = /usr/sbin/nginx
directory = /
umask = 022
autostart = true
autorestart = unexpected
startsecs = 5
exitcodes = 0
user = root

[program:galaxy_uwsgi]
command = /usr/bin/uwsgi --plugin python --ini-paste /home/galaxy/galaxy-dist/universe_wsgi.ini
directory = /home/galaxy/galaxy-dist
umask = 022
autostart = true
autorestart = true
startsecs = 10
user = galaxy
environment = PATH=/home/galaxy/venv:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin,PYTHON_EGG_CACHE=/home/galaxy/.python-eggs,PYTHONPATH=/home/galaxy/galaxy-dist/eggs/PasteDeploy-1.5.0-py2.7.egg
numprocs = 1
stopsignal = INT

[program:handler]
command = /home/galaxy/venv/bin/python ./scripts/paster.py serve universe_wsgi.ini --server-name=handler%(process_num)s --pid-file=/home/galaxy/handler%(process_num)s.pid --log-file=/home/galaxy/handler%(process_num)s.log
directory = /home/galaxy/galaxy-dist
process_name = handler%(process_num)s
numprocs = 2
umask = 022
autostart = true
autorestart = true
startsecs = 15
user = galaxy
environment = PYTHON_EGG_CACHE=/home/galaxy/.python-eggs,DRMAA_LIBRARY_PATH=/usr/lib/gridengine-drmaa/lib/libdrmaa.so.1.0,SGE_ROOT=/var/lib/gridengine

[group:galaxy]
programs = handler
}}}

== Start Galaxy and nginx ==

{{{#!highlight console
ubuntu@bioit:~$ sudo supervisorctl update
galaxy: added process group
galaxy_uwsgi: added process group
nginx: added process group
ubuntu@bioit:~$ sudo supervisorctl status
galaxy:handler0 STARTING
galaxy:handler1 STARTING
galaxy_uwsgi STARTING
nginx STARTING

}}}

You can now visit your Galaxy server at:

||<-10: rowclass="th">VM Galaxy Instances ||
|| [[http://bioit0.galaxyproject.org|bioit0]] || [[http://bioit1.galaxyproject.org|bioit1]] || [[http://bioit2.galaxyproject.org|bioit2]] || [[http://bioit3.galaxyproject.org|bioit3]] || [[http://bioit4.galaxyproject.org|bioit4]] || [[http://bioit5.galaxyproject.org|bioit5]] || [[http://bioit6.galaxyproject.org|bioit6]] || [[http://bioit7.galaxyproject.org|bioit7]] || [[http://bioit8.galaxyproject.org|bioit8]] || [[http://bioit9.galaxyproject.org|bioit9]] ||
|| [[http://bioit10.galaxyproject.org|bioit10]] || [[http://bioit11.galaxyproject.org|bioit11]] || [[http://bioit12.galaxyproject.org|bioit12]] || [[http://bioit13.galaxyproject.org|bioit13]] || [[http://bioit14.galaxyproject.org|bioit14]] || [[http://bioit15.galaxyproject.org|bioit15]] || [[http://bioit16.galaxyproject.org|bioit16]] || [[http://bioit17.galaxyproject.org|bioit17]] || [[http://bioit18.galaxyproject.org|bioit18]] || [[http://bioit19.galaxyproject.org|bioit19]] ||
|| [[http://bioit20.galaxyproject.org|bioit20]] || [[http://bioit21.galaxyproject.org|bioit21]] || [[http://bioit22.galaxyproject.org|bioit22]] || [[http://bioit23.galaxyproject.org|bioit23]] || [[http://bioit24.galaxyproject.org|bioit24]] || [[http://bioit25.galaxyproject.org|bioit25]] || [[http://bioit26.galaxyproject.org|bioit26]] || [[http://bioit27.galaxyproject.org|bioit27]] || [[http://bioit28.galaxyproject.org|bioit28]] || [[http://bioit29.galaxyproject.org|bioit29]] ||
|| [[http://bioit30.galaxyproject.org|bioit30]] || [[http://bioit31.galaxyproject.org|bioit31]] || [[http://bioit32.galaxyproject.org|bioit32]] || [[http://bioit33.galaxyproject.org|bioit33]] || [[http://bioit34.galaxyproject.org|bioit34]] || [[http://bioit35.galaxyproject.org|bioit35]] || [[http://bioit36.galaxyproject.org|bioit36]] || [[http://bioit37.galaxyproject.org|bioit37]] || [[http://bioit38.galaxyproject.org|bioit38]] || [[http://bioit39.galaxyproject.org|bioit39]] ||

== References ==

 * [[http://uwsgi-docs.readthedocs.org/en/latest/|uWSGI]]
 * [[http://supervisord.org/|Supervisor]]
 * [[http://packaging.ubuntu.com/html/|Ubuntu Packaging Guide]] - for repackaging `nginx-extras`, particularly, chapters 4-7 in the Knowledge Base section
 * [[https://code.launchpad.net/~natefoo/ubuntu/trusty/nginx/nginx-upload-module|Modifications to the nginx-extras package]] - I added the `nginx-upload` module, which was part of the nginx-extras package in Ubuntu 12.04 LTS ("precise").

= Transcripts =

== Adding local data by hand ==

{{{#!highlight console
ubuntu@bioit:~$ mkdir -p ~/local_data/sacCer2/seq/work
ubuntu@bioit:~$ cd ~/local_data/sacCer2/seq/work
ubuntu@bioit:~/local_data/sacCer2/seq/work$ rsync -vz rsync://hgdownload.cse.ucsc.edu/goldenPath/sacCer2/bigZips/chromFa.tar.gz .
chromFa.tar.gz

sent 51 bytes received 3,824,563 bytes 1,092,746.86 bytes/sec
total size is 3,823,174 speedup is 1.00
ubuntu@bioit:~/local_data/sacCer2/seq/work$ tar zxvf chromFa.tar.gz
2micron.fa
chrI.fa
chrII.fa
chrIII.fa
chrIV.fa
chrIX.fa
chrM.fa
chrV.fa
chrVI.fa
chrVII.fa
chrVIII.fa
chrX.fa
chrXI.fa
chrXII.fa
chrXIII.fa
chrXIV.fa
chrXV.fa
chrXVI.fa
ubuntu@bioit:~/local_data/sacCer2/seq/work$ cat *.fa >../sacCer2.fa
ubuntu@bioit:~/local_data/sacCer2/seq/work$ cd ../..
ubuntu@bioit:~/local_data/sacCer2$ mkdir bwa_index
ubuntu@bioit:~/local_data/sacCer2$ cd bwa_index
ubuntu@bioit:~/local_data/sacCer2/bwa_index$ ~/tool_deps/bwa/0.5.9/devteam/package_bwa_0_5_9/ec2595e4d313/bin/bwa index -a bwtsw sacCer2.fa
[bwa_index] Pack FASTA... 0.18 sec
[bwa_index] Reverse the packed sequence... 0.06 sec
[bwa_index] Construct BWT for the packed sequence...
[BWTIncConstructFromPacked] 10 iterations done. 2968163 characters processed.
[BWTIncConstructFromPacked] 20 iterations done. 5189523 characters processed.
[BWTIncConstructFromPacked] 30 iterations done. 6938035 characters processed.
[BWTIncConstructFromPacked] 40 iterations done. 8313523 characters processed.
[BWTIncConstructFromPacked] 50 iterations done. 9394739 characters processed.
[BWTIncConstructFromPacked] 60 iterations done. 10243827 characters processed.
[BWTIncConstructFromPacked] 70 iterations done. 10909811 characters processed.
[BWTIncConstructFromPacked] 80 iterations done. 11431331 characters processed.
[BWTIncConstructFromPacked] 90 iterations done. 11838867 characters processed.
[BWTIncConstructFromPacked] 100 iterations done. 12156547 characters processed.
[bwt_gen] Finished constructing BWT in 101 iterations.
[bwa_index] 3.30 seconds elapse.
[bwa_index] Construct BWT for the reverse packed sequence...
[BWTIncConstructFromPacked] 10 iterations done. 2968163 characters processed.
[BWTIncConstructFromPacked] 20 iterations done. 5189523 characters processed.
[BWTIncConstructFromPacked] 30 iterations done. 6938035 characters processed.
[BWTIncConstructFromPacked] 40 iterations done. 8313523 characters processed.
[BWTIncConstructFromPacked] 50 iterations done. 9394739 characters processed.
[BWTIncConstructFromPacked] 60 iterations done. 10243827 characters processed.
[BWTIncConstructFromPacked] 70 iterations done. 10909811 characters processed.
[BWTIncConstructFromPacked] 80 iterations done. 11431331 characters processed.
[BWTIncConstructFromPacked] 90 iterations done. 11838867 characters processed.
[BWTIncConstructFromPacked] 100 iterations done. 12156547 characters processed.
[bwt_gen] Finished constructing BWT in 101 iterations.
[bwa_index] 3.41 seconds elapse.
[bwa_index] Update BWT... 0.08 sec
[bwa_index] Update reverse BWT... 0.07 sec
[bwa_index] Construct SA from BWT and Occ... 1.03 sec
[bwa_index] Construct SA from reverse BWT and Occ... 1.02 sec
ubuntu@bioit:~/local_data/sacCer2/bwa_index$ cd ~/galaxy-dist/tool-data
ubuntu@bioit:~/galaxy-dist/tool-data$ vim bwa_index.loc
  ...
  sacCer2byhand sacCer2 S. cerevisiae June 2008 (index by hand) /home/ubuntu/local_data/sacCer2/bwa_index/sacCer2.fa
  ...
ubuntu@bioit:~/galaxy-dist/tool-data$ cd ..
ubuntu@bioit:~/galaxy-dist$ vim tool_data_table_conf.xml
  ...
  <table name="bwa_indexes" comment_char="#">
      <columns>value, dbkey, name, path</columns>
      <file path="tool-data/bwa_index.loc" />
  </table>
  ...
ubuntu@bioit:~/galaxy-dist$ sh run.sh
  ...
}}}

Tutorial: Galaxy Installation and Administration

Nate Coraor and John Chilton


https://dev.twitter.com/sites/default/files/images_documentation/bird_blue_16.png #usegalaxy

This this follow-along page assumes you have already installed and started a Training Day VM - please do this before arriving.

Please use Firefox or Chrome for this tutorial. Galaxy is compatible with all modern versions of Firefox, Chrome, Safari, and Internet Explorer. However, for the purposes of this tutorial it will help us when assisting people encountering problems if only Firefox or Chrome are used.

Setting up a Local Galaxy Tutorial (Part I)

Clone (download) Galaxy

The Galaxy distribution is found at https://bitbucket.org/galaxy/galaxy-dist/, but for the purposes of this tutorial, we'll use a trimmed version to decrease the time it takes to clone.

Trying again:

   1 galaxy@gcc2014:~$ hg clone /home/galaxy/galaxy-central galaxy-dist
   2 requesting all changes
   3 adding changesets
   4 adding manifests
   5 adding file changes
   6 added 8 changesets with 3443 changes to 3443 files
   7 updating to branch default
   8 3443 files updated, 0 files merged, 0 files removed, 0 files unresolved
   9 galaxy@gcc2014:~$ cd galaxy-dist
  10 galaxy@gcc2014:~/galaxy-dist$

References

Update to the stable branch

TODO: Replace console.

   1 ubuntu@bioit:~$ cd galaxy-dist
   2 ubuntu@bioit:~/galaxy-dist$ hg update stable
   3 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   4 ubuntu@bioit:~/galaxy-dist$

Start Galaxy

TODO: Replace console.

   1 ubuntu@bioit:~/galaxy-dist$ sh run.sh
   2 Initializing datatypes_conf.xml from datatypes_conf.xml.sample
   3   ...
   4 Some eggs are out of date, attempting to fetch...
   5 Fetched http://scofield.galaxyproject.org/eggs/Mako/Mako-0.4.1-py2.7.egg
   6   ...
   7 Fetch successful.
   8 python path is: /home/ubuntu/galaxy-dist/eggs/mercurial-2...
   9   ...
  10 Starting server in PID 3091.
  11 serving on http://127.0.0.1:8080
  12 

Serve over public interface

Stop Galaxy by hitting CTRL-c:

TODO: Replace console.

   1 serving on http://127.0.0.1:8080
   2 ^Cgalaxy.jobs.handler INFO 2014-04-23 13:27:59,203 sending stop signal to worker thread
   3 galaxy.jobs.handler INFO 2014-04-23 13:27:59,204 job handler queue stopped
   4 galaxy.jobs.runners INFO 2014-04-23 13:27:59,204 LWRRunner: Sending stop signal to monitor thread
   5 galaxy.jobs.runners INFO 2014-04-23 13:27:59,204 LWRRunner: Sending stop signal to 3 worker threads
   6 galaxy.jobs.runners INFO 2014-04-23 13:27:59,204 LocalRunner: Sending stop signal to 5 worker threads
   7 galaxy.jobs.handler INFO 2014-04-23 13:27:59,205 sending stop signal to worker thread
   8 galaxy.jobs.handler INFO 2014-04-23 13:27:59,205 job handler stop queue stopped
   9 ubuntu@bioit:~/galaxy-dist$

Edit the primary Galaxy configuration file, universe_wsgi.ini. If you are not familiar with vi, consider using nano instead.

TODO: Replace console.

   1 ubuntu@bioit:~/galaxy-dist$ vi universe_wsgi.ini

In the [server:main] section, uncomment #host = 127.0.0.1 and set:

   1 host = 0.0.0.0

While we are in the config, we should set two options necessary for the next section. The file is large and it's easiest to search for these (/<pattern> in vi, CTRL-w <pattern> in nano):

TODO: Replace tool_dependency_dir.

   1 [app:main]
   2 admin_users = nate@bx.psu.edu
   3 tool_dependency_dir = /home/ubuntu/tool_deps

Then save and quit (CTRL-x y ENTER in nano). Start Galaxy again:

TODO: Replace console.

   1 ubuntu@bioit:~/galaxy-dist$ sh run.sh
   2   ...
   3 Starting server in PID 3298.
   4 serving on 0.0.0.0:8080 view at http://127.0.0.1:8080
   5 

The message view at http://127.0.0.1:8080 is generated by the embedded webserver and cannot be changed so it is not entirely accurate, but serving on 0.0.0.0:8080 reveals that the server is now listening on public interfaces.

Installing tools from the Tool Shed

Topics for this section

  • What is a Galaxy tool?
    • Basic: An XML description of the tool's interface, allowing Galaxy to render a UI (tool form), as well as the command line to execute.
    • Complex: XML + wrapper scripts and interfaces to external dependencies
  • Exploring preinstalled tools and filesystem layout
    • galaxy-dist/tool_conf.xml

    • galaxy-dist/tools/

    • Example simple tool: galaxy-dist/tools/filters/sorter.xml (tool xml), galaxy-dist/tools/filters/sorter.py (tool code)

    • Example tool with unmet dependencies: galaxy-dist/tools/sr_mapping/mosaik.xml

  • The Tool Shed
    • Installing tools from the Tool Shed
    • Exploring the filesystem layout of tools installed from the Tool Shed

Install a tool from the Tool Shed

You will need to enable 3rd-party cookies in your browser for Tool Shed installations to work:

  • Chrome: Settings -> Show advanced settings... -> Privacy -> Content Settings... -> Block third-party cookies and site data -> uncheck

  • Firefox: Settings -> Privacy -> History -> Firefox will: Remember history or Firefox will: Use custom settings for history -> Accept third-party cookies: Always

Reload the Galaxy interface if your 3rd party cookies were not previously enabled.

TODO: Replace paths below if needed.

  • Register an account that matches the address you set in admin_users

  • Follow the tutorial on installing tools from the Tool Shed. In brief:

    • Click Admin from the masthead

    • Click Search and browse tool sheds from the left panel

    • Click the popup icon for Galaxy main tool shed and select Search for valid tools

    • Search for Tool names that contain the name bwa

    • Click the popup icon for bwa_wrappers and select Install to Galaxy

    • Select the NGS: Mapping section and click Install to Galaxy

  • Tools (XML, wrapper scripts) are installed in /home/ubuntu/shed_tools

  • Tool dependencies (binaries) are installed in /home/ubuntu/tool_deps

References

Managing local data

Topics for this section

  • What is local data?
  • Manual data inclusion
    • Building indexes on the command line
    • .loc files

    • tool_data_table_conf.xml

    • Example of the above with bwa and S. cerevisiae (sacCer2) transcript

  • Galaxy Data Managers

Adding local data with a Galaxy Data Manager

Install data managers for fetching the reference genome and building BWA indexes:

  • Click Admin from the masthead

  • Click Search and browse tool sheds from the left panel

  • Click the popup icon for Galaxy main tool shed and select Search for valid tools

  • Search for Tool ids that contain the name manager

  • Check data_manager_fetch_genome_all_fasta and data_manager_bwa_index_builder, then click Install to Galaxy (at the bottom of the page)

  • Click Install

Fetch reference genome (fasta):

  • Click Manage local data (beta) from the left panel

  • Click Reference Genome - fetching

  • In the DBKEY to assign to data: field, type sacCer2

  • In the UCSC's DBKEY for source FASTA: field, type sacCer2

  • Click Execute

Build BWA indexes:

  • Click Manage local data (beta) from the left panel

  • Click BWA index - builder

  • Click Execute

Upon completion:

  • galaxy-dist/tool-data/sacCer2/seq/sacCer2.fa has been created from chromosome fastas fetched from UCSC

  • galaxy-dist/tool-data/sacCer2/bwa_index/sacCer2.fa.* indexes have been generated with bwa index

  • galaxy-dist/tool-data/toolshed.g2.bx.psu.edu/repos/devteam/data_manager_fetch_genome_all_fasta/2ebc856bce29/all_fasta.loc contains a reference to the newly created sacCer2.fa

  • galaxy-dist/tool-data/toolshed.g2.bx.psu.edu/repos/devteam/data_manager_bwa_index_builder/367878cb3698/bwa_index.loc contains a reference to the newly built bwa indexes

  • galaxy-dist/shed_tool_data_table_conf.xml includes entries for the all_fasta and bwa_indexes data tables

References

Setting up a Local Galaxy Tutorial (Part II)

Documentation for the features used in this section can be found at usegalaxy.org/production (forwards to Admin/Config/Performance/ProductionServer)

Install and configure PostgreSQL

TODO: Replace console.

ubuntu@bioit:~$ sudo apt-get install postgresql
  ...
After this operation, 15.5 MB of additional disk space will be used.
Do you want to continue? [Y/n]
  ...
Creating new cluster 9.3/main ...
  config /etc/postgresql/9.3/main
  data   /var/lib/postgresql/9.3/main
  locale en_US.UTF-8
  port   5432
 * Starting PostgreSQL 9.3 database server
   ...done.
ubuntu@bioit:~$ sudo -u postgres createuser galaxy
ubuntu@bioit:~$ sudo -u postgres createdb -O galaxy galaxy

Create a new user for Galaxy

TODO: Replace console.

   1 ubuntu@bioit:~$ sudo useradd -m -s /bin/bash galaxy
   2 ubuntu@bioit:~$

Create a Python virtual environment

TODO: Replace console.

   1 ubuntu@bioit:~$ sudo apt-get install python-virtualenv
   2 Reading package lists... Done
   3 Building dependency tree
   4 Reading state information... Done
   5 The following extra packages will be installed:
   6   ...
   7 Do you want to continue? [Y/n]
   8   ...
   9 Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libasan0 amd64 4.8.2-19ubuntu1 [63.0 kB]
  10   ...
  11 Processing triggers for libc-bin (2.19-0ubuntu6) ...
  12 ubuntu@bioit:~$ sudo -iu galaxy
  13 galaxy@bioit:~$ virtualenv venv
  14 New python executable in venv/bin/python
  15 Installing setuptools, pip...done.
  16 galaxy@bioit:~$ source ./venv/bin/activate
  17 (venv)galaxy@bioit:~$

Clone (download) Galaxy

TODO: Replace console.

   1 galaxy@bioit:~$ hg clone https://bitbucket.org/natefoo/galaxy-bioit galaxy-dist
   2 requesting all changes
   3 adding changesets
   4 adding manifests
   5 adding file changes
   6 added 8 changesets with 3443 changes to 3443 files
   7 updating to branch default
   8 3443 files updated, 0 files merged, 0 files removed, 0 files unresolved
   9 galaxy@bioit:~$ cd galaxy-dist
  10 galaxy@bioit:~/galaxy-dist$ hg update stable
  11 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  12 galaxy@bioit:~/galaxy-dist$

Configure Galaxy

TODO: Replace console.

   1 galaxy@bioit:~/galaxy-dist$ cp universe_wsgi.ini.sample universe_wsgi.ini
   2 galaxy@bioit:~/galaxy-dist$ vi universe_wsgi.ini

Add the following section for uWSGI's configuration and the job handler processes

   1 [uwsgi]
   2 socket = 127.0.0.1:4001
   3 stats = 127.0.0.1:9191
   4 processes = 2
   5 threads = 4
   6 master = True
   7 logto = /home/galaxy/uwsgi.log
   8 pythonpath = lib
   9 
  10 [server:handler0]
  11 use = egg:Paste#http
  12 port = 9010
  13 use_threadpool = True
  14 threadpool_workers = 10
  15 
  16 [server:handler1]
  17 use = egg:Paste#http
  18 port = 9011
  19 use_threadpool = True
  20 threadpool_workers = 10

Set the following settings in the [app:main] section:

   1 database_connection = postgresql:///galaxy?host=/var/run/postgresql
   2 database_engine_option_server_side_cursors = True
   3 database_engine_option_strategy = threadlocal
   4 tool_dependency_dir = /home/galaxy/tool_deps
   5 static_enabled = False
   6 nginx_x_accel_redirect_base = /_x_accel_redirect
   7 nginx_upload_store = /home/galaxy/uploads
   8 nginx_upload_path = /_upload
   9 log_events = False
  10 log_actions = False
  11 debug = False
  12 use_interactive = False
  13 id_secret = <random text>
  14 admin_users = nate@bx.psu.edu

Explanations of these options:

  • database_connection = postgresql:///galaxy?host=/var/run/postgresql - Use a PostgreSQL database via a local UNIX domain socket (the socket is in /var/run/postgresql). documentation

  • database_engine_option_server_side_cursors = True - Keep large SQL query results on the PostgreSQL server, rather the transferring the entire result set to the Galaxy processes.

  • database_engine_option_strategy = threadlocal - Only use one database connection per thread

  • tool_dependency_dir = /home/galaxy/tool_deps - The directory that will house tool dependencies

  • static_enabled = False - Static content will be served by the proxy server

  • nginx_x_accel_redirect_base = /_x_accel_redirect - Delegate dataset downloads to nginx

  • nginx_upload_store = /home/galaxy/uploads - Delegate uploads to nginx, set temporary directory

  • nginx_upload_path = /_upload - Special path configured in nginx where uploads will be POSTed

  • log_events = False - Don't log events in the database (faster)

  • log_actions = False - Don't log actions in the database (faster)

  • debug = False - Disables debugging middleware that loads server responses in to memory (can crash the server when handling large files)

  • use_interactive = False - Disables live client browser debugging (insecure).

  • id_secret = <random text> - Ensures that the encoded IDs used by Galaxy (especially session IDs) are unique. One simple way to generate a value for this is with a shell command like $ date | md5sum

  • admin_users = nate@bx.psu.edu - Make nate@example.org an administrator. Galaxy's Admin UI is only accessible if you define administrators here!

Honorable mentions for features we won't use today but that are common in big setups:

  • ftp_upload_dir and ftp_upload_site - Allow users to upload data to the server using FTP

  • use_remote_user and remote_user_maildomain - Use your institution's existing authentication system to log in to Galaxy. Apache documentation or nginx documentation

  • allow_user_impersonation - Users configured as administrators (with admin_users) can "become" other users to view Galaxy exactly as the impersonated user does. Useful for providing support.

  • library_import_dir - Administrators can directly import datasets from this directory on the server to Data Libraries. This includes an option that allows an effective "symlink" to the data, rather than copying it in to Galaxy's file_path directory. documentation

  • user_library_import_dir - Non-administrators can directly import datasets from this directory on this server to Data Libraries from which they have been given write permission. documentation

  • allow_library_path_paste - Administrators can import datasets from anywhere on the server's filesystem(s) by entering their paths in to a text box

  • object_store_config_file - Configure Galaxy's "object storage" layer to store data in multiple filesystems, Amazon S3, iRODS, etc.

  • error_email_to (with smtp_server) - Allow users to send bug reports directly to you

  • user_activation_on and related options - Require new users to verify their email address

  • allow_user_dataset_purge = True - Allow users to forcibly remove their datasets from disk (note that the data is only actually removed if all versions of a shared dataset are purged by all users who are sharing the dataset). By default, Galaxy does not remove data, as this is done at a later time by the dataset cleanup scripts.

  • enable_quotas = True - Enable Galaxy's quota system. Quotas are configured by administrators in the Galaxy Admin UI

Create a job system configuration:

TODO: Replace console.

   1 galaxy@bioit:~/galaxy-dist$ vi job_conf.xml

In the editor, paste:

   1 <?xml version="1.0"?>
   2 <job_conf>
   3     <plugins workers="2">
   4         <plugin id="gridengine" type="runner" load="galaxy.jobs.runners.drmaa:DRMAAJobRunner"/>
   5     </plugins>
   6     <handlers default="handlers">
   7         <handler id="handler0" tags="handlers"/>
   8         <handler id="handler1" tags="handlers"/>
   9     </handlers>
  10     <destinations default="gridengine">
  11         <destination id="gridengine" runner="gridengine"/>
  12     </destinations>
  13     <limits>
  14         <limit type="registered_user_concurrent_jobs">2</limit>
  15         <limit type="unregistered_user_concurrent_jobs">1</limit>
  16         <limit type="job_walltime">24:00:00</limit>
  17     </limits>
  18 </job_conf>

Start a Galaxy server to complete first run setup

TODO: Replace console.

   1 galaxy@bioit:~/galaxy-dist$ sh run.sh
   2 Initializing datatypes_conf.xml from datatypes_conf.xml.sample
   3   ...
   4 serving on http://127.0.0.1:8080
   5 ^C
   6   ...
   7 galaxy@bioit:~/galaxy-dist$ logout
   8 ubuntu@bioit:~$

Install and configure Grid Engine

   1 ubuntu@bioit:~$ sudo apt-get install gridengine-master gridengine-exec gridengine-client gridengine-drmaa1.0
   2 Reading package lists... Done
   3 Building dependency tree
   4 Reading state information... Done
   5 The following extra packages will be installed:
   6   bsd-mailx gridengine-common postfix tcsh
   7 Suggested packages:
   8   gridengine-qmon procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin dovecot-common postfix-cdb mail-reader postfix-doc
   9 The following NEW packages will be installed:
  10   bsd-mailx gridengine-client gridengine-common gridengine-drmaa1.0 gridengine-exec gridengine-master postfix tcsh
  11 0 upgraded, 8 newly installed, 0 to remove and 5 not upgraded.
  12 Need to get 9,172 kB of archives.
  13 After this operation, 51.6 MB of additional disk space will be used.
  14 Do you want to continue? [Y/n]
  15   ...
  16 Preconfiguring packages ...
  17 

You'll be asked a series of configuration questions for Postfix and Grid Engine at this point. The following answers are suitable for this tutorial:

  • General type of mail configuration: Local only
  • System mail name: bioit
  • Configure SGE automatically?: Yes
  • SGE cell name: default
  • SGE master hostname: bioit

TODO: Replace console.

   1 ubuntu@bioit:~$ sudo vi /var/lib/gridengine/default/common/host_aliases
   2   ...
   3 localhost bioit
   4   ...
   5 ubuntu@bioit:~$ sudo service gridengine-master restart
   6 ubuntu@bioit:~$ sudo pkill sge_execd && sudo service gridengine-exec restart
   7 ubuntu@bioit:~$ sudo qconf -aq all.q
   8   ...
   9 hostlist              localhost
  10 shell                 /bin/bash
  11   ...
  12 ubuntu@bioit:~$ sudo qconf -as localhost
  13 localhost added to submit host list
  14 ubuntu@bioit:~$

Install nginx, uWSGI, and supervisord

TODO: Replace console.

   1 ubuntu@bioit:~$ sudo add-apt-repository ppa:natefoo/bioit2014
   2  Provides a rebuilt nginx-extras with the upload module for the workshop @
   3  Bio-IT World Expo 2014
   4  More info: https://launchpad.net/~natefoo/+archive/bioit2014
   5 Press [ENTER] to continue or ctrl-c to cancel adding it
   6 
   7 gpg: keyring `/tmp/tmp71rhd5g3/secring.gpg' created
   8 gpg: keyring `/tmp/tmp71rhd5g3/pubring.gpg' created
   9 gpg: requesting key 12788738 from hkp server keyserver.ubuntu.com
  10 gpg: /tmp/tmp71rhd5g3/trustdb.gpg: trustdb created
  11 gpg: key 12788738: public key "Launchpad PPA for Nate Coraor" imported
  12 gpg: Total number processed: 1
  13 gpg:               imported: 1  (RSA: 1)
  14 OK
  15 ubuntu@bioit:~$ sudo apt-get update
  16   ...
  17 Fetched 141 kB in 4s (34.0 kB/s)
  18 Reading package lists... Done
  19 ubuntu@bioit:~$ sudo apt-get install nginx-extras uwsgi uwsgi-plugin-python supervisor
  20   ...
  21 After this operation, 10.4 MB of additional disk space will be used.
  22 Do you want to continue? [Y/n]
  23 Get:1 http://ppa.launchpad.net/natefoo/bioit2014/ubuntu/ trusty/main nginx-common all 1.4.6-1ubuntu3ppa1 [81.5 kB]
  24 Get:2 http://ppa.launchpad.net/natefoo/bioit2014/ubuntu/ trusty/main nginx-extras amd64 1.4.6-1ubuntu3ppa1 [570 kB]
  25   ...
  26 ubuntu@bioit:~$ sudo /etc/init.d/nginx stop
  27 ubuntu@bioit:~$ sudo update-rc.d -f nginx remove
  28  Removing any system startup links for /etc/init.d/nginx ...
  29    /etc/rc0.d/K20nginx
  30    /etc/rc1.d/K20nginx
  31    /etc/rc2.d/S20nginx
  32    /etc/rc3.d/S20nginx
  33    /etc/rc4.d/S20nginx
  34    /etc/rc5.d/S20nginx
  35    /etc/rc6.d/K20nginx
  36 ubuntu@bioit:~$ sudo update-rc.d -f uwsgi remove
  37  Removing any system startup links for /etc/init.d/uwsgi ...
  38    /etc/rc0.d/K20uwsgi
  39    /etc/rc1.d/K20uwsgi
  40    /etc/rc2.d/S20uwsgi
  41    /etc/rc3.d/S20uwsgi
  42    /etc/rc4.d/S20uwsgi
  43    /etc/rc5.d/S20uwsgi
  44    /etc/rc6.d/K20uwsgi
  45 ubuntu@bioit:~$ 

Configure nginx

TODO: Replace console.

   1 ubuntu@bioit:~$ cd /etc/nginx
   2 ubuntu@bioit:/etc/nginx$ sudo vi nginx.conf
   3   ...
   4   user galaxy;
   5   daemon off;
   6   http {
   7       gzip_vary on;
   8       gzip_proxied any;
   9       gzip_comp_level 6;
  10       gzip_buffers 16 8k;
  11       gzip_http_version 1.1;
  12       gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  13   }
  14   ...
  15 ubuntu@bioit:/etc/nginx$ cd sites-available
  16 ubuntu@bioit:/etc/nginx/sites-available$ sudo vi galaxy

In the editor, paste:

   1 client_max_body_size 50g;
   2 uwsgi_read_timeout 300;
   3 
   4 server {
   5     listen 80 default_server;
   6     server_name  bioit.galaxyproject.org;
   7 
   8     # pass to uWSGI by default
   9     location / {
  10         uwsgi_pass 127.0.0.1:4001;
  11         include uwsgi_params;
  12     }
  13 
  14     # serve static content
  15     location /static {
  16         alias /home/galaxy/galaxy-dist/static;
  17         gzip on;
  18         gzip_types text/plain text/xml text/javascript text/css application/x-javascript;
  19         expires 24h;
  20     }
  21     location /static/style {
  22         alias /home/galaxy/galaxy-dist/static/style/blue;
  23         gzip on;
  24         gzip_types text/plain text/xml text/javascript text/css application/x-javascript;
  25         expires 24h;
  26     }
  27     location /static/scripts {
  28         alias /home/galaxy/galaxy-dist/static/scripts/packed;
  29         gzip on;
  30         gzip_types text/plain text/javascript application/x-javascript;
  31         expires 24h;
  32     }
  33     location ~ ^/plugins/visualizations/(?<vis_name>.+?)/static/(?<static_file>.*?)$ {
  34         alias /home/galaxy/galaxy-dist/config/plugins/visualizations/$vis_name/static/$static_file;
  35     }
  36 
  37     # delegated downloads
  38     location /_x_accel_redirect {
  39         internal;
  40         alias /;
  41     }
  42 
  43     # delegated uploads
  44     location /_upload {
  45         upload_store /home/galaxy/uploads;
  46         upload_store_access user:rw;
  47         upload_pass_form_field "";
  48         upload_set_form_field "__${upload_field_name}__is_composite" "true";
  49         upload_set_form_field "__${upload_field_name}__keys" "name path";
  50         upload_set_form_field "${upload_field_name}_name" "$upload_file_name";
  51         upload_set_form_field "${upload_field_name}_path" "$upload_tmp_path";
  52         upload_pass_args on;
  53         upload_pass /_upload_done;
  54     }
  55     location /_upload_done {
  56         set $dst /api/tools;
  57         if ($args ~ nginx_redir=([^&]+)) {
  58             set $dst $1;
  59         }
  60         rewrite "" $dst;
  61     }
  62 }

   1 ubuntu@bioit:/etc/nginx/sites-available$ cd ../sites-enabled/
   2 ubuntu@bioit:/etc/nginx/sites-enabled$ sudo rm default
   3 ubuntu@bioit:/etc/nginx/sites-enabled$ sudo ln -s ../sites-available/galaxy
   4 ubuntu@bioit:/etc/nginx/sites-enabled$

Configure supervisord

   1 ubuntu@bioit:~$ cd /etc/supervisor/conf.d
   2 ubuntu@bioit:/etc/supervisor/conf.d$ sudo vi galaxy.conf

In the editor, paste:

   1 [program:nginx]
   2 command         = /usr/sbin/nginx
   3 directory       = /
   4 umask           = 022
   5 autostart       = true
   6 autorestart     = unexpected
   7 startsecs       = 5
   8 exitcodes       = 0
   9 user            = root
  10 
  11 [program:galaxy_uwsgi]
  12 command         = /usr/bin/uwsgi --plugin python --ini-paste /home/galaxy/galaxy-dist/universe_wsgi.ini
  13 directory       = /home/galaxy/galaxy-dist
  14 umask           = 022
  15 autostart       = true
  16 autorestart     = true
  17 startsecs       = 10
  18 user            = galaxy
  19 environment     = PATH=/home/galaxy/venv:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin,PYTHON_EGG_CACHE=/home/galaxy/.python-eggs,PYTHONPATH=/home/galaxy/galaxy-dist/eggs/PasteDeploy-1.5.0-py2.7.egg
  20 numprocs        = 1
  21 stopsignal      = INT
  22 
  23 [program:handler]
  24 command         = /home/galaxy/venv/bin/python ./scripts/paster.py serve universe_wsgi.ini --server-name=handler%(process_num)s --pid-file=/home/galaxy/handler%(process_num)s.pid --log-file=/home/galaxy/handler%(process_num)s.log
  25 directory       = /home/galaxy/galaxy-dist
  26 process_name    = handler%(process_num)s
  27 numprocs        = 2
  28 umask           = 022
  29 autostart       = true
  30 autorestart     = true
  31 startsecs       = 15
  32 user            = galaxy
  33 environment     = PYTHON_EGG_CACHE=/home/galaxy/.python-eggs,DRMAA_LIBRARY_PATH=/usr/lib/gridengine-drmaa/lib/libdrmaa.so.1.0,SGE_ROOT=/var/lib/gridengine
  34 
  35 [group:galaxy]
  36 programs = handler

Start Galaxy and nginx

   1 ubuntu@bioit:~$ sudo supervisorctl update
   2 galaxy: added process group
   3 galaxy_uwsgi: added process group
   4 nginx: added process group
   5 ubuntu@bioit:~$ sudo supervisorctl status
   6 galaxy:handler0                  STARTING
   7 galaxy:handler1                  STARTING
   8 galaxy_uwsgi                     STARTING
   9 nginx                            STARTING
  10 

You can now visit your Galaxy server at:

VM Galaxy Instances

bioit0

bioit1

bioit2

bioit3

bioit4

bioit5

bioit6

bioit7

bioit8

bioit9

bioit10

bioit11

bioit12

bioit13

bioit14

bioit15

bioit16

bioit17

bioit18

bioit19

bioit20

bioit21

bioit22

bioit23

bioit24

bioit25

bioit26

bioit27

bioit28

bioit29

bioit30

bioit31

bioit32

bioit33

bioit34

bioit35

bioit36

bioit37

bioit38

bioit39

References

Transcripts

Adding local data by hand

   1 ubuntu@bioit:~$ mkdir -p ~/local_data/sacCer2/seq/work
   2 ubuntu@bioit:~$ cd ~/local_data/sacCer2/seq/work
   3 ubuntu@bioit:~/local_data/sacCer2/seq/work$ rsync -vz rsync://hgdownload.cse.ucsc.edu/goldenPath/sacCer2/bigZips/chromFa.tar.gz .
   4 chromFa.tar.gz
   5 
   6 sent 51 bytes  received 3,824,563 bytes  1,092,746.86 bytes/sec
   7 total size is 3,823,174  speedup is 1.00
   8 ubuntu@bioit:~/local_data/sacCer2/seq/work$ tar zxvf chromFa.tar.gz
   9 2micron.fa
  10 chrI.fa
  11 chrII.fa
  12 chrIII.fa
  13 chrIV.fa
  14 chrIX.fa
  15 chrM.fa
  16 chrV.fa
  17 chrVI.fa
  18 chrVII.fa
  19 chrVIII.fa
  20 chrX.fa
  21 chrXI.fa
  22 chrXII.fa
  23 chrXIII.fa
  24 chrXIV.fa
  25 chrXV.fa
  26 chrXVI.fa
  27 ubuntu@bioit:~/local_data/sacCer2/seq/work$ cat *.fa >../sacCer2.fa
  28 ubuntu@bioit:~/local_data/sacCer2/seq/work$ cd ../..
  29 ubuntu@bioit:~/local_data/sacCer2$ mkdir bwa_index
  30 ubuntu@bioit:~/local_data/sacCer2$ cd bwa_index
  31 ubuntu@bioit:~/local_data/sacCer2/bwa_index$ ~/tool_deps/bwa/0.5.9/devteam/package_bwa_0_5_9/ec2595e4d313/bin/bwa index -a bwtsw sacCer2.fa
  32 [bwa_index] Pack FASTA... 0.18 sec
  33 [bwa_index] Reverse the packed sequence... 0.06 sec
  34 [bwa_index] Construct BWT for the packed sequence...
  35 [BWTIncConstructFromPacked] 10 iterations done. 2968163 characters processed.
  36 [BWTIncConstructFromPacked] 20 iterations done. 5189523 characters processed.
  37 [BWTIncConstructFromPacked] 30 iterations done. 6938035 characters processed.
  38 [BWTIncConstructFromPacked] 40 iterations done. 8313523 characters processed.
  39 [BWTIncConstructFromPacked] 50 iterations done. 9394739 characters processed.
  40 [BWTIncConstructFromPacked] 60 iterations done. 10243827 characters processed.
  41 [BWTIncConstructFromPacked] 70 iterations done. 10909811 characters processed.
  42 [BWTIncConstructFromPacked] 80 iterations done. 11431331 characters processed.
  43 [BWTIncConstructFromPacked] 90 iterations done. 11838867 characters processed.
  44 [BWTIncConstructFromPacked] 100 iterations done. 12156547 characters processed.
  45 [bwt_gen] Finished constructing BWT in 101 iterations.
  46 [bwa_index] 3.30 seconds elapse.
  47 [bwa_index] Construct BWT for the reverse packed sequence...
  48 [BWTIncConstructFromPacked] 10 iterations done. 2968163 characters processed.
  49 [BWTIncConstructFromPacked] 20 iterations done. 5189523 characters processed.
  50 [BWTIncConstructFromPacked] 30 iterations done. 6938035 characters processed.
  51 [BWTIncConstructFromPacked] 40 iterations done. 8313523 characters processed.
  52 [BWTIncConstructFromPacked] 50 iterations done. 9394739 characters processed.
  53 [BWTIncConstructFromPacked] 60 iterations done. 10243827 characters processed.
  54 [BWTIncConstructFromPacked] 70 iterations done. 10909811 characters processed.
  55 [BWTIncConstructFromPacked] 80 iterations done. 11431331 characters processed.
  56 [BWTIncConstructFromPacked] 90 iterations done. 11838867 characters processed.
  57 [BWTIncConstructFromPacked] 100 iterations done. 12156547 characters processed.
  58 [bwt_gen] Finished constructing BWT in 101 iterations.
  59 [bwa_index] 3.41 seconds elapse.
  60 [bwa_index] Update BWT... 0.08 sec
  61 [bwa_index] Update reverse BWT... 0.07 sec
  62 [bwa_index] Construct SA from BWT and Occ... 1.03 sec
  63 [bwa_index] Construct SA from reverse BWT and Occ... 1.02 sec
  64 ubuntu@bioit:~/local_data/sacCer2/bwa_index$ cd ~/galaxy-dist/tool-data
  65 ubuntu@bioit:~/galaxy-dist/tool-data$ vim bwa_index.loc
  66   ...
  67   sacCer2byhand   sacCer2 S. cerevisiae June 2008 (index by hand) /home/ubuntu/local_data/sacCer2/bwa_index/sacCer2.fa
  68   ...
  69 ubuntu@bioit:~/galaxy-dist/tool-data$ cd ..
  70 ubuntu@bioit:~/galaxy-dist$ vim tool_data_table_conf.xml
  71   ...
  72   <table name="bwa_indexes" comment_char="#">
  73       <columns>value, dbkey, name, path</columns>
  74       <file path="tool-data/bwa_index.loc" />
  75   </table>
  76   ...
  77 ubuntu@bioit:~/galaxy-dist$ sh run.sh
  78   ...
  79