
$(document).ready(function() {

    var gene_table = create_gene_table(bioents);
    create_download_button("gene_list_table_download", gene_table, list_name);
    $("#gene_list_table_analyze").hide();
    set_up_tools(gene_table, "go_term_finder", "go_slim_mapper", "spell", "yeastmine");

});

function create_gene_table(data) {
    var gene_table = null;
    if(data != null && data.length > 0) {
	    var datatable = [];

        for (var i=0; i < data.length; i++) {
            datatable.push(gene_data_to_table(data[i]));
        }

        $("#gene_list_table_header").html(data.length);

        var options = {};
	    options["bPaginate"] = false;
	    options["aaSorting"] = [[3, "asc"]];
	    options["aoColumns"] = [{"bSearchable":false, "bVisible":false}, {"bSearchable":false, "bVisible":false}, {"bSearchable":false, "bVisible":false}, null, null];
	    options["aaData"] = datatable;

        gene_table = create_table("gene_list_table", options);
	}
	return gene_table;
}

function post_to_yeastmine(bioent_ids) {
    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement("form");
    form.setAttribute("method", "post");
    form.setAttribute("action", "https://yeastmine.yeastgenome.org/yeastmine/portal.do?goToListUpload=true");
    
    var cinp = document.createElement("input");
    cinp.setAttribute("type", "hidden");
    cinp.setAttribute("name", "class");
    cinp.setAttribute("value", "Gene");
    form.appendChild(cinp);

    var vinp = document.createElement("input");
    vinp.setAttribute("type", "hidden");
    vinp.setAttribute("name", "extraValue");
    vinp.setAttribute("value", "S. cerevisiae");
    form.appendChild(vinp);

    var hiddenField = document.createElement("input");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("name", "externalids");
    hiddenField.setAttribute("value", bioent_ids);
    hiddenField.id = "data";
    form.appendChild(hiddenField);

    document.body.appendChild(form);
    form.submit();
}

function set_up_tools(table, go_term_finder_id, go_slim_mapper_id, spell_id, yeastmine_id) {
	document.getElementById(go_term_finder_id).onclick = function f() {
		var bioent_format_names = '';

		var data = table._('tr', {"filter": "applied"});
		for (var i=0,len=data.length; i<len; i++) { 
			var sys_name = data[i][2];
			bioent_format_names = bioent_format_names + sys_name + ' ';
		}
		post_to_url("http://yeastgenome.org/cgi-bin/GO/goTermFinder.pl", {
			"loci" : bioent_format_names
		});
	};
	document.getElementById(go_slim_mapper_id).onclick = function f() {
		var bioent_format_names = '';
		var data = table._('tr', {"filter": "applied"});
		for (var i=0,len=data.length; i<len; i++) { 
			var sys_name = data[i][2];
			bioent_format_names = bioent_format_names + sys_name + ' ';
		}
		post_to_url("http://yeastgenome.org/cgi-bin/GO/goSlimMapper.pl", {
			"loci" : bioent_format_names
		});
	};
	document.getElementById(spell_id).onclick = function f() {
		var bioent_format_names = [];
		var data = table._('tr', {"filter": "applied"});
		for (var i=0,len=data.length; i<len; i++) { 
			var sys_name = data[i][2];
			bioent_format_names.push(sys_name);
		}
		post_to_url("https://spell.yeastgenome.org/search/show_results", {
			"search_string" : bioent_format_names
		});
	};
	document.getElementById(yeastmine_id).onclick = function f() {
		var bioent_format_names = [];
		var data = table._('tr', {"filter": "applied"});
		for (var i=0,len=data.length; i<len; i++) { 
			var sys_name = data[i][2];
			bioent_format_names.push(sys_name);
		}
		post_to_yeastmine(bioent_format_names);
	};
}

@@ -2481,110 +2481,200 @@
 %7D%0A%09%09
-post_to_url(%22http://yeastgenome.org/cgi-bin/GO/goTermFinder.pl%22, %7B%0A%09%09%09%22loci%22 : bioent_format_names%0A%09%09%7D
+var lociQueryString = data.reduce(function(acc, d) %7B%0A%09%09%09var sysName = d%5B2%5D;%0A%09%09%09return acc + sysName + '+';%0A%09%09%7D, %22?genes=%22);%0A%09%09var url = '/goTermFinder' + lociQueryString;%0A%09%09location.assign(url
 );%0A%09
@@ -2968,24 +2968,25 @@
  + ' ';%0A%09%09%7D%0A
+%0A
 %09%09post_to_ur

add qs of gene to GTF