From 8c5787f21dc188dd271e140c99ce9338df1d151e Mon Sep 17 00:00:00 2001 From: Daniel Blankenberg Date: Tue, 20 May 2008 19:54:12 +0000 Subject: [PATCH] Fix Errors reported by Cathy regarding the GMAJ tool. With these notes: User's can now specify the warnings that they which to report ('nowarns'). There are likely more options but they are unknown. Using Firefox 1.5.0.12 on Ubuntu with no extensions/addons installed gives me no issues with loading the applet while Javascript is enabled or disabled (works for me). --- lib/galaxy/tools/actions/__init__.py | 4 +-- lib/galaxy/tools/parameters/basic.py | 18 +++++++--- lib/galaxy/web/controllers/root.py | 15 ++++---- tools/visualization/GMAJ.xml | 51 ++++++++++++++++++---------- 4 files changed, 55 insertions(+), 33 deletions(-) diff --git a/lib/galaxy/tools/actions/__init__.py b/lib/galaxy/tools/actions/__init__.py index 3617c9e1246..3c90fd320f1 100644 --- a/lib/galaxy/tools/actions/__init__.py +++ b/lib/galaxy/tools/actions/__init__.py @@ -32,7 +32,7 @@ class DefaultToolAction( object ): if target_ext in data.get_converter_types(): assoc = data.get_associated_files_by_type( "CONVERTED_%s" % target_ext ) if assoc: data = assoc[0].dataset - else: + elif not tool.config_files: #run converter here assoc = trans.app.model.DatasetAssociatedFile( parent_id = data.id, file_type = "CONVERTED_%s" % target_ext, metadata_safe = False ) new_data = data.datatype.convert_dataset( trans, data, target_ext, return_output = True, visible = False ).values()[0] @@ -40,7 +40,7 @@ class DefaultToolAction( object ): new_data.name = data.name assoc.dataset_id = new_data.id data = new_data - break + break return data if isinstance( input, DataToolParameter ): if isinstance( value, list ): diff --git a/lib/galaxy/tools/parameters/basic.py b/lib/galaxy/tools/parameters/basic.py index beb459958db..79516257280 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -1049,6 +1049,8 @@ class DataToolParameter( ToolParameter ): assoc = data.get_associated_files_by_type( "CONVERTED_%s" % target_ext ) if assoc: data = assoc[0].dataset + elif self.tool.config_files: + continue #dataset conversion and configuration files currently only work with datasets that have already been converted selected = ( value and ( data in value ) ) field.add_option( "%s: (as %s) %s" % ( hid, target_ext, data.name[:30] ), data.id, selected ) break #we only report the first valid converter, assume self.extensions is a priority list @@ -1065,7 +1067,10 @@ class DataToolParameter( ToolParameter ): else: field.options[-1] = a, b, True if self.optional: - field.add_option( "Selection is Optional", 'None', True ) + if not value: + field.add_option( "Selection is Optional", 'None', True ) + else: + field.add_option( "Selection is Optional", 'None', False ) return field def get_initial_value( self, trans, context ): @@ -1079,14 +1084,21 @@ class DataToolParameter( ToolParameter ): assert trans is not None, "DataToolParameter requires a trans" history = trans.history assert history is not None, "DataToolParameter requires a history" + if self.optional: + return None history = trans.history most_recent_dataset = [None] filter_key = filter_value = None if self.options: filter_key, filter_value = self.options.get_options( trans, context ) def dataset_collector( datasets ): + def is_convertable( dataset ): + for target_ext in self.extensions: + if target_ext in data.get_converter_types(): + return True + return False for i, data in enumerate( datasets ): - if isinstance( data.datatype, self.formats) and not data.deleted and data.state not in [data.states.ERROR]: + if data.visible and not data.deleted and data.state not in [data.states.ERROR] and ( isinstance( data.datatype, self.formats) or is_convertable( data ) ): if self.options and filter_key == 'build' and data.get_dbkey() != filter_value: continue most_recent_dataset[0] = data @@ -1096,8 +1108,6 @@ class DataToolParameter( ToolParameter ): most_recent_dataset = most_recent_dataset.pop() if most_recent_dataset is not None: return most_recent_dataset - elif self.optional: - return None else: return '' diff --git a/lib/galaxy/web/controllers/root.py b/lib/galaxy/web/controllers/root.py index 1ed2742308d..f32b1563db2 100644 --- a/lib/galaxy/web/controllers/root.py +++ b/lib/galaxy/web/controllers/root.py @@ -530,20 +530,17 @@ class RootController( BaseController ): """Adds a POSTed file to a History""" try: history = trans.app.model.History.get( history_id ) - data = trans.app.model.Dataset() - data.name = name - data.extension = ext - data.dbkey = dbkey - data.info = info + data = trans.app.model.Dataset( name = name, info = info, extension = ext, dbkey = dbkey ) data.flush() - data_file = open(data.file_name, "w") - file_data.file.seek(0) - data_file.writelines(file_data.file.readlines()) + data_file = open( data.file_name, "wb" ) + file_data.file.seek( 0 ) + data_file.write( file_data.file.read() ) data_file.close() data.state = data.states.OK data.init_meta() + data.set_meta() data.flush() - history.add_dataset( data) + history.add_dataset( data ) history.flush() data.set_peek() data.set_size() diff --git a/tools/visualization/GMAJ.xml b/tools/visualization/GMAJ.xml index 09510fbb38e..293aa853b3c 100644 --- a/tools/visualization/GMAJ.xml +++ b/tools/visualization/GMAJ.xml @@ -3,6 +3,18 @@ GMAJ.py $out_file1 $maf_input $gmaj_file $filenames_file + + + + + @@ -10,11 +22,11 @@ - - - - - + + + + + @@ -24,29 +36,32 @@ title = "Galaxy: $maf_input.name" alignfile = input.maf refseq = any -tabext = .bed +tabext = .bed .gff .gtf +#if $nowarn.value: +nowarn = $nowarn +#end if #for $seq_count, $annotation in $enumerate( $annotations ): seq ${seq_count}: -#if $annotation['chromosome']: +#if $annotation['chromosome'].value: seqname = $annotation['species'].$annotation['chromosome'] #else: seqname = $annotation['species'] #end if #if $annotation['exons_file'].value: -exons = ${seq_count}.exons.bed +exons = ${seq_count}.exons.${annotation['exons_file'].extension} #end if #if $annotation['repeats_file'].value: -exons = ${seq_count}.repeats.bed +repeats = ${seq_count}.repeats.${annotation['repeats_file'].extension} #end if #if $annotation['links_file'].value: -exons = ${seq_count}.links.bed +links = ${seq_count}.links.${annotation['links_file'].extension} #end if #if $annotation['underlays_file'].value: -exons = ${seq_count}.underlays.bed +underlays = ${seq_count}.underlays.${annotation['underlays_file'].extension} #end if #if $annotation['highlights_file'].value: -exons = ${seq_count}.highlights.bed +highlights = ${seq_count}.highlights.${annotation['highlights_file'].extension} #end if offset = $annotation['offset'] @@ -55,19 +70,19 @@ offset = $annotation['offset'] #for $seq_count, $annotation in $enumerate( $annotations ): #if $annotation['exons_file'].value: -$annotation['exons_file'] = ${seq_count}.exons.bed +$annotation['exons_file'] = ${seq_count}.exons.${annotation['exons_file'].extension} #end if #if $annotation['repeats_file'].value: -$annotation['repeats_file'] = ${seq_count}.repeats.bed +$annotation['repeats_file'] = ${seq_count}.repeats.${annotation['repeats_file'].extension} #end if #if $annotation['links_file'].value: -$annotation['links_file'] = ${seq_count}.links.bed +$annotation['links_file'] = ${seq_count}.links.${annotation['links_file'].extension} #end if #if $annotation['underlays_file'].value: -$annotation['underlays_file'] = ${seq_count}.underlays.bed +$annotation['underlays_file'] = ${seq_count}.underlays.${annotation['underlays_file'].extension} #end if #if $annotation['highlights_file'].value: -$annotation['highlights_file'] = ${seq_count}.highlights.bed +$annotation['highlights_file'] = ${seq_count}.highlights.${annotation['highlights_file'].extension} #end if #end for @@ -76,7 +91,7 @@ $annotation['highlights_file'] = ${seq_count}.highlights.bed -You can use this tool to view a set of MAF alignments. You may also include optional additional information about the primary organism in the BED format. +You can use this tool to view a set of MAF alignments. You may also include optional annotation data for one or more of the organisms. For detailed information on GMAJ, click here_.