# HG changeset patch # User iuc # Date 1574117007 18000 # Node ID 5c77d4091880075617e5ee2da29bb1c5ce7d30c1 # Parent 9946bc39c834637d8f83f2253e977106c4115b86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f" diff -r 9946bc39c834 -r 5c77d4091880 data_manager/twobit_builder.py --- a/data_manager/twobit_builder.py Tue Apr 04 18:16:29 2017 -0400 +++ b/data_manager/twobit_builder.py Mon Nov 18 17:43:27 2019 -0500 @@ -12,7 +12,7 @@ CHUNK_SIZE = 2**20 # 1mb -def get_id_name( params, dbkey, fasta_description=None): +def get_id_name(params, dbkey, fasta_description=None): # TODO: ensure sequence_id is unique and does not already appear in location file sequence_id = params['param_dict']['sequence_id'] if not sequence_id: @@ -26,73 +26,73 @@ return sequence_id, sequence_name -def build_twobit( data_manager_dict, fasta_filename, params, target_directory, dbkey, sequence_id, sequence_name ): - twobit_base_name = "%s.2bit" % ( sequence_id ) - twobit_filename = os.path.join( target_directory, twobit_base_name ) +def build_twobit(data_manager_dict, fasta_filename, params, target_directory, dbkey, sequence_id, sequence_name): + twobit_base_name = "%s.2bit" % (sequence_id) + twobit_filename = os.path.join(target_directory, twobit_base_name) - args = [ 'faToTwoBit', fasta_filename, twobit_filename ] - tmp_stderr = tempfile.NamedTemporaryFile( prefix="tmp-data-manager-twobit-builder-stderr" ) - proc = subprocess.Popen( args=args, shell=False, cwd=target_directory, stderr=tmp_stderr.fileno() ) + args = ['faToTwoBit', fasta_filename, twobit_filename] + tmp_stderr = tempfile.NamedTemporaryFile(prefix="tmp-data-manager-twobit-builder-stderr") + proc = subprocess.Popen(args=args, shell=False, cwd=target_directory, stderr=tmp_stderr.fileno()) return_code = proc.wait() if return_code: tmp_stderr.flush() tmp_stderr.seek(0) print("Error building index:", file=sys.stderr) while True: - chunk = tmp_stderr.read( CHUNK_SIZE ) + chunk = tmp_stderr.read(CHUNK_SIZE) if not chunk: break - sys.stderr.write( chunk ) - sys.exit( return_code ) + sys.stderr.write(chunk) + sys.exit(return_code) tmp_stderr.close() # lastz_seqs - data_table_entry = dict( value=sequence_id, name=sequence_name, path=twobit_base_name ) + data_table_entry = dict(value=sequence_id, name=sequence_name, path=twobit_base_name) - _add_data_table_entry( data_manager_dict, "lastz_seqs", data_table_entry ) + _add_data_table_entry(data_manager_dict, "lastz_seqs", data_table_entry) # twobit.loc - data_table_entry = dict( value=sequence_id, path=twobit_base_name ) + data_table_entry = dict(value=sequence_id, path=twobit_base_name) - _add_data_table_entry( data_manager_dict, "twobit", data_table_entry ) + _add_data_table_entry(data_manager_dict, "twobit", data_table_entry) # alignseq - data_table_entry = dict( type="seq", value=sequence_id, path=twobit_base_name ) + data_table_entry = dict(type="seq", value=sequence_id, path=twobit_base_name) - _add_data_table_entry( data_manager_dict, "alignseq_seq", data_table_entry ) + _add_data_table_entry(data_manager_dict, "alignseq_seq", 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 ) +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 = optparse.OptionParser() - parser.add_option( '-f', '--fasta_filename', dest='fasta_filename', action='store', type="string", default=None, help='fasta_filename' ) - parser.add_option( '-d', '--fasta_dbkey', dest='fasta_dbkey', action='store', type="string", default=None, help='fasta_dbkey' ) - parser.add_option( '-t', '--fasta_description', dest='fasta_description', action='store', type="string", default=None, help='fasta_description' ) + parser.add_option('-f', '--fasta_filename', dest='fasta_filename', action='store', type="string", default=None, help='fasta_filename') + parser.add_option('-d', '--fasta_dbkey', dest='fasta_dbkey', action='store', type="string", default=None, help='fasta_dbkey') + parser.add_option('-t', '--fasta_description', dest='fasta_description', action='store', type="string", default=None, help='fasta_description') (options, args) = parser.parse_args() filename = args[0] - params = loads( open( filename ).read() ) + params = loads(open(filename).read()) - target_directory = params[ 'output_data' ][0]['extra_files_path'] - os.mkdir( target_directory ) + target_directory = params['output_data'][0]['extra_files_path'] + os.mkdir(target_directory) data_manager_dict = {} dbkey = options.fasta_dbkey - if dbkey in [ None, '', '?' ]: - raise Exception( '"%s" is not a valid dbkey. You must specify a valid dbkey.' % ( dbkey ) ) + if dbkey in [None, '', '?']: + raise Exception('"%s" is not a valid dbkey. You must specify a valid dbkey.' % (dbkey)) - sequence_id, sequence_name = get_id_name( params, dbkey=dbkey, fasta_description=options.fasta_description ) + sequence_id, sequence_name = get_id_name(params, dbkey=dbkey, fasta_description=options.fasta_description) # build the index - build_twobit( data_manager_dict, options.fasta_filename, params, target_directory, dbkey, sequence_id, sequence_name ) + build_twobit(data_manager_dict, options.fasta_filename, params, target_directory, dbkey, sequence_id, sequence_name) # save info to json file - open( filename, 'wb' ).write( dumps( data_manager_dict ) ) + open(filename, 'w').write(dumps(data_manager_dict, sort_keys=True)) if __name__ == "__main__": diff -r 9946bc39c834 -r 5c77d4091880 data_manager/twobit_builder.xml --- a/data_manager/twobit_builder.xml Tue Apr 04 18:16:29 2017 -0400 +++ b/data_manager/twobit_builder.xml Mon Nov 18 17:43:27 2019 -0500 @@ -1,6 +1,6 @@ - + - ucsc-fatotwobit + ucsc-fatotwobit builder - + diff -r 9946bc39c834 -r 5c77d4091880 test-data/alignseq.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/alignseq.loc Mon Nov 18 17:43:27 2019 -0500 @@ -0,0 +1,57 @@ +#This is a sample file distributed with Galaxy that enables tools +#to use alignment data stored as axt files (lines starting with "align") +#or nib files (lines starting with "seq"). You will need to index +#them and then create an alignseq.loc file similar to this one (store +#it in this directory) that points to the directories in which those +#alignments are stored. The "align" data referred to by the alignseq.loc +#file has this format (white space characters are TAB characters): +# +#align +# +#So, for example, if you had hg18/bosTau2 alignment files stored in +#/depot/data2/galaxy/hg18/align/bosTau2, then the alignseq.loc entry +#would look like this: +# +#align hg18 bosTau2 /depot/data2/galaxy/hg18/align/bosTau2 +# +#and your /depot/data2/galaxy/hg18/align/bosTau2 directory would +#contain all of your alignment files (e.g.): +# +#-rw-rw-r-- 1 nate galaxy 151842783 2006-01-08 01:00 chr10.axt +#-rw-rw-r-- 1 nate galaxy 79575 2006-01-08 01:00 chr10_random.axt +#-rw-rw-r-- 1 nate galaxy 155015634 2006-01-08 01:01 chr11.axt +#...etc... +# +#Your alignseq.loc file should include an entry per line for each alignment +#file you have stored. For example: +# +#align anoGam1 dm1 /depot/data2/galaxy/anoGam1/align/dm1 +#align anoGam1 dm2 /depot/data2/galaxy/anoGam1/align/dm2 +#align canFam1 hg17 /depot/data2/galaxy/canFam1/align/hg17 +#...etc... +# +#The "seq" data referred to by the alignseq.loc file has this +#format (white space characters are TAB characters): +# +#seq +# +#So, for example, if you had anoGam1 sequence files stored in +#/depot/data2/galaxy/anoGam1/seq, then the alignseq.loc entry +#would look like this: +# +#seq anoGam1 /depot/data2/galaxy/anoGam1/seq +#and your seq anoGam1 /depot/data2/galaxy/anoGam1/seq directory would +#contain all of your sequence files (e.g.): +# +#-rw-rw-r-- 1 nate galaxy 24397551 2006-06-26 12:51 chr2L.nib +#-rw-rw-r-- 1 nate galaxy 31362964 2006-06-26 12:51 chr2R.nib +#-rw-rw-r-- 1 nate galaxy 20642013 2006-06-26 12:51 chr3L.nib +#-rw-rw-r-- 1 nate galaxy 26636071 2006-06-26 12:51 chr3R.nib +# +#Your alignseq.loc file should include an entry per line for each sequence +#file you have stored. For example: +# +#seq anoGam1 /depot/data2/galaxy/anoGam1/seq +#seq bosTau2 /depot/data2/galaxy/bosTau2/seq +#seq bosTau3 /depot/data2/galaxy/bosTau3/seq +#...etc... diff -r 9946bc39c834 -r 5c77d4091880 test-data/all_fasta.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/all_fasta.loc Mon Nov 18 17:43:27 2019 -0500 @@ -0,0 +1,1 @@ +sacCer2 sacCer2 sacCer2 ${__HERE__}/sacCer2.fa diff -r 9946bc39c834 -r 5c77d4091880 test-data/data_manager_twobit.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/data_manager_twobit.json Mon Nov 18 17:43:27 2019 -0500 @@ -0,0 +1,1 @@ +{"data_tables": {"alignseq_seq": [{"path": "sacCer2.2bit", "type": "seq", "value": "sacCer2"}], "lastz_seqs": [{"name": "sacCer2", "path": "sacCer2.2bit", "value": "sacCer2"}], "twobit": [{"path": "sacCer2.2bit", "value": "sacCer2"}]}} \ No newline at end of file diff -r 9946bc39c834 -r 5c77d4091880 test-data/lastz_seqs.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/lastz_seqs.loc Mon Nov 18 17:43:27 2019 -0500 @@ -0,0 +1,30 @@ +#This is a sample file distributed with Galaxy that enables tools +#to use a directory of 2bit genome files for use with Lastz. You will +#need to supply these files and then create a lastz_seqs.loc file +#similar to this one (store it in this directory) that points to +#the directories in which those files are stored. The lastz_seqs.loc +#file has this format (white space characters are TAB characters): +# +# +# +#So, for example, if your lastz_seqs.loc began like this: +# +#hg18 Human (Homo sapiens): hg18 /depot/data2/galaxy/twobit/hg18.2bit +#hg19 Human (Homo sapiens): hg19 /depot/data2/galaxy/twobit/hg19.2bit +#mm9 Mouse (Mus musculus): mm9 /depot/data2/galaxy/twobit/mm9.2bit +# +#then your /depot/data2/galaxy/twobit/ directory +#would need to contain the following 2bit files: +# +#-rw-r--r-- 1 james universe 830134 2005-09-13 10:12 hg18.2bit +#-rw-r--r-- 1 james universe 527388 2005-09-13 10:12 hg19.2bit +#-rw-r--r-- 1 james universe 269808 2005-09-13 10:12 mm9.2bit +# +#Your lastz_seqs.loc file should include an entry per line for +#each file you have stored that you want to be available. Note that +#your files should all have the extension '2bit'. +# +#Note that for backwards compatibility with workflows, the unique ID of +#an entry must be the path that was in the original loc file, because that +#is the value stored in the workflow for that parameter. +# diff -r 9946bc39c834 -r 5c77d4091880 test-data/sacCer2.2bit Binary file test-data/sacCer2.2bit has changed diff -r 9946bc39c834 -r 5c77d4091880 test-data/sacCer2.fa --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/sacCer2.fa Mon Nov 18 17:43:27 2019 -0500 @@ -0,0 +1,2 @@ +>chr1 +ATGCATCGATCGATCGCATCGACTACGACTACGATCAGTCACTACACTACGTACAGCTACGACTACGACTACGATCGACTACGATCAGCTACGACA diff -r 9946bc39c834 -r 5c77d4091880 test-data/twobit.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/twobit.loc Mon Nov 18 17:43:27 2019 -0500 @@ -0,0 +1,26 @@ +#This is a sample file distributed with Galaxy that is used by some +#tools. The twobit.loc file has this format (white space characters +#are TAB characters): +# +# +# +#So, for example, if you had droPer1 twobit files stored in +#/depot/data2/galaxy/droPer1/, then the twobit.loc entry +#would look like this: +# +#droPer1 /depot/data2/galaxy/droPer1/droPer1.2bit +# +#and your /depot/data2/galaxy/droPer1/ directory would +#contain all of your twobit files (e.g.): +# +#-rw-rw-r-- 1 nate galaxy 48972650 2007-05-04 11:27 droPer1.2bit +#...etc... +# +#Your twobit.loc file should include an entry per line for each twobit +#file you have stored. For example: +# +#droPer1 /depot/data2/galaxy/droPer1/droPer1.2bit +#apiMel2 /depot/data2/galaxy/apiMel2/apiMel2.2bit +#droAna1 /depot/data2/galaxy/droAna1/droAna1.2bit +#droAna2 /depot/data2/galaxy/droAna2/droAna2.2bit +#...etc... diff -r 9946bc39c834 -r 5c77d4091880 tool_data_table_conf.xml.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.test Mon Nov 18 17:43:27 2019 -0500 @@ -0,0 +1,21 @@ + + + + + value, dbkey, name, path + +
+ + + value, name, path + +
+ + value, path + +
+ + type, value, path + +
+