From 79745f40124ecfbd5dcf7cb23d9b6a9512f5a74c Mon Sep 17 00:00:00 2001
From: Greg Von Kuster
Date: Thu, 29 Nov 2007 17:04:42 +0000
Subject: [PATCH] Modified all tools to use the new tag for dynamic
select lists. Completely eliminated the tag approach. With
the exception of find_clusters_mysql, the old dynamic_options approach is not
being used by any tool, although dynamic_options is still supported in
parameters.py.
---
lib/galaxy/tools/dynamic_options.py | 412 +++++++++---------
lib/galaxy/tools/parameters.py | 18 +-
.../encode_import_all_latest_datasets.xml | 4 +-
...ncode_import_chromatin_and_chromosomes.xml | 4 +-
tools/data_source/encode_import_gencode.xml | 4 +-
.../encode_import_genes_and_transcripts.xml | 4 +-
...import_multi-species_sequence_analysis.xml | 4 +-
...encode_import_transcription_regulation.xml | 4 +-
tools/data_source/microbial_import.xml | 78 ++--
tools/data_source/microbial_import_code.py | 80 ++++
tools/data_source/upload.xml | 7 +-
tools/data_source/upload_code.py | 13 -
tools/extract/interval2maf_pairwise.xml | 23 +-
tools/extract/interval2maf_pairwise_code.py | 46 --
.../extract/interval_maf_to_merged_fasta.xml | 2 +-
tools/filters/maf/maf_stats_code.py | 35 +-
tools/filters/maf/maf_thread_for_species.xml | 3 +-
.../maf/maf_thread_for_species_code.py | 38 --
tools/regVariation/windowSplitter.xml | 2 +-
19 files changed, 395 insertions(+), 386 deletions(-)
delete mode 100644 tools/data_source/upload_code.py
delete mode 100644 tools/extract/interval2maf_pairwise_code.py
delete mode 100644 tools/filters/maf/maf_thread_for_species_code.py
diff --git a/lib/galaxy/tools/dynamic_options.py b/lib/galaxy/tools/dynamic_options.py
index 6ebee9e2362..0d847365f92 100644
--- a/lib/galaxy/tools/dynamic_options.py
+++ b/lib/galaxy/tools/dynamic_options.py
@@ -6,6 +6,7 @@ log = logging.getLogger(__name__)
class DynamicOptions( object ):
"""Handles dynamically generated SelectToolParameter options"""
def __init__( self, elem ):
+ self.from_file_data = None
# FIXME: Pushing these things in as options ends up being pretty ugly.
# We should find a way to make this work through the validation mechanism.
self.no_data_option = [ ( 'No data available for this build', 'None', True ) ]
@@ -23,28 +24,20 @@ class DynamicOptions( object ):
except:
self.data_file = self.from_file
else: self.data_file = None
- if elem.tag == 'select_options':
- self.data_ref = elem.get( 'data_ref', None )
- self.param_ref = elem.get( 'param_ref', None )
- self.func = elem.get( 'func', None )
- assert self.func is not None, "Value for option generator function not found"
- self.func_params = elem.findall( 'func_param' )
- else: #elem.tag =='options'
- self.filters = elem.findall( 'filter' )
- self.data_ref = None
- for filter in self.filters:
- filter_type = filter.get( 'type', None )
- assert filter_type is not None, "Required 'type' attribute missing from filter"
- if filter_type.strip() == 'data_meta':
- self.data_ref = filter.get( 'data_ref', None )
- assert self.data_ref is not None, "Required 'data_ref' attribute missing from 'data_meta' filter"
- self.data_ref = self.data_ref.strip()
- elif filter_type.strip() == 'param_meta':
- self.param_ref = filter.get( 'param_ref', None )
- assert self.param_ref is not None, "Required 'param_ref' attribute missing from 'param_meta' filter"
- self.param_ref = self.param_ref.strip()
- #FIXME: this attr is used only by microbial import, so shouldn't be at this level
- self.microbe_info = None
+ self.tool_type = elem.get( 'tool_type', None )
+ self.filters = elem.findall( 'filter' )
+ self.data_ref = None
+ for filter in self.filters:
+ filter_type = filter.get( 'type', None )
+ assert filter_type is not None, "Required 'type' attribute missing from filter"
+ if filter_type.strip() == 'data_meta':
+ self.data_ref = filter.get( 'data_ref', None )
+ assert self.data_ref is not None, "Required 'data_ref' attribute missing from 'data_meta' filter"
+ self.data_ref = self.data_ref.strip()
+ elif filter_type.strip() == 'param_meta':
+ self.param_ref = filter.get( 'param_ref', None )
+ assert self.param_ref is not None, "Required 'param_ref' attribute missing from 'param_meta' filter"
+ self.param_ref = self.param_ref.strip()
def get_dataset( self, trans, other_values ):
# No value indicates a configuration error, the named DataToolParameter must preceed this parameter in the tool config
assert self.data_ref in other_values, "Value for associated DataToolParameter not found"
@@ -56,14 +49,18 @@ class DynamicOptions( object ):
# Currently dynamically generated select lists do not work well with optional datasets.
return None
return dataset
- def get_param_value( self, trans, other_values ):
+ def get_param_value( self, param, trans, other_values ):
+ if param is None: return None
+ assert param in other_values, "Value for associated param_value %s not found" %param
+ return other_values[ param ]
+ def get_param_ref_value( self, trans, other_values ):
if self.param_ref is None: return None
- assert self.param_ref in other_values, "Value for associated parameter %s not found" %self.param_ref.name
+ assert self.param_ref in other_values, "Value for associated param_ref %s not found" %self.param_ref.name
return other_values[ self.param_ref ]
def get_unique_elems( self, elems ):
seen = set()
return [ x for x in elems if x not in seen and not seen.add( x ) ]
- def get_options( self, trans, other_values, must_be_valid = False ):
+ def get_options( self, trans, other_values, must_be_valid=False ):
filters = {}
key = None
# Check for filters and build a dictionary from them
@@ -84,7 +81,6 @@ class DynamicOptions( object ):
if key == 'build': value = dataset.get_dbkey()
elif key == 'file_name': value = dataset.get_file_name()
elif key == 'species': value = dataset.metadata.species
- elif key == 'maf': pass # value does not need to be set, maf tools require special handling - see below
filters[ 'data_meta' ][ 'value' ] = value
if self.data_file == 'maf_index.loc' and key == 'build' and value == '?':
if must_be_valid: return []
@@ -94,8 +90,20 @@ class DynamicOptions( object ):
key = filter.get( 'key', None )
assert key is not None, "key attribute missing from param_meta filter"
filters[ 'param_meta' ][ 'key' ] = key.strip()
- value = self.get_param_value( trans, other_values )
+ value = self.get_param_ref_value( trans, other_values )
filters[ 'param_meta' ][ 'value' ] = value
+ elif filter_type == 'param_value':
+ n = filter.get( 'name', None )
+ assert n is not None, "param_value filters require a 'name' attribute"
+ n = n.strip()
+ v = self.get_param_value( n, trans, other_values )
+ assert v is not None, "param_value filters require a 'value' attribute"
+ v = v.strip()
+ try:
+ filters[ 'param_values' ][ n ] = v
+ except:
+ filters[ 'param_values' ] = {}
+ filters[ 'param_values' ][ n ] = v
elif filter_type == 'column':
n = filter.get( 'name', None )
assert n is not None, "column filters require a 'name' attribute"
@@ -109,7 +117,6 @@ class DynamicOptions( object ):
filters[ 'columns' ] = {}
filters[ 'columns' ][ n ] = v
elif filter_type == 'param':
- # TODO: I'm not sure I like the way 'param' filters are implemented, I may be rethinking this approach...
n = filter.get( 'name', None )
assert n is not None, "param filters require a 'name' attribute"
n = n.strip()
@@ -121,14 +128,15 @@ class DynamicOptions( object ):
except:
filters[ 'params' ] = {}
filters[ 'params' ][ n ] = v
- # Now that we've parsed our filters, we need to see if the tool is a maf tool which requires special handling
+ # Now that we've parsed our filters, we need to see if the tool is a maf tool
+ # which requires special handling
try: key = filters[ 'data_meta' ][ 'key' ]
- except: key == None
+ except: key = None
if key == 'maf':
maf_source = filters[ 'params' ][ 'maf_source' ]
if maf_source == 'cached':
maf_uid = filters[ 'param_meta' ][ 'value' ]
- if maf_uid in [None, 'None']:
+ if maf_uid in [ None, 'None' ]:
if must_be_valid: return []
if maf_uid is None: return self.no_data_option
if maf_uid == 'None': return self.build_not_set_option
@@ -137,45 +145,62 @@ class DynamicOptions( object ):
if dataset is None: return self.wait_for_maf_option
filters[ 'data_meta' ][ 'key' ] = 'species'
filters[ 'data_meta' ][ 'value' ] = dataset.metadata.species
- return self.generate_options( filters, must_be_valid = must_be_valid )
- def generate_options( self, filters={}, sep='\t', must_be_valid = False ):
- # Extract the info from the tool's options filters, if any
- try: key = filters[ 'data_meta' ][ 'key' ]
- except: key = None
- try: value = filters[ 'data_meta' ][ 'value' ]
- except: value = None
- if key is None and value is None:
- # Look for param_meta filter
- try: key = filters[ 'param_meta' ][ 'key' ]
- except: key = None
- try: value = filters[ 'param_meta' ][ 'value' ]
- except: value = None
- try: name_col = int( filters[ 'columns' ][ 'name_col' ] )
- except: name_col = None
- try: value_col = int( filters[ 'columns' ][ 'value_col' ] )
- except: value_col = None
- try: encode_group = filters[ 'params' ][ 'encode_group' ]
- except: encode_group = None
- try: build = filters[ 'params' ][ 'build' ]
- except: build = None
- try: maf_source = filters[ 'params' ][ 'maf_source' ]
- except: maf_source = None
-
- # Order of the following conditionals is critical
- if encode_group is not None and build is not None:
- return self.generate_from_file_for_encode( encode_group, build, must_be_valid = must_be_valid )
- elif key == 'species':
- return self.generate_from_dataset_for_species( value )
- elif key == 'maf':
- return self.generate_from_file_for_maf( maf_source, value, must_be_valid = must_be_valid )
- elif key == 'file_name':
- return self.generate_from_dataset( value, value_col )
- elif key == 'build':
- build_col = int( filters[ 'columns' ][ 'build_col' ].strip() )
- return self.generate_from_file_for_build( value, build_col, name_col, value_col, must_be_valid = must_be_valid )
- elif key is None:
- return self.generate_from_file( name_col, value_col )
- def generate_from_file_for_encode( self, encode_group, build, sep='\t', must_be_valid = False ):
+ return self.generate_options( filters, must_be_valid=must_be_valid )
+ def generate_options( self, filters={}, sep='\t', must_be_valid=False ):
+ if self.tool_type == 'upload':
+ return self.generate_from_datatypes_registry()
+ elif self.tool_type == 'encode':
+ encode_group = filters[ 'params' ][ 'encode_group' ]
+ build = filters[ 'params' ][ 'build' ]
+ return self.generate_from_file_for_encode( encode_group, build, must_be_valid=must_be_valid )
+ elif self.tool_type == 'microbial':
+ if self.from_file_data is None: self.load_microbial_data()
+ try: kingdom = filters[ 'param_values' ][ 'kingdom' ]
+ except: kingdom = None
+ try: org = filters[ 'param_values' ][ 'org' ]
+ except: org = None
+ try: feature = filters[ 'params' ][ 'feature' ]
+ except: feature = None
+ return self.generate_from_file_for_microbial( kingdom, org, feature, must_be_valid=must_be_valid )
+ else: # self.tool_type is None
+ try: key = filters[ 'data_meta' ][ 'key' ]
+ except:
+ try: key = filters[ 'param_meta' ][ 'key' ]
+ except: key = None
+ if key == 'species':
+ value = filters[ 'data_meta' ][ 'value' ]
+ return self.generate_from_dataset_for_species( value )
+ elif key == 'maf':
+ maf_source = filters[ 'params' ][ 'maf_source' ]
+ try: value = filters[ 'data_meta' ][ 'value' ]
+ except: value = filters[ 'param_meta' ][ 'value' ]
+ return self.generate_from_file_for_maf( maf_source, value, must_be_valid=must_be_valid )
+ elif key == 'file_name':
+ value = filters[ 'data_meta' ][ 'value' ]
+ value_col = int( filters[ 'columns' ][ 'value_col' ] )
+ return self.generate_from_dataset( value, value_col )
+ elif key == 'build':
+ value = filters[ 'data_meta' ][ 'value' ]
+ build_col = int( filters[ 'columns' ][ 'build_col' ].strip() )
+ name_col = int( filters[ 'columns' ][ 'name_col' ] )
+ value_col = int( filters[ 'columns' ][ 'value_col' ] )
+ return self.generate_from_file_for_build( value, build_col, name_col, value_col, must_be_valid=must_be_valid )
+ else: # key is None
+ name_col = int( filters[ 'columns' ][ 'name_col' ] )
+ value_col = int( filters[ 'columns' ][ 'value_col' ] )
+ return self.generate_from_file( name_col, value_col )
+ def generate_from_datatypes_registry( self ):
+ from galaxy.datatypes import registry
+ datatypes_registry = registry.Registry()
+ options = []
+ formats = datatypes_registry.datatypes_by_extension.keys()
+ formats.sort()
+ options.append( ( 'Auto-detect', 'auto', True ) )
+ for format in formats:
+ label = format.capitalize()
+ options.append( ( label, format, False ) )
+ return options
+ def generate_from_file_for_encode( self, encode_group, build, sep='\t', must_be_valid=False ):
options = []
def generate():
encode_sets = {}
@@ -253,12 +278,121 @@ class DynamicOptions( object ):
if must_be_valid: return []
return self.no_data_option_not_selected
return options
+ def generate_from_file_for_microbial( self, kingdom=None, org=None, feature=None, must_be_valid=False ):
+ options = []
+ if not kingdom and not org and not feature:
+ kingdoms = self.from_file_data.keys()
+ kingdoms.sort()
+ for kingdom in kingdoms:
+ options.append( ( kingdom, kingdom, False ) )
+ if options:
+ options[0] = ( options[0][0], options[0][1], True )
+ elif kingdom and not org and not feature:
+ orgs = self.from_file_data[ kingdom ].keys()
+ #need to sort by name
+ swap_test = False
+ for i in range( 0, len( orgs ) - 1 ):
+ for j in range( 0, len( orgs ) - i - 1 ):
+ if self.from_file_data[ kingdom ][ orgs[ j ] ][ 'name' ] > self.from_file_data[ kingdom ][ orgs[ j + 1 ] ][ 'name' ]:
+ orgs[ j ], orgs[ j + 1 ] = orgs[ j + 1 ], orgs[ j ]
+ swap_test = True
+ if swap_test == False: break
+ for org in orgs:
+ if self.from_file_data[ kingdom ][ org ][ 'link_site' ] == "UCSC":
+ options.append( ( "" + self.from_file_data[ kingdom ][ org ][ 'name' ] + " (about)", org, False ) )
+ else:
+ options.append( ( self.from_file_data[ kingdom ][ org ][ 'name' ] + " (about)", org, False ) )
+ if options:
+ options[0] = ( options[0][0], options[0][1], True)
+ else:
+ chroms = self.from_file_data[ kingdom ][ org ][ 'chrs' ].keys()
+ chroms.sort()
+ for chr in chroms:
+ for data in self.from_file_data[ kingdom ][ org ][ 'chrs' ][ chr ][ 'data' ]:
+ if self.from_file_data[ kingdom ][ org ][ 'chrs' ][ chr ][ 'data' ][ data ][ 'feature' ] == feature:
+ options.append( ( self.from_file_data[ kingdom ][ org ][ 'chrs' ][ chr ][ 'name' ] + " (about)", data, False ) )
+ return options
+ def load_microbial_data( self, sep='\t' ):
+ microbe_info= {}
+ orgs = {}
+ for line in open( self.from_file ):
+ line = line.rstrip( '\r\n' )
+ if line and not line.startswith( '#' ):
+ fields = line.split( sep )
+ #read each line, if not enough fields, go to next line
+ try:
+ info_type = fields.pop(0)
+ if info_type.upper() == "ORG":
+ #ORG 12521 Clostridium perfringens SM101 bacteria Firmicutes CP000312,CP000313,CP000314,CP000315 http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=genomeprj&cmd=Retrieve&dopt=Overview&list_uids=12521
+ org_num = fields.pop(0)
+ name = fields.pop(0)
+ kingdom = fields.pop(0)
+ group = fields.pop(0)
+ chromosomes = fields.pop(0)
+ info_url = fields.pop(0)
+ link_site = fields.pop(0)
+ if org_num not in orgs:
+ orgs[ org_num ] = {}
+ orgs[ org_num ][ 'chrs' ] = {}
+ orgs[ org_num ][ 'name' ] = name
+ orgs[ org_num ][ 'kingdom' ] = kingdom
+ orgs[ org_num ][ 'group' ] = group
+ orgs[ org_num ][ 'chromosomes' ] = chromosomes
+ orgs[ org_num ][ 'info_url' ] = info_url
+ orgs[ org_num ][ 'link_site' ] = link_site
+ elif info_type.upper() == "CHR":
+ #CHR 12521 CP000315 Clostridium perfringens phage phiSM101, complete genome 38092 110684521 CP000315.1
+ org_num = fields.pop(0)
+ chr_acc = fields.pop(0)
+ name = fields.pop(0)
+ length = fields.pop(0)
+ gi = fields.pop(0)
+ gb = fields.pop(0)
+ info_url = fields.pop(0)
+ chr = {}
+ chr[ 'name' ] = name
+ chr[ 'length' ] = length
+ chr[ 'gi' ] = gi
+ chr[ 'gb' ] = gb
+ chr[ 'info_url' ] = info_url
+ if org_num not in orgs:
+ orgs[ org_num ] = {}
+ orgs[ org_num ][ 'chrs' ] = {}
+ orgs[ org_num ][ 'chrs' ][ chr_acc ] = chr
+ elif info_type.upper() == "DATA":
+ #DATA 12521_12521_CDS 12521 CP000315 CDS bed /home/djb396/alignments/playground/bacteria/12521/CP000315.CDS.bed
+ uid = fields.pop(0)
+ org_num = fields.pop(0)
+ chr_acc = fields.pop(0)
+ feature = fields.pop(0)
+ filetype = fields.pop(0)
+ path = fields.pop(0)
+ data = {}
+ data[ 'filetype' ] = filetype
+ data[ 'path' ] = path
+ data[ 'feature' ] = feature
+
+ if org_num not in orgs:
+ orgs[ org_num ] = {}
+ orgs[ org_num ][ 'chrs' ] = {}
+ if 'data' not in orgs[ org_num ][ 'chrs' ][ chr_acc ]:
+ orgs[ org_num ][ 'chrs' ][ chr_acc ][ 'data' ] = {}
+ orgs[ org_num ][ 'chrs' ][ chr_acc ][ 'data' ][ uid ] = data
+ else: continue
+ except: continue
+ for org_num in orgs:
+ org = orgs[ org_num ]
+ if org[ 'kingdom' ] not in microbe_info:
+ microbe_info[ org[ 'kingdom' ] ] = {}
+ if org_num not in microbe_info[ org[ 'kingdom' ] ]:
+ microbe_info[ org[ 'kingdom' ] ][org_num] = org
+ self.from_file_data = microbe_info
def generate_from_dataset_for_species( self, value ):
options = []
for species in value:
options.append( ( species, species, False ) )
return options
- def generate_from_file_for_maf( self, maf_source, maf_uid, sep='\t', must_be_valid = False ):
+ def generate_from_file_for_maf( self, maf_source, maf_uid, sep='\t', must_be_valid=False ):
options = []
d = {}
# We will only reach here if the maf-source param value is 'cached'
@@ -285,7 +419,7 @@ class DynamicOptions( object ):
if must_be_valid: return []
return self.no_data_option
return options
- def generate_from_dataset( self, value, value_col, sep='\t', must_be_valid = False ):
+ def generate_from_dataset( self, value, value_col, sep='\t', must_be_valid=False ):
options = []
elem_list = []
try: in_file = open( value, "r" )
@@ -307,7 +441,7 @@ class DynamicOptions( object ):
for elem in elem_list:
options.append( ( elem, elem, False ) )
return options
- def generate_from_file_for_build( self, value, build_col, name_col, value_col, sep='\t', must_be_valid = False ):
+ def generate_from_file_for_build( self, value, build_col, name_col, value_col, sep='\t', must_be_valid=False ):
options = []
d = {}
for line in open( self.from_file ):
@@ -330,7 +464,7 @@ class DynamicOptions( object ):
if not fields[ build_col ] in d:
d[ fields[ build_col ] ] = []
d[ fields[ build_col ] ].append( (fields[ name_col ], fields[ value_col ]) )
- elif self.data_file == 'maf_index.loc':
+ elif self.data_file == 'maf_index.loc' or self.data_file == 'maf_pairwise.loc':
try:
maf_desc = fields[ name_col ] # ENCODE TBA (hg17)
maf_uid = fields[ value_col ] # ENCODE_TBA_hg17
@@ -359,7 +493,7 @@ class DynamicOptions( object ):
if value in d:
for (key, val) in d[ value ]:
options.append( ( key, val, False ) )
- elif self.data_file == 'maf_index.loc':
+ elif self.data_file == 'maf_index.loc' or self.data_file == 'maf_pairwise.loc':
for key in d:
if value in d[ key ][ 'builds' ]:
options.append( ( d[ key ][ 'description' ], key, False ) )
@@ -379,131 +513,3 @@ class DynamicOptions( object ):
# TODO: this option list should be sorted
options.append( ( fields[ name_col ], fields[ value_col ], False ) )
return options
- def load_from_file_for_microbial( self ):
- self.from_file = "/depot/data2/galaxy/microbes/microbial_data.loc"
- microbe_info= {}
- orgs = {}
- for line in open( self.from_file ):
- line = line.rstrip( '\r\n' )
- if line and not line.startswith( '#' ):
- fields = line.split( '\t' )
- #read each line, if not enough fields, go to next line
- try:
- info_type = fields.pop(0)
- if info_type.upper() == "ORG":
- #ORG 12521 Clostridium perfringens SM101 bacteria Firmicutes CP000312,CP000313,CP000314,CP000315 http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=genomeprj&cmd=Retrieve&dopt=Overview&list_uids=12521
- org_num = fields.pop(0)
- name = fields.pop(0)
- kingdom = fields.pop(0)
- group = fields.pop(0)
- chromosomes = fields.pop(0)
- info_url = fields.pop(0)
- link_site = fields.pop(0)
- if org_num not in orgs:
- orgs[org_num] = {}
- orgs[org_num]['chrs'] = {}
- orgs[org_num]['name'] = name
- orgs[org_num]['kingdom'] = kingdom
- orgs[org_num]['group'] = group
- orgs[org_num]['chromosomes'] = chromosomes
- orgs[org_num]['info_url'] = info_url
- orgs[org_num]['link_site'] = link_site
- elif info_type.upper() == "CHR":
- #CHR 12521 CP000315 Clostridium perfringens phage phiSM101, complete genome 38092 110684521 CP000315.1
- org_num = fields.pop(0)
- chr_acc = fields.pop(0)
- name = fields.pop(0)
- length = fields.pop(0)
- gi = fields.pop(0)
- gb = fields.pop(0)
- info_url = fields.pop(0)
- chr = {}
- chr['name'] = name
- chr['length'] = length
- chr['gi'] = gi
- chr['gb'] = gb
- chr['info_url'] = info_url
- if org_num not in orgs:
- orgs[org_num] = {}
- orgs[org_num]['chrs'] = {}
- orgs[org_num]['chrs'][chr_acc] = chr
- elif info_type.upper() == "DATA":
- #DATA 12521_12521_CDS 12521 CP000315 CDS bed /home/djb396/alignments/playground/bacteria/12521/CP000315.CDS.bed
- uid = fields.pop(0)
- org_num = fields.pop(0)
- chr_acc = fields.pop(0)
- feature = fields.pop(0)
- filetype = fields.pop(0)
- path = fields.pop(0)
- data = {}
- data['filetype'] = filetype
- data['path'] = path
- data['feature'] = feature
-
- if org_num not in orgs:
- orgs[org_num] = {}
- orgs[org_num]['chrs'] = {}
- if 'data' not in orgs[org_num]['chrs'][chr_acc]:
- orgs[org_num]['chrs'][chr_acc]['data'] = {}
- orgs[org_num]['chrs'][chr_acc]['data'][uid] = data
- else: continue
- except: continue
- for org_num in orgs:
- org = orgs[org_num]
- if org['kingdom'] not in microbe_info:
- microbe_info[org['kingdom']] = {}
- if org_num not in microbe_info[org['kingdom']]:
- microbe_info[org['kingdom']][org_num] = org
- self.microbe_info = microbe_info
- def get_options_for_kingdoms( self, trans, other_values ):
- if self.microbe_info == None: self.load_from_file_for_microbial()
- options = []
- kingdoms = self.microbe_info.keys()
- kingdoms.sort()
- for kingdom in kingdoms:
- options.append( (kingdom, kingdom, False) )
- if options:
- options[0] = ( options[0][0], options[0][1], True)
- return options
- def get_options_for_orgs_by_kingdom( self, trans, other_values ):
- if self.microbe_info == None: self.load_from_file_for_microbial()
- options = []
- for func_param in self.func_params:
- if func_param.get( 'name' ) == 'kingdom':
- kingdom = other_values[ func_param.get( 'value' ) ]
- orgs = self.microbe_info[kingdom].keys()
- #need to sort by name
- swap_test = False
- for i in range( 0, len(orgs) - 1 ):
- for j in range( 0, len(orgs) - i - 1 ):
- if self.microbe_info[kingdom][orgs[j]]['name'] > self.microbe_info[kingdom][orgs[j + 1]]['name']:
- orgs[j], orgs[j + 1] = orgs[j + 1], orgs[j]
- swap_test = True
- if swap_test == False: break
- for org in orgs:
- if self.microbe_info[kingdom][org]['link_site'] == "UCSC":
- options.append( ( "" + self.microbe_info[kingdom][org]['name'] + " (about)", org, False ) )
- else:
- options.append( ( self.microbe_info[kingdom][org]['name'] + " (about)", org, False ) )
- if options:
- options[0] = ( options[0][0], options[0][1], True)
- return options
- def get_options_for_kingdom_org_feature( self, trans, other_values ):
- if self.microbe_info == None: self.load_from_file_for_microbial()
- options = []
- for func_param in self.func_params:
- if func_param.get( 'name' ) == 'kingdom':
- kingdom = other_values[ func_param.get( 'value' ) ]
- elif func_param.get( 'name' ) == 'org':
- org = other_values[ func_param.get( 'value' ) ]
- elif func_param.get( 'name' ) == 'feature':
- feature = func_param.get( 'value' )
- log.debug("kingdom: %s, org: %s, feature: %s" %(kingdom, org, feature))
- chroms = self.microbe_info[kingdom][org]['chrs'].keys()
- chroms.sort()
- for chr in chroms:
- for data in self.microbe_info[kingdom][org]['chrs'][chr]['data']:
- if self.microbe_info[kingdom][org]['chrs'][chr]['data'][data]['feature'] == feature:
- options.append( ( self.microbe_info[kingdom][org]['chrs'][chr]['name'] + " (about)", data, False ) )
- return options
-
diff --git a/lib/galaxy/tools/parameters.py b/lib/galaxy/tools/parameters.py
index 865d9522fdd..721980e2de9 100644
--- a/lib/galaxy/tools/parameters.py
+++ b/lib/galaxy/tools/parameters.py
@@ -407,29 +407,22 @@ class SelectToolParameter( ToolParameter ):
self.separator = elem.get( 'separator', ',' )
self.legal_values = set()
self.dynamic_options = elem.get( "dynamic_options", None )
- select_options = elem.find( 'select_options' )
- if select_options is None:
- self.select_options = None
- else:
- self.select_options = dynamic_options.DynamicOptions( select_options )
options = elem.find( 'options' )
if options is None:
self.options = None
else:
self.options = dynamic_options.DynamicOptions( options )
- if self.dynamic_options is None and self.select_options is None and self.options is None:
+ if self.dynamic_options is None and self.options is None:
self.static_options = list()
for index, option in enumerate( elem.findall( "option" ) ):
value = option.get( "value" )
self.legal_values.add( value )
selected = ( option.get( "selected", None ) == "true" )
self.static_options.append( ( option.text, value, selected ) )
- self.is_dynamic = ( ( self.dynamic_options is not None ) or ( self.select_options is not None ) or ( self.options is not None ) )
+ self.is_dynamic = ( ( self.dynamic_options is not None ) or ( self.options is not None ) )
def get_options( self, trans, other_values ):
if self.options:
return self.options.get_options( trans, other_values )
- elif self.select_options:
- return eval( '''self.select_options.%s( trans, other_values )''' %self.select_options.func )
elif self.dynamic_options:
return eval( self.dynamic_options, self.tool.code_namespace, other_values )
else:
@@ -437,8 +430,6 @@ class SelectToolParameter( ToolParameter ):
def get_legal_values( self, trans, other_values ):
if self.options:
return set( v for _, v, _ in self.options.get_options( trans, other_values, must_be_valid = True ) )
- elif self.select_options:
- return set( v for _, v, _ in eval( '''self.select_options.%s( trans, other_values )''' %self.select_options.func ) )
elif self.dynamic_options:
return set( v for _, v, _ in eval( self.dynamic_options, self.tool.code_namespace, other_values ) )
else:
@@ -519,11 +510,6 @@ class SelectToolParameter( ToolParameter ):
except: pass
try: param_ref = self.options.param_ref
except: pass
- elif self.select_options:
- try: data_ref = self.select_options.data_ref
- except: pass
- try: param_ref = self.select_options.param_ref
- except: pass
if data_ref is None and param_ref is None: return []
elif data_ref is None: return [ param_ref ]
elif param_ref is None: return [ data_ref ]
diff --git a/tools/data_source/encode_import_all_latest_datasets.xml b/tools/data_source/encode_import_all_latest_datasets.xml
index 03f47320780..61731cdeada 100644
--- a/tools/data_source/encode_import_all_latest_datasets.xml
+++ b/tools/data_source/encode_import_all_latest_datasets.xml
@@ -6,13 +6,13 @@
hg16 (most recent datasets in bold)
$hg16
-
+
-
+
diff --git a/tools/data_source/encode_import_chromatin_and_chromosomes.xml b/tools/data_source/encode_import_chromatin_and_chromosomes.xml
index 9985f645c74..4712068e278 100644
--- a/tools/data_source/encode_import_chromatin_and_chromosomes.xml
+++ b/tools/data_source/encode_import_chromatin_and_chromosomes.xml
@@ -6,13 +6,13 @@
hg16 (most recent datasets in bold)
$hg16
-
+
-
+
diff --git a/tools/data_source/encode_import_gencode.xml b/tools/data_source/encode_import_gencode.xml
index 9b64d3cc55b..f31b5617e48 100644
--- a/tools/data_source/encode_import_gencode.xml
+++ b/tools/data_source/encode_import_gencode.xml
@@ -6,13 +6,13 @@
hg16 (most recent datasets in bold)
$hg16
-
+
-
+
diff --git a/tools/data_source/encode_import_genes_and_transcripts.xml b/tools/data_source/encode_import_genes_and_transcripts.xml
index d93740d1c71..a5a493fd898 100644
--- a/tools/data_source/encode_import_genes_and_transcripts.xml
+++ b/tools/data_source/encode_import_genes_and_transcripts.xml
@@ -6,13 +6,13 @@
hg16 (most recent datasets in bold)
$hg16
-
+
-
+
diff --git a/tools/data_source/encode_import_multi-species_sequence_analysis.xml b/tools/data_source/encode_import_multi-species_sequence_analysis.xml
index d6cbed08adf..982fc564d3b 100644
--- a/tools/data_source/encode_import_multi-species_sequence_analysis.xml
+++ b/tools/data_source/encode_import_multi-species_sequence_analysis.xml
@@ -6,13 +6,13 @@
hg16 (most recent datasets in bold)
$hg16
-
+
-
+
diff --git a/tools/data_source/encode_import_transcription_regulation.xml b/tools/data_source/encode_import_transcription_regulation.xml
index 83dceedd494..26db457e369 100644
--- a/tools/data_source/encode_import_transcription_regulation.xml
+++ b/tools/data_source/encode_import_transcription_regulation.xml
@@ -6,13 +6,13 @@
hg16 (most recent datasets in bold)
$hg16
-
+
-
+
diff --git a/tools/data_source/microbial_import.xml b/tools/data_source/microbial_import.xml
index 4dc76e95c54..9b67a4b7f74 100644
--- a/tools/data_source/microbial_import.xml
+++ b/tools/data_source/microbial_import.xml
@@ -6,7 +6,7 @@
Select the Desired Kingdom
$kingdom
-
+
@@ -14,9 +14,9 @@
Select the Desired Organism
$org
-
-
-
+
+
+
@@ -30,53 +30,53 @@
Select Desired Glimmer3 Annotations
$Glimmer3
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
diff --git a/tools/data_source/microbial_import_code.py b/tools/data_source/microbial_import_code.py
index bbdd0b878a5..f5a211dd9be 100644
--- a/tools/data_source/microbial_import_code.py
+++ b/tools/data_source/microbial_import_code.py
@@ -1,7 +1,86 @@
+def load_microbial_data( sep='\t' ):
+ # FIXME: this function is duplicated in the DynamicOptions class. It is used here only to
+ # set data.name in exec_after_process().
+ microbe_info= {}
+ orgs = {}
+ for line in open( "/depot/data2/galaxy/microbes/microbial_data.loc" ):
+ line = line.rstrip( '\r\n' )
+ if line and not line.startswith( '#' ):
+ fields = line.split( sep )
+ #read each line, if not enough fields, go to next line
+ try:
+ info_type = fields.pop(0)
+ if info_type.upper() == "ORG":
+ #ORG 12521 Clostridium perfringens SM101 bacteria Firmicutes CP000312,CP000313,CP000314,CP000315 http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=genomeprj&cmd=Retrieve&dopt=Overview&list_uids=12521
+ org_num = fields.pop(0)
+ name = fields.pop(0)
+ kingdom = fields.pop(0)
+ group = fields.pop(0)
+ chromosomes = fields.pop(0)
+ info_url = fields.pop(0)
+ link_site = fields.pop(0)
+ if org_num not in orgs:
+ orgs[ org_num ] = {}
+ orgs[ org_num ][ 'chrs' ] = {}
+ orgs[ org_num ][ 'name' ] = name
+ orgs[ org_num ][ 'kingdom' ] = kingdom
+ orgs[ org_num ][ 'group' ] = group
+ orgs[ org_num ][ 'chromosomes' ] = chromosomes
+ orgs[ org_num ][ 'info_url' ] = info_url
+ orgs[ org_num ][ 'link_site' ] = link_site
+ elif info_type.upper() == "CHR":
+ #CHR 12521 CP000315 Clostridium perfringens phage phiSM101, complete genome 38092 110684521 CP000315.1
+ org_num = fields.pop(0)
+ chr_acc = fields.pop(0)
+ name = fields.pop(0)
+ length = fields.pop(0)
+ gi = fields.pop(0)
+ gb = fields.pop(0)
+ info_url = fields.pop(0)
+ chr = {}
+ chr[ 'name' ] = name
+ chr[ 'length' ] = length
+ chr[ 'gi' ] = gi
+ chr[ 'gb' ] = gb
+ chr[ 'info_url' ] = info_url
+ if org_num not in orgs:
+ orgs[ org_num ] = {}
+ orgs[ org_num ][ 'chrs' ] = {}
+ orgs[ org_num ][ 'chrs' ][ chr_acc ] = chr
+ elif info_type.upper() == "DATA":
+ #DATA 12521_12521_CDS 12521 CP000315 CDS bed /home/djb396/alignments/playground/bacteria/12521/CP000315.CDS.bed
+ uid = fields.pop(0)
+ org_num = fields.pop(0)
+ chr_acc = fields.pop(0)
+ feature = fields.pop(0)
+ filetype = fields.pop(0)
+ path = fields.pop(0)
+ data = {}
+ data[ 'filetype' ] = filetype
+ data[ 'path' ] = path
+ data[ 'feature' ] = feature
+
+ if org_num not in orgs:
+ orgs[ org_num ] = {}
+ orgs[ org_num ][ 'chrs' ] = {}
+ if 'data' not in orgs[ org_num ][ 'chrs' ][ chr_acc ]:
+ orgs[ org_num ][ 'chrs' ][ chr_acc ][ 'data' ] = {}
+ orgs[ org_num ][ 'chrs' ][ chr_acc ][ 'data' ][ uid ] = data
+ else: continue
+ except: continue
+ for org_num in orgs:
+ org = orgs[ org_num ]
+ if org[ 'kingdom' ] not in microbe_info:
+ microbe_info[ org[ 'kingdom' ] ] = {}
+ if org_num not in microbe_info[ org[ 'kingdom' ] ]:
+ microbe_info[ org[ 'kingdom' ] ][org_num] = org
+ return microbe_info
+
#post processing, set build for data and add additional data to history
from galaxy import datatypes, config, jobs
from shutil import copyfile
+
def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
history = out_data.items()[0][1].history
if history == None:
@@ -15,6 +94,7 @@ def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr
if not (kingdom or org):
print "Parameters are not available."
+ microbe_info = load_microbial_data()
new_stdout = ""
split_stdout = stdout.split("\n")
basic_name = ""
diff --git a/tools/data_source/upload.xml b/tools/data_source/upload.xml
index e8d46194c12..55f3b5d6d2f 100644
--- a/tools/data_source/upload.xml
+++ b/tools/data_source/upload.xml
@@ -11,8 +11,10 @@
-
-
+
+
+
+
**Auto-detect**
@@ -128,5 +130,4 @@ Any data in tab delimited format (tabular)
Any text file
-
diff --git a/tools/data_source/upload_code.py b/tools/data_source/upload_code.py
deleted file mode 100644
index 245ec44c92e..00000000000
--- a/tools/data_source/upload_code.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from galaxy.datatypes import registry
-
-def get_formats():
- datatypes_registry = registry.Registry()
- options = []
- formats = datatypes_registry.datatypes_by_extension.keys()
- formats.sort()
-
- options.append(('Auto-detect','auto',True))
- for format in formats:
- label = format.capitalize()
- options.append((label,format,False))
- return options
\ No newline at end of file
diff --git a/tools/extract/interval2maf_pairwise.xml b/tools/extract/interval2maf_pairwise.xml
index 38ca12c326f..0f0fb52dd9e 100644
--- a/tools/extract/interval2maf_pairwise.xml
+++ b/tools/extract/interval2maf_pairwise.xml
@@ -2,16 +2,26 @@
given a set of genomic intervals
interval2maf_pairwise.py --dbkey=$dbkey --chromCol=$input1_chromCol --startCol=$input1_startCol --endCol=$input1_endCol --strandCol=$input1_strandCol --mafType=$mafType --interval_file=$input1 --output_file=$out_file1
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
**What it does**
@@ -26,5 +36,4 @@ Here a single interval is superimposed on three MAF blocks. Blocks 1 and 3 are t
.. image:: ../static/images/maf_icons/interval2maf.png
-
diff --git a/tools/extract/interval2maf_pairwise_code.py b/tools/extract/interval2maf_pairwise_code.py
deleted file mode 100644
index c02b3944e96..00000000000
--- a/tools/extract/interval2maf_pairwise_code.py
+++ /dev/null
@@ -1,46 +0,0 @@
-#build list of available data
-import os, sys
-maf_sets = {}
-
-try:
- for line in open( "/depot/data2/galaxy/maf_pairwise.loc" ):
- if line[0:1] == "#" : continue
-
- fields = line.split('\t')
- #read each line, if not enough fields, go to next line
- try:
- maf_desc = fields[0]
- maf_uid = fields[1]
- builds = fields[2]
- build_list =[]
- split_builds = builds.split(",")
- for build in split_builds:
- this_build = build.split("=")[0]
- build_list.append(this_build)
- paths = fields[3].replace("\n","").replace("\r","")
- maf_sets[maf_uid]={}
- maf_sets[maf_uid]['description']=maf_desc
- maf_sets[maf_uid]['builds']=build_list
- except:
- continue
-
-except Exception, exc:
- print >>sys.stdout, 'interval2maf_pairwise_code.py initialization error -> %s' % exc
-
-#return available datasets for group and build, set None option as selected for hg16
-def get_available_data( build ):
- available_sets = []
- for key in maf_sets:
- if build in maf_sets[key]['builds']:
- available_sets.append((maf_sets[key]['description'],key,False))
- if len(available_sets) < 1:
- available_sets.append(('No data available for this build','None',True))
- return available_sets
-
-
-def exec_before_job(app,inp_data, out_data, param_dict, tool):
- for name, data in out_data.items():
- try:
- data.name = data.name + " [" + maf_sets[param_dict['mafType']]['description'] + "]"
- except KeyError:
- data.name = data.name + " [unknown MAF source specified]"
diff --git a/tools/extract/interval_maf_to_merged_fasta.xml b/tools/extract/interval_maf_to_merged_fasta.xml
index e33ac1fc30b..1ebf27489fb 100644
--- a/tools/extract/interval_maf_to_merged_fasta.xml
+++ b/tools/extract/interval_maf_to_merged_fasta.xml
@@ -23,7 +23,7 @@
-
+
diff --git a/tools/filters/maf/maf_stats_code.py b/tools/filters/maf/maf_stats_code.py
index 46ae78996fb..2a6c233d322 100644
--- a/tools/filters/maf/maf_stats_code.py
+++ b/tools/filters/maf/maf_stats_code.py
@@ -1,12 +1,37 @@
-def exec_before_job(app, inp_data, out_data, param_dict, tool):
+def load_maf_data( sep='\t' ):
+ # FIXME: this function is duplicated in the DynamicOptions class. It is used here only to
+ # set data.name in exec_before_job().
maf_sets = {}
- if param_dict['maf_source_type']['maf_source'] == "cached":
+ for line in open( "/depot/data2/galaxy/maf_index.loc" ):
+ line = line.rstrip( '\r\n' )
+ if line and not line.startswith( '#' ):
+ fields = line.split( sep )
+ #read each line, if not enough fields, go to next line
+ try:
+ maf_desc = fields[0]
+ maf_uid = fields[1]
+ builds = fields[2]
+ build_list =[]
+ split_builds = builds.split( "," )
+ for build in split_builds:
+ this_build = build.split( "=" )[0]
+ build_list.append( this_build )
+ paths = fields[3]
+ maf_sets[ maf_uid ] = {}
+ maf_sets[ maf_uid ][ 'description' ] = maf_desc
+ maf_sets[ maf_uid ][ 'builds' ] = build_list
+ except:
+ continue
+ return maf_sets
+def exec_before_job(app, inp_data, out_data, param_dict, tool):
+ maf_sets = load_maf_data()
+ if param_dict[ 'maf_source_type' ][ 'maf_source' ] == "cached":
for name, data in out_data.items():
try:
- data.name = data.name + " [" + maf_sets[str(param_dict['maf_source_type']['mafType'])]['description'] + "]"
+ data.name = data.name + " [" + maf_sets[ str( param_dict[ 'maf_source_type' ][ 'mafType' ] ) ][ 'description' ] + "]"
except KeyError:
data.name = data.name + " [unknown MAF source specified]"
- if param_dict['summary'].lower() == "true":
+ if param_dict[ 'summary' ].lower() == "true":
for name, data in out_data.items():
- data.change_datatype('tabular')
+ data.change_datatype( 'tabular' )
diff --git a/tools/filters/maf/maf_thread_for_species.xml b/tools/filters/maf/maf_thread_for_species.xml
index dc31122722b..3b39038156c 100644
--- a/tools/filters/maf/maf_thread_for_species.xml
+++ b/tools/filters/maf/maf_thread_for_species.xml
@@ -50,7 +50,6 @@ results in::
-
-
+
diff --git a/tools/filters/maf/maf_thread_for_species_code.py b/tools/filters/maf/maf_thread_for_species_code.py
deleted file mode 100644
index fe414c098ce..00000000000
--- a/tools/filters/maf/maf_thread_for_species_code.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import pkg_resources; pkg_resources.require( "bx-python" )
-from bx.align import maf
-# No initialization required.
-
-#return lists of species available, showing gapped and ungapped base counts
-def get_available_species( input_filename ):
- try:
- rval = []
- species={}
-
- file_in = open(input_filename, 'r')
- try:
- maf_reader = maf.Reader( file_in )
-
- for i, m in enumerate( maf_reader ):
- l = m.components
- for c in l:
- spec,chrom = maf.src_split( c.src )
- if not spec or not chrom:
- spec = chrom = c.src
- if spec not in species:
- species[spec]={"bases":0,"nongaps":0}
- species[spec]["bases"] = species[spec]["bases"] + c.size + c.text.count("-")
- species[spec]["nongaps"] = species[spec]["nongaps"] + c.size
-
- file_in.close()
- except:
- return [("There is a problem with your MAF file",'None',True)]
- species_names = species.keys()
- species_names.sort()
-
- for spec in species_names:
- display = "%s: %i nongap, %i total bases" % (spec, species[spec]["nongaps"], species[spec]["bases"] )
- rval.append( ( display,spec,True) )
-
- return rval
- except:
- return [("You must wait for the MAF file to be created before you can merge MAF blocks by species.",'None',True)]
diff --git a/tools/regVariation/windowSplitter.xml b/tools/regVariation/windowSplitter.xml
index f9322a23ce8..60aa7a51024 100644
--- a/tools/regVariation/windowSplitter.xml
+++ b/tools/regVariation/windowSplitter.xml
@@ -2,7 +2,7 @@
windowSplitter.py $input $size $out_file1 ${wintype.choice} ${wintype.offset} -l $input_chromCol,$input_startCol,$input_endCol,$input_strandCol
-
+