Mercurial > repos > iuc > dram_set_database_locations
changeset 0:6e52f03e612d draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dram commit 52575ece22fcdbb6fc3aa3582ea377075aaa4db1
author | iuc |
---|---|
date | Thu, 01 Sep 2022 17:16:35 +0000 |
parents | |
children | |
files | dram_set_database_locations.py dram_set_database_locations.xml macros.xml |
diffstat | 3 files changed, 177 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dram_set_database_locations.py Thu Sep 01 17:16:35 2022 +0000 @@ -0,0 +1,102 @@ +#!/usr/bin/env python + +import argparse +import os +import subprocess + +parser = argparse.ArgumentParser() + +parser.add_argument('--db_version', action='store', dest='db_version', help='Version of DRAM databases') +parser.add_argument('--skip_uniref', action='store_true', dest='skip_uniref', default=False, help='Flag to Download and process uniref') +parser.add_argument('--galaxy_data_manager_data_path', action='store', dest='galaxy_data_manager_data_path', help='Absolute Galaxy data manager data path') +parser.add_argument('--output', action='store', dest='output', help='Output file') + +args = parser.parse_args() + + +def get_new_dram_config_entry(db_version, old_entry, new_base_path): + # Example old_entry: + # KOfam db: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/kofam_profiles.hmm + base_path, file_name = os.path.split(old_entry) + # The new entry must be GALAXY_DATA_MANAGER_DATA_PATH/DRAM/${value}/file_name + return os.path.join(new_base_path, 'DRAM', db_version, file_name) + + +# At this point the DRAM config will look something like this. +# Processed search databases +# KEGG db: None +# KOfam db: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/kofam_profiles.hmm +# KOfam KO list: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/kofam_ko_list.tsv +# UniRef db: None +# Pfam db: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/pfam.mmspro +# dbCAN db: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/dbCAN-HMMdb-V10.txt +# RefSeq Viral db: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/refseq_viral.20220707.mmsdb +# MEROPS peptidase db: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/peptidases.20220707.mmsdb +# VOGDB db: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/vog_latest_hmms.txt +# +# Descriptions of search database entries +# Pfam hmm dat: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/Pfam-A.hmm.dat.gz +# dbCAN family activities: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/CAZyDB.07292021.fam-activities.txt +# VOG annotations: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/vog_annotations_latest.tsv.gz +# +# Description db: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/description_db.sqlite +# +# DRAM distillation sheets +# Genome summary form: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/genome_summary_form.20220707.tsv +# Module step form: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/module_step_form.20220707.tsv +# ETC module database: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/etc_mdoule_database.20220707.tsv +# Function heatmap form: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/function_heatmap_form.20220707.tsv +# AMG database: /home/galaxies/gvk/jwd/003/3045/working/dataset_4268_files/amg_database.20220707.tsv + +# Write the current DRAM CONFIG to a file for processing. +cmd = 'DRAM-setup.py print_config > dram_config.txt' +subprocess.check_call(cmd, shell=True) + +# Update the database locations that DRAM sets in it's CONFIG +# to point to the configured GALAXY_DATA_MANAGER_DATA_PATH location +# for the DRAM databases. +cmd = 'DRAM-setup.py set_database_locations' +with open('dram_config.txt', 'r') as fh: + for line in fh: + line = line.rstrip('\r\n') + if line.startswith('KOfam db:'): + cmd = '%s --kofam_hmm_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('KOfam KO list:'): + cmd = '%s --kofam_ko_list_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('UniRef db:'): + if not args.skip_uniref: + cmd = '%s --uniref_db_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('Pfam db:'): + cmd = '%s --pfam_db_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('dbCAN db:'): + cmd = '%s --dbcan_db_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('RefSeq Viral db:'): + cmd = '%s --viral_db_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('MEROPS peptidase db:'): + cmd = '%s --peptidase_db_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('VOGDB db:'): + cmd = '%s --vogdb_db_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('Pfam hmm dat:'): + cmd = '%s --pfam_hmm_dat %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('dbCAN family activities:'): + cmd = '%s --dbcan_fam_activities %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('VOG annotations:'): + cmd = '%s --vog_annotations %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('Description db:'): + cmd = '%s --description_db_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('Genome summary form:'): + cmd = '%s --genome_summary_form_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('Module step form:'): + cmd = '%s --module_step_form_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('ETC module database:'): + cmd = '%s --etc_module_database_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('Function heatmap form:'): + cmd = '%s --function_heatmap_form_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) + elif line.startswith('AMG database:'): + cmd = '%s --amg_database_loc %s' % (cmd, get_new_dram_config_entry(args.db_version, line, args.galaxy_data_manager_data_path)) +cmd = '%s --update_description_db' % cmd +subprocess.check_call(cmd, shell=True) + +# Write the new DRAM CONFIG to a file to the output. +cmd = 'DRAM-setup.py print_config > %s' % args.output +subprocess.check_call(cmd, shell=True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dram_set_database_locations.xml Thu Sep 01 17:16:35 2022 +0000 @@ -0,0 +1,52 @@ +<tool id="dram_set_database_locations" name="DRAM: set database locations" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@"> + <description>after installation by the data manager</description> + <macros> + <import>macros.xml</import> + </macros> + <expand macro="requirements"/> + <command detect_errors="exit_code"><![CDATA[ +python '$__tool_directory__/dram_set_database_locations.py' +$skip_uniref +--db_version '$db_version' +--galaxy_data_manager_data_path '$galaxy_data_manager_data_path' +--output '$output' + ]]></command> + <inputs> + <param argument="--skip_uniref" type="boolean" truevalue="--skip_uniref" falsevalue="" checked="false" label="Did you skip downloading and processing uniref when you installed the DRAM databases?"/> + <param name="db_version" type="text" value="1.3.5" label="DRAM database version"> + <expand macro="sanitizer"/> + </param> + <param name="galaxy_data_manager_data_path" type="text" value="" label="Absolute Galaxy data manager data path" help="This is the absolute path for the Galaxy tool-data config setting"> + <expand macro="sanitizer"/> + </param> + </inputs> + <outputs> + <data name="output" format="txt"/> + </outputs> + <tests> + <test expect_failure="true"> + <param name="skip_uniref" value="true"/> + <param name="galaxy_data_manager_data_path" value="/gx/tool-data"/> + <assert_stderr> + <has_text text="error: unrecognized arguments: db: None"/> + </assert_stderr> + </test> + </tests> + <help> +Use of this tool should be restricted to a Galaxy administrator. This tool updates the DRAM configuration file +with the location of the databases after installation by the data manager. This is necessary because DRAM creates +a configuration file during installation, but the file is written before the Galaxy job finishes, so the database +locations are relative to the job working directory instead of the configured GALAXY_DATA_MANAGER_DATA_PATH. + +It may be more ideal to perform this task as a second step in the data manager tool, but DRAM will not allow +the configuration file to be updated to point to locations unless the databases exist in those locations. But +the data manager tool moves the databases to these locations as its last step, making it impossible to update +the DRAM configuration file as a second step of that tool. + +See https://github.com/WrightonLabCSU/DRAM/wiki/5.-Managing%2C-updating-or-moving-a-DRAM-installation-and-databases for details. + </help> + <citations> + <citation type="doi">10.1093/nar/gkaa621</citation> + </citations> +</tool> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/macros.xml Thu Sep 01 17:16:35 2022 +0000 @@ -0,0 +1,23 @@ +<macros> + <token name="@TOOL_VERSION@">1.3.5</token> + <token name="@VERSION_SUFFIX@">0</token> + <token name="@PROFILE@">20.09</token> + <xml name="requirements"> + <requirements> + <requirement type="package" version="@TOOL_VERSION@">dram</requirement> + </requirements> + </xml> + <xml name="sanitizer"> + <sanitizer invalid_char=""> + <valid initial="string.printable"> + <remove value="'"/> + </valid> + </sanitizer> + </xml> + <xml name="citations"> + <citations> + <citation type="doi">10.1186/s13104-016-1900-2</citation> + </citations> + </xml> +</macros> +