2 * solGS prediction raw, model input downloads
3 * Isaak Y Tecle <iyt2@cornell.edu>
7 var solGS = solGS || function solGS() {};
10 getTrainingPopRawDataFiles: function () {
11 var args = solGS.getTrainingPopArgs();
12 args = JSON.stringify(args);
14 var popDataReq = jQuery.ajax({
20 url: "/solgs/download/training/pop/data",
26 getSelectionPopRawDataFiles: function () {
27 var args = solGS.getSelectionPopArgs();
28 args = JSON.stringify(args);
30 var popDataReq = jQuery.ajax({
36 url: "/solgs/download/selection/pop/data",
43 getTraitsAcronymFile: function () {
44 var args = solGS.getTrainingPopArgs();
45 args = JSON.stringify(args);
47 var popDataReq = jQuery.ajax({
53 url: "/solgs/download/traits/acronym",
59 createTrainingPopDownloadLinks: function (res) {
60 var genoFiles = res.training_pop_raw_geno_file;
61 var phenoFiles = res.training_pop_raw_pheno_file;
62 var genoFileLink = '';
65 genoFiles.forEach(function(genoFile) {
66 var genoFileName = genoFile.split("/").pop();
67 var genoTxt = "Genotype data";
68 if (genoFiles.length > 1) { genoTxt = genoTxt + "-" + cnt};
69 if ( cnt > 1) { genoFileLink += ' | '};
72 '<a href="' + genoFile + '" download=' + genoFileName + '">' + genoTxt + "</a>";
77 var phenoFileLink = '';
80 phenoFiles.forEach(function(phenoFile) {
81 var phenoFileName = phenoFile.split("/").pop();
82 var phenoTxt = "Phenotype data";
83 if (phenoFiles.length > 1) { phenoTxt = phenoTxt + "-" + cnt};
84 if ( cnt > 1) { phenoFileLink += ' | '};
87 '<a href="' + phenoFile + '" download=' + phenoFileName + '">' + phenoTxt + "</a>";
92 var traitsAcronymLink = this.createTraitsAcronymLinks(res);
95 " <strong>Download training population</strong>: " +
98 phenoFileLink + " | " + traitsAcronymLink;
100 jQuery("#training_pop_download").prepend(
101 '<p style="margin-top: 20px">' + downloadLinks + "</p>"
106 createTraitsAcronymLinks: function (res) {
107 var acronymFile = res.traits_acronym_file;
109 var acronymFileName = acronymFile.split("/").pop();
110 var acronymFileLink =
111 '<a href="' + acronymFile + '" download=' + acronymFileName + '">' + "Traits acronyms" + "</a>";
113 return acronymFileLink;
117 createSelectionPopDownloadLinks: function (res) {
118 var genoFile = res.selection_pop_filtered_geno_file;
119 var reportFile = res.selection_prediction_report_file;
121 var genoFileName = genoFile.split("/").pop();
123 '<a href="' + genoFile + '" download=' + genoFileName + '">' + "Genotype data" + "</a>";
125 var reportFileName = reportFile.split("/").pop();
127 '<a href="' + reportFile + '" download=' + reportFileName + '">' + "Analysis log" + "</a>";
130 " <strong>Download selection population</strong>: " +
131 genoFileLink + ' | ' + reportFileLink;
133 jQuery("#selection_pop_download").prepend(
134 '<p style="margin-top: 20px">' + downloadLinks + "</p>"
138 getModelInputDataFiles: function () {
139 var args = solGS.getModelArgs();
140 args = JSON.stringify(args);
142 var modelInputReq = jQuery.ajax({
148 url: "/solgs/download/model/input/data",
151 return modelInputReq;
154 createModelInputDownloadLinks: function (res) {
155 var genoFile = res.model_geno_data_file;
156 var phenoFile = res.model_pheno_data_file;
157 var logFile = res.model_analysis_report_file;
159 console.log("geno file: " + genoFile);
160 console.log("pheno file: " + phenoFile);
161 console.log("log file: " + logFile);
163 var genoFileName = genoFile.split("/").pop();
165 '<a href="' + genoFile + '" download=' + genoFileName + '">' + "Genotype data" + "</a>";
167 var phenoFileName = phenoFile.split("/").pop();
169 '<a href="' + phenoFile + '" download=' + phenoFileName + '">' + "Phenotype data" + "</a>";
171 var logFileName = logFile.split("/").pop();
173 '<a href="' + logFile + '" download=' + logFileName + '">' + "Analysis log" + "</a>";
175 " <strong>Download model</strong>: " + genoFileLink + " | " + phenoFileLink + " | " + logFileLink;
177 jQuery("#model_input_data_download").prepend(
178 '<p style="margin-top: 20px">' + downloadLinks + "</p>"
182 getValidationFile: function () {
183 var args = solGS.getModelArgs();
184 args = JSON.stringify(args);
186 var valDataReq = jQuery.ajax({
192 url: "/solgs/download/model/validation",
198 createValidationDownloadLink: function (res) {
199 var valFileName = res.validation_file.split("/").pop();
202 res.validation_file +
206 "Download model accuracy" +
209 jQuery("#validation_download").prepend('<p style="margin-top: 20px">' + valFileLink + "</p>");
212 getMarkerEffectsFile: function () {
213 var args = solGS.getModelArgs();
214 args = JSON.stringify(args);
216 var markerEffectsReq = jQuery.ajax({
222 url: "/solgs/download/model/marker/effects",
225 return markerEffectsReq;
228 createMarkerEffectsDownloadLink: function (res) {
229 var effectsFileName = res.marker_effects_file.split("/").pop();
230 var effectsFileLink =
232 res.marker_effects_file +
236 "Download marker effects" +
239 jQuery("#marker_effects_download").prepend(
240 '<p style="margin-top: 20px">' + effectsFileLink + "</p>"
245 jQuery(document).ready(function () {
247 var downloadMsgDiv = "#download_message";
248 solGS.checkPageType().done(function (res) {
249 if (res.page_type.match(/training_population/)) {
250 solGS.download.getTrainingPopRawDataFiles().done(function (res) {
251 solGS.download.createTrainingPopDownloadLinks(res);
254 solGS.download.getTrainingPopRawDataFiles().fail(function (res) {
255 var errorMsg = "Error occured getting training pop raw data files.";
256 solGS.showMessage(downloadMsgDiv, errorMsg)
259 solGS.download.getTrainingPopRawDataFiles().fail(function (res) {
260 var errorMsg = "Error occured getting training pop raw data files.";
261 solGS.showMessage(downloadMsgDiv, errorMsg)
265 } else if (res.page_type.match(/training_model/)) {
266 solGS.download.getModelInputDataFiles().done(function (res) {
267 solGS.download.createModelInputDownloadLinks(res);
270 solGS.download.getModelInputDataFiles().fail(function (res) {
271 var errorMsg = "Error occured getting model input data files.";
272 solGS.showMessage(downloadMsgDiv, errorMsg)
275 solGS.download.getValidationFile().done(function (res) {
276 solGS.download.createValidationDownloadLink(res);
279 solGS.download.getValidationFile().fail(function (res) {
280 var errorMsg = "Error occured getting model validation file.";
281 solGS.showMessage("#validation_download_message", errorMsg);
284 solGS.download.getMarkerEffectsFile().done(function (res) {
285 solGS.download.createMarkerEffectsDownloadLink(res);
288 solGS.download.getMarkerEffectsFile().fail(function (res) {
289 var errorMsg = "Error occured getting marker effects file.";
290 solGS.showMessage("#marker_effects_download_message", errorMsg);
293 } else if (res.page_type.match(/selection_prediction/)) {
294 solGS.download.getSelectionPopRawDataFiles().done(function (res) {
295 solGS.download.createSelectionPopDownloadLinks(res);
298 solGS.download.getSelectionPopRawDataFiles().fail(function (res) {
299 var errorMsg = "Error occured getting selection population genotype data files.";
300 solGS.showMessage(downloadMsgDiv, errorMsg);
305 solGS.checkPageType().fail(function (res) {
306 var errorMsg = "Error occured checking for page type.";
307 solGS.showMessage(downloadMsgDiv, errorMsg)