Beispiel #1
0
def _install_galaxy(env):
    """
    Used to install Galaxy and setup its environment, including tools.
    This method is somewhat targeted for the cloud deployment so some
    tweaking of the code may be desirable. This method cannot be used
    to update an existing Galaxy.
    """
    _clone_galaxy_repo(env)
    _chown_galaxy(env, env.galaxy_home)  # Make sure env.galaxy_user owns env.galaxy_home
    sudo("chmod 755 %s" % os.path.split(env.galaxy_home)[0])
    setup_db = _read_boolean(env, "galaxy_setup_database", False)
    if setup_db:
        _setup_galaxy_db(env)
    setup_service = _read_boolean(env, "galaxy_setup_service", False)
    if setup_service:
        _setup_service(env)
    _setup_trackster(env)
    _setup_shed_tools_dir(env)
    _install_tools(env)
    setup_xvfb = _read_boolean(env, "galaxy_setup_xvfb", False)
    if setup_xvfb:
        _setup_xvfb(env)
    _chown_galaxy(env, env.galaxy_home)  # Make sure env.galaxy_user owns env.galaxy_home
    _chown_galaxy(env, env.galaxy_loc_files)  # Make sure env.galaxy_user owns env.galaxy_loc_files
    return True
Beispiel #2
0
def __check_conditional(conf_dict):
    passes = True
    try:
        if "if" in conf_dict:
            value = conf_dict["if"]
            passes = _read_boolean(env, value, False)
        elif "unless" in conf_dict:
            value = conf_dict["unless"]
            passes = not _read_boolean(env, value, False)
    except TypeError:
        # configuration is not a dictionary, default to True
        pass
    return passes
Beispiel #3
0
def _install_tools(env, tools_conf=None):
    """
    Install tools needed for Galaxy along with tool configuration
    directories needed by Galaxy.
    """

    if not tools_conf:
        tools_conf = _load_tools_conf(env)

    if _read_boolean(env, "galaxy_install_dependencies", False):
       # Need to ensure the install dir exists and is owned by env.galaxy_user
        _setup_install_dir(env)
        _install_applications(env, tools_conf)

    if _read_boolean(env, "galaxy_install_r_packages", False):
        _install_r_packages(tools_conf)
Beispiel #4
0
def _clone_galaxy_repo(env):
    """
    Clone Galaxy source code repository from ``env.galaxy_repository`` to
    ``env.galaxy_home``, setting the directory ownership to ``env.galaxy_user``

    This method cannot be used to update an existing Galaxy installation.
    """
    # Make sure ``env.galaxy_home`` dir exists but without Galaxy in it
    galaxy_exists = False
    if exists(env.galaxy_home):
        if exists(os.path.join(env.galaxy_home, '.hg')):
            env.logger.warning("Galaxy install dir {0} exists and seems to have " \
                "a Mercurial repository already there. Galaxy already installed?"\
                .format(env.galaxy_home))
            galaxy_exists = True
    else:
        sudo("mkdir -p '%s'" % env.galaxy_home)
    if not galaxy_exists:
        with cd(env.galaxy_home):
            # Needs to be done as non galaxy user, otherwise we have a
            # permissions problem.
            galaxy_repository = env.get("galaxy_repository", 'https://bitbucket.org/galaxy/galaxy-central/')
            env.safe_sudo('hg clone %s .' % galaxy_repository)
    # Make sure ``env.galaxy_home`` is owned by ``env.galaxy_user``
    _chown_galaxy(env, env.galaxy_home)
    # Make sure env.galaxy_home root dir is also owned by env.galaxy_user so Galaxy
    # process can create necessary dirs (e.g., shed_tools, tmp)
    sudo("chown {0}:{0} {1}".format(env.galaxy_user, os.path.split(env.galaxy_home)[0]))
    # If needed, custom-configure this freshly cloned Galaxy
    preconfigured = _read_boolean(env, "galaxy_preconfigured_repository", False)
    if not preconfigured:
        _configure_galaxy_repository(env)
Beispiel #5
0
def _install_galaxy_config(tool_env, bin_dirs, env_vars):
    """
    Setup galaxy tool config files (env.sh-es) and default version
    symbolic links.
    """
    install_dir = tool_env["system_install"]
    env_path = os.path.join(install_dir, "env.sh")
    bin_paths = [os.path.join(install_dir, bin_dir) for bin_dir in bin_dirs]
    path_pieces = [bin_path for bin_path in bin_paths if env.safe_exists(bin_path)]
    if len(path_pieces) > 0 and not env.safe_exists(env_path):
        path_addtion = ":".join(path_pieces)
        # Standard bin install, just add it to path
        env.safe_sudo("echo 'PATH=%s:$PATH' > %s" % (path_addtion, env_path))
        venv_path = "%s/%s" % (install_dir, "venv")
        if env.safe_exists(venv_path):
            #  Have env.sh activate virtualdirectory
            env.safe_sudo("echo '. %s/bin/activate' >> %s" % (venv_path, env_path))
        env.safe_sudo("chmod +x %s" % env_path)
        for env_var, env_var_value in env_vars.iteritems():
            env_var_template = Template(env_var_value)
            expanded_env_var_value = env_var_template.substitute(tool_env)
            env.safe_sudo("echo 'export %s=%s' >> %s" % (env_var, expanded_env_var_value, env_path))
        env.logger.debug("Added Galaxy env.sh file: %s" % env_path)

    # TODO: If a direct install (i.e. tool_install_dir specified instead of galaxy_tools_dir)
    # default is still setup. This is not really desired.
    _set_default_config(tool_env, install_dir)
    if _read_boolean(tool_env, "autoload_galaxy_tools", False) and env.safe_exists(env_path):
        # In this case, the web user (e.g. ubuntu) should auto-load all of
        # galaxy's default env.sh files so they are available for direct use
        # as well.
        _add_to_profiles(". %s" % env_path, profiles=["~/.bashrc"])
Beispiel #6
0
def _install_tools(env, tools_conf=None):
    """
    Install tools needed for Galaxy along with tool configuration
    directories needed by Galaxy.
    """

    if not tools_conf:
        tools_conf = _load_tools_conf(env)

    if _read_boolean(env, "galaxy_install_dependencies", False):
       # Need to ensure the install dir exists and is owned by env.galaxy_user
        _setup_install_dir(env)
        _install_configured_applications(env, tools_conf)
        _chown_galaxy(env, env.galaxy_tools_dir)
        _chown_galaxy(env, env.galaxy_jars_dir)

    if _read_boolean(env, "galaxy_install_r_packages", False):
        _install_r_packages(tools_conf)
Beispiel #7
0
def _install_galaxy(env):
    """ Used to install Galaxy and setup its environment.
    This method cannot be used to update an existing instance of Galaxy code;
    see volume_manipulations_fab.py script for that functionality.
    Also, this method is somewhat targeted for the EC2 deployment so some
    tweaking of the code may be desirable."""
    _clone_galaxy_repo(env)
    # MP: Ensure that everything under install dir is owned by env.galaxy_user
    sudo("chown --recursive %s:%s %s"
       % (env.galaxy_user, env.galaxy_user, os.path.split(env.galaxy_tools_dir)[0]))
    sudo("chmod 755 %s" % os.path.split(env.galaxy_tools_dir)[0])
    setup_service = _read_boolean(env, "galaxy_setup_service", False)
    if setup_service:
        _setup_service(env)
    _install_tools(env)
    setup_xvfb = _read_boolean(env, "galaxy_setup_xvfb", False)
    if setup_xvfb:
        _setup_xvfb(env)
    return True
Beispiel #8
0
def _install_galaxy(env):
    """ Used to install Galaxy and setup its environment.
    This method cannot be used to update an existing instance of Galaxy code;
    see volume_manipulations_fab.py script for that functionality.
    Also, this method is somewhat targeted for the EC2 deployment so some
    tweaking of the code may be desirable."""
    _clone_galaxy_repo(env)
    # MP: Ensure that everything under install dir is owned by env.galaxy_user
    sudo("chown --recursive %s:%s %s"
       % (env.galaxy_user, env.galaxy_user, os.path.split(env.galaxy_tools_dir)[0]))
    sudo("chmod 755 %s" % os.path.split(env.galaxy_tools_dir)[0])
    setup_service = _read_boolean(env, "galaxy_setup_service", False)
    if setup_service:
        _setup_service(env)
    _install_tools(env)
    setup_xvfb = _read_boolean(env, "galaxy_setup_xvfb", False)
    if setup_xvfb:
        _setup_xvfb(env)
    return True
Beispiel #9
0
def _configure_galaxy_repository(env):
    """
    Custom-configure Galaxy repository. This is primarily targeted at a cloud
    deployment.

    mi-deployment would always edit the repository in this way, but
    galaxy-vm-launcher requires the configured Galaxy repository to pull
    in the changesets from https://bitbucket.org/jmchilton/cloud-galaxy-dist
    which prebakes these modifications in.
    """
    _chown_galaxy(env, env.galaxy_home)  # Make sure env.galaxy_user owns env.galaxy_home
    with cd(env.galaxy_home):  # and settings(warn_only=True):
        # Make sure Galaxy runs in a new shell and does not
        # inherit the environment by adding the '-ES' flag
        # to all invocations of python within run.sh
        sudo("sed -i 's/python .\//python -ES .\//g' run.sh", user=env.galaxy_user)
        if _read_boolean(env, "galaxy_cloud", True):
            # Append DRMAA_LIBRARY_PATH in run.sh as well (this file will exist
            # once SGE is installed - which happens at instance contextualization)
            sudo(
                "grep -q 'export DRMAA_LIBRARY_PATH=/opt/sge/lib/lx24-amd64/libdrmaa.so.1.0' run.sh; if [ $? -eq 1 ]; then sed -i '2 a export DRMAA_LIBRARY_PATH=/opt/sge/lib/lx24-amd64/libdrmaa.so.1.0' run.sh; fi",
                user=env.galaxy_user,
            )
            # Upload the custom cloud welcome screen files
            if not exists("%s/static/images/cloud.gif" % env.galaxy_home):
                sudo(
                    "wget --output-document=%s/static/images/cloud.gif %s/cloud.gif" % (env.galaxy_home, CDN_ROOT_URL),
                    user=env.galaxy_user,
                )
            if not exists("%s/static/images/cloud_txt.png" % env.galaxy_home):
                sudo(
                    "wget --output-document=%s/static/images/cloud_text.png %s/cloud_text.png"
                    % (env.galaxy_home, CDN_ROOT_URL),
                    user=env.galaxy_user,
                )
            sudo(
                "wget --output-document=%s/static/welcome.html %s/welcome.html" % (env.galaxy_home, CDN_ROOT_URL),
                user=env.galaxy_user,
            )
        # Set up the symlink for SAMTOOLS (remove this code once SAMTOOLS is converted to data tables)
        if exists("%s/tool-data/sam_fa_indices.loc" % env.galaxy_home):
            sudo("rm %s/tool-data/sam_fa_indices.loc" % env.galaxy_home, user=env.galaxy_user)
        # TODO: Is this really necessary here? Shouldn't the tools do this themselves?
        # set up the jars directory for Java tools
        if not exists(env.galaxy_jars_dir):
            sudo("mkdir -p %s" % env.galaxy_jars_dir, user=env.galaxy_user)
        srma_dir = os.path.join(env.galaxy_tools_dir, "srma", "default")
        haploview_dir = os.path.join(env.galaxy_tools_dir, "haploview", "default")
        picard_dir = os.path.join(env.galaxy_tools_dir, "picard", "default")
        sudo("ln -s %s/srma.jar %s" % (srma_dir, env.galaxy_jars_dir), user=env.galaxy_user)
        sudo("ln -s %s/haploview.jar %s" % (haploview_dir, env.galaxy_jars_dir), user=env.galaxy_user)
        sudo("ln -s %s/*.jar %s" % (picard_dir, env.galaxy_jars_dir), user=env.galaxy_user)
    return True
Beispiel #10
0
def _get_nginx_modules(env):
    """Retrieve add-on modules compiled along with nginx.
    """
    modules = {"upload": True, "chunk": True, "ldap": False}

    module_dirs = []

    for module, enabled_by_default in modules.iteritems():
        enabled = _read_boolean(env, "nginx_enable_module_%s" % module, enabled_by_default)
        if enabled:
            module_dirs.append(eval("_get_nginx_module_%s" % module)(env))

    return module_dirs
Beispiel #11
0
def _get_nginx_modules(env):
    """Retrieve add-on modules compiled along with nginx.
    """
    modules = {"upload": True, "chunk": True, "ldap": False}

    module_dirs = []

    for module, enabled_by_default in modules.iteritems():
        enabled = _read_boolean(env, "nginx_enable_module_%s" % module,
                                enabled_by_default)
        if enabled:
            module_dirs.append(eval("_get_nginx_module_%s" % module)(env))

    return module_dirs
Beispiel #12
0
def _install_galaxy(env):
    """ Used to install Galaxy and setup its environment.
    This method cannot be used to update an existing instance of Galaxy code;
    see volume_manipulations_fab.py script for that functionality.
    Also, this method is somewhat targeted for the EC2 deployment so some
    tweaking of the code may be desirable."""
    # MP: we need to have a tmp directory available if files already exist
    # in the galaxy install directory
    install_cmd = sudo if env.get("use_sudo", True) else run

    base_tmp_dir = env.get("galaxy_tmp_dir", "/mnt")
    tmp_dir = os.path.join(base_tmp_dir, "fab_tmp")
    if exists(tmp_dir):
        install_cmd("rm -rf %s" % tmp_dir)
    if exists(env.galaxy_home):
        if exists(os.path.join(env.galaxy_home, '.hg')):
            env.logger.info("Galaxy install dir '%s' exists and seems to have a Mercurial repository already there. Galaxy already installed.")
            return False
        else:
            # MP: need to move any files already in galaxy home so that hg
            # can checkout files.
            if not exists(tmp_dir):
                install_cmd("mkdir %s" % tmp_dir)
                install_cmd("chown %s %s" % (env.user, tmp_dir))
            install_cmd("mv %s/* %s" % (env.galaxy_home, tmp_dir))
    ## This is slightly different than mi-deployment to handle the
    ## case when the bucket url doesn't match the desired path.
    if not exists(env.galaxy_home):
        sudo("mkdir -p '%s'" % env.galaxy_home)
        _chown_galaxy(env, env.galaxy_home)
    with cd(env.galaxy_home):
        # MP needs to be done as non galaxy user, otherwise we have a
        # permissions problem.
        galaxy_repository = env.get("galaxy_repository", 'https://bitbucket.org/galaxy/galaxy-central/')
        sudo('hg clone %s .' % galaxy_repository)
    # MP: now we need to move the files back into the galaxy directory.
    if exists(tmp_dir):
        install_cmd("cp -R %s/* %s" % (tmp_dir, env.galaxy_home))
        install_cmd("rm -rf %s" % tmp_dir)
    # MP: Ensure that everything under install dir is owned by env.galaxy_user
    sudo("chown --recursive %s:%s %s"
       % (env.galaxy_user, env.galaxy_user, os.path.split(env.galaxy_tools_dir)[0]))
    sudo("chmod 755 %s" % os.path.split(env.galaxy_tools_dir)[0])
    env.get("galaxy_preconfigured_repository", False)
    preconfigured = _read_boolean(env, "galaxy_preconfigured_repository", False)
    if not preconfigured:
        _configure_galaxy_repository(env)
    _install_tools(env)
    return True
Beispiel #13
0
def _configure_galaxy_repository(env):
    """ mi-deployment would always edit the repository in this way, but
    galaxy-vm-launcher requires the configured Galaxy repository to pull
    in the changesets from https://bitbucket.org/jmchilton/cloud-galaxy-dist
    which prebakes these modifications in.
    """
    sudo("chown -R %s %s" % (env.galaxy_user, env.galaxy_home))
    with cd(env.galaxy_home):  # and settings(warn_only=True):
        # Make sure Galaxy runs in a new shell and does not
        # inherit the environment by adding the '-ES' flag
        # to all invocations of python within run.sh
        sudo("sed -i 's/python .\//python -ES .\//g' run.sh", user=env.galaxy_user)
        if _read_boolean(env, "galaxy_cloud", True):
            # Append DRMAA_LIBRARY_PATH in run.sh as well (this file will exist
            # once SGE is installed - which happens at instance contextualization)
            sudo("grep -q 'export DRMAA_LIBRARY_PATH=/opt/sge/lib/lx24-amd64/libdrmaa.so.1.0' run.sh; if [ $? -eq 1 ]; then sed -i '2 a export DRMAA_LIBRARY_PATH=/opt/sge/lib/lx24-amd64/libdrmaa.so.1.0' run.sh; fi", user=env.galaxy_user)
            # Upload the custom cloud welcome screen files
            if not exists("%s/static/images/cloud.gif" % env.galaxy_home):
                sudo("wget --output-document=%s/static/images/cloud.gif %s/cloud.gif" % (env.galaxy_home, CDN_ROOT_URL), user=env.galaxy_user)
            if not exists("%s/static/images/cloud_txt.png" % env.galaxy_home):
                sudo("wget --output-document=%s/static/images/cloud_text.png %s/cloud_text.png" % (env.galaxy_home, CDN_ROOT_URL), user=env.galaxy_user)
            sudo("wget --output-document=%s/static/welcome.html %s/welcome.html" % (env.galaxy_home, CDN_ROOT_URL), user=env.galaxy_user)
        # Set up the symlink for SAMTOOLS (remove this code once SAMTOOLS is converted to data tables)
        if exists("%s/tool-data/sam_fa_indices.loc" % env.galaxy_home):
            sudo("rm %s/tool-data/sam_fa_indices.loc" % env.galaxy_home, user=env.galaxy_user)
        tmp_loc = False
        if not exists(env.galaxy_loc_files):
            sudo("mkdir -p '%s'" % env.galaxy_loc_files)
            _chown_galaxy(env, env.galaxy_loc_files)
        if not exists("%s/sam_fa_indices.loc" % env.galaxy_loc_files):
            sudo("touch %s/sam_fa_indices.loc" % env.galaxy_loc_files, user=env.galaxy_user)
            tmp_loc = True
        sudo("ln -s %s/sam_fa_indices.loc %s/tool-data/sam_fa_indices.loc" % (env.galaxy_loc_files, env.galaxy_home), user=env.galaxy_user)
        if tmp_loc:
            sudo("rm %s/sam_fa_indices.loc" % env.galaxy_loc_files, user=env.galaxy_user)
        # set up the special HYPHY link in tool-data/
        hyphy_dir = os.path.join(env.galaxy_tools_dir, 'hyphy', 'default')
        sudo('ln -s %s tool-data/HYPHY' % hyphy_dir, user=env.galaxy_user)
        # set up the jars directory for Java tools
        if not exists('tool-data/shared/jars'):
            sudo("mkdir -p tool-data/shared/jars", user=env.galaxy_user)
        srma_dir = os.path.join(env.galaxy_tools_dir, 'srma', 'default')
        haploview_dir = os.path.join(env.galaxy_tools_dir, 'haploview', 'default')
        picard_dir = os.path.join(env.galaxy_tools_dir, 'picard', 'default')
        sudo('ln -s %s/srma.jar tool-data/shared/jars/.' % srma_dir, user=env.galaxy_user)
        sudo('ln -s %s/haploview.jar tool-data/shared/jars/.' % haploview_dir, user=env.galaxy_user)
        sudo('ln -s %s/*.jar tool-data/shared/jars/.' % picard_dir, user=env.galaxy_user)
    return True
Beispiel #14
0
def _configure_galaxy_repository(env):
    """ mi-deployment would always edit the repository in this way, but
    galaxy-vm-launcher requires the configured Galaxy repository to pull
    in the changesets from https://bitbucket.org/jmchilton/cloud-galaxy-dist
    which prebakes these modifications in.
    """
    with cd(env.galaxy_home):  # and settings(warn_only=True):
        # Make sure Galaxy runs in a new shell and does not
        # inherit the environment by adding the '-ES' flag
        # to all invocations of python within run.sh
        sudo("sed -i 's/python .\//python -ES .\//g' run.sh", user=env.galaxy_user)
        if _read_boolean(env, "galaxy_cloud", True):
            # Append DRMAA_LIBRARY_PATH in run.sh as well (this file will exist
            # once SGE is installed - which happens at instance contextualization)
            sudo("grep -q 'export DRMAA_LIBRARY_PATH=/opt/sge/lib/lx24-amd64/libdrmaa.so.1.0' run.sh; if [ $? -eq 1 ]; then sed -i '2 a export DRMAA_LIBRARY_PATH=/opt/sge/lib/lx24-amd64/libdrmaa.so.1.0' run.sh; fi", user=env.galaxy_user)
            # Upload the custom cloud welcome screen files
            if not exists("%s/static/images/cloud.gif" % env.galaxy_home):
                sudo("wget --output-document=%s/static/images/cloud.gif %s/cloud.gif" % (env.galaxy_home, CDN_ROOT_URL), user=env.galaxy_user)
            if not exists("%s/static/images/cloud_txt.png" % env.galaxy_home):
                sudo("wget --output-document=%s/static/images/cloud_text.png %s/cloud_text.png" % (env.galaxy_home, CDN_ROOT_URL), user=env.galaxy_user)
            sudo("wget --output-document=%s/static/welcome.html %s/welcome.html" % (env.galaxy_home, CDN_ROOT_URL), user=env.galaxy_user)
        # Set up the symlink for SAMTOOLS (remove this code once SAMTOOLS is converted to data tables)
        if exists("%s/tool-data/sam_fa_indices.loc" % env.galaxy_home):
            sudo("rm %s/tool-data/sam_fa_indices.loc" % env.galaxy_home, user=env.galaxy_user)
        tmp_loc = False
        if not exists(env.galaxy_loc_files):
            sudo("mkdir -p '%s'" % env.galaxy_loc_files)
            _chown_galaxy(env, env.galaxy_loc_files)
        if not exists("%s/sam_fa_indices.loc" % env.galaxy_loc_files):
            sudo("touch %s/sam_fa_indices.loc" % env.galaxy_loc_files, user=env.galaxy_user)
            tmp_loc = True
        sudo("ln -s %s/sam_fa_indices.loc %s/tool-data/sam_fa_indices.loc" % (env.galaxy_loc_files, env.galaxy_home), user=env.galaxy_user)
        if tmp_loc:
            sudo("rm %s/sam_fa_indices.loc" % env.galaxy_loc_files, user=env.galaxy_user)
        # set up the special HYPHY link in tool-data/
        hyphy_dir = os.path.join(env.galaxy_tools_dir, 'hyphy', 'default')
        sudo('ln -s %s tool-data/HYPHY' % hyphy_dir, user=env.galaxy_user)
        # set up the jars directory for Java tools
        if not exists('tool-data/shared/jars'):
            sudo("mkdir -p tool-data/shared/jars", user=env.galaxy_user)
        srma_dir = os.path.join(env.galaxy_tools_dir, 'srma', 'default')
        haploview_dir = os.path.join(env.galaxy_tools_dir, 'haploview', 'default')
        picard_dir = os.path.join(env.galaxy_tools_dir, 'picard', 'default')
        sudo('ln -s %s/srma.jar tool-data/shared/jars/.' % srma_dir, user=env.galaxy_user)
        sudo('ln -s %s/haploview.jar tool-data/shared/jars/.' % haploview_dir, user=env.galaxy_user)
        sudo('ln -s %s/*.jar tool-data/shared/jars/.' % picard_dir, user=env.galaxy_user)
    return True
Beispiel #15
0
def _configure_galaxy_repository(env):
    """
    Custom-configure Galaxy repository. This is primarily targeted at a cloud
    deployment.

    mi-deployment would always edit the repository in this way, but
    galaxy-vm-launcher requires the configured Galaxy repository to pull
    in the changesets from https://bitbucket.org/jmchilton/cloud-galaxy-dist
    which prebakes these modifications in.
    """
    _chown_galaxy(env, env.galaxy_home)  # Make sure env.galaxy_user owns env.galaxy_home
    with cd(env.galaxy_home):  # and settings(warn_only=True):
        # Make sure Galaxy runs in a new shell and does not
        # inherit the environment by adding the '-ES' flag
        # to all invocations of python within run.sh
        env.safe_sudo("sed -i 's/python .\//python -ES .\//g' %s/run.sh" % ( env.galaxy_home ), user=env.galaxy_user)
        if _read_boolean(env, "galaxy_cloud", True):
            # Append DRMAA_LIBRARY_PATH in run.sh as well (this file will exist
            # once SGE is installed - which happens at instance contextualization)
            env.safe_sudo("grep -q 'export DRMAA_LIBRARY_PATH=/opt/sge/lib/lx24-amd64/libdrmaa.so.1.0' %s/run.sh; if [ $? -eq 1 ]; then sed -i '2 a export DRMAA_LIBRARY_PATH=/opt/sge/lib/lx24-amd64/libdrmaa.so.1.0' run.sh; fi" % (env.galaxy_home), user=env.galaxy_user)
            # Upload the custom cloud welcome screen files
            if not env.safe_exists("%s/static/images/cloud.gif" % env.galaxy_home):
                env.safe_sudo("wget --output-document=%s/static/images/cloud.gif %s/cloud.gif" % (env.galaxy_home, CDN_ROOT_URL), user=env.galaxy_user)
            if not env.safe_exists("%s/static/images/cloud_txt.png" % env.galaxy_home):
                env.safe_sudo("wget --output-document=%s/static/images/cloud_text.png %s/cloud_text.png" % (env.galaxy_home, CDN_ROOT_URL), user=env.galaxy_user)
            env.safe_sudo("wget --output-document=%s/static/welcome.html %s/welcome.html" % (env.galaxy_home, CDN_ROOT_URL), user=env.galaxy_user)
        # Set up the symlink for SAMTOOLS (remove this code once SAMTOOLS is converted to data tables)
        if env.safe_exists("%s/tool-data/sam_fa_indices.loc" % env.galaxy_home):
            env.safe_sudo("rm %s/tool-data/sam_fa_indices.loc" % env.galaxy_home, user=env.galaxy_user)
        # TODO: Is this really necessary here? Shouldn't the tools do this themselves?
        # set up the jars directory for Java tools
        if not env.safe_exists(env.galaxy_jars_dir):
            env.safe_sudo("mkdir -p %s" % env.galaxy_jars_dir, user=env.galaxy_user)
        srma_dir = os.path.join(env.galaxy_tools_dir, 'srma', 'default')
        haploview_dir = os.path.join(env.galaxy_tools_dir, 'haploview', 'default')
        picard_dir = os.path.join(env.galaxy_tools_dir, 'picard', 'default')
        env.safe_sudo('ln -s -f %s/srma.jar %s' % (srma_dir, env.galaxy_jars_dir), user=env.galaxy_user)
        env.safe_sudo('ln -s -f %s/haploview.jar %s' % (haploview_dir, env.galaxy_jars_dir), user=env.galaxy_user)
        env.safe_sudo('ln -s -f %s/*.jar %s' % (picard_dir, env.galaxy_jars_dir), user=env.galaxy_user)
    return True
Beispiel #16
0
def _clone_galaxy_repo(env):
    """
    Clone Galaxy source code repository from ``env.galaxy_repository`` to
    ``env.galaxy_home``, setting the directory ownership to ``env.galaxy_user``

    This method cannot be used to update an existing Galaxy installation.
    """
    # Make sure ``env.galaxy_home`` dir exists but without Galaxy in it
    galaxy_exists = False
    if env.safe_exists(env.galaxy_home):
        if env.safe_exists(os.path.join(env.galaxy_home, '.hg')):
            env.logger.warning(
                "Galaxy install dir {0} exists and seems to have "
                "a Mercurial repository already there. Galaxy already installed?"
                .format(env.galaxy_home))
            galaxy_exists = True
    else:
        env.safe_sudo("mkdir -p '%s'" % env.galaxy_home)
    if not galaxy_exists:
        with cd(env.galaxy_home):
            # Needs to be done as non galaxy user, otherwise we have a
            # permissions problem.
            galaxy_repository = env.get(
                "galaxy_repository",
                'https://bitbucket.org/galaxy/galaxy-central/')
            env.safe_sudo('hg clone %s .' % galaxy_repository)
    # Make sure ``env.galaxy_home`` is owned by ``env.galaxy_user``
    _chown_galaxy(env, env.galaxy_home)
    # Make sure env.galaxy_home root dir is also owned by env.galaxy_user so Galaxy
    # process can create necessary dirs (e.g., shed_tools, tmp)
    env.safe_sudo("chown {0}:{0} {1}".format(env.galaxy_user,
                                             os.path.split(
                                                 env.galaxy_home)[0]))
    # If needed, custom-configure this freshly cloned Galaxy
    preconfigured = _read_boolean(env, "galaxy_preconfigured_repository",
                                  False)
    if not preconfigured:
        _configure_galaxy_repository(env)
Beispiel #17
0
def _clone_galaxy_repo(env):
    # MP: we need to have a tmp directory available if files already exist
    # in the galaxy install directory
    install_cmd = sudo if env.get("use_sudo", True) else run

    base_tmp_dir = env.get("galaxy_tmp_dir", "/mnt")
    tmp_dir = os.path.join(base_tmp_dir, "fab_tmp")
    if exists(tmp_dir):
        install_cmd("rm -rf %s" % tmp_dir)
    if exists(env.galaxy_home):
        if exists(os.path.join(env.galaxy_home, '.hg')):
            env.logger.info("Galaxy install dir '%s' exists and seems to have a Mercurial repository already there. Galaxy already installed.")
            return False
        else:
            # MP: need to move any files already in galaxy home so that hg
            # can checkout files.
            if not exists(tmp_dir):
                install_cmd("mkdir %s" % tmp_dir)
                install_cmd("chown %s %s" % (env.user, tmp_dir))
            install_cmd("mv %s/* %s" % (env.galaxy_home, tmp_dir))
    ## This is slightly different than mi-deployment to handle the
    ## case when the bucket url doesn't match the desired path.
    if not exists(env.galaxy_home):
        sudo("mkdir -p '%s'" % env.galaxy_home)
        _chown_galaxy(env, env.galaxy_home)
    with cd(env.galaxy_home):
        # MP needs to be done as non galaxy user, otherwise we have a
        # permissions problem.
        galaxy_repository = env.get("galaxy_repository", 'https://bitbucket.org/galaxy/galaxy-central/')
        sudo('hg clone %s .' % galaxy_repository)
    # MP: now we need to move the files back into the galaxy directory.
    if exists(tmp_dir):
        install_cmd("cp -R %s/* %s" % (tmp_dir, env.galaxy_home))
        install_cmd("rm -rf %s" % tmp_dir)
    preconfigured = _read_boolean(env, "galaxy_preconfigured_repository", False)
    if not preconfigured:
        _configure_galaxy_repository(env)
Beispiel #18
0
def _clone_galaxy_repo(env):
    # MP: we need to have a tmp directory available if files already exist
    # in the galaxy install directory
    install_cmd = sudo if env.get("use_sudo", True) else run

    base_tmp_dir = env.get("galaxy_tmp_dir", "/mnt")
    tmp_dir = os.path.join(base_tmp_dir, "fab_tmp")
    if exists(tmp_dir):
        install_cmd("rm -rf %s" % tmp_dir)
    if exists(env.galaxy_home):
        if exists(os.path.join(env.galaxy_home, '.hg')):
            env.logger.info("Galaxy install dir '%s' exists and seems to have a Mercurial repository already there. Galaxy already installed.")
            return False
        else:
            # MP: need to move any files already in galaxy home so that hg
            # can checkout files.
            if not exists(tmp_dir):
                install_cmd("mkdir %s" % tmp_dir)
                install_cmd("chown %s %s" % (env.user, tmp_dir))
            install_cmd("mv %s/* %s" % (env.galaxy_home, tmp_dir))
    ## This is slightly different than mi-deployment to handle the
    ## case when the bucket url doesn't match the desired path.
    if not exists(env.galaxy_home):
        sudo("mkdir -p '%s'" % env.galaxy_home)
        _chown_galaxy(env, env.galaxy_home)
    with cd(env.galaxy_home):
        # MP needs to be done as non galaxy user, otherwise we have a
        # permissions problem.
        galaxy_repository = env.get("galaxy_repository", 'https://bitbucket.org/galaxy/galaxy-central/')
        sudo('hg clone %s .' % galaxy_repository)
    # MP: now we need to move the files back into the galaxy directory.
    if exists(tmp_dir):
        install_cmd("cp -R %s/* %s" % (tmp_dir, env.galaxy_home))
        install_cmd("rm -rf %s" % tmp_dir)
    preconfigured = _read_boolean(env, "galaxy_preconfigured_repository", False)
    if not preconfigured:
        _configure_galaxy_repository(env)
Beispiel #19
0
def _install_galaxy_config(tool_env, bin_dirs, env_vars):
    """
    Setup galaxy tool config files (env.sh-es) and default version
    symbolic links.
    """
    install_dir = tool_env["system_install"]
    env_path = os.path.join(install_dir, "env.sh")
    bin_paths = [os.path.join(install_dir, bin_dir) for bin_dir in bin_dirs]
    path_pieces = [
        bin_path for bin_path in bin_paths if env.safe_exists(bin_path)
    ]
    if len(path_pieces) > 0 and not env.safe_exists(env_path):
        path_addtion = ":".join(path_pieces)
        # Standard bin install, just add it to path
        env.safe_sudo("echo 'PATH=%s:$PATH' > %s" % (path_addtion, env_path))
        venv_path = "%s/%s" % (install_dir, "venv")
        if env.safe_exists(venv_path):
            #  Have env.sh activate virtualdirectory
            env.safe_sudo("echo '. %s/bin/activate' >> %s" %
                          (venv_path, env_path))
        env.safe_sudo("chmod +x %s" % env_path)
        for env_var, env_var_value in env_vars.iteritems():
            env_var_template = Template(env_var_value)
            expanded_env_var_value = env_var_template.substitute(tool_env)
            env.safe_sudo("echo 'export %s=%s' >> %s" %
                          (env_var, expanded_env_var_value, env_path))
        env.logger.debug("Added Galaxy env.sh file: %s" % env_path)

    # TODO: If a direct install (i.e. tool_install_dir specified instead of galaxy_tools_dir)
    # default is still setup. This is not really desired.
    _set_default_config(tool_env, install_dir)
    if _read_boolean(tool_env, "autoload_galaxy_tools",
                     False) and env.safe_exists(env_path):
        # In this case, the web user (e.g. ubuntu) should auto-load all of
        # galaxy's default env.sh files so they are available for direct use
        # as well.
        _add_to_profiles(". %s" % env_path, profiles=["~/.bashrc"])