# HG changeset patch # User iuc # Date 1479852720 18000 # Node ID a7fb84abef45ba17c34a098e848a9264efb6f7d7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/data_managers/data_manager_bwameth_index_builder commit 30192223eeb60f33a42046921351c6ba3c80c90c diff -r 000000000000 -r a7fb84abef45 data_manager/bwameth_index_builder.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/bwameth_index_builder.py Tue Nov 22 17:12:00 2016 -0500 @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# Based heavily on the HISAT2 data manager wrapper + +import argparse +import os +import subprocess +import sys +from json import dumps, loads + +DEFAULT_DATA_TABLE_NAME = "bwameth_indexes" + + +def build_bwameth_index(data_manager_dict, params, args): + data_table_name = args.data_table_name + target_directory = params[ 'output_data' ][0]['extra_files_path'] + if not os.path.exists( target_directory ): + os.mkdir( target_directory ) + fasta_base_name = os.path.basename(args.fasta_filename) + sym_linked_fasta_filename = os.path.join(target_directory, fasta_base_name) + os.symlink(os.path.abspath(args.fasta_filename), sym_linked_fasta_filename) + cmd = ['bwameth.py', 'index', sym_linked_fasta_filename] + proc = subprocess.Popen(args=cmd, shell=False, cwd=target_directory) + return_code = proc.wait() + if return_code: + print >> sys.stderr, "Error building index." + sys.exit( return_code ) + data_table_entry = dict(value=args.dbKey, dbkey=args.dbkey, name=args.name, path=args.dbKey) + _add_data_table_entry(data_manager_dict, data_table_name, data_table_entry) + + +def _add_data_table_entry( data_manager_dict, data_table_name, data_table_entry ): + data_manager_dict['data_tables'] = data_manager_dict.get( 'data_tables', {} ) + data_manager_dict['data_tables'][ data_table_name ] = data_manager_dict['data_tables'].get( data_table_name, [] ) + data_manager_dict['data_tables'][ data_table_name ].append( data_table_entry ) + return data_manager_dict + + +def main(): + # Parse Command Line + parser = argparse.ArgumentParser() + parser.add_argument( '--output', default=None ) + parser.add_argument( '--fasta_filename', default=None ) + parser.add_argument( '--dbkey', default=None ) + parser.add_argument( '--name', default=None ) + parser.add_argument( '--description', default=None ) + parser.add_argument( '--data_table_name', default=DEFAULT_DATA_TABLE_NAME ) + args = parser.parse_args() + + filename = args.output + params = loads(open(filename).read()) + data_manager_dict = {} + + if args.dbkey in [ None, '', '?' ]: + raise Exception('"%s" is not a valid dbkey. You must specify a valid dbkey.' % (args.dbkey)) + + # build the index + build_bwameth_index(data_manager_dict, params, args) + + # save info to json file + open(filename, 'wb').write(dumps(data_manager_dict)) + + +if __name__ == "__main__": + main() diff -r 000000000000 -r a7fb84abef45 data_manager/bwameth_index_builder.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/bwameth_index_builder.xml Tue Nov 22 17:12:00 2016 -0500 @@ -0,0 +1,59 @@ + + builder + + bwa + samtools + bwameth + + + + + + + + + + + + + + + + + + @misc{1401.1129, + Author = {Brent S. Pedersen and Kenneth Eyring and Subhajyoti De and Ivana V. Yang and David A. Schwartz}, + Title = {Fast and accurate alignment of long bisulfite-seq reads}, + Year = {2014}, + Eprint = {arXiv:1401.1129}, + } + + diff -r 000000000000 -r a7fb84abef45 data_manager_conf.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager_conf.xml Tue Nov 22 17:12:00 2016 -0500 @@ -0,0 +1,19 @@ + + + + + + + + + + + ${dbkey}/bwameth_index/${value} + + ${GALAXY_DATA_MANAGER_DATA_PATH}/${dbkey}/bwameth_index/${value}/${path} + abspath + + + + + diff -r 000000000000 -r a7fb84abef45 tool-data/all_fasta.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/all_fasta.loc.sample Tue Nov 22 17:12:00 2016 -0500 @@ -0,0 +1,18 @@ +#This file lists the locations and dbkeys of all the fasta files +#under the "genome" directory (a directory that contains a directory +#for each build). The script extract_fasta.py will generate the file +#all_fasta.loc. This file has the format (white space characters are +#TAB characters): +# +# +# +#So, all_fasta.loc could look something like this: +# +#apiMel3 apiMel3 Honeybee (Apis mellifera): apiMel3 /path/to/genome/apiMel3/apiMel3.fa +#hg19canon hg19 Human (Homo sapiens): hg19 Canonical /path/to/genome/hg19/hg19canon.fa +#hg19full hg19 Human (Homo sapiens): hg19 Full /path/to/genome/hg19/hg19full.fa +# +#Your all_fasta.loc file should contain an entry for each individual +#fasta file. So there will be multiple fasta files for each build, +#such as with hg19 above. +# diff -r 000000000000 -r a7fb84abef45 tool-data/bwameth_indexes.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/bwameth_indexes.loc.sample Tue Nov 22 17:12:00 2016 -0500 @@ -0,0 +1,15 @@ +# This is a sample file distributed with Galaxy that is used to define a +# list of bwa-meth indices, using three columns tab separated: +# +# +# +# An index can be created with the following command: +# +# bwameth.py index /some/path/genome.fa +# +# "/some/path/genome.fa" would then be the last column in the line +# If this were for the mm10 mouse genome, the resulting entry would look like: +# +#mm9 mm9 Mouse (mm9) /some/path/genome.fa +# +# diff -r 000000000000 -r a7fb84abef45 tool_data_table_conf.xml.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.sample Tue Nov 22 17:12:00 2016 -0500 @@ -0,0 +1,13 @@ + + + + + value, dbkey, name, path + +
+ + + value, dbkey, name, path + +
+
diff -r 000000000000 -r a7fb84abef45 tool_dependencies.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_dependencies.xml Tue Nov 22 17:12:00 2016 -0500 @@ -0,0 +1,12 @@ + + + + + + + + + + + +