diff --git a/src/main/webapp/ProgressWatch.jsp b/src/main/webapp/ProgressWatch.jsp index f7fd0f38..8d1e30d8 100644 --- a/src/main/webapp/ProgressWatch.jsp +++ b/src/main/webapp/ProgressWatch.jsp @@ -1,84 +1,147 @@ -<%-- - * GIGWA - Genotype Investigator for Genome Wide Analyses - * Copyright (C) 2016 - 2019, - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU Affero General Public License, version 3 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more - * details. - * - * See for details about GNU General - * Public License V3. ---%> -<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="UTF-8" import="fr.cirad.web.controller.gigwa.GigwaRestController"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - - - - - - - - - - Gigwa process watcher - - - -
- - - +<%-- + * GIGWA - Genotype Investigator for Genome Wide Analyses + * Copyright (C) 2016 - 2019, + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU Affero General Public License, version 3 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more + * details. + * + * See for details about GNU General + * Public License V3. +--%> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="UTF-8" import="fr.cirad.web.controller.gigwa.GigwaRestController"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> + + + + + + + + + + + + + Gigwa process watcher + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index ee8127d1..1263813d 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -333,7 +333,7 @@ https://doi.org/10.1093/gigascience/giz051

Please wait...


- + @@ -784,7 +784,7 @@ https://doi.org/10.1093/gigascience/giz051 }); $.ajax({ - url: '?module=' + referenceset, + url: '', async: false, type: "GET", contentType: "application/json;charset=utf-8", @@ -1961,7 +1961,12 @@ https://doi.org/10.1093/gigascience/giz051 $("div#exportPanel").hide(); $("a#exportBoxToggleButton").removeClass("active"); } - displayProcessProgress(2, "export_" + token, null, showServerExportBox); + displayProcessProgress(2, "export_" + token, null, function() { + let fileExtensions = $("#exportFormat option:selected").data('ext').split(";"); + if ($('#exportPanel input#exportedIndividualMetadataCheckBox').is(':checked') && "FLAPJACK" != $('#exportFormat').val() && "DARWIN" != $('#exportFormat').val() /* these two already have their own metadata file format*/) + fileExtensions.push("tsv"); + showServerExportBox(fileExtensions); + }); } function postDataToIFrame(frameName, url, params) diff --git a/src/main/webapp/js/common.js b/src/main/webapp/js/common.js index 2ce0749f..41329c37 100644 --- a/src/main/webapp/js/common.js +++ b/src/main/webapp/js/common.js @@ -307,4 +307,205 @@ function grabNcbiTaxon(inputObj) $(inputObj).attr('species', genus + " " + species); $(inputObj).val(taxonName); +} + +function showServerExportBox(exportFormatExtensions) +{ + $("div#exportPanel").hide(); + $("a#exportBoxToggleButton").removeClass("active"); + if (processAborted || downloadURL == null) + return; + + var fileName = downloadURL.substring(downloadURL.lastIndexOf("/") + 1); + $('#serverExportBox').html(' Export file will be available at this URL for 48h:
' + fileName + ' ').show(); + var exportedFormat = $('#exportFormat').val().toUpperCase(); + if ("VCF" == exportedFormat) + addIgvExportIfRunning(); + else if ("FLAPJACK" == exportedFormat) + addFjBytesExport(); + + var archivedDataFiles = new Array(); + for (var key in exportFormatExtensions) + archivedDataFiles[exportFormatExtensions[key]] = location.origin + downloadURL.replace(new RegExp(/\.[^.]*$/), '.' + exportFormatExtensions[key]); + + var galaxyInstanceUrl = $("#galaxyInstanceURL").val().trim(); + if (galaxyInstanceUrl.startsWith("http")) { + var fileURLs = ""; + for (key in archivedDataFiles) + fileURLs += (fileURLs == "" ? "" : " ,") + "'" + archivedDataFiles[key] + "'"; + $('#serverExportBox').append('

  '); + } + + if (onlineOutputTools != null) + for (var toolName in onlineOutputTools) { + var toolConfig = getOutputToolConfig(toolName); + if (toolConfig['url'] != null && toolConfig['url'].trim() != "" && (toolConfig['formats'] == null || toolConfig['formats'].trim() == "" || toolConfig['formats'].toUpperCase().split(",").includes($('#exportFormat').val().toUpperCase()))) { + + var formatsForThisButton = "", urlForThisButton = toolConfig['url']; + var matchResult = urlForThisButton.match(/{([^}]+)}/g); + if (matchResult != null) { + var placeHolders = matchResult.map(res => res.replace(/{|}/g , '')); + phLoop: for (var i in placeHolders) { + var phFormats = placeHolders[i].split("\|"); + for (var j in phFormats) { + for (var key in archivedDataFiles) { + if (key == phFormats[j]) { + formatsForThisButton += (formatsForThisButton == "" ? "" : ", ") + key; + urlForThisButton = urlForThisButton.replace("\{" + placeHolders[i] + "\}", archivedDataFiles[key]); + continue phLoop; + } + } + } + console.log("unused param: " + placeHolders[i]); + urlForThisButton = urlForThisButton.replace("\{" + placeHolders[i] + "\}", ""); + } + } + + if (urlForThisButton == toolConfig['url'] && urlForThisButton.indexOf("*") != -1) { + urlForThisButton = urlForThisButton.replace("\*", Object.values(archivedDataFiles).join(",")); + formatsForThisButton = Object.keys(archivedDataFiles).join(", "); + } + + if (formatsForThisButton != "") + $('#serverExportBox').append('

  ') + } + } +} + +function getOutputToolConfig(toolName) +{ + var storedToolConfig = localStorage.getItem("outputTool_" + toolName); + return storedToolConfig != null ? JSON.parse(storedToolConfig) : onlineOutputTools[toolName]; +} + +function addIgvExportIfRunning() { + if (igvDataLoadPort == null) + return; + + var igvGenomeOptions = null; + $.ajax({ + type:"GET", + url:"http://127.0.0.1:" + igvDataLoadPort, + success:function(jsonResult) { + if ("ERROR Unknown command: /" == jsonResult) + { + if (igvGenomeOptions == null) + { + var genomeList = $.ajax({ + async:false, + type:"GET", + url:igvGenomeListUrl, + crossDomain : true, + error:function(xhr, ajaxOptions, thrownError) {} + }); + + igvGenomeOptions = ""; + if (genomeList.responseText != null) + { + var genomeLines = genomeList.responseText.split("\n"); + for (var i=0; i 0 || !genomeLines[i].startsWith("<")) // skip header + { + var genomeFields = genomeLines[i].split("\t"); + if (genomeFields.length == 3) + igvGenomeOptions += ""; + } + } + $('div#serverExportBox').append("

View in IGV within genomic/structural context 

(you may select a genome to switch to)
 
"); + } + } + }, + error:function(xhr, ajaxOptions, thrownError) { + //handleError(xhr, ajaxOptions, thrownError); + console.log("Unable to find IGV instance"); + } + }); +} + +function addFjBytesExport() { + $('div#serverExportBox').append("

" + (exportedIndividualCount * count > 500000000 ? "
WARNING: Exported dataset potentially contains more than 500 million genotypes.
A standard workstation's web-browser may be unable to load it in with Flapjack-Bytes
" : "") + "
"); +} + +function sendToGalaxy(archivedDataFiles) { + var galaxyInstanceUrl = $("#galaxyInstanceURL").val().trim(), apiKey = sessionStorage.getItem("galaxyApiKey::" + galaxyInstanceUrl); + if (apiKey == null) + apiKey = prompt("Enter the API key tied to your account on\n" + galaxyInstanceUrl); + if (apiKey != null && apiKey.trim() != "") { + sessionStorage.setItem("galaxyApiKey::" + galaxyInstanceUrl, apiKey); + $('#progressText').html("Pushing files to " + galaxyInstanceUrl + " ..."); + $('#asyncProgressButton').hide(); + $('button#abort').hide(); + $('#progress').modal({ + backdrop: 'static', + keyboard: false, + show: true + }); + setTimeout(function() { + var n = 0, responseMsg = null; + for (var fileUrl in archivedDataFiles) + $.ajax({ + async: false, + url: galaxyPushURL + "?galaxyUrl=" + galaxyInstanceUrl + "&galaxyApiKey=" + apiKey + "&fileUrl=" + archivedDataFiles[fileUrl], + type: "GET", + success: function(respString) { + responseMsg = respString; + n++; + }, + error: function(xhr, ajaxOptions, thrownError) { + $('#progress').modal('hide'); + + if (xhr.status == 403) { + console.log("Removing invalid Galaxy API key: " + apiKey); + sessionStorage.removeItem("galaxyApiKey::" + galaxyInstanceUrl); + } + + if (thrownError == "" && xhr.getAllResponseHeaders() == '') + alert("Error accessing resource: " + genomeURL); + else + handleError(xhr, thrownError); + } + }); + if (n > 0) + if (confirm(n + " file(s) " + responseMsg + "\nOpen a window pointing to that Galaxy instance?")) + window.open(galaxyInstanceUrl); + $('#progress').modal('hide'); + }, 1); + } +} + +function sendToFjBytes() { + let url = "fjbytes.html?m=" + location.origin + $("a#exportOutputUrl").attr("href").replace(new RegExp(/\.[^.]*$/), '.map') + + "&g=" + location.origin + $("a#exportOutputUrl").attr("href").replace(new RegExp(/\.[^.]*$/), '.genotype') + + "&p=" + location.origin + $("a#exportOutputUrl").attr("href").replace(new RegExp(/\.[^.]*$/), '.phenotype') + + "&id=" + getModuleName(); + + if ($("#fjBytesPanel").length == 0) { + location.href = url; + return; + } + + $("#fjBytesPanel").modal({ + opacity: 80, + overlayCss: { + backgroundColor: "#111111" + } + }); + + $('#fjBytesPanelHeader').html('
This is a functionality under development and might not be totally stable. Check https://github.com/cropgeeks/flapjack-bytes for information about Flapjack-Bytes.   Open in separate window
'); + $("#fjBytesFrame").attr('src', url); +} + +function sendToIGV(genomeID) +{ + var genomeID = $("select#igvGenome").val(); + $.ajax({ + type:"GET", + url:"http://127.0.0.1:" + igvDataLoadPort + "/load?" + (genomeID != "" ? "genome=" + genomeID + "&" : "") + "file=" + location.origin + $("a#exportOutputUrl").attr("href").replace(new RegExp(/\.[^.]*$/), '.vcf'), + success:function(tsvResult) { + alert("Variant list was sent to IGV!"); + }, + error:function(xhr, ajaxOptions, thrownError) { + handleError(xhr, ajaxOptions, thrownError); + } + }); } \ No newline at end of file diff --git a/src/main/webapp/js/main.js b/src/main/webapp/js/main.js index 85465343..d9c0c535 100644 --- a/src/main/webapp/js/main.js +++ b/src/main/webapp/js/main.js @@ -22,85 +22,6 @@ var igvGenomeOptions = null; var filtersToColumns = new Array(); -function addIgvExportIfRunning() { - if (igvDataLoadPort == null) - return; - - var igvGenomeOptions = null; - $.ajax({ - type:"GET", - url:"http://127.0.0.1:" + igvDataLoadPort, - success:function(jsonResult) { - if ("ERROR Unknown command: /" == jsonResult) - { - if (igvGenomeOptions == null) - { - var genomeList = $.ajax({ - async:false, - type:"GET", - url:igvGenomeListUrl, - crossDomain : true, - error:function(xhr, ajaxOptions, thrownError) {} - }); - - igvGenomeOptions = ""; - if (genomeList.responseText != null) - { - var genomeLines = genomeList.responseText.split("\n"); - for (var i=0; i 0 || !genomeLines[i].startsWith("<")) // skip header - { - var genomeFields = genomeLines[i].split("\t"); - if (genomeFields.length == 3) - igvGenomeOptions += ""; - } - } - $('div#serverExportBox').append("

View in IGV within genomic/structural context 

(you may select a genome to switch to)
 
"); - } - } - }, - error:function(xhr, ajaxOptions, thrownError) { - //handleError(xhr, ajaxOptions, thrownError); - console.log("Unable to find IGV instance"); - } - }); -} - -function addFjBytesExport() { - $('div#serverExportBox').append("

" + (exportedIndividualCount * count > 500000000 ? "
WARNING: Exported dataset potentially contains more than 500 million genotypes.
A standard workstation's web-browser may be unable to load it in with Flapjack-Bytes
" : "") + "
"); -} - -function sendToFjBytes() { - $("#fjBytesPanel").modal({ - opacity: 80, - overlayCss: { - backgroundColor: "#111111" - } - }); - - let url = "fjbytes.html?m=" + location.origin + $("a#exportOutputUrl").attr("href").replace(new RegExp(/\.[^.]*$/), '.map') + - "&g=" + location.origin + $("a#exportOutputUrl").attr("href").replace(new RegExp(/\.[^.]*$/), '.genotype') + - "&p=" + location.origin + $("a#exportOutputUrl").attr("href").replace(new RegExp(/\.[^.]*$/), '.phenotype') + - "&id=" + getModuleName(); - $('#fjBytesPanelHeader').html('
This is a functionality under development and might not be totally stable. Check https://github.com/cropgeeks/flapjack-bytes for information about Flapjack-Bytes.   Open in separate window
'); - $("#fjBytesFrame").attr('src', url); -} - -function sendToIGV(genomeID) -{ - var genomeID = $("select#igvGenome").val(); - $.ajax({ - type:"GET", - url:"http://127.0.0.1:" + igvDataLoadPort + "/load?" + (genomeID != "" ? "genome=" + genomeID + "&" : "") + "file=" + location.origin + $("a#exportOutputUrl").attr("href").replace(new RegExp(/\.[^.]*$/), '.vcf'), - success:function(tsvResult) { - alert("Variant list was sent to IGV!"); - }, - error:function(xhr, ajaxOptions, thrownError) { - handleError(xhr, ajaxOptions, thrownError); - } - }); -} - function getSelectedTypes() { var variantTypes = $('#variantTypes').val(); if (variantTypes === null || variantTypes.length === variantTypesCount) @@ -1136,59 +1057,6 @@ function checkGroupOverlap(groupNumber) { }); } -function sendToGalaxy(archivedDataFiles) { - var galaxyInstanceUrl = $("#galaxyInstanceURL").val().trim(), apiKey = sessionStorage.getItem("galaxyApiKey::" + galaxyInstanceUrl); - if (apiKey == null) - apiKey = prompt("Enter the API key tied to your account on\n" + galaxyInstanceUrl); - if (apiKey != null && apiKey.trim() != "") { - sessionStorage.setItem("galaxyApiKey::" + galaxyInstanceUrl, apiKey); - $('#progressText').html("Pushing files to " + galaxyInstanceUrl + " ..."); - $('#asyncProgressButton').hide(); - $('button#abort').hide(); - $('#progress').modal({ - backdrop: 'static', - keyboard: false, - show: true - }); - setTimeout(function() { - var n = 0, responseMsg = null; - for (var fileUrl in archivedDataFiles) - $.ajax({ - async: false, - url: galaxyPushURL + "?galaxyUrl=" + galaxyInstanceUrl + "&galaxyApiKey=" + apiKey + "&fileUrl=" + archivedDataFiles[fileUrl], - type: "GET", - success: function(respString) { - responseMsg = respString; - n++; - }, - error: function(xhr, ajaxOptions, thrownError) { - $('#progress').modal('hide'); - - if (xhr.status == 403) { - console.log("Removing invalid Galaxy API key: " + apiKey); - sessionStorage.removeItem("galaxyApiKey::" + galaxyInstanceUrl); - } - - if (thrownError == "" && xhr.getAllResponseHeaders() == '') - alert("Error accessing resource: " + genomeURL); - else - handleError(xhr, thrownError); - } - }); - if (n > 0) - if (confirm(n + " file(s) " + responseMsg + "\nOpen a window pointing to that Galaxy instance?")) - window.open(galaxyInstanceUrl); - $('#progress').modal('hide'); - }, 1); - } -} - -function getOutputToolConfig(toolName) -{ - var storedToolConfig = localStorage.getItem("outputTool_" + toolName); - return storedToolConfig != null ? JSON.parse(storedToolConfig) : onlineOutputTools[toolName]; -} - function applyOutputToolConfig(t) { if ($("input#outputToolURL").val().trim() == "") { localStorage.removeItem("outputTool_" + $("#onlineOutputTools").val()); @@ -1216,71 +1084,6 @@ function checkIfOuputToolConfigChanged() { $("#applyOutputToolConfig").prop('disabled', changed ? false : 'disabled'); } -function showServerExportBox() -{ - $("div#exportPanel").hide(); - $("a#exportBoxToggleButton").removeClass("active"); - if (processAborted || downloadURL == null) - return; - - var fileName = downloadURL.substring(downloadURL.lastIndexOf("/") + 1); - $('#serverExportBox').html(' Export file will be available at this URL for 48h:
' + fileName + ' ').show(); - var exportedFormat = $('#exportFormat').val().toUpperCase(); - if ("VCF" == exportedFormat) - addIgvExportIfRunning(); - else if ("FLAPJACK" == exportedFormat) - addFjBytesExport(); - - var archivedDataFiles = new Array(), exportFormatExtensions = $("#exportFormat option:selected").data('ext').split(";"); - if ($('#exportPanel input#exportedIndividualMetadataCheckBox').is(':checked') && "FLAPJACK" != exportedFormat && "DARWIN" != exportedFormat /* these two already have their own metadata file format*/) - exportFormatExtensions.push("tsv"); - for (var key in exportFormatExtensions) - archivedDataFiles[exportFormatExtensions[key]] = location.origin + downloadURL.replace(new RegExp(/\.[^.]*$/), '.' + exportFormatExtensions[key]); - - var galaxyInstanceUrl = $("#galaxyInstanceURL").val().trim(); - if (galaxyInstanceUrl.startsWith("http")) { - var fileURLs = ""; - for (key in archivedDataFiles) - fileURLs += (fileURLs == "" ? "" : " ,") + "'" + archivedDataFiles[key] + "'"; - $('#serverExportBox').append('

  '); - } - - if (onlineOutputTools != null) - for (var toolName in onlineOutputTools) { - var toolConfig = getOutputToolConfig(toolName); - if (toolConfig['url'] != null && toolConfig['url'].trim() != "" && (toolConfig['formats'] == null || toolConfig['formats'].trim() == "" || toolConfig['formats'].toUpperCase().split(",").includes($('#exportFormat').val().toUpperCase()))) { - - var formatsForThisButton = "", urlForThisButton = toolConfig['url']; - var matchResult = urlForThisButton.match(/{([^}]+)}/g); - if (matchResult != null) { - var placeHolders = matchResult.map(res => res.replace(/{|}/g , '')); - phLoop: for (var i in placeHolders) { - var phFormats = placeHolders[i].split("\|"); - for (var j in phFormats) { - for (var key in archivedDataFiles) { - if (key == phFormats[j]) { - formatsForThisButton += (formatsForThisButton == "" ? "" : ", ") + key; - urlForThisButton = urlForThisButton.replace("\{" + placeHolders[i] + "\}", archivedDataFiles[key]); - continue phLoop; - } - } - } - console.log("unused param: " + placeHolders[i]); - urlForThisButton = urlForThisButton.replace("\{" + placeHolders[i] + "\}", ""); - } - } - - if (urlForThisButton == toolConfig['url'] && urlForThisButton.indexOf("*") != -1) { - urlForThisButton = urlForThisButton.replace("\*", Object.values(archivedDataFiles).join(",")); - formatsForThisButton = Object.keys(archivedDataFiles).join(", "); - } - - if (formatsForThisButton != "") - $('#serverExportBox').append('

  ') - } - } -} - function resetFilters() { $('#genomeBrowserPanel').fadeOut(); $('#variantDetailPanel').fadeOut();