commit/galaxy-central: guerler: Add VCF visualization support for dataset viewer
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/43e609a791a1/ Changeset: 43e609a791a1 User: guerler Date: 2013-06-27 20:35:37 Summary: Add VCF visualization support for dataset viewer Affected #: 1 file diff -r 507ac09f587d2e0c40c1d8f06ed385817a209626 -r 43e609a791a13c37612e5e440d5890acc070a351 static/scripts/mvc/data.js --- a/static/scripts/mvc/data.js +++ b/static/scripts/mvc/data.js @@ -120,7 +120,7 @@ initialize: function(options) { // load trackster button - (new TabularButtonTracksterView(options)).render(); + new TabularButtonTracksterView(options); }, render: function() @@ -252,23 +252,63 @@ // database key genome_build: null, + // data type + data_type: null, + // backbone initialize initialize: function (options) { - // verify that metadata exists - var metadata = options.model.attributes.metadata.attributes; - if (typeof metadata.chromCol === "undefined" || typeof metadata.startCol === "undefined" || typeof metadata.endCol === "undefined") - console.log("TabularButtonTrackster : Metadata for column identification is missing."); - else { - // read in columns - this.col.chrom = metadata.chromCol - 1; - this.col.start = metadata.startCol - 1; - this.col.end = metadata.endCol - 1; + // get options + var attributes = options.model.attributes; + var metadata = options.model.attributes.metadata.attributes; + + // check for datatype + if (typeof attributes.data_type !== "undefined") + this.data_type = attributes.data_type; + else + console.log("TabularButtonTrackster : Data type missing."); + + // check for bed-file format + if (this.data_type == "bed") + { + // verify that metadata exists + if (typeof metadata.chromCol !== "undefined" || typeof metadata.startCol !== "undefined" || typeof metadata.endCol !== "undefined") + { + // read in columns + this.col.chrom = metadata.chromCol - 1; + this.col.start = metadata.startCol - 1; + this.col.end = metadata.endCol - 1; + } else + console.log("TabularButtonTrackster : Bed-file metadata incomplete."); + } + + // check for vcf-file format + if (this.data_type == "vcf") + { + // search array + function search (str, array) + { + for (var j = 0; j < array.length; j++) + if (array[j].match(str)) return j; + return -1; + }; + + // load + this.col.chrom = search("Chrom", metadata.column_names); + this.col.start = search("Pos", metadata.column_names); + this.col.end = null; + + // verify that metadata exists + if (this.col.chrom == -1 || this.col.start == -1) + console.log("TabularButtonTrackster : VCF-file metadata incomplete."); } // check if(this.col.chrom === null) + { + console.log("TabularButtonTrackster : Chromosome column undefined."); return; + } // get dataset id if (typeof options.model.attributes.id === "undefined") @@ -285,6 +325,19 @@ // get genome_build / database key if (typeof options.model.attributes.genome_build !== "undefined") this.genome_build = options.model.attributes.genome_build; + + // render the icon from template + var btn_viz = new IconButtonView({ model : new IconButton({ + title : 'Visualize', + icon_class : 'chart_curve', + id : 'btn_viz' + })}); + + // add it to the screen + this.$el.append(btn_viz.render().$el); + + // hide the button + $('#btn_viz').hide(); }, // backbone events @@ -297,29 +350,39 @@ // show button btn_viz_show: function (e) { + // is numeric + function is_numeric(n) + { + return !isNaN(parseFloat(n)) && isFinite(n); + }; + // check if(this.col.chrom === null) return; - + // get selected data line var row = $(e.target).parent(); - + // verify that location has been found var chrom = row.children().eq(this.col.chrom).html(); var start = row.children().eq(this.col.start).html(); - var end = row.children().eq(this.col.end).html(); - if (chrom !== "" && start !== "" && end !== "") + + // end is optional + var end = this.col.end ? row.children().eq(this.col.end).html() : start; + + // double check location + if (!chrom.match("^#") && chrom !== "" && is_numeric(start)) { // get target gene region var btn_viz_pars = { dataset_id : this.dataset_id, gene_region : chrom + ":" + start + "-" + end }; - + // get button position var offset = row.offset(); var left = offset.left - 10; - var top = offset.top; + var top = offset.top - $(window).scrollTop(); // update css $('#btn_viz').css({'position': 'fixed', 'top': top + 'px', 'left': left + 'px'}); @@ -328,6 +391,9 @@ // show the button $('#btn_viz').show(); + } else { + // hide the button + $('#btn_viz').hide(); } }, @@ -401,24 +467,7 @@ }); return false; }; - }, - - // render frame - render: function() - { - // render the icon from template - var btn_viz = new IconButtonView({ model : new IconButton({ - title : 'Visualize', - icon_class : 'chart_curve', - id : 'btn_viz' - })}); - - // add it to the screen - this.$el.append(btn_viz.render().$el); - - // hide the button - $('#btn_viz').hide(); - } + } }); // -- Utility functions. -- 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.
participants (1)
-
commits-noreply@bitbucket.org