# HG changeset patch
# User dfornika
# Date 1557186134 14400
# Node ID 4c9f9d6098ebcc08a952f80d60873e6fb7e01cfd
# Parent d9f190088154e724314771a55867c98835f0280c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken2_database/ commit db9eb9472b9f6caea6a0755697ee8d3a93e85b5b-dirty
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_custom.py
--- a/data_manager/kraken2_build_custom.py Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-#!/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 run(args, cwd):
- proc = subprocess.Popen(args=args, shell=False, cwd=cwd)
- return_code = proc.wait()
- if return_code:
- print("Error building database.", file=sys.stderr)
- sys.exit( return_code )
-
-
-def kraken2_build(data_manager_dict, kraken2_args, database_name, params, target_directory, data_table_name=DATA_TABLE_NAME):
- today = datetime.date.today().isoformat()
-
- args = [
- '--threads', str(kraken2_args["threads"]),
- '--download-taxonomy',
- '--db', database_name
- ]
-
- run(['kraken2-build'] + args, target_directory)
-
- args = [
- '--threads', str(kraken2_args["threads"]),
- '--add-to-library', kraken2_args["fasta"],
- '--db', database_name
- ]
-
- run(['kraken2-build'] + args, target_directory)
-
- args = [
- '--threads', str(kraken2_args["threads"]),
- '--build',
- '--kmer-len', str(kraken2_args["kmer_len"]),
- '--minimizer-len', str(kraken2_args["minimizer_len"]),
- '--minimizer-spaces', str(kraken2_args["minimizer_spaces"]),
- '--db', database_name
- ]
-
- run(['kraken2-build'] + args, target_directory)
-
- args = [
- '--threads', str(kraken2_args["threads"]),
- '--clean',
- '--db', database_name
- ]
-
- run(['kraken2-build'] + args, target_directory)
-
- 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( '-d', '--db', dest='database_name', help='database name' )
- 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( '-f', '--fasta', dest='fasta', help='fasta' )
- 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,
- "fasta": args.fasta,
- "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(
- 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 d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_custom.xml
--- a/data_manager/kraken2_build_custom.xml Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-
-
- database builder
-
- kraken2
-
- kraken2 -version | head -n 1 | awk '{print $NF}'
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 10.1186/gb-2014-15-3-r46
-
-
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_database.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/kraken2_build_database.py Mon May 06 19:42:14 2019 -0400
@@ -0,0 +1,332 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+
+import argparse
+import datetime
+import errno
+import json
+import os
+import shutil
+import subprocess
+import sys
+import tarfile
+from enum import Enum
+
+try:
+ # Python3
+ from urllib.request import urlopen
+except ImportError:
+ from urllib2 import urlopen
+
+
+DATA_TABLE_NAME = "kraken2_databases"
+
+
+class KrakenDatabaseTypes(Enum):
+ standard = 'standard'
+ minikraken = 'minikraken'
+ special = 'special'
+ custom = 'custom'
+
+ def __str__(self):
+ return self.value
+
+
+class SpecialDatabaseTypes(Enum):
+ rdp = 'rdp'
+ greengenes = 'greengenes'
+ silva = 'silva'
+
+ def __str__(self):
+ return self.value
+
+
+class Minikraken2Versions(Enum):
+ v1 = 'v1'
+ v2 = 'v2'
+
+ def __str__(self):
+ return self.value
+
+
+def kraken2_build_standard(data_manager_dict, kraken2_args, target_directory, data_table_name=DATA_TABLE_NAME):
+ now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")
+
+ database_value = "_".join([
+ now,
+ "standard",
+ "kmer-len", str(kraken2_args["kmer_len"]),
+ "minimizer-len", str(kraken2_args["minimizer_len"]),
+ "minimizer-spaces", str(kraken2_args["minimizer_spaces"]),
+ ])
+
+ database_name = " ".join([
+ "Standard",
+ "(Created:",
+ now + ",",
+ "kmer-len=" + str(kraken2_args["kmer_len"]) + ",",
+ "minimizer-len=" + str(kraken2_args["minimizer_len"]) + ",",
+ "minimizer-spaces=" + str(kraken2_args["minimizer_spaces"]) + ")",
+ ])
+
+ database_path = database_value
+
+ args = [
+ '--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_path
+ ]
+
+ subprocess.check_call(['kraken2-build'] + args, cwd=target_directory)
+
+ args = [
+ '--threads', str(kraken2_args["threads"]),
+ '--clean',
+ '--db', database_path
+ ]
+
+ subprocess.check_call(['kraken2-build'] + args, cwd=target_directory)
+
+ data_table_entry = {
+ "value": database_value,
+ "name": database_name,
+ "path": database_path,
+ }
+
+ _add_data_table_entry(data_manager_dict, data_table_entry)
+
+
+def kraken2_build_minikraken(data_manager_dict, minikraken2_version, target_directory, data_table_name=DATA_TABLE_NAME):
+
+ now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")
+
+ database_value = "_".join([
+ now,
+ "minikraken2",
+ minikraken2_version,
+ "8GB",
+ ])
+
+ database_name = " ".join([
+ "Minikraken2",
+ minikraken2_version,
+ "(Created:",
+ now + ")"
+ ])
+
+ # download the minikraken2 data
+ src = urlopen(
+ 'ftp://ftp.ccb.jhu.edu/pub/data/kraken2_dbs/minikraken2_%s_8GB_201904_UPDATE.tgz'
+ % minikraken2_version
+ )
+ with open('tmp_data.tar.gz', 'wb') as dst:
+ shutil.copyfileobj(src, dst)
+ # unpack the downloaded archive to the target directory
+ with tarfile.open('tmp_data.tar.gz', 'r:gz') as fh:
+ fh.extractall(target_directory)
+
+ data_table_entry = {
+ "value": database_value,
+ "name": database_name,
+ "path": database_value,
+ }
+
+ _add_data_table_entry(data_manager_dict, data_table_entry)
+
+
+def kraken2_build_special(data_manager_dict, kraken2_args, target_directory, data_table_name=DATA_TABLE_NAME):
+
+ now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")
+
+ special_database_names = {
+ "rdp": "RDP",
+ "greengenes": "Greengenes",
+ "silva": "Silva",
+ }
+
+ database_value = "_".join([
+ now,
+ kraken2_args["special_database_type"],
+ "kmer-len", str(kraken2_args["kmer_len"]),
+ "minimizer-len", str(kraken2_args["minimizer_len"]),
+ "minimizer-spaces", str(kraken2_args["minimizer_spaces"]),
+ ])
+
+ database_name = " ".join([
+ special_database_names[kraken2_args["special_database_type"]],
+ "(Created:",
+ now + ",",
+ "kmer-len=" + str(kraken2_args["kmer_len"]) + ",",
+ "minimizer-len=" + str(kraken2_args["minimizer_len"]) + ",",
+ "minimizer-spaces=" + str(kraken2_args["minimizer_spaces"]) + ")",
+ ])
+
+ database_path = database_value
+
+ args = [
+ '--threads', str(kraken2_args["threads"]),
+ '--special', kraken2_args["special_database_type"],
+ '--kmer-len', str(kraken2_args["kmer_len"]),
+ '--minimizer-len', str(kraken2_args["minimizer_len"]),
+ '--minimizer-spaces', str(kraken2_args["minimizer_spaces"]),
+ '--db', database_path
+ ]
+
+ subprocess.check_call(['kraken2-build'] + args, cwd=target_directory)
+
+ args = [
+ '--threads', str(kraken2_args["threads"]),
+ '--clean',
+ '--db', database_path
+ ]
+
+ subprocess.check_call(['kraken2-build'] + args, cwd=target_directory)
+
+ data_table_entry = {
+ "value": database_value,
+ "name": database_name,
+ "path": database_path,
+ }
+
+ _add_data_table_entry(data_manager_dict, data_table_entry)
+
+
+def kraken2_build_custom(data_manager_dict, kraken2_args, custom_database_name, target_directory, data_table_name=DATA_TABLE_NAME):
+
+ args = [
+ '--threads', str(kraken2_args["threads"]),
+ '--download-taxonomy',
+ '--db', custom_database_name
+ ]
+
+ subprocess.check_call(['kraken2-build'] + args, cwd=target_directory)
+
+ args = [
+ '--threads', str(kraken2_args["threads"]),
+ '--add-to-library', kraken2_args["custom_fasta"],
+ '--db', custom_database_name
+ ]
+
+ subprocess.check_call(['kraken2-build'] + args, cwd=target_directory)
+
+ args = [
+ '--threads', str(kraken2_args["threads"]),
+ '--build',
+ '--kmer-len', str(kraken2_args["kmer_len"]),
+ '--minimizer-len', str(kraken2_args["minimizer_len"]),
+ '--minimizer-spaces', str(kraken2_args["minimizer_spaces"]),
+ '--db', custom_database_name
+ ]
+
+ subprocess.check_call(['kraken2-build'] + args, cwd=target_directory)
+
+ args = [
+ '--threads', str(kraken2_args["threads"]),
+ '--clean',
+ '--db', custom_database_name
+ ]
+
+ subprocess.check_call(['kraken2-build'] + args, target_directory)
+
+ data_table_entry = {
+ "value": custom_database_name,
+ "name": custom_database_name,
+ "path": custom_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_entry, data_table_name=DATA_TABLE_NAME):
+ 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('data_manager_json')
+ parser.add_argument('--kmer-len', dest='kmer_len', type=int, default=35, help='kmer length')
+ parser.add_argument('--minimizer-len', dest='minimizer_len', type=int, default=31, help='minimizer length')
+ parser.add_argument('--minimizer-spaces', dest='minimizer_spaces', default=6, help='minimizer spaces')
+ parser.add_argument('--threads', dest='threads', default=1, help='threads')
+ parser.add_argument('--database-type', dest='database_type', type=KrakenDatabaseTypes, choices=list(KrakenDatabaseTypes), required=True, help='type of kraken database to build')
+ parser.add_argument('--minikraken2-version', dest='minikraken2_version', type=Minikraken2Versions, choices=list(Minikraken2Versions), help='MiniKraken2 version (only applies to --database-type minikraken)')
+ parser.add_argument('--special-database-type', dest='special_database_type', type=SpecialDatabaseTypes, choices=list(SpecialDatabaseTypes), help='type of special database to build (only applies to --database-type special)')
+ parser.add_argument('--custom-fasta', dest='custom_fasta', help='fasta file for custom database (only applies to --database-type custom)')
+ parser.add_argument( '--custom-database-name', dest='custom_database_name', help='Name for custom database (only applies to --database-type custom)' )
+ args = parser.parse_args()
+
+ data_manager_input = json.loads(open(args.data_manager_json).read())
+
+ target_directory = data_manager_input['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_output = {}
+
+ print(args.database_type)
+ if str(args.database_type) == 'standard':
+ kraken2_args = {
+ "kmer_len": args.kmer_len,
+ "minimizer_len": args.minimizer_len,
+ "minimizer_spaces": args.minimizer_spaces,
+ "threads": args.threads,
+ }
+ kraken2_build_standard(
+ data_manager_output,
+ kraken2_args,
+ target_directory,
+ )
+ elif str(args.database_type) == 'minikraken':
+ kraken2_build_minikraken(
+ data_manager_output,
+ str(args.minikraken2_version),
+ target_directory
+ )
+ elif str(args.database_type) == 'special':
+ kraken2_args = {
+ "special_database_type": str(args.special_database_type),
+ "kmer_len": args.kmer_len,
+ "minimizer_len": args.minimizer_len,
+ "minimizer_spaces": args.minimizer_spaces,
+ "threads": args.threads,
+ }
+ kraken2_build_special(
+ data_manager_output,
+ kraken2_args,
+ target_directory,
+ )
+ elif str(args.database_type) == 'custom':
+ kraken2_args = {
+ "custom_fasta": args.custom_fasta,
+ "kmer_len": args.kmer_len,
+ "minimizer_len": args.minimizer_len,
+ "minimizer_spaces": args.minimizer_spaces,
+ "threads": args.threads,
+ }
+ kraken2_build_custom(
+ data_manager_output,
+ kraken2_args,
+ args.custom_database_name,
+ target_directory,
+ )
+ else:
+ sys.exit("Invalid database type")
+
+ open(args.data_manager_json, 'w').write(json.dumps(data_manager_output))
+
+
+if __name__ == "__main__":
+ main()
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_database.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/kraken2_build_database.xml Mon May 06 19:42:14 2019 -0400
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+ database builder
+
+ kraken2
+
+ kraken2 -version | head -n 1 | awk '{print $NF}'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10.1186/gb-2014-15-3-r46
+
+
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_minikraken.py
--- a/data_manager/kraken2_build_minikraken.py Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-#!/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
-
-
-DATA_TABLE_NAME = "kraken2_databases"
-
-def run(args, cwd):
- proc = subprocess.Popen(args=args, shell=False, cwd=cwd)
- return_code = proc.wait()
- if return_code:
- print("Error building database.", file=sys.stderr)
- sys.exit( return_code )
-
-def kraken2_build_minikraken(data_manager_dict, minikraken2_version, target_directory, data_table_name=DATA_TABLE_NAME):
-
- now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")
-
- database_value = "_".join([
- now,
- "minikraken2",
- minikraken2_version,
- "8GB",
- ])
-
- database_name = " ".join([
- "Minikraken2",
- minikraken2_version,
- "(Created:",
- now + ")"
- ])
-
- database_path = database_value
-
- args = [
- 'https://ccb.jhu.edu/software/kraken2/dl/minikraken2_' + minikraken2_version + '_8GB.tgz'
- ]
-
- run(['wget'] + args, target_directory)
-
- args = [
- '-p',
- database_path,
- ]
-
- run(['mkdir'] + args, target_directory)
-
- args = [
- '-xvzf',
- 'minikraken2_' + minikraken2_version + '_8GB.tgz',
- '-C',
- database_path,
- ]
-
- run(['tar'] + args, target_directory)
-
- data_table_entry = {
- "value": database_value,
- "name": database_name,
- "path": database_path,
- }
-
- _add_data_table_entry(data_manager_dict, data_table_entry)
-
-
-def _add_data_table_entry(data_manager_dict, data_table_entry, data_table_name=DATA_TABLE_NAME):
- 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('data_manager_json')
- parser.add_argument( '-v', '--minikraken2-version', dest='minikraken2_version', default="v2", help='MiniKraken2 version (v1 or v2)' )
- parser.add_argument( '-t', '--threads', dest='threads', default=1, help='threads' )
-
- args = parser.parse_args()
-
- data_manager_input = json.loads(open(args.data_manager_json).read())
-
- target_directory = data_manager_input['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_output = {}
-
- kraken2_build_minikraken(
- data_manager_output,
- args.minikraken2_version,
- target_directory,
- )
-
- open(args.data_manager_json, 'wb').write(json.dumps(data_manager_output))
-
-
-if __name__ == "__main__":
- main()
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_minikraken.xml
--- a/data_manager/kraken2_build_minikraken.xml Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-
-
- database builder
-
- kraken2
-
- kraken2 -version | head -n 1 | awk '{print $NF}'
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 10.1186/gb-2014-15-3-r46
-
-
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_special.py
--- a/data_manager/kraken2_build_special.py Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-#!/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
-
-
-DATA_TABLE_NAME = "kraken2_databases"
-
-def run(args, cwd):
- proc = subprocess.Popen(args=args, shell=False, cwd=cwd)
- return_code = proc.wait()
- if return_code:
- print("Error building database.", file=sys.stderr)
- sys.exit( return_code )
-
-def kraken2_build_standard(data_manager_dict, kraken2_args, target_directory, data_table_name=DATA_TABLE_NAME):
-
- now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")
-
- special_database_names = {
- "rdp": "RDP",
- "greengenes": "Greengenes",
- "silva": "Silva",
- }
-
- database_value = "_".join([
- now,
- kraken2_args["special"],
- "kmer-len", str(kraken2_args["kmer_len"]),
- "minimizer-len", str(kraken2_args["minimizer_len"]),
- "minimizer-spaces", str(kraken2_args["minimizer_spaces"]),
- ])
-
- database_name = " ".join([
- special_database_names[kraken2_args["special"]],
- "(Created:",
- now + ",",
- "kmer-len=" + str(kraken2_args["kmer_len"]) + ",",
- "minimizer-len=" + str(kraken2_args["minimizer_len"]) + ",",
- "minimizer-spaces=" + str(kraken2_args["minimizer_spaces"]) + ")",
- ])
-
- database_path = database_value
-
- args = [
- '--threads', str(kraken2_args["threads"]),
- '--special', kraken2_args["special"],
- '--kmer-len', str(kraken2_args["kmer_len"]),
- '--minimizer-len', str(kraken2_args["minimizer_len"]),
- '--minimizer-spaces', str(kraken2_args["minimizer_spaces"]),
- '--db', database_path
- ]
-
- run(['kraken2-build'] + args, target_directory)
-
- args = [
- '--threads', str(kraken2_args["threads"]),
- '--clean',
- '--db', database_path
- ]
-
- run(['kraken2-build'] + args, target_directory)
-
- data_table_entry = {
- "value": database_value,
- "name": database_name,
- "path": database_path,
- }
-
- _add_data_table_entry(data_manager_dict, data_table_entry)
-
-
-def _add_data_table_entry(data_manager_dict, data_table_entry, data_table_name=DATA_TABLE_NAME):
- 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('data_manager_json')
- parser.add_argument( '-b', '--db-type', dest='db_type', help='database type (one of: silva, rdp, greengenes)' )
- 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 = {
- "special": args.db_type,
- "kmer_len": args.kmer_len,
- "minimizer_len": args.minimizer_len,
- "minimizer_spaces": args.minimizer_spaces,
- "threads": args.threads,
- }
-
- data_manager_input = json.loads(open(args.data_manager_json).read())
-
- target_directory = data_manager_input['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_output = {}
-
- kraken2_build_standard(
- data_manager_output,
- kraken2_args,
- target_directory,
- )
-
- open(args.data_manager_json, 'wb').write(json.dumps(data_manager_output))
-
-
-if __name__ == "__main__":
- main()
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_special.xml
--- a/data_manager/kraken2_build_special.xml Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-
-
- database builder
-
- kraken2
-
- kraken2 -version | head -n 1 | awk '{print $NF}'
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 10.1186/gb-2014-15-3-r46
-
-
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_standard.py
--- a/data_manager/kraken2_build_standard.py Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-#!/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
-
-
-DATA_TABLE_NAME = "kraken2_databases"
-
-def run(args, cwd):
- proc = subprocess.Popen(args=args, shell=False, cwd=cwd)
- return_code = proc.wait()
- if return_code:
- print("Error building database.", file=sys.stderr)
- sys.exit( return_code )
-
-def kraken2_build_standard(data_manager_dict, kraken2_args, target_directory, data_table_name=DATA_TABLE_NAME):
- now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")
-
- database_value = "_".join([
- now,
- "standard",
- "kmer-len" + str(kraken2_args["kmer_len"]),
- "minimizer-len" + str(kraken2_args["minimizer_len"]),
- "minimizer-spaces" + str(kraken2_args["minimizer_spaces"]),
- ])
-
- database_name = " ".join([
- "Standard",
- "(Created:",
- now + ",",
- "kmer-len=" + str(kraken2_args["kmer_len"]) + ",",
- "minimizer-len=" + str(kraken2_args["minimizer_len"]) + ",",
- "minimizer-spaces=" + str(kraken2_args["minimizer_spaces"]) + ")",
- ])
-
- database_path = database_value
-
- args = [
- '--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_path
- ]
-
- run(['kraken2-build'] + args, target_directory)
-
- args = [
- '--threads', str(kraken2_args["threads"]),
- '--clean',
- '--db', database_path
- ]
-
- run(['kraken2-build'] + args, target_directory)
-
- data_table_entry = {
- "value": database_value,
- "name": database_name,
- "path": database_path,
- }
-
- _add_data_table_entry(data_manager_dict, data_table_entry)
-
-
-def _add_data_table_entry(data_manager_dict, data_table_entry, data_table_name=DATA_TABLE_NAME):
- 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('data_manager_json')
- 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,
- }
-
- data_manager_input = json.loads(open(args.data_manager_json).read())
-
- target_directory = data_manager_input['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_output = {}
-
- kraken2_build_standard(
- data_manager_output,
- kraken2_args,
- target_directory,
- )
-
- open(args.data_manager_json, 'wb').write(json.dumps(data_manager_output))
-
-
-if __name__ == "__main__":
- main()
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_standard.xml
--- a/data_manager/kraken2_build_standard.xml Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-
-
- database builder
-
- kraken2
-
- kraken2 -version | head -n 1 | awk '{print $NF}'
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 10.1186/gb-2014-15-3-r46
-
-
diff -r d9f190088154 -r 4c9f9d6098eb data_manager_conf.xml
--- a/data_manager_conf.xml Tue Mar 05 16:45:43 2019 -0500
+++ b/data_manager_conf.xml Mon May 06 19:42:14 2019 -0400
@@ -1,5 +1,5 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-