4 reference population upload from lists.
10 JSAN.use("CXGN.List");
11 JSAN.use("jquery.blockUI");
14 jQuery(document).ready( function() {
16 var list = new CXGN.List();
18 var listMenu = list.listSelect("list_type_training_pops", ['plots', 'trials']);
20 if (listMenu.match(/option/) != null) {
21 jQuery("#list_type_training_pops_list").append(listMenu);
23 jQuery("#list_type_training_pops_list").append("<select><option>no lists found</option></select>");
29 jQuery(document).ready( function() {
31 jQuery("<option>", {value: 'select...', selected: true})
32 .prependTo("#list_type_training_pops_list_select");
34 jQuery("#list_type_training_pops_list_select")
37 var listId = jQuery(this).find("option:selected").val();
39 var listDetail = getListTypeTrainingPopDetail(listId);
40 jQuery("#list_type_training_pop_load").click(function() {
42 if (listDetail.type.match(/plots/)) {
43 askJobQueueing(listId);
45 var trialsList = listDetail.list;
46 var trialsNames = listDetail.elementsNames;
48 loadTrialListTypeTrainingPop(trialsNames);
56 function getListElementsNames (list) {
59 for (var i = 0; i < list.length; i++) {
60 names.push(list[i][1]);
68 function getListTypeTrainingPopDetail(listId) {
70 var list = new CXGN.List();
76 var listElementsNames;
79 listData = list.getListData(listId);
80 listType = list.getListType(listId);
81 listName = list.listNameById(listId);
82 listElements = listData.elements;
84 listElementsNames = getListElementsNames(listElements);
87 return {'name' : listName,
88 'list' : listElements,
90 'elementsNames' : listElementsNames,
95 function loadTrialListTypeTrainingPop (trialsNames) {
99 url: '/solgs/get/trial/id/',
101 data: { 'trials_names': trialsNames},
102 success: function (res) {
103 getCombinedPopsId(res.trials_ids);
105 error: function(response) {
106 alert('Error occured querying for trials ids');
112 function askJobQueueing (listId) {
114 var args = createReqArgs(listId);
115 var modelId = args.population_id;
117 var page = '/solgs/population/' + modelId;
119 solGS.waitPage(page, args);
124 function createReqArgs (listId) {
126 var genoList = getListTypeTrainingPopDetail(listId);
127 var listName = genoList.name;
128 var list = genoList.list;
129 var popId = getModelId(listId);
131 var popType = 'uploaded_reference';
134 'list_name' : listName,
137 'analysis_type' : 'population download',
138 'data_set_type' : 'single population',
139 'population_id' : popId,
140 'population_type': popType,
148 function loadPlotListTypeTrainingPop(listId) {
150 var args = createReqArgs(listId);
151 var len = args.list.length;
152 var popId = args.population_id;
154 if (window.Prototype) {
155 delete Array.prototype.toJSON;
158 args = JSON.stringify(args);
161 alert('The list is empty. Please select a list with content.' );
164 jQuery.blockUI.defaults.applyPlatformOpacityRules = false;
165 jQuery.blockUI({message: 'Please wait..'});
170 data: {'arguments': args},
171 url: '/solgs/load/plots/list/training',
172 success: function(response) {
174 if (response.status == 'success') {
176 window.location = '/solgs/population/' + popId;
180 alert("fail: Error occured while querying for the training data.");
184 error: function(res) {
185 alert("Error occured while querying for the training data.");
193 jQuery.fn.doesExist = function(){
194 return jQuery(this).length > 0;
199 function getUserUploadedRefPop (listId) {
201 var genoList = getListTypeTrainingPopDetail(listId);
202 var listName = genoList.name;
203 var list = genoList.list;
204 var modelId = getModelId(listId);
206 var url = '\'/solgs/population/'+ modelId + '\'';
207 var listIdArg = '\'' + listId +'\'';
208 var listSource = '\'from_db\'';
209 var popIdName = {id : modelId, name: listName,};
210 popIdName = JSON.stringify(popIdName);
211 var hiddenInput = '<input type="hidden" value=\'' + popIdName + '\'/>';
213 var uploadedSelPop ='<table id="uploaded_reference_pops_table" style="width:100%; text-align:left"><tr>'
214 + '<th>List-based training population</th>'
219 + '<a href="/solgs/population/' + modelId + '\" onclick="javascript:loadPopulationPage(' + url + ','
220 + listIdArg + ',' + listSource + ')">' + '<data>'+ hiddenInput + '</data>'
223 + '<td id="list_reference_page_' + modelId + '">'
224 + '<a href="/solgs/population/' + modelId + '\" onclick="javascript:loadPopulationPage(' + url + ','
225 + listIdArg + ',' + listSource + ')">'
226 + '[ Build model ]'+ '</a>'
227 + '</td></tr></table>';
229 return uploadedSelPop;
233 function loadPopulationPage (url, listId, listSource) {
235 var genoList = getListTypeTrainingPopDetail(listId);
236 var listName = genoList.name;
237 var modelId = getModelId(listId);
239 jQuery.blockUI.defaults.applyPlatformOpacityRules = false;
240 jQuery.blockUI({message: 'Please wait..'});
247 'uploaded_reference': 1,
249 'list_source': listSource,
250 'list_name' : listName,
252 success: function (response) {
254 if (response.status == 'success') {
258 alert('Fail: Error occured calculating GEBVs for the list of selection genotypes.');
262 error: function(response) {
263 alert('error: ' + res.responseText);
271 function getModelId (listId) {
273 var modelId = 'uploaded_' + listId;