Remove hardcoded path to builds.txt from util, fix unit test that relies on this.

This commit is contained in:
Nate Coraor
2014-07-27 02:59:24 -04:00
parent 4227d0eabb
commit dfc08662cc
5 changed files with 11 additions and 6 deletions
+2 -2
View File
@@ -1002,7 +1002,7 @@ class GenomeBuildParameter( SelectToolParameter ):
>>> # Create a mock transaction with 'hg17' as the current build
>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch( history=Bunch( genome_build='hg17' ), db_builds=util.dbnames )
>>> trans = Bunch( history=Bunch( genome_build='hg17' ), db_builds=util.read_dbnames( None ) )
>>> p = GenomeBuildParameter( None, XML(
... '''
@@ -1071,7 +1071,7 @@ class GenomeBuildParameter( SelectToolParameter ):
def _get_dbkey_names( self, trans=None ):
if not self.tool:
# Hack for unit tests, since we have no tool
return util.dbnames
return util.read_dbnames( None )
return self.tool.app.genome_builds.get_genome_build_names( trans=trans )
+3 -2
View File
@@ -796,6 +796,9 @@ def read_dbnames(filename):
ucsc_builds = {}
man_builds = [] # assume these are integers
name_to_db_base = {}
if filename is None:
# Should only be happening with the galaxy.tools.parameters.basic:GenomeBuildParameter docstring unit test
filename = os.path.join( 'tool-data', 'shared', 'ucsc', 'builds.txt.sample' )
for line in open(filename):
try:
if line[0:1] == "#":
@@ -1126,8 +1129,6 @@ def safe_str_cmp(a, b):
galaxy_root_path = os.path.join(__path__[0], "..", "..", "..")
# The dbnames list is used in edit attributes and the upload tool
dbnames = read_dbnames( os.path.join( galaxy_root_path, "tool-data", "shared", "ucsc", "builds.txt" ) )
ucsc_build_sites = read_build_sites( os.path.join( galaxy_root_path, "tool-data", "shared", "ucsc", "ucsc_build_sites.txt" ) )
gbrowse_build_sites = read_build_sites( os.path.join( galaxy_root_path, "tool-data", "shared", "gbrowse", "gbrowse_build_sites.txt" ) )
+2 -2
View File
@@ -2,7 +2,7 @@
Functionality for dealing with dbkeys.
"""
#dbkeys read from disk using builds.txt
from galaxy.util import dbnames
from galaxy.util import read_dbnames
from galaxy.util.json import from_json_string
import os.path
@@ -17,7 +17,7 @@ class GenomeBuilds( object ):
self._static_chrom_info_path = app.config.len_file_path
# A dbkey can be listed multiple times, but with different names, so we can't use dictionaries for lookups
if load_old_style:
self._static_dbkeys = list( dbnames )
self._static_dbkeys = list( read_dbnames( app.config.builds_file_path ) )
else:
self._static_dbkeys = []
+1
View File
@@ -99,6 +99,7 @@ class MockApp( object ):
root=os.path.join(test_directory, "galaxy"),
admin_users="mary@example.com",
len_file_path=os.path.join( 'tool-data', 'shared', 'ucsc', 'chrom' ),
builds_file_path=os.path.join( 'tool-data', 'shared', 'ucsc', 'builds.txt.sample' ),
)
# Setup some attributes for downstream extension by specific tests.
+3
View File
@@ -180,6 +180,9 @@ paste.app_factory = galaxy.web.buildapp:app_factory
# https://wiki.galaxyproject.org/Admin/DataIntegration
#tool_data_path = tool-data
# File containing old-style genome builds
#builds_file_path = tool-data/shared/ucsc/builds.txt
# Directory where chrom len files are kept, currently mainly used by trackster
#len_file_path = tool-data/shared/ucsc/chrom