# HG changeset patch
# User devteam
# Date 1434053667 14400
# Node ID 74b09c8e5f6e17e4847ae21ea1e9dc04144dab71
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
diff -r 000000000000 -r 74b09c8e5f6e README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README Thu Jun 11 16:14:27 2015 -0400
@@ -0,0 +1,1 @@
+TODO
diff -r 000000000000 -r 74b09c8e5f6e data_manager/twobit_builder.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/twobit_builder.py Thu Jun 11 16:14:27 2015 -0400
@@ -0,0 +1,92 @@
+#!/usr/bin/env python
+#Dan Blankenberg
+
+import sys, os, tempfile, optparse, uuid, subprocess
+
+from json import loads, dumps
+
+
+CHUNK_SIZE = 2**20 #1mb
+
+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:
+ sequence_id = dbkey #uuid.uuid4() generate and use an uuid
+
+ sequence_name = params['param_dict']['sequence_name']
+ if not sequence_name:
+ sequence_name = fasta_description
+ if not sequence_name:
+ sequence_name = dbkey
+ 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 )
+
+ 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 >> sys.stderr, "Error building index:"
+ while True:
+ chunk = tmp_stderr.read( CHUNK_SIZE )
+ if not chunk:
+ break
+ 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 )
+
+ _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 )
+
+ _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 )
+
+ _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 )
+ return data_manager_dict
+
+def main():
+ #Parse Command Line
+ 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' )
+ (options, args) = parser.parse_args()
+
+ filename = args[0]
+
+ params = loads( open( filename ).read() )
+
+ 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 ) )
+
+ 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 )
+
+ #save info to json file
+ open( filename, 'wb' ).write( dumps( data_manager_dict ) )
+
+if __name__ == "__main__": main()
+
diff -r 000000000000 -r 74b09c8e5f6e data_manager/twobit_builder.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/twobit_builder.xml Thu Jun 11 16:14:27 2015 -0400
@@ -0,0 +1,35 @@
+
+
+ ucsc_tools
+
+ builder
+ twobit_builder.py "${out_file}" --fasta_filename "${all_fasta_source.fields.path}" --fasta_dbkey "${all_fasta_source.fields.dbkey}" --fasta_description "${all_fasta_source.fields.name}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+.. class:: infomark
+
+**Notice:** If you leave name, description, or id blank, it will be generated automatically.
+
+
+
+
diff -r 000000000000 -r 74b09c8e5f6e data_manager_conf.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager_conf.xml Thu Jun 11 16:14:27 2015 -0400
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 000000000000 -r 74b09c8e5f6e tool-data/alignseq.loc.sample
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/alignseq.loc.sample Thu Jun 11 16:14:27 2015 -0400
@@ -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 000000000000 -r 74b09c8e5f6e tool-data/all_fasta.loc.sample
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/all_fasta.loc.sample Thu Jun 11 16:14:27 2015 -0400
@@ -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 74b09c8e5f6e tool-data/lastz_seqs.loc.sample
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/lastz_seqs.loc.sample Thu Jun 11 16:14:27 2015 -0400
@@ -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 000000000000 -r 74b09c8e5f6e tool-data/twobit.loc.sample
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/twobit.loc.sample Thu Jun 11 16:14:27 2015 -0400
@@ -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 000000000000 -r 74b09c8e5f6e tool_data_table_conf.xml.sample
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample Thu Jun 11 16:14:27 2015 -0400
@@ -0,0 +1,21 @@
+
+
+
+