Mercurial > repos > iuc > data_manager_hisat2_index_builder
comparison data_manager/hisat2_index_builder.py @ 4:d210e1f185bd draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_hisat2_index_builder commit 8652f36a3a3838dca989426961561e81432acf4f
author | iuc |
---|---|
date | Tue, 04 Apr 2017 18:09:40 -0400 |
parents | 98a60a4cfb9a |
children | 8eac26f44d29 |
comparison
equal
deleted
inserted
replaced
3:98a60a4cfb9a | 4:d210e1f185bd |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Based heavily on the Bowtie 2 data manager wrapper script by Dan Blankenberg | 2 # Based heavily on the Bowtie 2 data manager wrapper script by Dan Blankenberg |
3 from __future__ import print_function | |
3 | 4 |
5 import argparse | |
6 import os | |
4 import shlex | 7 import shlex |
8 import subprocess | |
5 import sys | 9 import sys |
6 import os | 10 from json import dumps, loads |
7 import argparse | |
8 import subprocess | |
9 | |
10 from json import loads, dumps | |
11 | |
12 | 11 |
13 DEFAULT_DATA_TABLE_NAME = "hisat2_indexes" | 12 DEFAULT_DATA_TABLE_NAME = "hisat2_indexes" |
14 | 13 |
15 | 14 |
16 def get_id_name( params, dbkey, fasta_description=None): | 15 def get_id_name( params, dbkey, fasta_description=None): |
39 args.extend( shlex.split( options.indexer_options ) ) | 38 args.extend( shlex.split( options.indexer_options ) ) |
40 args.extend( [ sym_linked_fasta_filename, sequence_id ] ) | 39 args.extend( [ sym_linked_fasta_filename, sequence_id ] ) |
41 proc = subprocess.Popen( args=args, shell=False, cwd=target_directory ) | 40 proc = subprocess.Popen( args=args, shell=False, cwd=target_directory ) |
42 return_code = proc.wait() | 41 return_code = proc.wait() |
43 if return_code: | 42 if return_code: |
44 print >> sys.stderr, "Error building index." | 43 print("Error building index.", file=sys.stderr) |
45 sys.exit( return_code ) | 44 sys.exit( return_code ) |
46 data_table_entry = dict( value=sequence_id, dbkey=options.fasta_dbkey, name=sequence_name, path=sequence_id ) | 45 data_table_entry = dict( value=sequence_id, dbkey=options.fasta_dbkey, name=sequence_name, path=sequence_id ) |
47 _add_data_table_entry( data_manager_dict, data_table_name, data_table_entry ) | 46 _add_data_table_entry( data_manager_dict, data_table_name, data_table_entry ) |
48 | 47 |
49 | 48 |
69 | 68 |
70 params = loads( open( filename ).read() ) | 69 params = loads( open( filename ).read() ) |
71 data_manager_dict = {} | 70 data_manager_dict = {} |
72 | 71 |
73 if options.fasta_dbkey in [ None, '', '?' ]: | 72 if options.fasta_dbkey in [ None, '', '?' ]: |
74 raise Exception( '"%s" is not a valid dbkey. You must specify a valid dbkey.' % ( dbkey ) ) | 73 raise Exception( '"%s" is not a valid dbkey. You must specify a valid dbkey.' % ( options.fasta_dbkey ) ) |
75 | 74 |
76 sequence_id, sequence_name = get_id_name( params, dbkey=options.fasta_dbkey, fasta_description=options.fasta_description ) | 75 sequence_id, sequence_name = get_id_name( params, dbkey=options.fasta_dbkey, fasta_description=options.fasta_description ) |
77 | 76 |
78 # build the index | 77 # build the index |
79 build_hisat_index( data_manager_dict, options, params, sequence_id, sequence_name ) | 78 build_hisat_index( data_manager_dict, options, params, sequence_id, sequence_name ) |
80 | 79 |
81 # save info to json file | 80 # save info to json file |
82 open( filename, 'wb' ).write( dumps( data_manager_dict ) ) | 81 open( filename, 'w' ).write( dumps( data_manager_dict ) ) |
82 | |
83 | 83 |
84 if __name__ == "__main__": | 84 if __name__ == "__main__": |
85 main() | 85 main() |