Mercurial > repos > iuc > data_manager_genomic_super_signature_ravmodels
changeset 0:b5bca6d58e4c draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_genomic_super_signature_ravmodels commit 1aadd5dce3b254e7714c2fdd39413029fd4b9b7a"
author | iuc |
---|---|
date | Wed, 12 Jan 2022 19:07:19 +0000 |
parents | |
children | |
files | README data_manager/data_manager_genomic_super_signature_ravmodels.py data_manager/data_manager_genomic_super_signature_ravmodels.xml data_manager_conf.xml test-data/RAVmodel_prior_C2.data_manager_json tool-data/genomic_super_signature_ravmodels.loc.sample tool_data_table_conf.xml.sample |
diffstat | 7 files changed, 184 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README Wed Jan 12 19:07:19 2022 +0000 @@ -0,0 +1,1 @@ +Adds new entries to data tables for GenomicSuperSignature Replicable Axes of Variation (RAV) models (RAVmodels). See also https://www.biorxiv.org/content/10.1101/2021.05.26.445900v1. \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/data_manager_genomic_super_signature_ravmodels.py Wed Jan 12 19:07:19 2022 +0000 @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# Dan Blankenberg + + +import argparse +import json +import os +import re +import shutil +import urllib.request + + +OUTPUT_BASE_NAME = 'RAVmodel.rds' + +BUCKET_NAME = "genomic_super_signature" +RAVMODEL_NAME = "RAVmodel_{prior}.rds" +PRIOR_URL = "https://storage.googleapis.com/{bucket_name}/{prior_filename}" + + +def get_prior_url(prior): + return PRIOR_URL.format(bucket_name=BUCKET_NAME, prior_filename=RAVMODEL_NAME.format(prior=prior)) + + +def clean(text): + return re.sub(r'[^\w\-_\.]', '-', text) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--output', dest='output', action='store', type=str, default=None) + parser.add_argument('--json', dest='json', action='store', type=str, default=None) + parser.add_argument('--dbkey', dest='dbkey', action='store', type=str, default=None, help='dbkey') + parser.add_argument('--name', dest='name', action='store', type=str, default=None) + parser.add_argument('--id', dest='id', action='store', type=str, default=None) + parser.add_argument('--prior', dest='prior', action='store', type=str, default=None) + parser.add_argument('--url', dest='url', action='store', type=str, default=None) + parser.add_argument('--input', dest='input', action='store', type=str, default=None) + parser.add_argument('--symlink', dest='symlink', action='store_true', default=False) + parser.add_argument('--version', dest='version', action='store', type=str, default="0") + parser.add_argument('--tablename', dest='tablename', action='store', type=str, default="genomic_super_signature_ravmodels") + args = parser.parse_args() + + os.makedirs(args.output, exist_ok=True) + output_filename = os.path.join(args.output, OUTPUT_BASE_NAME) + if args.symlink: + assert args.input, "You must provide a filename when using symlink functionality." + os.symlink(args.input, output_filename) + else: + url = args.url + if args.prior: + url = get_prior_url(args.prior) + if url: + urllib.request.urlretrieve(url, output_filename) + else: + assert args.input, "You must provide a filename, prior, or URL." + shutil.copyfile(args.input, output_filename) + data_manager_dict = {'data_tables': {args.tablename: [dict(value=clean(args.id), dbkey=args.dbkey, version=args.version, name=args.name, path=OUTPUT_BASE_NAME)]}} + + with open(args.json, 'w') as fh: + json.dump(data_manager_dict, fh, sort_keys=True) + + +if __name__ == "__main__": + main()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/data_manager_genomic_super_signature_ravmodels.xml Wed Jan 12 19:07:19 2022 +0000 @@ -0,0 +1,89 @@ +<tool id="data_manager_genomic_super_signature_ravmodels" name="Load GenomicSuperSignature RAVmodels" version="0.0.1" tool_type="manage_data" profile="19.01"> + <description>into built-in cache</description> + <requirements> + <requirement type="package" version="3.8">python</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + #set $guess_name = "" + #set $guess_id = "" + python '$__tool_directory__/data_manager_genomic_super_signature_ravmodels.py' + --tablename 'genomic_super_signature_ravmodels' + --version '0' + --output '${out_file.extra_files_path}' + --json '${out_file}' + --dbkey '${rav_dbkey}' + #if str($reference_source.reference_source_selector) == 'prior': + --prior '${reference_source.prior_name}' + #if str($reference_source.prior_name) == 'C2': + #set $this_guess = "MSigDB C2 (curated gene sets)" + #elif str($reference_source.prior_name) == 'PLIERpriors': + #set $this_guess = "PLIERpriors: bloodCellMarkersIRISDMAP, svmMarkers, and canonicalPathways" + #else: + #set $this_guess = $reference_source.prior_name + #end if + #set $guess_name = $this_guess + #set $guess_id = $reference_source.prior_name + #elif str($reference_source.reference_source_selector) == 'url': + --url '${reference_source.user_url}' + #set $guess_name = $reference_source.user_url + #set $guess_id = $reference_source.user_url + #elif str($reference_source.reference_source_selector) == 'history': + --input '${reference_source.input_rav}' + #set $guess_name = $reference_source.input_rav.element_identifier + #set $guess_id = $reference_source.input_rav.id + #else: + #raise('Bad Selection') + #end if + --name '${$rav_name or $guess_name}' + --id '${rav_id or $guess_id}' + ]]></command> + <inputs> + <param name="rav_name" type="text" value="" label="Name of RAV" help="Leave blank to generate automatically" /> + <param name="rav_id" type="text" value="" label="ID for RAV" help="Leave blank to generate automatically" /> + <param name="rav_dbkey" type="text" value="hg38" label="Identifier for reference genome for RAV" /> + <conditional name="reference_source"> + <param name="reference_source_selector" type="select" label="Choose the source for the RAV"> + <option value="prior" selected="True">Published GenomicSuperSignature RAVmodel</option> + <option value="url">URL</option> + <option value="history">History</option> + </param> + <when value="prior"> + <param name="prior_name" type="select" optional="false" label="Published GenomicSuperSignature model"> + <option value="C2" selected="True">MSigDB C2 (curated gene sets)</option> + <option value="PLIERpriors">PLIERpriors: bloodCellMarkersIRISDMAP, svmMarkers, and canonicalPathways</option> + </param> + </when> + <when value="url"> + <param name="user_url" type="text" area="True" value="https://" optional="false" label="URL" /> + </when> + <when value="history"> + <param name="input_rav" type="data" format="rds" label="RAV Model file" /> + </when> + </conditional> + </inputs> + <outputs> + <data name="out_file" format="data_manager_json"/> + </outputs> + <tests> + <!-- TODO: need some way to test that new entry was added to data table --> + <test> + <param name="rav_name" value=""/> + <param name="rav_id" value=""/> + <param name="rav_dbkey" value="hg38"/> + <param name="dbkey_source|reference_source_selector" value="prior"/> + <param name="dbkey_source|prior_name" value="C2"/> + <output name="out_file" file="RAVmodel_prior_C2.data_manager_json"/> + </test> + </tests> + <help> +**What it does** + +Fetches a reference RAVmodel from various sources (Google Cloud, URL, Galaxy History, or a server file) and populates the "genomic_super_signature_ravmodels" data table. + +------ + +.. class:: infomark + +**Notice:** If you leave name or id blank, it will be generated automatically. + </help> +</tool>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager_conf.xml Wed Jan 12 19:07:19 2022 +0000 @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<data_managers> + <data_manager tool_file="data_manager/data_manager_genomic_super_signature_ravmodels.xml" id="data_manager_genomic_super_signature_ravmodels"> + <data_table name="genomic_super_signature_ravmodels"> + <output> + <column name="value" /> + <column name="dbkey" /> + <column name="version" /> + <column name="name" /> + <column name="path" output_ref="out_file" > + <move type="directory" relativize_symlinks="True"> + <!-- <source>${path}</source>--> <!-- out_file.extra_files_path is used as base by default --> <!-- if no source, eg for type=directory, then refers to base --> + <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">${dbkey}/genomic_super_signature_ravmodels/${version}/${value}</target> + </move> + <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/${dbkey}/genomic_super_signature_ravmodels/${version}/${value}/${path}</value_translation> + <value_translation type="function">abspath</value_translation> + </column> + </output> + </data_table> + </data_manager> +</data_managers>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/RAVmodel_prior_C2.data_manager_json Wed Jan 12 19:07:19 2022 +0000 @@ -0,0 +1,1 @@ +{"data_tables": {"genomic_super_signature_ravmodels": [{"dbkey": "hg38", "name": "MSigDB C2 (curated gene sets)", "path": "RAVmodel.rds", "value": "C2", "version": "0"}]}} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/genomic_super_signature_ravmodels.loc.sample Wed Jan 12 19:07:19 2022 +0000 @@ -0,0 +1,1 @@ +#<value/id> <dbkey> <RAV format version> <display_name> <path>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.sample Wed Jan 12 19:07:19 2022 +0000 @@ -0,0 +1,7 @@ +<tables> + <!-- Locations of RAVmodels for GenomicSuperSignature --> + <table name="genomic_super_signature_ravmodels" comment_char="#"> + <columns>value, dbkey, version, name, path</columns> + <file path="tool-data/genomic_super_signature_ravmodels.loc" /> + </table> +</tables>