# HG changeset patch
# User dfornika
# Date 1551339158 18000
# Node ID 7e43f66abe9de660eb1e5045cb86822908fc0b10
planemo upload for repository https://github.com/dfornika/galaxytools/tree/master/data_managers/data_manager_build_kraken2_database/ commit cc42cd530378bfa3df83b08b6b41aaf2f5072b49-dirty
diff -r 000000000000 -r 7e43f66abe9d data_manager/kraken2_build_standard.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/kraken2_build_standard.py Thu Feb 28 02:32:38 2019 -0500
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+
+import argparse
+import datetime
+import errno
+import json
+import os
+import string
+import subprocess
+import sys
+
+from pprint import pprint
+
+DATA_TABLE_NAME = "kraken2_databases"
+
+def kraken2_build_standard(data_manager_dict, kraken2_args, params, target_directory, data_table_name=DATA_TABLE_NAME):
+ today = datetime.date.today().isoformat()
+ database_name = "_".join([today, "standard"])
+ args = [
+ 'kraken2-build',
+ '--threads', str(kraken2_args["threads"]),
+ '--standard',
+ '--kmer-len', str(kraken2_args["kmer_len"]),
+ '--minimizer-len', str(kraken2_args["minimizer_len"]),
+ '--minimizer-spaces', str(kraken2_args["minimizer_spaces"]),
+ '--db', database_name
+ ]
+ pprint(args)
+ proc = subprocess.Popen(args=args, shell=False, cwd=target_directory)
+ return_code = proc.wait()
+ if return_code:
+ print("Error building database.", file=sys.stderr)
+ sys.exit( return_code )
+
+ data_table_entry = {
+ "value": database_name,
+ "name": database_name,
+ "path": database_name
+ }
+
+ _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():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('params')
+ parser.add_argument( '-k', '--kmer-len', dest='kmer_len', type=int, default=35, help='kmer length' )
+ parser.add_argument( '-m', '--minimizer-len', dest='minimizer_len', type=int, default=31, help='minimizer length' )
+ parser.add_argument( '-s', '--minimizer-spaces', dest='minimizer_spaces', default=6, help='minimizer spaces' )
+ parser.add_argument( '-t', '--threads', dest='threads', default=1, help='threads' )
+ args = parser.parse_args()
+
+ kraken2_args = {
+ "kmer_len": args.kmer_len,
+ "minimizer_len": args.minimizer_len,
+ "minimizer_spaces": args.minimizer_spaces,
+ "threads": args.threads,
+ }
+
+ params = json.loads(open(args.params).read())
+ pprint(params)
+ target_directory = params['output_data'][0]['extra_files_path']
+
+ try:
+ os.mkdir( target_directory )
+ except OSError as exc:
+ if exc.errno == errno.EEXIST and os.path.isdir( target_directory ):
+ pass
+ else:
+ raise
+
+ data_manager_dict = {}
+
+ # build the index
+ kraken2_build_standard(
+ data_manager_dict,
+ kraken2_args,
+ params,
+ target_directory
+ )
+
+ # save info to json file
+ open(args.params, 'wb').write(json.dumps(data_manager_dict))
+
+
+if __name__ == "__main__":
+ main()
diff -r 000000000000 -r 7e43f66abe9d data_manager/kraken2_build_standard.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/kraken2_build_standard.xml Thu Feb 28 02:32:38 2019 -0500
@@ -0,0 +1,31 @@
+
+
+ database builder
+
+ kraken2
+
+ kraken2 -version | head -n 1 | awk '{print $NF}'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10.1186/gb-2014-15-3-r46
+
+
diff -r 000000000000 -r 7e43f66abe9d data_manager/kraken2_custom_database_builder.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/kraken2_custom_database_builder.xml Thu Feb 28 02:32:38 2019 -0500
@@ -0,0 +1,50 @@
+
+
+ database builder
+
+ kraken2
+
+ kraken2 -version | head -n 1 | awk '{print $NF}'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10.1186/gb-2014-15-3-r46
+
+
diff -r 000000000000 -r 7e43f66abe9d data_manager/kraken2_standard_database_builder.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/kraken2_standard_database_builder.xml Thu Feb 28 02:32:38 2019 -0500
@@ -0,0 +1,37 @@
+
+
+ database builder
+
+ kraken2
+
+ kraken2 -version | head -n 1 | awk '{print $NF}'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10.1186/gb-2014-15-3-r46
+
+
diff -r 000000000000 -r 7e43f66abe9d data_manager/make_json.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/make_json.py Thu Feb 28 02:32:38 2019 -0500
@@ -0,0 +1,27 @@
+import argparse
+import json
+import os
+import shutil
+
+
+def main(args):
+ data_manager_entry = {}
+ data_manager_entry['value'] = args.database.lower()
+ data_manager_entry['name'] = args.database
+ data_manager_entry['path'] = '.'
+ data_manager_json = dict(data_tables=dict(kraken2_databases=data_manager_entry))
+ params = json.loads(open(args.output).read())
+ target_directory = params['output_data'][0]['extra_files_path']
+ os.mkdir(target_directory)
+ output_path = os.path.join(os.getcwd(), 'kraken2-database')
+ for filename in os.listdir(output_path):
+ shutil.move(os.path.join(output_path, filename), target_directory)
+ file(args.output, 'w').write(json.dumps(data_manager_json))
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description='Create data manager json.')
+ parser.add_argument('--db', dest='database', action='store', help='Database name')
+ parser.add_argument('--out', dest='output', action='store', help='JSON filename')
+ args = parser.parse_args()
+ main(args)
diff -r 000000000000 -r 7e43f66abe9d data_manager_conf.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager_conf.xml Thu Feb 28 02:32:38 2019 -0500
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+