[hg] galaxy 3742: trackster: fix BAM data error; display tweaks
details: http://www.bx.psu.edu/hg/galaxy/rev/49c11691bc2e changeset: 3742:49c11691bc2e user: Kanwei Li <kanwei@gmail.com> date: Tue May 04 15:43:34 2010 -0400 description: trackster: fix BAM data error; display tweaks diffstat: lib/galaxy/datatypes/converters/bed_to_summary_tree_converter.py | 2 +- lib/galaxy/visualization/tracks/data/bam.py | 11 +++++++++- lib/galaxy/visualization/tracks/data/summary_tree.py | 4 +- static/scripts/trackster.js | 5 ++- 4 files changed, 16 insertions(+), 6 deletions(-) diffs (84 lines): diff -r c7607fba91b9 -r 49c11691bc2e lib/galaxy/datatypes/converters/bed_to_summary_tree_converter.py --- a/lib/galaxy/datatypes/converters/bed_to_summary_tree_converter.py Tue May 04 14:21:21 2010 -0400 +++ b/lib/galaxy/datatypes/converters/bed_to_summary_tree_converter.py Tue May 04 15:43:34 2010 -0400 @@ -15,7 +15,7 @@ reader = BedReader( open( input_fname ) ) - st = SummaryTree(block_size=100, levels=4, draw_cutoff=100, detail_cutoff=20) + st = SummaryTree(block_size=25, levels=6, draw_cutoff=150, detail_cutoff=30) for chrom, chrom_start, chrom_end, name, score in reader: st.insert_range(chrom, chrom_start, chrom_end) diff -r c7607fba91b9 -r 49c11691bc2e lib/galaxy/visualization/tracks/data/bam.py --- a/lib/galaxy/visualization/tracks/data/bam.py Tue May 04 14:21:21 2010 -0400 +++ b/lib/galaxy/visualization/tracks/data/bam.py Tue May 04 15:43:34 2010 -0400 @@ -10,6 +10,8 @@ import logging log = logging.getLogger(__name__) +MAX_VALS = 50 # only display first MAX_VALS datapoints + class BamDataProvider( object ): """ Provides access to intervals from a sorted indexed BAM file. @@ -26,18 +28,25 @@ 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 ) + message = None try: data = bamfile.fetch(start=start, end=end, reference=chrom) except ValueError, e: # Some BAM files do not prefix chromosome names with chr, try without if chrom.startswith( 'chr' ): - data = bamfile.fetch( start=start, end=end, reference=chrom[3:] ) + try: + data = bamfile.fetch( start=start, end=end, reference=chrom[3:] ) + except: + return None else: return None # Encode reads as list of dictionaries results = [] paired_pending = {} for read in data: + if len(results) > MAX_VALS: + message = "Only the first %s pairs are being displayed." % MAX_VALS + break qname = read.qname if read.is_proper_pair: if qname in paired_pending: # one in dict is always first diff -r c7607fba91b9 -r 49c11691bc2e lib/galaxy/visualization/tracks/data/summary_tree.py --- a/lib/galaxy/visualization/tracks/data/summary_tree.py Tue May 04 14:21:21 2010 -0400 +++ b/lib/galaxy/visualization/tracks/data/summary_tree.py Tue May 04 15:43:34 2010 -0400 @@ -32,12 +32,12 @@ level = int(max( level, 0 )) if level <= 0: return None - + stats = st.chrom_stats[chrom] results = st.query(chrom, int(start), int(end), level) if results == "detail": return None - elif results == "draw": + elif results == "draw" or level <= 1: return "no_detail" else: return results, stats[level]["max"], stats[level]["avg"], stats[level]["delta"] diff -r c7607fba91b9 -r 49c11691bc2e static/scripts/trackster.js --- a/static/scripts/trackster.js Tue May 04 14:21:21 2010 -0400 +++ b/static/scripts/trackster.js Tue May 04 15:43:34 2010 -0400 @@ -439,8 +439,9 @@ return; } - var data = this.data_cache.get(key); - if (data === null) { return; } + var result = this.data_cache.get(key); + if (result === null) { return; } + console.log(result); canvas.css( { position: "absolute",
participants (1)
-
Nate Coraor