1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/64bb99fd3d3c/ Changeset: 64bb99fd3d3c User: jgoecks Date: 2013-04-16 15:24:45 Summary: Visual analytics enhancements and fixes: (i) handle uncalled alleles in VCF display; (b) whitespace fixes; and (c) move methods so that non-feature tracks can be used when running tools; (d) fixes for SamDataProvider constructor; (e) fix for handling paired-end reads when using reference-based packing. Affected #: 3 files diff -r b0a7fc043a9b24b28c0450839405cf534291352c -r 64bb99fd3d3cec9a65cc63ecfb0074ac5a87bd93 lib/galaxy/visualization/data_providers/genome.py --- a/lib/galaxy/visualization/data_providers/genome.py +++ b/lib/galaxy/visualization/data_providers/genome.py @@ -2,7 +2,7 @@ Data providers for genome visualizations. """ -import os, sys, operator, re +import os, sys, re from math import ceil, log import pkg_resources pkg_resources.require( "bx-python" ) @@ -696,12 +696,17 @@ has_alleles = False alleles_seen.clear() for allele in genotype_re.split( genotype ): - allele = int( allele ) - # Only count allele if it hasn't been seen yet. - if allele != 0 and allele not in alleles_seen: - allele_counts[ allele - 1 ] += 1 - alleles_seen[ allele ] = True - has_alleles = True + try: + # This may throw a ValueError if allele is missing. + allele = int( allele ) + + # Only count allele if it hasn't been seen yet. + if allele != 0 and allele not in alleles_seen: + allele_counts[ allele - 1 ] += 1 + alleles_seen[ allele ] = True + has_alleles = True + except ValueError: + pass # If no alleles, use empty string as proxy. if not has_alleles: @@ -1048,34 +1053,44 @@ # If there are results and reference data, transform read sequence and cigar. if len( results ) != 0 and ref_seq: + def process_read( read, start_field, cigar_field, seq_field ): + ''' + Process a read using the designated fields. + ''' + read_seq, read_cigar = get_ref_based_read_seq_and_cigar( read[ seq_field ].upper(), + read[ start_field ], + ref_seq, + start, + read[ cigar_field ] ) + read[ seq_field ] = read_seq + read[ cigar_field ] = read_cigar + def process_se_read( read ): ''' Process single-end read. ''' - read_seq, read_cigar = get_ref_based_read_seq_and_cigar( read[ 6 ].upper(), read[ 1 ], - ref_seq, start, read[ 4 ] ) - read[ 6 ] = read_seq - read[ 4 ] = read_cigar - + process_read( read, 1, 4, 6) + def process_pe_read( read ): ''' Process paired-end read. ''' - process_se_read( read[ 4 ] ) - process_se_read( read[ 5 ] ) + if len( read[4] ) > 2: + process_read( read[4], 0, 2, 4 ) + if len( read[5] ) > 2: + process_read( read[5], 0, 2, 4 ) # Uppercase for easy comparison. ref_seq = ref_seq.upper() - # Choose correct function for processing reads. - process_fn = process_se_read - if isinstance( results[ 0 ][ 5 ], list ): - process_fn = process_pe_read - # Process reads. for read in results: - process_fn( read ) - + # Use correct function for processing reads. + if isinstance( read[ 5 ], list ): + process_pe_read( read ) + else: + process_se_read( read ) + max_low, max_high = get_bounds( results, 1, 2 ) return { 'data': results, 'message': message, 'max_low': max_low, 'max_high': max_high } @@ -1086,14 +1101,16 @@ def __init__( self, converted_dataset=None, original_dataset=None, dependencies=None ): """ Create SamDataProvider. """ + super( SamDataProvider, self ).__init__( converted_dataset=converted_dataset, + original_dataset=original_dataset, + dependencies=dependencies ) - # HACK: to use BamDataProvider, original dataset must be BAM and + # To use BamDataProvider, original dataset must be BAM and # converted dataset must be BAI. Use BAI from BAM metadata. if converted_dataset: + self.original_dataset = converted_dataset self.converted_dataset = converted_dataset.metadata.bam_index - self.original_dataset = converted_dataset - self.dependencies = dependencies - + class BBIDataProvider( GenomeDataProvider ): """ BBI data provider for the Galaxy track browser. diff -r b0a7fc043a9b24b28c0450839405cf534291352c -r 64bb99fd3d3cec9a65cc63ecfb0074ac5a87bd93 static/scripts/viz/trackster/painters.js --- a/static/scripts/viz/trackster/painters.js +++ b/static/scripts/viz/trackster/painters.js @@ -1660,7 +1660,10 @@ // Get variant to draw and set drawing properties. variant = null; if (genotype[0] === genotype[1]) { - if (genotype[0] !== '0') { + if (genotype[0] === '.') { + // TODO: draw uncalled variant. + } + else if (genotype[0] !== '0') { // Homozygous for variant. variant = alt[ parseInt(genotype[0], 10) - 1 ]; ctx.globalAlpha = 1; diff -r b0a7fc043a9b24b28c0450839405cf534291352c -r 64bb99fd3d3cec9a65cc63ecfb0074ac5a87bd93 static/scripts/viz/trackster/tracks.js --- a/static/scripts/viz/trackster/tracks.js +++ b/static/scripts/viz/trackster/tracks.js @@ -2421,15 +2421,18 @@ // Remove track. Drawable.prototype.action_icons_def[2] ], + can_draw: function() { if ( this.dataset_id && Drawable.prototype.can_draw.call(this) ) { return true; } return false; }, + build_container_div: function () { return $("<div/>").addClass('track').attr("id", "track_" + this.id).css("position", "relative"); }, + build_header_div: function() { var header_div = $("<div class='track-header'/>"); if (this.view.editor) { this.drag_div = $("<div/>").addClass(this.drag_handle_class).appendTo(header_div); } @@ -2437,10 +2440,22 @@ .attr( "id", this.name.replace(/\s+/g,'-').replace(/[^a-zA-Z0-9\-]/g,'').toLowerCase() ); return header_div; }, + + /** + * Set track's dataset. + */ + set_dataset: function(dataset) { + this.dataset = dataset; + this.data_manager.set('dataset', dataset); + this.dataset_id = dataset.get('id'); + this.hda_ldda = dataset.get('hda_ldda'); + }, + /** * Action to take during resize. */ on_resize: function() {}, + /** * Add resizing handle to drawable's container_div. */ @@ -2477,6 +2492,7 @@ track.changed(); }).appendTo(track.container_div); }, + /** * Set track's modes and update mode icon popup. */ @@ -2508,6 +2524,7 @@ make_popupmenu(this.action_icons.mode_icon, mode_mapping); }, + build_action_icons: function() { Drawable.prototype.build_action_icons.call(this, this.action_icons_def); @@ -2516,6 +2533,7 @@ this.set_display_modes(this.display_modes); } }, + /** * Hide any elements that are part of the tracks contents area. Should * remove as approprite, the track will be redrawn by show_contents. @@ -2526,6 +2544,7 @@ // Hide any y axis labels (common to several track types) this.container_div.find(".yaxislabel, .track-resize").hide(); }, + show_contents: function() { // Show the contents div and labels (if present) this.tiles_div.show(); @@ -2533,6 +2552,7 @@ // Request a redraw of the content this.request_draw(); }, + /** * Returns track type. */ @@ -2561,6 +2581,7 @@ } return ""; }, + /** * Initialize and draw the track. */ @@ -2652,6 +2673,7 @@ this.update_icons(); return init_deferred; }, + /** * Additional initialization required before drawing track for the first time. */ @@ -3817,13 +3839,7 @@ this.set_painter_from_config(); }; extend(FeatureTrack.prototype, Drawable.prototype, TiledTrack.prototype, { - set_dataset: function(dataset) { - this.dataset_id = dataset.get('id'); - this.hda_ldda = dataset.get('hda_ldda'); - this.dataset = dataset; - this.data_manager.set('dataset', dataset); - }, - + set_painter_from_config: function() { if ( this.config.values['connector_style'] === 'arcs' ) { this.painter = painters.ArcLinkedFeaturePainter; Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.