mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Prevent make_html_table() datatype methods from raising Exceptions
This was preventing the browse of a data library which contained a purged dataset of gg datatype. Also fix import order and Python3 compatibility.
This commit is contained in:
@@ -53,8 +53,10 @@ lib/galaxy/datatypes/dataproviders/__init__.py
|
||||
lib/galaxy/datatypes/data.py
|
||||
lib/galaxy/datatypes/display_applications/__init__.py
|
||||
lib/galaxy/datatypes/display_applications/util.py
|
||||
lib/galaxy/datatypes/genetics.py
|
||||
lib/galaxy/datatypes/images.py
|
||||
lib/galaxy/datatypes/__init__.py
|
||||
lib/galaxy/datatypes/interval.py
|
||||
lib/galaxy/datatypes/metadata.py
|
||||
lib/galaxy/datatypes/msa.py
|
||||
lib/galaxy/datatypes/ngsindex.py
|
||||
|
||||
@@ -13,7 +13,9 @@ lib/galaxy/datatypes/constructive_solid_geometry.py
|
||||
lib/galaxy/datatypes/converters/
|
||||
lib/galaxy/datatypes/dataproviders/
|
||||
lib/galaxy/datatypes/data.py
|
||||
lib/galaxy/datatypes/genetics.py
|
||||
lib/galaxy/datatypes/images.py
|
||||
lib/galaxy/datatypes/interval.py
|
||||
lib/galaxy/datatypes/msa.py
|
||||
lib/galaxy/datatypes/ngsindex.py
|
||||
lib/galaxy/datatypes/proteomics.py
|
||||
|
||||
@@ -11,18 +11,18 @@ subsequent row values are all numeric ! Will fail if any non numeric (eg '+' or
|
||||
ross lazarus for rgenetics
|
||||
august 20 2007
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import urllib
|
||||
from cgi import escape
|
||||
|
||||
from six.moves.urllib.parse import quote_plus
|
||||
|
||||
from galaxy.datatypes import metadata
|
||||
from galaxy.datatypes.text import Html
|
||||
from galaxy.datatypes.metadata import MetadataElement
|
||||
from galaxy.datatypes.tabular import Tabular
|
||||
from galaxy.datatypes.text import Html
|
||||
from galaxy.util import nice_size
|
||||
from galaxy.web import url_for
|
||||
|
||||
@@ -95,9 +95,9 @@ class GenomeGraphs( Tabular ):
|
||||
action='display_at',
|
||||
filename='ucsc_' + site_name )
|
||||
display_url = "%s%s/display_as?id=%i&display_app=%s&authz_method=display_at" % (base_url, url_for( controller='root' ), dataset.id, type)
|
||||
display_url = urllib.quote_plus( display_url )
|
||||
# was display_url = urllib.quote_plus( "%s/display_as?id=%i&display_app=%s" % (base_url, dataset.id, type) )
|
||||
# redirect_url = urllib.quote_plus( "%sdb=%s&position=%s:%s-%s&hgt.customText=%%s" % (site_url, dataset.dbkey, chrom, start, stop) )
|
||||
display_url = quote_plus( display_url )
|
||||
# was display_url = quote_plus( "%s/display_as?id=%i&display_app=%s" % (base_url, dataset.id, type) )
|
||||
# redirect_url = quote_plus( "%sdb=%s&position=%s:%s-%s&hgt.customText=%%s" % (site_url, dataset.dbkey, chrom, start, stop) )
|
||||
sl = ["%sdb=%s" % (site_url, dataset.dbkey ), ]
|
||||
# sl.append("&hgt.customText=%s")
|
||||
sl.append("&hgGenome_dataSetName=%s&hgGenome_dataSetDescription=%s" % (dataset.name, 'GalaxyGG_data'))
|
||||
@@ -106,7 +106,7 @@ class GenomeGraphs( Tabular ):
|
||||
sl.append("&hgGenome_doSubmitUpload=submit")
|
||||
sl.append("&hgGenome_maxGapToFill=25000000&hgGenome_uploadFile=%s" % display_url)
|
||||
s = ''.join(sl)
|
||||
s = urllib.quote_plus(s)
|
||||
s = quote_plus(s)
|
||||
redirect_url = s
|
||||
link = '%s?redirect_url=%s&display_url=%s' % ( internal_url, redirect_url, display_url )
|
||||
ret_val.append( (site_name, link) )
|
||||
@@ -117,17 +117,17 @@ class GenomeGraphs( Tabular ):
|
||||
Create HTML table, used for displaying peek
|
||||
"""
|
||||
out = ['<table cellspacing="0" cellpadding="3">']
|
||||
f = open(dataset.file_name, 'r')
|
||||
d = f.readlines()[:5]
|
||||
if len(d) == 0:
|
||||
out = "Cannot find anything to parse in %s" % dataset.name
|
||||
return out
|
||||
hasheader = 0
|
||||
try:
|
||||
['%f' % x for x in d[0][1:]] # first is name - see if starts all numerics
|
||||
except:
|
||||
hasheader = 1
|
||||
try:
|
||||
with open(dataset.file_name, 'r') as f:
|
||||
d = f.readlines()[:5]
|
||||
if len(d) == 0:
|
||||
out = "Cannot find anything to parse in %s" % dataset.name
|
||||
return out
|
||||
hasheader = 0
|
||||
try:
|
||||
['%f' % x for x in d[0][1:]] # first is name - see if starts all numerics
|
||||
except:
|
||||
hasheader = 1
|
||||
# Generate column header
|
||||
out.append( '<tr>' )
|
||||
if hasheader:
|
||||
@@ -150,16 +150,16 @@ class GenomeGraphs( Tabular ):
|
||||
Validate a gg file - all numeric after header row
|
||||
"""
|
||||
errors = list()
|
||||
infile = open(dataset.file_name, "r")
|
||||
infile.next() # header
|
||||
for i, row in enumerate(infile):
|
||||
ll = row.strip().split('\t')[1:] # first is alpha feature identifier
|
||||
badvals = []
|
||||
for j, x in enumerate(ll):
|
||||
try:
|
||||
x = float(x)
|
||||
except:
|
||||
badvals.append('col%d:%s' % (j + 1, x))
|
||||
with open(dataset.file_name, "r") as infile:
|
||||
next(infile) # header
|
||||
for i, row in enumerate(infile):
|
||||
ll = row.strip().split('\t')[1:] # first is alpha feature identifier
|
||||
badvals = []
|
||||
for j, x in enumerate(ll):
|
||||
try:
|
||||
x = float(x)
|
||||
except:
|
||||
badvals.append('col%d:%s' % (j + 1, x))
|
||||
if len(badvals) > 0:
|
||||
errors.append('row %d, %s' % (' '.join(badvals)))
|
||||
return errors
|
||||
@@ -219,7 +219,7 @@ class rgTabList(Tabular):
|
||||
|
||||
def display_peek( self, dataset ):
|
||||
"""Returns formated html of peek"""
|
||||
return Tabular.make_html_table( self, dataset, column_names=self.column_names )
|
||||
return self.make_html_table( dataset, column_names=self.column_names )
|
||||
|
||||
def get_mime(self):
|
||||
"""Returns the mime type of the datatype"""
|
||||
@@ -246,8 +246,8 @@ class rgSampleList(rgTabList):
|
||||
# this is what Plink wants as at 2009
|
||||
|
||||
def sniff(self, filename):
|
||||
infile = open(filename, "r")
|
||||
header = infile.next() # header
|
||||
with open(filename, "r") as infile:
|
||||
header = next(infile) # header
|
||||
if header[0] == 'FID' and header[1] == 'IID':
|
||||
return True
|
||||
else:
|
||||
@@ -287,7 +287,7 @@ class Rgenetics(Html):
|
||||
def generate_primary_file( self, dataset=None ):
|
||||
rval = ['<html><head><title>Rgenetics Galaxy Composite Dataset </title></head><p/>']
|
||||
rval.append('<div>This composite dataset is composed of the following files:<p/><ul>')
|
||||
for composite_name, composite_file in self.get_composite_files( dataset=dataset ).iteritems():
|
||||
for composite_name, composite_file in self.get_composite_files( dataset=dataset ).items():
|
||||
fn = composite_name
|
||||
opt_text = ''
|
||||
if composite_file.optional:
|
||||
@@ -617,7 +617,7 @@ class RexpBase( Html ):
|
||||
del useConc[i] # get rid of concordance
|
||||
del useCols[i] # and usecols entry
|
||||
for i, conc in enumerate(useConc): # these are all unique columns for the design matrix
|
||||
ccounts = sorted([(conc.get(code, 0), code) for code in conc.keys()]) # decorate
|
||||
ccounts = sorted((conc.get(code, 0), code) for code in conc.keys()) # decorate
|
||||
cc = [(x[1], x[0]) for x in ccounts] # list of code count tuples
|
||||
codeDetails = (head[useCols[i]], cc) # ('foo',[('a',3),('b',11),..])
|
||||
listCol.append(codeDetails)
|
||||
|
||||
@@ -6,10 +6,10 @@ import math
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import urllib
|
||||
|
||||
import numpy
|
||||
from bx.intervals.io import GenomicIntervalReader, ParseError
|
||||
from six.moves.urllib.parse import quote_plus
|
||||
|
||||
from galaxy import util
|
||||
from galaxy.datatypes import metadata
|
||||
@@ -19,8 +19,10 @@ from galaxy.datatypes.tabular import Tabular
|
||||
from galaxy.datatypes.util.gff_util import parse_gff_attributes
|
||||
from galaxy.web import url_for
|
||||
|
||||
import data
|
||||
import dataproviders
|
||||
from . import (
|
||||
data,
|
||||
dataproviders
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -86,7 +88,7 @@ class Interval( Tabular ):
|
||||
self.init_meta( dataset )
|
||||
line = line.strip( '#' )
|
||||
elems = line.split( '\t' )
|
||||
for meta_name, header_list in alias_spec.iteritems():
|
||||
for meta_name, header_list in alias_spec.items():
|
||||
for header_val in header_list:
|
||||
if header_val in elems:
|
||||
# found highest priority header to meta_name
|
||||
@@ -239,7 +241,7 @@ class Interval( Tabular ):
|
||||
|
||||
def display_peek( self, dataset ):
|
||||
"""Returns formated html of peek"""
|
||||
return Tabular.make_html_table( self, dataset, column_parameter_alias={'chromCol': 'Chrom', 'startCol': 'Start', 'endCol': 'End', 'strandCol': 'Strand', 'nameCol': 'Name'} )
|
||||
return self.make_html_table( dataset, column_parameter_alias={'chromCol': 'Chrom', 'startCol': 'Start', 'endCol': 'End', 'strandCol': 'Strand', 'nameCol': 'Name'} )
|
||||
|
||||
def ucsc_links( self, dataset, type, app, base_url ):
|
||||
"""
|
||||
@@ -263,10 +265,10 @@ class Interval( Tabular ):
|
||||
for site_name, site_url in valid_sites:
|
||||
internal_url = url_for( controller='dataset', dataset_id=dataset.id,
|
||||
action='display_at', filename='ucsc_' + site_name )
|
||||
display_url = urllib.quote_plus( "%s%s/display_as?id=%i&display_app=%s&authz_method=display_at"
|
||||
% (base_url, url_for( controller='root' ), dataset.id, type) )
|
||||
redirect_url = urllib.quote_plus( "%sdb=%s&position=%s:%s-%s&hgt.customText=%%s"
|
||||
% (site_url, dataset.dbkey, chrom, start, stop ) )
|
||||
display_url = quote_plus( "%s%s/display_as?id=%i&display_app=%s&authz_method=display_at" %
|
||||
(base_url, url_for( controller='root' ), dataset.id, type) )
|
||||
redirect_url = quote_plus( "%sdb=%s&position=%s:%s-%s&hgt.customText=%%s" %
|
||||
(site_url, dataset.dbkey, chrom, start, stop ) )
|
||||
link = '%s?redirect_url=%s&display_url=%s' % ( internal_url, redirect_url, display_url )
|
||||
ret_val.append( ( site_name, link ) )
|
||||
return ret_val
|
||||
@@ -286,7 +288,7 @@ class Interval( Tabular ):
|
||||
|
||||
while True:
|
||||
try:
|
||||
reader.next()
|
||||
next(reader)
|
||||
except ParseError as e:
|
||||
errors.append(e)
|
||||
except StopIteration:
|
||||
@@ -635,8 +637,8 @@ class _RemoteCallMixin:
|
||||
"""
|
||||
internal_url = "%s" % url_for( controller='dataset', dataset_id=dataset.id, action='display_at', filename='%s_%s' % ( type, site_name ) )
|
||||
base_url = app.config.get( "display_at_callback", base_url )
|
||||
display_url = urllib.quote_plus( "%s%s/display_as?id=%i&display_app=%s&authz_method=display_at" %
|
||||
( base_url, url_for( controller='root' ), dataset.id, type ) )
|
||||
display_url = quote_plus( "%s%s/display_as?id=%i&display_app=%s&authz_method=display_at" %
|
||||
( base_url, url_for( controller='root' ), dataset.id, type ) )
|
||||
link = '%s?redirect_url=%s&display_url=%s' % ( internal_url, redirect_url, display_url )
|
||||
return link
|
||||
|
||||
@@ -723,7 +725,7 @@ class Gff( Tabular, _RemoteCallMixin ):
|
||||
|
||||
def display_peek( self, dataset ):
|
||||
"""Returns formated html of peek"""
|
||||
return Tabular.make_html_table( self, dataset, column_names=self.column_names )
|
||||
return self.make_html_table( dataset, column_names=self.column_names )
|
||||
|
||||
def get_estimated_display_viewport( self, dataset ):
|
||||
"""
|
||||
@@ -808,7 +810,7 @@ class Gff( Tabular, _RemoteCallMixin ):
|
||||
if seqid is not None:
|
||||
for site_name, site_url in app.datatypes_registry.get_legacy_sites_by_build('ucsc', dataset.dbkey ):
|
||||
if site_name in app.datatypes_registry.get_display_sites('ucsc'):
|
||||
redirect_url = urllib.quote_plus(
|
||||
redirect_url = quote_plus(
|
||||
"%sdb=%s&position=%s:%s-%s&hgt.customText=%%s" %
|
||||
( site_url, dataset.dbkey, seqid, start, stop ) )
|
||||
link = self._get_remote_call_url( redirect_url, site_name, dataset, type, app, base_url )
|
||||
@@ -823,7 +825,7 @@ class Gff( Tabular, _RemoteCallMixin ):
|
||||
if site_name in app.datatypes_registry.get_display_sites('gbrowse'):
|
||||
if seqid.startswith( 'chr' ) and len( seqid ) > 3:
|
||||
seqid = seqid[3:]
|
||||
redirect_url = urllib.quote_plus( "%s/?q=%s:%s..%s&eurl=%%s" % ( site_url, seqid, start, stop ) )
|
||||
redirect_url = quote_plus( "%s/?q=%s:%s..%s&eurl=%%s" % ( site_url, seqid, start, stop ) )
|
||||
link = self._get_remote_call_url( redirect_url, site_name, dataset, type, app, base_url )
|
||||
ret_val.append( ( site_name, link ) )
|
||||
return ret_val
|
||||
@@ -1170,7 +1172,7 @@ class Wiggle( Tabular, _RemoteCallMixin ):
|
||||
if site_name in app.datatypes_registry.get_display_sites('gbrowse'):
|
||||
if chrom.startswith( 'chr' ) and len( chrom ) > 3:
|
||||
chrom = chrom[3:]
|
||||
redirect_url = urllib.quote_plus( "%s/?q=%s:%s..%s&eurl=%%s" % ( site_url, chrom, start, stop ) )
|
||||
redirect_url = quote_plus( "%s/?q=%s:%s..%s&eurl=%%s" % ( site_url, chrom, start, stop ) )
|
||||
link = self._get_remote_call_url( redirect_url, site_name, dataset, type, app, base_url )
|
||||
ret_val.append( ( site_name, link ) )
|
||||
return ret_val
|
||||
@@ -1181,14 +1183,14 @@ class Wiggle( Tabular, _RemoteCallMixin ):
|
||||
if chrom is not None:
|
||||
for site_name, site_url in app.datatypes_registry.get_legacy_sites_by_build('ucsc', dataset.dbkey ):
|
||||
if site_name in app.datatypes_registry.get_display_sites('ucsc'):
|
||||
redirect_url = urllib.quote_plus( "%sdb=%s&position=%s:%s-%s&hgt.customText=%%s" % ( site_url, dataset.dbkey, chrom, start, stop ) )
|
||||
redirect_url = quote_plus( "%sdb=%s&position=%s:%s-%s&hgt.customText=%%s" % ( site_url, dataset.dbkey, chrom, start, stop ) )
|
||||
link = self._get_remote_call_url( redirect_url, site_name, dataset, type, app, base_url )
|
||||
ret_val.append( ( site_name, link ) )
|
||||
return ret_val
|
||||
|
||||
def display_peek( self, dataset ):
|
||||
"""Returns formated html of peek"""
|
||||
return Tabular.make_html_table( self, dataset, skipchars=['track', '#'] )
|
||||
return self.make_html_table( dataset, skipchars=['track', '#'] )
|
||||
|
||||
def set_meta( self, dataset, overwrite=True, **kwd ):
|
||||
max_data_lines = None
|
||||
@@ -1266,7 +1268,7 @@ class Wiggle( Tabular, _RemoteCallMixin ):
|
||||
x = numpy.arange( t_start, t_end ) * resolution
|
||||
y = data[ t_start : t_end ]
|
||||
|
||||
return zip(x.tolist(), y.tolist())
|
||||
return list(zip(x.tolist(), y.tolist()))
|
||||
|
||||
def get_track_resolution( self, dataset, start, end):
|
||||
range = end - start
|
||||
@@ -1305,7 +1307,7 @@ class CustomTrack ( Tabular ):
|
||||
|
||||
def display_peek( self, dataset ):
|
||||
"""Returns formated html of peek"""
|
||||
return Tabular.make_html_table( self, dataset, skipchars=['track', '#'] )
|
||||
return self.make_html_table( dataset, skipchars=['track', '#'] )
|
||||
|
||||
def get_estimated_display_viewport( self, dataset, chrom_col=None, start_col=None, end_col=None ):
|
||||
"""Return a chrom, start, stop tuple for viewing a file."""
|
||||
@@ -1372,8 +1374,8 @@ class CustomTrack ( Tabular ):
|
||||
for site_name, site_url in app.datatypes_registry.get_legacy_sites_by_build('ucsc', dataset.dbkey):
|
||||
if site_name in app.datatypes_registry.get_display_sites('ucsc'):
|
||||
internal_url = "%s" % url_for( controller='dataset', dataset_id=dataset.id, action='display_at', filename='ucsc_' + site_name )
|
||||
display_url = urllib.quote_plus( "%s%s/display_as?id=%i&display_app=%s&authz_method=display_at" % (base_url, url_for( controller='root' ), dataset.id, type) )
|
||||
redirect_url = urllib.quote_plus( "%sdb=%s&position=%s:%s-%s&hgt.customText=%%s" % (site_url, dataset.dbkey, chrom, start, stop ) )
|
||||
display_url = quote_plus( "%s%s/display_as?id=%i&display_app=%s&authz_method=display_at" % (base_url, url_for( controller='root' ), dataset.id, type) )
|
||||
redirect_url = quote_plus( "%sdb=%s&position=%s:%s-%s&hgt.customText=%%s" % (site_url, dataset.dbkey, chrom, start, stop ) )
|
||||
link = '%s?redirect_url=%s&display_url=%s' % ( internal_url, redirect_url, display_url )
|
||||
ret_val.append( (site_name, link) )
|
||||
return ret_val
|
||||
|
||||
@@ -61,12 +61,12 @@ class PepXmlReport(Tabular):
|
||||
file_ext = "pepxml.tsv"
|
||||
|
||||
def __init__(self, **kwd):
|
||||
Tabular.__init__(self, **kwd)
|
||||
super(PepXmlReport, self).__init__(**kwd)
|
||||
self.column_names = ['Protein', 'Peptide', 'Assumed Charge', 'Neutral Pep Mass (calculated)', 'Neutral Mass', 'Retention Time', 'Start Scan', 'End Scan', 'Search Engine', 'PeptideProphet Probability', 'Interprophet Probabaility']
|
||||
|
||||
def display_peek(self, dataset):
|
||||
"""Returns formated html of peek"""
|
||||
return Tabular.make_html_table(self, dataset, column_names=self.column_names)
|
||||
return self.make_html_table(dataset, column_names=self.column_names)
|
||||
|
||||
|
||||
class ProtXmlReport(Tabular):
|
||||
@@ -76,7 +76,7 @@ class ProtXmlReport(Tabular):
|
||||
comment_lines = 1
|
||||
|
||||
def __init__(self, **kwd):
|
||||
Tabular.__init__(self, **kwd)
|
||||
super(ProtXmlReport, self).__init__(**kwd)
|
||||
self.column_names = [
|
||||
"Entry Number", "Group Probability",
|
||||
"Protein", "Protein Link", "Protein Probability",
|
||||
@@ -91,7 +91,7 @@ class ProtXmlReport(Tabular):
|
||||
|
||||
def display_peek(self, dataset):
|
||||
"""Returns formated html of peek"""
|
||||
return Tabular.make_html_table(self, dataset, column_names=self.column_names)
|
||||
return self.make_html_table(dataset, column_names=self.column_names)
|
||||
|
||||
|
||||
class ProteomicsXml(GenericXml):
|
||||
|
||||
@@ -408,7 +408,7 @@ class Taxonomy( Tabular ):
|
||||
|
||||
def display_peek( self, dataset ):
|
||||
"""Returns formated html of peek"""
|
||||
return super(Taxonomy, self).make_html_table( dataset, column_names=self.column_names )
|
||||
return self.make_html_table( dataset, column_names=self.column_names )
|
||||
|
||||
|
||||
@dataproviders.decorators.has_dataproviders
|
||||
@@ -428,7 +428,7 @@ class Sam( Tabular ):
|
||||
|
||||
def display_peek( self, dataset ):
|
||||
"""Returns formated html of peek"""
|
||||
return super( Sam, self ).make_html_table( dataset, column_names=self.column_names )
|
||||
return self.make_html_table( dataset, column_names=self.column_names )
|
||||
|
||||
def sniff( self, filename ):
|
||||
"""
|
||||
@@ -614,7 +614,7 @@ class Pileup( Tabular ):
|
||||
|
||||
def display_peek( self, dataset ):
|
||||
"""Returns formated html of peek"""
|
||||
return super( Pileup, self ).make_html_table( dataset, column_parameter_alias={'chromCol': 'Chrom', 'startCol': 'Start', 'baseCol': 'Base'} )
|
||||
return self.make_html_table( dataset, column_parameter_alias={'chromCol': 'Chrom', 'startCol': 'Start', 'baseCol': 'Base'} )
|
||||
|
||||
def repair_methods( self, dataset ):
|
||||
"""Return options for removing errors along with a description"""
|
||||
@@ -691,7 +691,7 @@ class Vcf( Tabular ):
|
||||
|
||||
def display_peek( self, dataset ):
|
||||
"""Returns formated html of peek"""
|
||||
return super( Vcf, self ).make_html_table( dataset, column_names=self.column_names )
|
||||
return self.make_html_table( dataset, column_names=self.column_names )
|
||||
|
||||
def set_meta( self, dataset, **kwd ):
|
||||
super( Vcf, self ).set_meta( dataset, **kwd )
|
||||
|
||||
Reference in New Issue
Block a user