Changeset 1354:0000247a6bd8
- Timestamp:
- 06/03/08 16:29:54
(7 months ago)
- Author:
- Greg Von Kuster <greg@bx.psu.edu>
- branch:
- default
- convert_revision:
- svn:9bcadc22-80f8-0310-8a53-c8f022958886/galaxy/trunk@2715
- Message:
Requires config change, temporary files are now created in a configurable location - affects many tools.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1301 |
r1354 |
|
| 32 | 32 | self.file_path = resolve_path( kwargs.get( "file_path", "database/files" ), self.root ) |
|---|
| 33 | 33 | self.new_file_path = resolve_path( kwargs.get( "new_file_path", "database/tmp" ), self.root ) |
|---|
| | 34 | # Directory to be used when creating temporary files ( generally from tools ) |
|---|
| | 35 | self.tmp_file_path = resolve_path( kwargs.get( "tmp_file_path", "/tmp" ), self.root ) |
|---|
| 34 | 36 | self.tool_path = resolve_path( kwargs.get( "tool_path", "tools" ), self.root ) |
|---|
| 35 | 37 | self.tool_data_path = resolve_path( kwargs.get( "tool_data_path", "tool-data" ), os.getcwd() ) |
|---|
| r1304 |
r1354 |
|
| 224 | 224 | class Text( Data ): |
|---|
| 225 | 225 | |
|---|
| 226 | | def write_from_stream(self, dataset, stream): |
|---|
| | 226 | def write_from_stream( self, dataset, stream, directory=None ): |
|---|
| 227 | 227 | """Writes data from a stream""" |
|---|
| 228 | 228 | # write it twice for now |
|---|
| 229 | | fd, temp_name = tempfile.mkstemp() |
|---|
| | 229 | fd, temp_name = tempfile.mkstemp( dir=directory ) |
|---|
| 230 | 230 | while 1: |
|---|
| 231 | 231 | chunk = stream.read(1048576) |
|---|
| … | … | |
| 242 | 242 | fp.close() |
|---|
| 243 | 243 | |
|---|
| 244 | | def set_raw_data(self, dataset, data): |
|---|
| | 244 | def set_raw_data( self, dataset, data, directory=None ): |
|---|
| 245 | 245 | """Saves the data on the disc""" |
|---|
| 246 | | fd, temp_name = tempfile.mkstemp() |
|---|
| | 246 | fd, temp_name = tempfile.mkstemp( dir=directory ) |
|---|
| 247 | 247 | os.write(fd, data) |
|---|
| 248 | 248 | os.close(fd) |
|---|
| r1335 |
r1354 |
|
| 13 | 13 | return full_path |
|---|
| 14 | 14 | |
|---|
| 15 | | def stream_to_file(stream): |
|---|
| | 15 | def stream_to_file( stream, directory=None ): |
|---|
| 16 | 16 | """ |
|---|
| 17 | 17 | Writes a stream to a temporary file, returns the temporary file's name |
|---|
| 18 | 18 | """ |
|---|
| 19 | | fd, temp_name = tempfile.mkstemp() |
|---|
| | 19 | fd, temp_name = tempfile.mkstemp( dir=directory ) |
|---|
| 20 | 20 | while 1: |
|---|
| 21 | 21 | chunk = stream.read(1048576) |
|---|
| … | … | |
| 26 | 26 | return temp_name |
|---|
| 27 | 27 | |
|---|
| 28 | | def convert_newlines( fname ): |
|---|
| | 28 | def convert_newlines( fname, directory=None ): |
|---|
| 29 | 29 | """ |
|---|
| 30 | 30 | Converts in place a file from universal line endings |
|---|
| … | … | |
| 38 | 38 | '1 2\\n3 4\\n' |
|---|
| 39 | 39 | """ |
|---|
| 40 | | fd, temp_name = tempfile.mkstemp() |
|---|
| | 40 | fd, temp_name = tempfile.mkstemp( dir=directory ) |
|---|
| 41 | 41 | fp = os.fdopen( fd, "wt" ) |
|---|
| 42 | 42 | for i, line in enumerate( file( fname, "U" ) ): |
|---|
| … | … | |
| 47 | 47 | return i + 1 |
|---|
| 48 | 48 | |
|---|
| 49 | | def sep2tabs(fname, patt="\\s+"): |
|---|
| | 49 | def sep2tabs( fname, patt="\\s+", directory=None ): |
|---|
| 50 | 50 | """ |
|---|
| 51 | 51 | Transforms in place a 'sep' separated file to a tab separated one |
|---|
| … | … | |
| 59 | 59 | """ |
|---|
| 60 | 60 | regexp = re.compile( patt ) |
|---|
| 61 | | fd, temp_name = tempfile.mkstemp() |
|---|
| | 61 | fd, temp_name = tempfile.mkstemp( dir=directory ) |
|---|
| 62 | 62 | fp = os.fdopen( fd, "wt" ) |
|---|
| 63 | 63 | for i, line in enumerate( file( fname ) ): |
|---|
| … | … | |
| 70 | 70 | return i + 1 |
|---|
| 71 | 71 | |
|---|
| 72 | | def convert_newlines_sep2tabs( fname, patt="\\s+" ): |
|---|
| | 72 | def convert_newlines_sep2tabs( fname, patt="\\s+", directory=None ): |
|---|
| 73 | 73 | """ |
|---|
| 74 | 74 | Combines above methods: convert_newlines() and sep2tabs() |
|---|
| … | … | |
| 83 | 83 | """ |
|---|
| 84 | 84 | regexp = re.compile( patt ) |
|---|
| 85 | | fd, temp_name = tempfile.mkstemp() |
|---|
| | 85 | fd, temp_name = tempfile.mkstemp( dir=directory ) |
|---|
| 86 | 86 | fp = os.fdopen( fd, "wt" ) |
|---|
| 87 | 87 | for i, line in enumerate( file( fname, "U" ) ): |
|---|
| r1304 |
r1354 |
|
| 175 | 175 | ERROR = 'error', |
|---|
| 176 | 176 | DELETED = 'deleted') |
|---|
| | 177 | # The following is used for functional tests |
|---|
| 177 | 178 | file_path = "/tmp/" |
|---|
| 178 | 179 | engine = None |
|---|
| r1331 |
r1354 |
|
| 986 | 986 | # The following points to location (xxx.loc) files which are pointers to locally cached data |
|---|
| 987 | 987 | param_dict['GALAXY_DATA_INDEX_DIR'] = self.app.config.tool_data_path |
|---|
| | 988 | # Directory to be used when creating temporary files ( generally from tools ) |
|---|
| | 989 | param_dict['GALAXY_TMP_FILE_DIR'] = self.app.config.tmp_file_path |
|---|
| 988 | 990 | # Return the dictionary of parameters |
|---|
| 989 | 991 | return param_dict |
|---|
| r1335 |
r1354 |
|
| 80 | 80 | def add_file( self, trans, file_obj, file_name, file_type, dbkey, info=None, space_to_tab=False ): |
|---|
| 81 | 81 | data_type = None |
|---|
| 82 | | temp_name = sniff.stream_to_file( file_obj ) |
|---|
| | 82 | tmp_file_path = trans.app.config.tmp_file_path |
|---|
| | 83 | temp_name = sniff.stream_to_file( file_obj, directory=tmp_file_path ) |
|---|
| 83 | 84 | |
|---|
| 84 | 85 | # See if we have an empty file |
|---|
| … | … | |
| 93 | 94 | #We need to decompress the temp_name file |
|---|
| 94 | 95 | CHUNK_SIZE = 2**20 # 1Mb |
|---|
| 95 | | fd, uncompressed = tempfile.mkstemp() |
|---|
| | 96 | fd, uncompressed = tempfile.mkstemp( dir=tmp_file_path ) |
|---|
| 96 | 97 | gzipped_file = gzip.GzipFile( temp_name ) |
|---|
| 97 | 98 | while 1: |
|---|
| … | … | |
| 147 | 148 | if data_type != 'binary' and data_type != 'zip': |
|---|
| 148 | 149 | if space_to_tab: |
|---|
| 149 | | self.line_count = sniff.convert_newlines_sep2tabs( temp_name ) |
|---|
| | 150 | self.line_count = sniff.convert_newlines_sep2tabs( temp_name, directory=tmp_file_path ) |
|---|
| 150 | 151 | else: |
|---|
| 151 | 152 | self.line_count = sniff.convert_newlines( temp_name ) |
|---|
| r1196 |
r1354 |
|
| 3 | 3 | import tempfile, os |
|---|
| 4 | 4 | |
|---|
| 5 | | def get_filled_temp_filename(contents): |
|---|
| 6 | | fh = tempfile.NamedTemporaryFile('w') |
|---|
| | 5 | def get_filled_temp_filename( contents, directory=None ): |
|---|
| | 6 | fh = tempfile.NamedTemporaryFile( mode='w', dir=directory ) |
|---|
| 7 | 7 | filename = fh.name |
|---|
| 8 | 8 | fh.close() |
|---|
| r1338 |
r1354 |
|
| 144 | 144 | |
|---|
| 145 | 145 | #builds and returns (index, index_filename) for specified maf_file |
|---|
| 146 | | def build_maf_index( maf_file, species = None ): |
|---|
| | 146 | def build_maf_index( maf_file, species=None, directory=None ): |
|---|
| 147 | 147 | indexes = bx.interval_index_file.Indexes() |
|---|
| 148 | 148 | try: |
|---|
| … | … | |
| 157 | 157 | continue |
|---|
| 158 | 158 | indexes.add( c.src, c.forward_strand_start, c.forward_strand_end, pos ) |
|---|
| 159 | | fd, index_filename = tempfile.mkstemp() |
|---|
| | 159 | fd, index_filename = tempfile.mkstemp( dir=directory ) |
|---|
| 160 | 160 | out = os.fdopen( fd, 'w' ) |
|---|
| 161 | 161 | indexes.write( out ) |
|---|
| r1335 |
r1354 |
|
| 56 | 56 | if not data.missing_meta(): |
|---|
| 57 | 57 | line_ctr = -1 |
|---|
| 58 | | temp = tempfile.NamedTemporaryFile('w') |
|---|
| | 58 | temp = tempfile.NamedTemporaryFile( mode='w', dir=app.config.tmp_file_path ) |
|---|
| 59 | 59 | temp_filename = temp.name |
|---|
| 60 | 60 | temp.close() |
|---|
| r1303 |
r1354 |
|
| 1 | 1 | #!/usr/bin/env python |
|---|
| 2 | 2 | #Retreives data from GMOD and stores in a file. GBrowse parameters are provided in the input/output file. |
|---|
| 3 | | import urllib, sys, os, gzip, tempfile, shutil |
|---|
| | 3 | import urllib, sys |
|---|
| 4 | 4 | from galaxy import eggs |
|---|
| 5 | 5 | from galaxy.datatypes import data |
|---|
| r835 |
r1354 |
|
| 51 | 51 | if not data.missing_meta(): |
|---|
| 52 | 52 | line_ctr = -1 |
|---|
| 53 | | temp = tempfile.NamedTemporaryFile('w') |
|---|
| | 53 | temp = tempfile.NamedTemporaryFile( mode='w', dir=app.config.tmp_file_path ) |
|---|
| 54 | 54 | temp_filename = temp.name |
|---|
| 55 | 55 | temp.close() |
|---|
| r1181 |
r1354 |
|
| 21 | 21 | def __main__(): |
|---|
| 22 | 22 | filename = sys.argv[1] |
|---|
| | 23 | GALAXY_TMP_FILE_DIR = sys.argv[2] |
|---|
| 23 | 24 | params = {} |
|---|
| 24 | 25 | |
|---|
| … | … | |
| 50 | 51 | out.close() |
|---|
| 51 | 52 | if check_gzip( filename ): |
|---|
| 52 | | fd, uncompressed = tempfile.mkstemp() |
|---|
| | 53 | fd, uncompressed = tempfile.mkstemp( dir=GALAXY_TMP_FILE_DIR ) |
|---|
| 53 | 54 | gzipped_file = gzip.GzipFile( filename ) |
|---|
| 54 | 55 | while 1: |
|---|
| r1129 |
r1354 |
|
| 4 | 4 | <description>table browser</description> |
|---|
| 5 | 5 | |
|---|
| 6 | | <command interpreter="python">ucsc_tablebrowser.py $output</command> |
|---|
| | 6 | <command interpreter="python">ucsc_tablebrowser.py $output ${GALAXY_TMP_FILE_DIR}</command> |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | <inputs action="http://genome.ucsc.edu/cgi-bin/hgTables" check_values="false" method="get"> |
|---|
| r1129 |
r1354 |
|
| 4 | 4 | <description>table browser</description> |
|---|
| 5 | 5 | |
|---|
| 6 | | <command interpreter="python">ucsc_tablebrowser.py $output</command> |
|---|
| | 6 | <command interpreter="python">ucsc_tablebrowser.py $output ${GALAXY_TMP_FILE_DIR}</command> |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | <inputs action="http://archaea.ucsc.edu/cgi-bin/hgTables" check_values="false" method="get"> |
|---|
| r1129 |
r1354 |
|
| 4 | 4 | <description>table browser</description> |
|---|
| 5 | 5 | |
|---|
| 6 | | <command interpreter="python">ucsc_tablebrowser.py $output</command> |
|---|
| | 6 | <command interpreter="python">ucsc_tablebrowser.py $output ${GALAXY_TMP_FILE_DIR}</command> |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | <inputs action="http://genome-test.cse.ucsc.edu/cgi-bin/hgTables" check_values="false" method="get"> |
|---|
| r1172 |
r1354 |
|
| 15 | 15 | input_filename = sys.argv[1] |
|---|
| 16 | 16 | output_filename = sys.argv[2] |
|---|
| | 17 | tmp_file_dir = sys.argv[3] |
|---|
| 17 | 18 | species = odict() |
|---|
| 18 | 19 | cur_size = 0 |
|---|
| … | … | |
| 21 | 22 | for component in components: |
|---|
| 22 | 23 | if component.species not in species: |
|---|
| 23 | | species[component.species] = tempfile.TemporaryFile() |
|---|
| | 24 | species[component.species] = tempfile.TemporaryFile( dir=tmp_file_dir ) |
|---|
| 24 | 25 | species[component.species].write( "-" * cur_size ) |
|---|
| 25 | 26 | species[component.species].write( component.text ) |
|---|
| r1242 |
r1354 |
|
| 1 | 1 | <tool id="fasta_concatenate0" name="Concatenate" version="0.0.0"> |
|---|
| 2 | 2 | <description>FASTA alignment by species</description> |
|---|
| 3 | | <command interpreter="python">fasta_concatenate_by_species.py $input1 $out_file1</command> |
|---|
| | 3 | <command interpreter="python">fasta_concatenate_by_species.py $input1 $out_file1 ${GALAXY_TMP_FILE_DIR}</command> |
|---|
| 4 | 4 | <inputs> |
|---|
| 5 | 5 | <param name="input1" type="data" format="fasta" label="FASTA alignment"/> |
|---|
| r1012 |
r1354 |
|
| 13 | 13 | |
|---|
| 14 | 14 | class OffsetList: |
|---|
| 15 | | def __init__( self, filesize = 0, fmt = None ): |
|---|
| 16 | | self.file = tempfile.NamedTemporaryFile( 'w+b' ) |
|---|
| | 15 | def __init__( self, filesize=0, fmt=None, directory=None ): |
|---|
| | 16 | self.file = tempfile.NamedTemporaryFile( mode='w+b', dir=directory ) |
|---|
| 17 | 17 | if fmt: |
|---|
| 18 | 18 | self.fmt = fmt |
|---|
| … | … | |
| 60 | 60 | |
|---|
| 61 | 61 | class SortedOffsets( OffsetList ): |
|---|
| 62 | | def __init__( self, indexed_filename, column, split = None ): |
|---|
| 63 | | OffsetList.__init__( self, os.stat( indexed_filename ).st_size ) |
|---|
| | 62 | def __init__( self, indexed_filename, column, tmp_file_dir, split = None ): |
|---|
| | 63 | OffsetList.__init__( self, filesize=os.stat( indexed_filename ).st_size, directory=tmp_file_dir ) |
|---|
| 64 | 64 | self.indexed_filename = indexed_filename |
|---|
| 65 | 65 | self.indexed_file = open( indexed_filename, 'rb' ) |
|---|
| 66 | 66 | self.column = column |
|---|
| | 67 | self.tmp_file_dir = tmp_file_dir |
|---|
| 67 | 68 | self.split = split |
|---|
| 68 | 69 | self.last_identifier = None |
|---|
| … | … | |
| 75 | 76 | identifier2 = keys.pop( 0 ) |
|---|
| 76 | 77 | |
|---|
| 77 | | result_offsets = OffsetList( fmt = self.fmt ) |
|---|
| | 78 | result_offsets = OffsetList( fmt=self.fmt, directory=self.tmp_file_dir ) |
|---|
| 78 | 79 | offsets1 = enumerate( self.get_offsets() ) |
|---|
| 79 | 80 | try: |
|---|
| … | … | |
| 125 | 126 | #indexed set of offsets, index is built on demand |
|---|
| 126 | 127 | class OffsetIndex: |
|---|
| 127 | | def __init__( self, filename, column, split = None, index_depth = 3 ): |
|---|
| | 128 | def __init__( self, filename, column, tmp_file_dir, split = None, index_depth = 3 ): |
|---|
| 128 | 129 | self.filename = filename |
|---|
| 129 | 130 | self.file = open( filename, 'rb' ) |
|---|
| 130 | 131 | self.column = column |
|---|
| | 132 | self.tmp_file_dir = tmp_file_dir |
|---|
| 131 | 133 | self.split = split |
|---|
| 132 | 134 | self._offsets = {} |
|---|
| … | … | |
| 193 | 195 | if not keys: |
|---|
| 194 | 196 | if first_char not in self._offsets: |
|---|
| 195 | | self._offsets[first_char] = SortedOffsets( self.filename, self.column, self.split ) |
|---|
| | 197 | self._offsets[first_char] = SortedOffsets( self.filename, self.column, self.tmp_file_dir, split=self.split ) |
|---|
| 196 | 198 | self._offsets[first_char].merge_with_dict( temp ) |
|---|
| 197 | 199 | return |
|---|
| … | … | |
| 201 | 203 | else: |
|---|
| 202 | 204 | if first_char not in self._offsets: |
|---|
| 203 | | self._offsets[first_char] = SortedOffsets( self.filename, self.column, self.split ) |
|---|
| | 205 | self._offsets[first_char] = SortedOffsets( self.filename, self.column, self.tmp_file_dir, split=self.split ) |
|---|
| 204 | 206 | self._offsets[first_char].merge_with_dict( temp ) |
|---|
| 205 | 207 | temp = { identifier: d[identifier] } |
|---|
| … | … | |
| 207 | 209 | |
|---|
| 208 | 210 | class BufferedIndex: |
|---|
| 209 | | def __init__( self, filename, column, split = None, buffer = 1000000, index_depth = 3 ): |
|---|
| 210 | | self.index = OffsetIndex( filename, column, split, index_depth ) |
|---|
| | 211 | def __init__( self, filename, column, tmp_file_dir, split = None, buffer = 1000000, index_depth = 3 ): |
|---|
| | 212 | self.index = OffsetIndex( filename, column, tmp_file_dir, split=split, index_depth=index_depth ) |
|---|
| 211 | 213 | self.buffered_offsets = {} |
|---|
| 212 | 214 | f = open( filename, 'rb' ) |
|---|
| … | … | |
| 236 | 238 | yield self.index.get_line_by_offset( offset ) |
|---|
| 237 | 239 | |
|---|
| 238 | | def join_files( filename1, column1, filename2, column2, out_filename, split = None, buffer = 1000000, keep_unmatched = False, keep_partial = False, index_depth = 3 ): |
|---|
| | 240 | def join_files( filename1, column1, filename2, column2, out_filename, tmp_file_dir, split = None, buffer = 1000000, keep_unmatched = False, keep_partial = False, index_depth = 3 ): |
|---|
| 239 | 241 | #return identifier based upon line |
|---|
| 240 | 242 | def get_identifier_by_line( line, column, split = None ): |
|---|
| … | … | |
| 245 | 247 | return None |
|---|
| 246 | 248 | out = open( out_filename, 'w+b' ) |
|---|
| 247 | | index = BufferedIndex( filename2, column2, split, buffer, index_depth ) |
|---|
| | 249 | index = BufferedIndex( filename2, column2, tmp_file_dir, split=split, buffer=buffer, index_depth=index_depth ) |
|---|
| 248 | 250 | for line1 in open( filename1, 'rb' ): |
|---|
| 249 | 251 | identifier = get_identifier_by_line( line1, column1, split ) |
|---|
| … | … | |
| 294 | 296 | column2 = int( args[3] ) - 1 |
|---|
| 295 | 297 | out_filename = args[4] |
|---|
| | 298 | tmp_file_dir = args[5] |
|---|
| 296 | 299 | except: |
|---|
| 297 | 300 | print >> sys.stderr, "Error parsing command line." |
|---|
| … | … | |
| 301 | 304 | split = "\t" |
|---|
| 302 | 305 | |
|---|
| 303 | | return join_files( filename1, column1, filename2, column2, out_filename, split, options.buffer, options.keep_unmatched, options.keep_partial, options.index_depth ) |
|---|
| | 306 | return join_files( filename1, column1, filename2, column2, out_filename, tmp_file_dir, split, options.buffer, options.keep_unmatched, options.keep_partial, options.index_depth ) |
|---|
| 304 | 307 | |
|---|
| 305 | 308 | if __name__ == "__main__": main() |
|---|
| r1055 |
r1354 |
|
| 1 | 1 | <tool id="join1" name="Join two Queries" version="2.0.0"> |
|---|
| 2 | 2 | <description>side by side on a specified field</description> |
|---|
| 3 | | <command interpreter="python">join.py $input1 $input2 $field1 $field2 $out_file1 $unmatched $partial --index_depth=3 --buffer=50000000</command> |
|---|
| | 3 | <command interpreter="python">join.py $input1 $input2 $field1 $field2 $out_file1 ${GALAXY_TMP_FILE_DIR} $unmatched $partial --index_depth=3 --buffer=50000000</command> |
|---|
| 4 | 4 | <inputs> |
|---|
| 5 | 5 | <param format="tabular" name="input1" type="data" label="Join"/> |
|---|
| r1196 |
r1354 |
|
| 5 | 5 | from galaxy.tools.util import hyphy_util |
|---|
| 6 | 6 | |
|---|
| | 7 | # Directory to be used when creating temporary files |
|---|
| | 8 | tmp_file_dir = sys.argv.pop() |
|---|
| 7 | 9 | #Retrieve hyphy path, this will need to be the same across the cluster |
|---|
| 8 | 10 | tool_data = sys.argv.pop() |
|---|
| … | … | |
| 20 | 22 | #Set up Temporary files for hyphy run |
|---|
| 21 | 23 | #set up tree file |
|---|
| 22 | | tree_filename = hyphy_util.get_filled_temp_filename(tree_contents) |
|---|
| | 24 | tree_filename = hyphy_util.get_filled_temp_filename( tree_contents, directory=tmp_file_dir ) |
|---|
| 23 | 25 | |
|---|
| 24 | 26 | #Guess if this is a single or multiple FASTA input file |
|---|
| … | … | |
| 34 | 36 | |
|---|
| 35 | 37 | #set up BranchLengths file |
|---|
| 36 | | BranchLengths_filename = hyphy_util.get_filled_temp_filename(hyphy_util.BranchLengths) |
|---|
| | 38 | BranchLengths_filename = hyphy_util.get_filled_temp_filename( hyphy_util.BranchLengths, directory=tmp_file_dir ) |
|---|
| 37 | 39 | if is_multiple: |
|---|
| 38 | 40 | os.unlink(BranchLengths_filename) |
|---|
| 39 | | BranchLengths_filename = hyphy_util.get_filled_temp_filename(hyphy_util.BranchLengthsMF) |
|---|
| | 41 | BranchLengths_filename = hyphy_util.get_filled_temp_filename( hyphy_util.BranchLengthsMF, directory=tmp_file_dir ) |
|---|
| 40 | 42 | print "Multiple Alignment Analyses" |
|---|
| 41 | 43 | else: print "Single Alignment Analyses" |
|---|
| r1196 |
r1354 |
|
| 4 | 4 | <description>Estimation</description> |
|---|
| 5 | 5 | |
|---|
| 6 | | <command interpreter="python">hyphy_branch_lengths_wrapper.py $input1 $out_file1 "$tree" "$model" "$base_freq" "Global" ${GALAXY_DATA_INDEX_DIR}</command> |
|---|
| | 6 | <command interpreter="python">hyphy_branch_lengths_wrapper.py $input1 $out_file1 "$tree" "$model" "$base_freq" "Global" ${GALAXY_DATA_INDEX_DIR} ${GALAXY_TMP_FILE_DIR}</command> |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | <inputs> |
|---|
| r1196 |
r1354 |
|
| 5 | 5 | from galaxy.tools.util import hyphy_util |
|---|
| 6 | 6 | |
|---|
| | 7 | # Directory to be used when creating temporary files |
|---|
| | 8 | tmp_file_dir = sys.argv.pop() |
|---|
| 7 | 9 | #Retrieve hyphy path, this will need to be the same across the cluster |
|---|
| 8 | 10 | tool_data = sys.argv.pop() |
|---|
| … | … | |
| 21 | 23 | sys.exit() |
|---|
| 22 | 24 | |
|---|
| 23 | | tree_filename = hyphy_util.get_filled_temp_filename(tree_contents) |
|---|
| | 25 | tree_filename = hyphy_util.get_filled_temp_filename( tree_contents, directory=tmp_file_dir ) |
|---|
| 24 | 26 | |
|---|
| 25 | 27 | if analysis == "local": |
|---|
| 26 | | fitter_filename = hyphy_util.get_filled_temp_filename(hyphy_util.SimpleLocalFitter) |
|---|
| | 28 | fitter_filename = hyphy_util.get_filled_temp_filename( hyphy_util.SimpleLocalFitter, directory=tmp_file_dir ) |
|---|
| 27 | 29 | else: |
|---|
| 28 | | fitter_filename = hyphy_util.get_filled_temp_filename(hyphy_util.SimpleGlobalFitter) |
|---|
| | 30 | fitter_filename = hyphy_util.get_filled_temp_filename( hyphy_util.SimpleGlobalFitter, directory=tmp_file_dir ) |
|---|
| 29 | 31 | |
|---|
| 30 | | tabwriter_filename = hyphy_util.get_filled_temp_filename(hyphy_util.TabWriter) |
|---|
| 31 | | FastaReader_filename = hyphy_util.get_filled_temp_filename(hyphy_util.FastaReader) |
|---|
| | 32 | tabwriter_filename = hyphy_util.get_filled_temp_filename( hyphy_util.TabWriter, directory=tmp_file_dir ) |
|---|
| | 33 | FastaReader_filename = hyphy_util.get_filled_temp_filename( hyphy_util.FastaReader, directory=tmp_file_dir ) |
|---|
| 32 | 34 | #setup Config file |
|---|
| 33 | 35 | config_filename = hyphy_util.get_dnds_config_filename(fitter_filename, tabwriter_filename, "Universal", tree_filename, input_filename, nuc_model, output_filename, FastaReader_filename) |
|---|
| r1196 |
r1354 |
|
| 4 | 4 | <description>Estimation</description> |
|---|
| 5 | 5 | |
|---|
| 6 | | <command interpreter="python">hyphy_dnds_wrapper.py $input1 $out_file1 "$tree" "$model" $analysis ${GALAXY_DATA_INDEX_DIR}</command> |
|---|
| | 6 | <command interpreter="python">hyphy_dnds_wrapper.py $input1 $out_file1 "$tree" "$model" $analysis ${GALAXY_DATA_INDEX_DIR} ${GALAXY_TMP_FILE_DIR}</command> |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | <inputs> |
|---|
| r1196 |
r1354 |
|
| 5 | 5 | from galaxy.tools.util import hyphy_util |
|---|
| 6 | 6 | |
|---|
| | 7 | # Directory to be used when creating temporary files |
|---|
| | 8 | tmp_file_dir = sys.argv.pop() |
|---|
| 7 | 9 | #Retrieve hyphy path, this will need to be the same across the cluster |
|---|
| 8 | 10 | tool_data = sys.argv.pop() |
|---|
| … | … | |
| 15 | 17 | output_filename2 = os.path.abspath(sys.argv[3].strip()) |
|---|
| 16 | 18 | distance_metric = sys.argv[4].strip() |
|---|
| 17 | | temp_ps_filename = hyphy_util.get_filled_temp_filename("") |
|---|
| | 19 | temp_ps_filename = hyphy_util.get_filled_temp_filename( "", directory=tmp_file_dir ) |
|---|
| 18 | 20 | |
|---|
| 19 | 21 | #Guess if this is a single or multiple FASTA input file |
|---|
| … | … | |
| 28 | 30 | else: found_blank = False |
|---|
| 29 | 31 | |
|---|
| 30 | | NJ_tree_shared_ibf = hyphy_util.get_filled_temp_filename(hyphy_util.NJ_tree_shared_ibf) |
|---|
| | 32 | NJ_tree_shared_ibf = hyphy_util.get_filled_temp_filename( hyphy_util.NJ_tree_shared_ibf, directory=tmp_file_dir ) |
|---|
| 31 | 33 | |
|---|
| 32 | 34 | #set up NJ_tree file |
|---|
| 33 | | NJ_tree_filename = hyphy_util.get_filled_temp_filename(hyphy_util.get_NJ_tree(NJ_tree_shared_ibf)) |
|---|
| | 35 | NJ_tree_filename = hyphy_util.get_filled_temp_filename( hyphy_util.get_NJ_tree( NJ_tree_shared_ibf ), directory=tmp_file_dir ) |
|---|
| 34 | 36 | #setup Config file |
|---|
| 35 | 37 | config_filename = hyphy_util.get_nj_tree_config_filename(input_filename, distance_metric, output_filename1, temp_ps_filename, NJ_tree_filename) |
|---|
| … | … | |
| 37 | 39 | os.unlink(NJ_tree_filename) |
|---|
| 38 | 40 | os.unlink(config_filename) |
|---|
| 39 | | NJ_tree_filename = hyphy_util.get_filled_temp_filename(hyphy_util.get_NJ_treeMF(NJ_tree_shared_ibf)) |
|---|
| | 41 | NJ_tree_filename = hyphy_util.get_filled_temp_filename( hyphy_util.get_NJ_treeMF( NJ_tree_shared_ibf ), directory=tmp_file_dir ) |
|---|
| 40 | 42 | config_filename = hyphy_util.get_nj_treeMF_config_filename(input_filename, output_filename1, temp_ps_filename, distance_metric, NJ_tree_filename) |
|---|
| 41 | 43 | print "Multiple Alignment Analyses" |
|---|
| r1224 |
r1354 |
|
| 4 | 4 | <description>Builder</description> |
|---|
| 5 | 5 | |
|---|
| 6 | | <command interpreter="python">hyphy_nj_tree_wrapper.py $input1 $out_file1 $out_file2 $distance_metric ${GALAXY_DATA_INDEX_DIR}</command> |
|---|
| | 6 | <command interpreter="python">hyphy_nj_tree_wrapper.py $input1 $out_file1 $out_file2 $distance_metric ${GALAXY_DATA_INDEX_DIR} ${GALAXY_TMP_FILE_DIR}</command> |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | <inputs> |
|---|
| r1338 |
r1354 |
|
| 1 | 1 | <tool id="GeneBed_Maf_Fasta2" name="Stitch Gene blocks"> |
|---|
| 2 | 2 | <description>given a set of coding exon intervals</description> |
|---|
| 3 | | <command interpreter="python">#if $maf_source_type.maf_source == "user":#interval_maf_to_merged_fasta.py --dbkey=$dbkey --species=$maf_source_type.species --mafSource=$maf_source_type.maf_file --interval_file=$input1 --output_file=$out_file1 --mafSourceType=$maf_source_type.maf_source --geneBED --mafIndexFileDir=${GALAXY_DATA_INDEX_DIR} |
|---|
| 4 | | #else:#interval_maf_to_merged_fasta.py --dbkey=$dbkey --species=$maf_source_type.species --mafSource=$maf_source_type.maf_identifier --interval_file=$input1 --output_file=$out_file1 --mafSourceType=$maf_source_type.maf_source --geneBED --mafIndexFileDir=${GALAXY_DATA_INDEX_DIR} |
|---|
| | 3 | <command interpreter="python">#if $maf_source_type.maf_source == "user":#interval_maf_to_merged_fasta.py --dbkey=$dbkey --species=$maf_source_type.species --mafSource=$maf_source_type.maf_file --interval_file=$input1 --output_file=$out_file1 --mafSourceType=$maf_source_type.maf_source --geneBED --mafIndexFileDir=${GALAXY_DATA_INDEX_DIR} --mafTmpFileDir=${GALAXY_TMP_FILE_DIR} |
|---|
| | 4 | #else:#interval_maf_to_merged_fasta.py --dbkey=$dbkey --species=$maf_source_type.species --mafSource=$maf_source_type.maf_identifier --interval_file=$input1 --output_file=$out_file1 --mafSourceType=$maf_source_type.maf_source --geneBED --mafIndexFileDir=${GALAXY_DATA_INDEX_DIR} --mafTmpFileDir=${GALAXY_TMP_FILE_DIR} |
|---|
| 5 | 5 | #end if |
|---|
| 6 | 6 | </command> |
|---|
| r1172 |
r1354 |
|
| 21 | 21 | -p, --species=p: Species to include in output |
|---|
| 22 | 22 | -l, --indexLocation=l: Override default maf_index.loc file |
|---|
| 23 | | -z, --mafIndexFile=z: Directory of local maf index file ( maf_index.loc or maf_pairwise.loc ) |
|---|
| | 23 | -y, --mafIndexFile=y: Directory of local maf index file ( maf_index.loc or maf_pairwise.loc ) |
|---|
| | 24 | -z, --mafTmpFileDir=z: Directory to be used when creating temporary files |
|---|
| 24 | 25 | """ |
|---|
| 25 | 26 | |
|---|
| … | … | |
| 94 | 95 | sys.exit() |
|---|
| 95 | 96 | elif options.mafFile: |
|---|
| 96 | | index, index_filename = maf_utilities.build_maf_index( options.mafFile, species = [dbkey] ) |
|---|
| | 97 | index, index_filename = maf_utilities.build_maf_index( options.mafFile, species=[dbkey], directory=options.mafTmpFileDir ) |
|---|
| 97 | 98 | if index is None: |
|---|
| 98 | 99 | print >> sys.stderr, "Your MAF file appears to be malformed." |
|---|
| r1338 |
r1354 |
|
| 3 | 3 | <command interpreter="python"> |
|---|
| 4 | 4 | #if $maf_source_type.maf_source == "user":#interval2maf.py --dbkey=$input1_dbkey --chromCol=$input1_chromCol --startCol=$input1_startCol --endCol=$input1_endCol --strandCol=$input1_strandCol --mafFile=$maf_source_type.mafFile --interval_file=$input1 --output_file=$out_file1 --mafIndexFile=${GALAXY_DATA_INDEX_DIR}/maf_index.loc |
|---|
| 5 | | #else:#interval2maf.py --dbkey=$input1_dbkey --chromCol=$input1_chromCol --startCol=$input1_startCol --endCol=$input1_endCol --strandCol=$input1_strandCol --mafType=$maf_source_type.mafType --interval_file=$input1 --output_file=$out_file1 --mafIndexFile=${GALAXY_DATA_INDEX_DIR}/maf_index.loc |
|---|
| | 5 | #else:#interval2maf.py --dbkey=$input1_dbkey --chromCol=$input1_chromCol --startCol=$input1_startCol --endCol=$input1_endCol --strandCol=$input1_strandCol --mafType=$maf_source_type.mafType --interval_file=$input1 --output_file=$out_file1 --mafIndexFile=${GALAXY_DATA_INDEX_DIR}/maf_index.loc --mafTmpFileDir=${GALAXY_TMP_FILE_DIR} |
|---|
| 6 | 6 | #end if |
|---|
| 7 | 7 | </command> |
|---|
| r1338 |
r1354 |
|
| 1 | 1 | <tool id="Interval2Maf_pairwise1" name="Extract Pairwise MAF blocks"> |
|---|
| 2 | 2 | <description>given a set of genomic intervals</description> |
|---|
| 3 | | <command interpreter="python">interval2maf.py --dbkey=$input1_dbkey --chromCol=$input1_chromCol --startCol=$input1_startCol --endCol=$input1_endCol --strandCol=$input1_strandCol --mafType=$mafType --interval_file=$input1 --output_file=$out_file1 --indexLocation=${GALAXY_DATA_INDEX_DIR}/maf_pairwise.loc</command> |
|---|
| | 3 | <command interpreter="python">interval2maf.py --dbkey=$input1_dbkey --chromCol=$input1_chromCol --startCol=$input1_startCol --endCol=$input1_endCol --strandCol=$input1_strandCol --mafType=$mafType --interval_file=$input1 --output_file=$out_file1 --indexLocation=${GALAXY_DATA_INDEX_DIR}/maf_pairwise.loc --mafTmpFileDir=${GALAXY_TMP_FILE_DIR}</command> |
|---|
| 4 | 4 | <inputs> |
|---|
| 5 | 5 | <param name="input1" type="data" format="interval" label="Interval File"> |
|---|
| r1172 |
r1354 |
|
| 19 | 19 | -o, --output_file=o: Output MAF file |
|---|
| 20 | 20 | -p, --species=p: Species to include in output |
|---|
| 21 | | -z, --mafIndexFileDir=z: Directory of local maf_index.loc file |
|---|
| | 21 | -y, --mafIndexFileDir=y: Directory of local maf_index.loc file |
|---|
| | 22 | -z, --mafTmpFileDir=z: Directory to be used when creating temporary files |
|---|
| 22 | 23 | |
|---|
| 23 | | usage: %prog dbkey_of_BED comma_separated_list_of_additional_dbkeys_to_extract comma_separated_list_of_indexed_maf_files input_gene_bed_file output_fasta_file cached|user GALAXY_DATA_INDEX_DIR |
|---|
| | 24 | usage: %prog dbkey_of_BED comma_separated_list_of_additional_dbkeys_to_extract comma_separated_list_of_indexed_maf_files input_gene_bed_file output_fasta_file cached|user GALAXY_DATA_INDEX_DIR GALAXY_TMP_FILE_DIR |
|---|
| 24 | 25 | """ |
|---|
| 25 | 26 | |
|---|
| … | … | |
| 88 | 89 | sys.exit() |
|---|
| 89 | 90 | mafIndexFile = "%s/maf_index.loc" % options.mafIndexFileDir |
|---|
| | 91 | tmpFileDir = options.mafTmpFileDir |
|---|
| 90 | 92 | #Finish parsing command line |
|---|
| 91 | 93 | |
|---|
| … | … | |
| 100 | 102 | elif options.mafSourceType.lower() in ["user"]: |
|---|
| 101 | 103 | #index maf for use here, need to remove index_file when finished |
|---|
| 102 | | index, index_filename = maf_utilities.build_maf_index( options.mafSource, species = [primary_species] ) |
|---|
| | 104 | index, index_filename = maf_utilities.build_maf_index( options.mafSource, species=[primary_species], directory=tmpFileDir ) |
|---|
| 103 | 105 | if index is None: |
|---|
| 104 | 106 | print >> sys.stderr, "Your MAF file appears to be malformed." |
|---|
| r1338 |
r1354 |
|
| 1 | 1 | <tool id="Interval_Maf_Merged_Fasta2" name="Stitch MAF blocks"> |
|---|
| 2 | 2 | <description>given a set of genomic intervals</description> |
|---|
| 3 | | <command interpreter="python">#if $maf_source_type.maf_source == "user":#interval_maf_to_merged_fasta.py --dbkey=$dbkey --species=$maf_source_type.species --mafSource=$maf_source_type.maf_file --interval_file=$input1 --output_file=$out_file1 --chromCol=$input1_chromCol --startCol=$input1_startCol --endCol=$input1_endCol --strandCol=$input1_strandCol --mafSourceType=$maf_source_type.maf_source --mafIndexFileDir=${GALAXY_DATA_INDEX_DIR} |
|---|
| 4 | | #else:#interval_maf_to_merged_fasta.py --dbkey=$dbkey --species=$maf_source_type.species --mafSource=$maf_source_type.maf_identifier --interval_file=$input1 --output_file=$out_file1 --chromCol=$input1_chromCol --startCol=$input1_startCol --endCol=$input1_endCol --strandCol=$input1_strandCol --mafSourceType=$maf_source_type.maf_source --mafIndexFileDir=${GALAXY_DATA_INDEX_DIR} |
|---|
| | 3 | <command interpreter="python">#if $maf_source_type.maf_source == "user":#interval_maf_to_merged_fasta.py --dbkey=$dbkey --species=$maf_source_type.species --mafSource=$maf_source_type.maf_file --interval_file=$input1 --output_file=$out_file1 --chromCol=$input1_chromCol --startCol=$input1_startCol --endCol=$input1_endCol --strandCol=$input1_strandCol --mafSourceType=$maf_source_type.maf_source --mafIndexFileDir=${GALAXY_DATA_INDEX_DIR} --mafTmpFileDir=${GALAXY_TMP_FILE_DIR} |
|---|
| | 4 | #else:#interval_maf_to_merged_fasta.py --dbkey=$dbkey --species=$maf_source_type.species --mafSource=$maf_source_type.maf_identifier --interval_file=$input1 --output_file=$out_file1 --chromCol=$input1_chromCol --startCol=$input1_startCol --endCol=$input1_endCol --strandCol=$input1_strandCol --mafSourceType=$maf_source_type.maf_source --mafIndexFileDir=${GALAXY_DATA_INDEX_DIR} --mafTmpFileDir=${GALAXY_TMP_FILE_DIR} |
|---|
| 5 | 5 | #end if |
|---|
| 6 | 6 | </command> |
|---|
| r1172 |
r1354 |
|
| 32 | 32 | |
|---|
| 33 | 33 | mafIndexFile = "%s/maf_index.loc" % sys.argv[9] |
|---|
| | 34 | tmpFileDir = sys.argv[10] |
|---|
| 34 | 35 | index = index_filename = None |
|---|
| 35 | 36 | if maf_source_type == "user": |
|---|
| 36 | 37 | #index maf for use here |
|---|
| 37 | | index, index_filename = maf_utilities.build_maf_index( input_maf_filename, species = [dbkey] ) |
|---|
| | 38 | index, index_filename = maf_utilities.build_maf_index( input_maf_filename, species=[dbkey], directory=tmpFileDir ) |
|---|
| 38 | 39 | if index is None: |
|---|
| 39 | 40 | print >>sys.stderr, "Your MAF file appears to be malformed." |
|---|
| r1338 |
r1354 |
|
| 9 | 9 | #end if |
|---|
| 10 | 10 | ${GALAXY_DATA_INDEX_DIR} |
|---|
| | 11 | ${GALAXY_TMP_FILE_DIR} |
|---|
| 11 | 12 | </command> |
|---|
| 12 | 13 | <inputs> |
|---|
| r1180 |
r1354 |
|
| 68 | 68 | |
|---|
| 69 | 69 | GALAXY_DATA_INDEX_DIR = sys.argv[8] |
|---|
| | 70 | GALAXY_TMP_FILE_DIR = sys.argv[9] |
|---|
| 70 | 71 | |
|---|
| 71 | 72 | all_files = [] |
|---|
| … | … | |
| 96 | 97 | |
|---|
| 97 | 98 | for detail_file_path in all_files: |
|---|
| 98 | | output_tempfile = tempfile.NamedTemporaryFile().name |
|---|
| | 99 | output_tempfile = tempfile.NamedTemporaryFile( dir=GALAXY_TMP_FILE_DIR ).name |
|---|
| 99 | 100 | command = "blat %s %s %s -oneOff=%s -tileSize=%s -minIdentity=%s -mask=lower -noHead -out=pslx 2>&1" % ( detail_file_path, query_file, output_tempfile, one_off, tile_size, min_iden ) |
|---|
| 100 | 101 | os.system( command ) |
|---|
| r1224 |
r1354 |
|
| 6 | 6 | #end if |
|---|
| 7 | 7 | ${GALAXY_DATA_INDEX_DIR} |
|---|
| | 8 | ${GALAXY_TMP_FILE_DIR} |
|---|
| 8 | 9 | </command> |
|---|
| 9 | 10 | <inputs> |
|---|
| r1258 |
r1354 |
|
| 20 | 20 | mega_iden_cutoff = sys.argv[5] # -p |
|---|
| 21 | 21 | mega_evalue_cutoff = sys.argv[6] # -e |
|---|
|