# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User jeremy goecks <jeremy.goecks@emory.edu> # Date 1286559820 14400 # Node ID d3fa82adee9782d27d4de9a92a3d1be47bd138c8 # Parent 13abfea1b0ef2fa93a6bca55af62c11fd220588d Finish refactoring of tracks data providers so that they all inherit from a single base object, TracksDataProvider. --- a/lib/galaxy/visualization/tracks/data/array_tree.py +++ b/lib/galaxy/visualization/tracks/data/array_tree.py @@ -10,8 +10,6 @@ from math import floor, ceil, log, pow from base import TracksDataProvider class ArrayTreeDataProvider( TracksDataProvider ): - def __init__( self, dataset, original_dataset ): - self.dataset = dataset def get_stats( self, chrom ): f = open( self.dataset.file_name ) @@ -48,7 +46,7 @@ class ArrayTreeDataProvider( TracksDataP if 'stats' in kwargs: return self.get_stats(chrom) - f = open( self.dataset.file_name ) + f = open( self.converted_dataset.file_name ) d = FileArrayTreeDict( f ) # Get the right chromosome --- a/lib/galaxy/visualization/tracks/data/summary_tree.py +++ b/lib/galaxy/visualization/tracks/data/summary_tree.py @@ -6,18 +6,16 @@ import pkg_resources; pkg_resources.requ from galaxy.visualization.tracks.summary import * from math import ceil, log from galaxy.util.lrucache import LRUCache +from base import TracksDataProvider CACHE = LRUCache(20) # Store 20 recently accessed indices for performance -class SummaryTreeDataProvider( object ): - def __init__( self, dataset, original_dataset ): - self.dataset = dataset - +class SummaryTreeDataProvider( TracksDataProvider ): def get_summary( self, chrom, start, end, **kwargs): - filename = self.dataset.file_name + filename = self.converted_dataset.file_name st = CACHE[filename] if st is None: - st = summary_tree_from_file( self.dataset.file_name ) + st = summary_tree_from_file( self.converted_dataset.file_name ) CACHE[filename] = st # If chrom is not found in blocks, try removing the first three --- a/lib/galaxy/visualization/tracks/data/bam.py +++ b/lib/galaxy/visualization/tracks/data/bam.py @@ -16,19 +16,14 @@ MAX_VALS = 5000 # only display first MAX class BamDataProvider( TracksDataProvider ): """ Provides access to intervals from a sorted indexed BAM file. - """ - def __init__( self, index, original_dataset ): - - self.index = index - self.original_dataset = original_dataset - + """ def get_data( self, chrom, start, end, **kwargs ): """ Fetch intervals in the region """ start, end = int(start), int(end) # Attempt to open the BAM file with index - bamfile = csamtools.Samfile( filename=self.original_dataset.file_name, mode='rb', index_filename=self.index.file_name ) + bamfile = csamtools.Samfile( filename=self.original_dataset.file_name, mode='rb', index_filename=self.converted_dataset.file_name ) message = None try: data = bamfile.fetch(start=start, end=end, reference=chrom)