1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/2edb06612c92/ Changeset: 2edb06612c92 User: dan Date: 2014-04-18 19:23:38 Summary: Update MAF to BED to use job working directory and built-in primary dataset collection. Affected #: 3 files diff -r bc34e6a879f7ec7a4e63e9a2cd858b89dda16761 -r 2edb06612c92b7e259e710f63b5cd15d4805c490 tools/maf/maf_to_bed.py --- a/tools/maf/maf_to_bed.py +++ b/tools/maf/maf_to_bed.py @@ -19,6 +19,7 @@ species = sys.argv[3].split(',') partial = sys.argv[4] + output_id = sys.argv[6] out_files = {} primary_spec = None @@ -47,10 +48,7 @@ out_files[spec] = open( output_filename, 'w' ) primary_spec = spec else: - out_files[spec] = tempfile.NamedTemporaryFile( mode = 'w', dir = database_tmp_dir, suffix = '.maf_to_bed' ) - filename = out_files[spec].name - out_files[spec].close() - out_files[spec] = open( filename, 'w' ) + out_files[ spec ] = open( os.path.join( database_tmp_dir, 'primary_%s_%s_visible_bed_%s' % ( output_id, spec, spec ) ), 'wb+' ) num_species = len( species ) print "Restricted to species:", ",".join( species ) @@ -71,10 +69,7 @@ if not spec or not chrom: spec = chrom = c.src if spec not in out_files.keys(): - out_files[spec] = tempfile.NamedTemporaryFile( mode='w', dir = database_tmp_dir, suffix = '.maf_to_bed' ) - filename = out_files[spec].name - out_files[spec].close() - out_files[spec] = open( filename, 'w' ) + out_files[ spec ] = open( os.path.join( database_tmp_dir, 'primary_%s_%s_visible_bed_%s' % ( output_id, spec, spec ) ), 'wb+' ) if c.strand == "-": out_files[spec].write( chrom + "\t" + str( c.src_size - c.end ) + "\t" + str( c.src_size - c.start ) + "\t" + spec + "_" + str( block_num ) + "\t" + "0\t" + c.strand + "\n" ) @@ -85,10 +80,6 @@ for file_out in out_files.keys(): out_files[file_out].close() - for spec in out_files.keys(): - if spec != primary_spec: - print "#FILE\t" + spec + "\t" + os.path.join( database_tmp_dir, os.path.split( out_files[spec].name )[1] ) - else: - print "#FILE1\t" + spec + "\t" + out_files[spec].name + print "#FILE1_DBKEY\t%s" % ( primary_spec ) if __name__ == "__main__": __main__() diff -r bc34e6a879f7ec7a4e63e9a2cd858b89dda16761 -r 2edb06612c92b7e259e710f63b5cd15d4805c490 tools/maf/maf_to_bed.xml --- a/tools/maf/maf_to_bed.xml +++ b/tools/maf/maf_to_bed.xml @@ -1,6 +1,6 @@ -<tool id="MAF_To_BED1" name="Maf to BED" force_history_refresh="True"> +<tool id="MAF_To_BED1" name="MAF to BED" force_history_refresh="True"><description>Converts a MAF formatted file to the BED format</description> - <command interpreter="python">maf_to_bed.py $input1 $out_file1 $species $complete_blocks $__new_file_path__</command> + <command interpreter="python">maf_to_bed.py "${ input1 }" "${ out_file1 }" "${ species }" "${ complete_blocks }" "." "${ out_file1.id }"</command><inputs><param format="maf" name="input1" type="data" label="MAF file to convert"/><param name="species" type="select" label="Select species" display="checkboxes" multiple="true" help="a separate history item will be created for each checked species"> diff -r bc34e6a879f7ec7a4e63e9a2cd858b89dda16761 -r 2edb06612c92b7e259e710f63b5cd15d4805c490 tools/maf/maf_to_bed_code.py --- a/tools/maf/maf_to_bed_code.py +++ b/tools/maf/maf_to_bed_code.py @@ -6,56 +6,20 @@ def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr): output_data = out_data.items()[0][1] - history = output_data.history - if history == None: - print "unknown history!" - return new_stdout = "" split_stdout = stdout.split("\n") - basic_name = output_data.name - output_data_list = [] for line in split_stdout: if line.startswith("#FILE1"): fields = line.split("\t") dbkey = fields[1] - filepath = fields[2] output_data.dbkey = dbkey - output_data.name = basic_name + " (" + dbkey + ")" + output_data.name = "%s (%s)" % ( output_data.name, dbkey ) app.model.context.add( output_data ) app.model.context.flush() - output_data_list.append(output_data) - elif line.startswith("#FILE"): - fields = line.split("\t") - dbkey = fields[1] - filepath = fields[2] - newdata = app.model.HistoryDatasetAssociation( create_dataset = True, sa_session = app.model.context ) - newdata.set_size() - newdata.extension = "bed" - newdata.name = basic_name + " (" + dbkey + ")" - app.model.context.add( newdata ) - app.model.context.flush() - history.add_dataset( newdata ) - app.security_agent.copy_dataset_permissions( output_data.dataset, newdata.dataset ) - app.model.context.add( history ) - app.model.context.flush() - try: - app.object_store.update_from_file( newdata.dataset, file_name=filepath, create=True ) - os.unlink( filepath ) - newdata.info = newdata.name - newdata.state = newdata.states.OK - except: - newdata.info = "The requested file is missing from the system." - newdata.state = newdata.states.ERROR - newdata.dbkey = dbkey - newdata.init_meta() - newdata.set_meta() - newdata.set_peek() - app.model.context.flush() - output_data_list.append(newdata) else: - new_stdout = new_stdout + line - for data in output_data_list: - if data.state == data.states.OK: - data.info = new_stdout - app.model.context.add( data ) - app.model.context.flush() + new_stdout = "%s\n%s" % ( new_stdout, line ) + for data in output_data.creating_job.output_datasets: + data = data.dataset + data.info = new_stdout + app.model.context.add( data ) + app.model.context.flush() Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.