6357 |
26 Aug 21 |
nicklas |
var TargetedGT = function() |
6357 |
26 Aug 21 |
nicklas |
2 |
{ |
6357 |
26 Aug 21 |
nicklas |
var gt = {}; |
6357 |
26 Aug 21 |
nicklas |
var debug = 0; |
6357 |
26 Aug 21 |
nicklas |
var manuallySelected = []; |
6357 |
26 Aug 21 |
nicklas |
var selectionIsValid = false; |
6357 |
26 Aug 21 |
nicklas |
var rawDataType; |
6357 |
26 Aug 21 |
nicklas |
var pipeline; |
6357 |
26 Aug 21 |
nicklas |
var annotationTypePipeline; |
6357 |
26 Aug 21 |
nicklas |
var targets; |
6357 |
26 Aug 21 |
nicklas |
var numTargetsSelected = 0; |
6357 |
26 Aug 21 |
nicklas |
12 |
|
6357 |
26 Aug 21 |
nicklas |
// Page initialization |
6357 |
26 Aug 21 |
nicklas |
gt.initPage = function() |
6357 |
26 Aug 21 |
nicklas |
15 |
{ |
6357 |
26 Aug 21 |
nicklas |
// Step 1 |
6357 |
26 Aug 21 |
nicklas |
Buttons.addClickHandler('btnSelectRawBioAssays', gt.selectRawBioAssays); |
6357 |
26 Aug 21 |
nicklas |
Events.addEventHandler('rawBioAssays', 'base-selected', gt.setRawBioAssayCallback); |
6357 |
26 Aug 21 |
nicklas |
Events.addEventHandler('rawBioAssays', 'change', gt.rawBioAssaysOnChange); |
6357 |
26 Aug 21 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', gt.validateStep1); |
6357 |
26 Aug 21 |
nicklas |
21 |
|
6357 |
26 Aug 21 |
nicklas |
// Step 2 |
6357 |
26 Aug 21 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', gt.initializeStep2); |
6357 |
26 Aug 21 |
nicklas |
Events.addEventHandler('clusters', 'change', gt.clusterOnChange); |
7372 |
06 Oct 23 |
nicklas |
Events.addEventHandler('debug', 'change', gt.debugOnChange); |
7372 |
06 Oct 23 |
nicklas |
Events.addEventHandler('override', 'change', gt.overrideOnChange); |
6357 |
26 Aug 21 |
nicklas |
Events.addEventHandler('gtSoftware', 'change', gt.softwareOnChange); |
6357 |
26 Aug 21 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', gt.validateStep2); |
6357 |
26 Aug 21 |
nicklas |
29 |
|
6357 |
26 Aug 21 |
nicklas |
// Navigation |
6357 |
26 Aug 21 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
6357 |
26 Aug 21 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
6357 |
26 Aug 21 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
6357 |
26 Aug 21 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
6357 |
26 Aug 21 |
nicklas |
35 |
|
6357 |
26 Aug 21 |
nicklas |
// Final registration |
6357 |
26 Aug 21 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', gt.submit); |
6357 |
26 Aug 21 |
nicklas |
38 |
|
6360 |
27 Aug 21 |
nicklas |
var url = '../VariantCalling.servlet?ID='+App.getSessionId(); |
6360 |
27 Aug 21 |
nicklas |
url += '&cmd=GetTargetedGenotypeDefs'; |
6360 |
27 Aug 21 |
nicklas |
Wizard.asyncJsonRequest(url, gt.targetsLoaded); |
6360 |
27 Aug 21 |
nicklas |
42 |
} |
6360 |
27 Aug 21 |
nicklas |
43 |
|
6360 |
27 Aug 21 |
nicklas |
gt.targetsLoaded = function(response) |
6360 |
27 Aug 21 |
nicklas |
45 |
{ |
6360 |
27 Aug 21 |
nicklas |
targets = response.targets; |
6360 |
27 Aug 21 |
nicklas |
if (targets.length == 0) |
6360 |
27 Aug 21 |
nicklas |
48 |
{ |
6360 |
27 Aug 21 |
nicklas |
Wizard.setFatalError('No targeted genotype definitions have been configured in reggie-config.xml.'); |
6360 |
27 Aug 21 |
nicklas |
return; |
6360 |
27 Aug 21 |
nicklas |
51 |
} |
6360 |
27 Aug 21 |
nicklas |
52 |
|
6360 |
27 Aug 21 |
nicklas |
var html = ''; |
6360 |
27 Aug 21 |
nicklas |
for (var tNo = 0; tNo < targets.length; tNo++) |
6360 |
27 Aug 21 |
nicklas |
55 |
{ |
6360 |
27 Aug 21 |
nicklas |
var target = targets[tNo]; |
6360 |
27 Aug 21 |
nicklas |
html += '<tr class="align-top" id="targetrow.'+tNo+'">'; |
6360 |
27 Aug 21 |
nicklas |
html += '<td class="subprompt"><label for="target.'+tNo+'">'+Strings.encodeTags(target.name)+'</label></td>'; |
6360 |
27 Aug 21 |
nicklas |
html += '<td style="width: 2em;"><input type="checkbox" name="target.'+tNo+'" id="target.'+tNo+'"></td>'; |
6360 |
27 Aug 21 |
nicklas |
html += '<td class="input"><div class="targetdescription">'+(Strings.encodeTags(target.description) || ' ')+'</div></td>'; |
6360 |
27 Aug 21 |
nicklas |
html += '<td class="status" id="target.'+tNo+'.status"></td>'; |
6360 |
27 Aug 21 |
nicklas |
html += '<td class="help"><span id="target.'+tNo+'.message" class="message"></span></td>'; |
6360 |
27 Aug 21 |
nicklas |
html += '</tr>'; |
6360 |
27 Aug 21 |
nicklas |
64 |
} |
6360 |
27 Aug 21 |
nicklas |
Doc.element('targets').innerHTML = html; |
6360 |
27 Aug 21 |
nicklas |
Forms.linkCheckboxesWithLabels(Doc.element('targets')); |
6360 |
27 Aug 21 |
nicklas |
67 |
|
6360 |
27 Aug 21 |
nicklas |
for (var tNo = 0; tNo < targets.length; tNo++) |
6360 |
27 Aug 21 |
nicklas |
69 |
{ |
6360 |
27 Aug 21 |
nicklas |
var target = targets[tNo]; |
6360 |
27 Aug 21 |
nicklas |
var checkbox = Doc.element('target.'+tNo); |
6360 |
27 Aug 21 |
nicklas |
if (target.error) |
6360 |
27 Aug 21 |
nicklas |
73 |
{ |
6360 |
27 Aug 21 |
nicklas |
Wizard.setInputStatus('target.'+tNo, 'warning', Reggie.softLineBreaks(target.error)); |
6360 |
27 Aug 21 |
nicklas |
checkbox.disabled = true; |
6360 |
27 Aug 21 |
nicklas |
76 |
} |
6360 |
27 Aug 21 |
nicklas |
else |
6360 |
27 Aug 21 |
nicklas |
78 |
{ |
6360 |
27 Aug 21 |
nicklas |
checkbox.checked = true; |
6360 |
27 Aug 21 |
nicklas |
80 |
} |
6360 |
27 Aug 21 |
nicklas |
Events.addEventHandler(checkbox, 'change', gt.onTargetSelected); |
6360 |
27 Aug 21 |
nicklas |
82 |
} |
6360 |
27 Aug 21 |
nicklas |
83 |
|
6357 |
26 Aug 21 |
nicklas |
Wizard.showLoadingAnimation('Loading bioassays...'); |
6357 |
26 Aug 21 |
nicklas |
var url = '../VariantCalling.servlet?ID='+App.getSessionId(); |
6357 |
26 Aug 21 |
nicklas |
url += '&cmd=GetRawBioAssaysForTargetedGenotyping'; |
6357 |
26 Aug 21 |
nicklas |
Wizard.asyncJsonRequest(url, gt.initializeStep1); |
6357 |
26 Aug 21 |
nicklas |
88 |
} |
6357 |
26 Aug 21 |
nicklas |
89 |
|
6357 |
26 Aug 21 |
nicklas |
// --- Step 1 ----------------------------------- |
6357 |
26 Aug 21 |
nicklas |
gt.initializeStep1 = function(response) |
6357 |
26 Aug 21 |
nicklas |
92 |
{ |
6357 |
26 Aug 21 |
nicklas |
var frm = document.forms['reggie']; |
6357 |
26 Aug 21 |
nicklas |
94 |
|
6357 |
26 Aug 21 |
nicklas |
rawDataType = response.rawDataType; |
6357 |
26 Aug 21 |
nicklas |
pipeline = response.pipeline; |
6357 |
26 Aug 21 |
nicklas |
97 |
|
6357 |
26 Aug 21 |
nicklas |
var rawBioAssays = response.rawBioAssays; |
6357 |
26 Aug 21 |
nicklas |
if (rawBioAssays.length > 0) |
6357 |
26 Aug 21 |
nicklas |
100 |
{ |
6357 |
26 Aug 21 |
nicklas |
var firstPlate = null; |
6357 |
26 Aug 21 |
nicklas |
for (var rawNo=0; rawNo < rawBioAssays.length; rawNo++) |
6357 |
26 Aug 21 |
nicklas |
103 |
{ |
6357 |
26 Aug 21 |
nicklas |
var raw = rawBioAssays[rawNo]; |
6357 |
26 Aug 21 |
nicklas |
105 |
|
6357 |
26 Aug 21 |
nicklas |
var libPlate = raw.lib.bioWell ? raw.lib.bioWell.bioPlate : null; |
6357 |
26 Aug 21 |
nicklas |
if (firstPlate == null && libPlate != null) firstPlate = libPlate.name; |
6357 |
26 Aug 21 |
nicklas |
var option = gt.createListOption(rawNo+1, raw, raw.DO_NOT_USE == null && libPlate != null && libPlate.name==firstPlate) |
6357 |
26 Aug 21 |
nicklas |
frm.rawBioAssays.options[frm.rawBioAssays.length] = option; |
6357 |
26 Aug 21 |
nicklas |
110 |
} |
6357 |
26 Aug 21 |
nicklas |
Events.sendChangeEvent('rawBioAssays'); |
6357 |
26 Aug 21 |
nicklas |
112 |
} |
6357 |
26 Aug 21 |
nicklas |
else |
6357 |
26 Aug 21 |
nicklas |
114 |
{ |
6357 |
26 Aug 21 |
nicklas |
Wizard.setInputStatus('rawBioAssays', 'invalid', 'No raw bioassays available for processing'); |
6357 |
26 Aug 21 |
nicklas |
116 |
} |
6357 |
26 Aug 21 |
nicklas |
117 |
|
6357 |
26 Aug 21 |
nicklas |
Doc.show('step-1'); |
6357 |
26 Aug 21 |
nicklas |
Doc.show('gonext'); |
6357 |
26 Aug 21 |
nicklas |
120 |
} |
6357 |
26 Aug 21 |
nicklas |
121 |
|
6357 |
26 Aug 21 |
nicklas |
gt.validateStep1 = function(event) |
6357 |
26 Aug 21 |
nicklas |
123 |
{ |
6357 |
26 Aug 21 |
nicklas |
if (!selectionIsValid) event.preventDefault(); |
6357 |
26 Aug 21 |
nicklas |
125 |
} |
6357 |
26 Aug 21 |
nicklas |
126 |
|
6357 |
26 Aug 21 |
nicklas |
gt.selectRawBioAssays = function() |
6357 |
26 Aug 21 |
nicklas |
128 |
{ |
6357 |
26 Aug 21 |
nicklas |
var frm = document.forms['reggie']; |
6357 |
26 Aug 21 |
nicklas |
if (frm.rawBioAssays.disabled) return; |
6357 |
26 Aug 21 |
nicklas |
// Reset list |
6357 |
26 Aug 21 |
nicklas |
manuallySelected = []; |
6357 |
26 Aug 21 |
nicklas |
var url = '&resetTemporary=1'; |
6357 |
26 Aug 21 |
nicklas |
if (rawDataType) url += '&tmpfilter:STRING:rawDataType='+encodeURIComponent(rawDataType); |
6357 |
26 Aug 21 |
nicklas |
if (pipeline != null) |
6357 |
26 Aug 21 |
nicklas |
136 |
{ |
6357 |
26 Aug 21 |
nicklas |
if (annotationTypePipeline == null) |
6357 |
26 Aug 21 |
nicklas |
138 |
{ |
6357 |
26 Aug 21 |
nicklas |
annotationTypePipeline = Reggie.getAnnotationTypeInfo('PIPELINE'); |
6357 |
26 Aug 21 |
nicklas |
140 |
} |
6357 |
26 Aug 21 |
nicklas |
url += '&tmpfilter:STRING:'+encodeURIComponent('#')+annotationTypePipeline.id+'='+encodeURIComponent(pipeline); |
6357 |
26 Aug 21 |
nicklas |
142 |
} |
6357 |
26 Aug 21 |
nicklas |
Dialogs.selectItem('RAWBIOASSAY', 'rawBioAssays', 1, url); |
6357 |
26 Aug 21 |
nicklas |
144 |
} |
6357 |
26 Aug 21 |
nicklas |
145 |
|
6357 |
26 Aug 21 |
nicklas |
gt.setRawBioAssayCallback = function(event) |
6357 |
26 Aug 21 |
nicklas |
147 |
{ |
6357 |
26 Aug 21 |
nicklas |
var raw = event.detail; |
6357 |
26 Aug 21 |
nicklas |
149 |
|
6357 |
26 Aug 21 |
nicklas |
var opt = Reggie.getListOption('rawBioAssays', raw.id); |
6357 |
26 Aug 21 |
nicklas |
if (opt) |
6357 |
26 Aug 21 |
nicklas |
152 |
{ |
6357 |
26 Aug 21 |
nicklas |
opt.selected = true; |
6357 |
26 Aug 21 |
nicklas |
154 |
} |
6357 |
26 Aug 21 |
nicklas |
else |
6357 |
26 Aug 21 |
nicklas |
156 |
{ |
6357 |
26 Aug 21 |
nicklas |
manuallySelected[manuallySelected.length] = raw.id; |
6357 |
26 Aug 21 |
nicklas |
158 |
} |
6357 |
26 Aug 21 |
nicklas |
159 |
|
6357 |
26 Aug 21 |
nicklas |
if (raw.remaining == 0 && manuallySelected.length > 0) |
6357 |
26 Aug 21 |
nicklas |
161 |
{ |
6357 |
26 Aug 21 |
nicklas |
var url = '../VariantCalling.servlet?ID='+App.getSessionId(); |
6357 |
26 Aug 21 |
nicklas |
url += '&cmd=GetRawBioAssaysForTargetedGenotyping'; |
6357 |
26 Aug 21 |
nicklas |
url += '&items='+manuallySelected.join(','); |
6357 |
26 Aug 21 |
nicklas |
Wizard.showLoadingAnimation('Loading bioassays...'); |
6357 |
26 Aug 21 |
nicklas |
Wizard.asyncJsonRequest(url, gt.manuallySelected); |
6357 |
26 Aug 21 |
nicklas |
167 |
} |
6357 |
26 Aug 21 |
nicklas |
else |
6357 |
26 Aug 21 |
nicklas |
169 |
{ |
6357 |
26 Aug 21 |
nicklas |
Events.sendChangeEvent('rawBioAssays'); |
6357 |
26 Aug 21 |
nicklas |
171 |
} |
6357 |
26 Aug 21 |
nicklas |
172 |
} |
6357 |
26 Aug 21 |
nicklas |
173 |
|
6357 |
26 Aug 21 |
nicklas |
gt.manuallySelected = function(response) |
6357 |
26 Aug 21 |
nicklas |
175 |
{ |
6357 |
26 Aug 21 |
nicklas |
var rawBioAssays = response.rawBioAssays; |
6357 |
26 Aug 21 |
nicklas |
var frm = document.forms['reggie']; |
6357 |
26 Aug 21 |
nicklas |
178 |
|
6357 |
26 Aug 21 |
nicklas |
if (rawBioAssays != null && rawBioAssays.length > 0) |
6357 |
26 Aug 21 |
nicklas |
180 |
{ |
6357 |
26 Aug 21 |
nicklas |
var offset = frm.rawBioAssays.length+1; |
6357 |
26 Aug 21 |
nicklas |
for (var rawNo=0; rawNo < rawBioAssays.length; rawNo++) |
6357 |
26 Aug 21 |
nicklas |
183 |
{ |
6357 |
26 Aug 21 |
nicklas |
var raw = rawBioAssays[rawNo]; |
6357 |
26 Aug 21 |
nicklas |
var option = gt.createListOption(rawNo+offset, raw, raw.DO_NOT_USE == null); |
6357 |
26 Aug 21 |
nicklas |
frm.rawBioAssays.options[frm.rawBioAssays.length] = option; |
6357 |
26 Aug 21 |
nicklas |
187 |
} |
6357 |
26 Aug 21 |
nicklas |
Events.sendChangeEvent('rawBioAssays'); |
6357 |
26 Aug 21 |
nicklas |
189 |
} |
6357 |
26 Aug 21 |
nicklas |
190 |
} |
6357 |
26 Aug 21 |
nicklas |
191 |
|
6357 |
26 Aug 21 |
nicklas |
gt.createListOption = function(index, rawItem, selected) |
6357 |
26 Aug 21 |
nicklas |
193 |
{ |
6357 |
26 Aug 21 |
nicklas |
var lib = rawItem.lib; |
6357 |
26 Aug 21 |
nicklas |
var isYellow = lib.specimen && lib.specimen.YellowLabel != null; |
6357 |
26 Aug 21 |
nicklas |
var libPlate = lib.bioWell ? lib.bioWell.bioPlate : null; |
6357 |
26 Aug 21 |
nicklas |
197 |
|
6357 |
26 Aug 21 |
nicklas |
var tooltip = null; |
6357 |
26 Aug 21 |
nicklas |
var name = (index) + ': '; |
6357 |
26 Aug 21 |
nicklas |
if (libPlate) name += libPlate.name + ' - '; |
6357 |
26 Aug 21 |
nicklas |
name += rawItem.name; |
6357 |
26 Aug 21 |
nicklas |
202 |
|
6357 |
26 Aug 21 |
nicklas |
if (rawItem.DO_NOT_USE) |
6357 |
26 Aug 21 |
nicklas |
204 |
{ |
6357 |
26 Aug 21 |
nicklas |
name += ' [DoNotUse]'; |
6357 |
26 Aug 21 |
nicklas |
tooltip = 'DoNotUse-'+Strings.encodeTags(rawItem.DO_NOT_USE+': '+rawItem.DO_NOT_USE_COMMENT); |
6357 |
26 Aug 21 |
nicklas |
207 |
} |
6357 |
26 Aug 21 |
nicklas |
else if (rawItem.AutoProcess == 'ReProcess') |
6357 |
26 Aug 21 |
nicklas |
209 |
{ |
6357 |
26 Aug 21 |
nicklas |
name += ' [R]'; |
6357 |
26 Aug 21 |
nicklas |
211 |
} |
6357 |
26 Aug 21 |
nicklas |
212 |
|
6357 |
26 Aug 21 |
nicklas |
var option = new Option(name, rawItem.id, false, selected); |
6357 |
26 Aug 21 |
nicklas |
if (isYellow) option.className = 'yellow'; |
6357 |
26 Aug 21 |
nicklas |
if (tooltip) option.title = tooltip; |
6357 |
26 Aug 21 |
nicklas |
option.rawBioAssay = rawItem; |
6357 |
26 Aug 21 |
nicklas |
return option; |
6357 |
26 Aug 21 |
nicklas |
218 |
} |
6357 |
26 Aug 21 |
nicklas |
219 |
|
6357 |
26 Aug 21 |
nicklas |
gt.rawBioAssaysOnChange = function() |
6357 |
26 Aug 21 |
nicklas |
221 |
{ |
6357 |
26 Aug 21 |
nicklas |
var frm = document.forms['reggie']; |
6357 |
26 Aug 21 |
nicklas |
223 |
|
6357 |
26 Aug 21 |
nicklas |
selectionIsValid = false; |
6357 |
26 Aug 21 |
nicklas |
var numSelected = 0; |
6357 |
26 Aug 21 |
nicklas |
var numDoNotUse = 0; |
6357 |
26 Aug 21 |
nicklas |
var invalidPipeline = null; |
6357 |
26 Aug 21 |
nicklas |
228 |
|
6357 |
26 Aug 21 |
nicklas |
Wizard.setInputStatus('rawBioAssays'); |
6357 |
26 Aug 21 |
nicklas |
Wizard.hideGoNextConfirmation(); |
6357 |
26 Aug 21 |
nicklas |
231 |
|
6357 |
26 Aug 21 |
nicklas |
for (var rawNo = 0; rawNo < frm.rawBioAssays.length; rawNo++) |
6357 |
26 Aug 21 |
nicklas |
233 |
{ |
6357 |
26 Aug 21 |
nicklas |
if (frm.rawBioAssays[rawNo].selected) |
6357 |
26 Aug 21 |
nicklas |
235 |
{ |
6357 |
26 Aug 21 |
nicklas |
numSelected++; |
6357 |
26 Aug 21 |
nicklas |
237 |
|
6357 |
26 Aug 21 |
nicklas |
var raw = frm.rawBioAssays[rawNo].rawBioAssay; |
6357 |
26 Aug 21 |
nicklas |
if (raw.DO_NOT_USE) numDoNotUse++; |
6357 |
26 Aug 21 |
nicklas |
240 |
|
6357 |
26 Aug 21 |
nicklas |
if (pipeline && raw.pipeline && raw.pipeline != pipeline) |
6357 |
26 Aug 21 |
nicklas |
242 |
{ |
6357 |
26 Aug 21 |
nicklas |
invalidPipeline = Strings.encodeTags(raw.name+' ('+raw.pipeline)+') is not intended for the '+pipeline+' pipeline.'; |
6357 |
26 Aug 21 |
nicklas |
244 |
} |
6357 |
26 Aug 21 |
nicklas |
245 |
} |
6357 |
26 Aug 21 |
nicklas |
246 |
} |
6357 |
26 Aug 21 |
nicklas |
if (numSelected == 0) |
6357 |
26 Aug 21 |
nicklas |
248 |
{ |
6357 |
26 Aug 21 |
nicklas |
Wizard.setInputStatus('rawBioAssays', 'invalid', 'Select at least one item'); |
6357 |
26 Aug 21 |
nicklas |
return; |
6357 |
26 Aug 21 |
nicklas |
251 |
} |
6357 |
26 Aug 21 |
nicklas |
if (invalidPipeline) |
6357 |
26 Aug 21 |
nicklas |
253 |
{ |
6357 |
26 Aug 21 |
nicklas |
Wizard.setInputStatus('rawBioAssays', 'invalid', invalidPipeline); |
6357 |
26 Aug 21 |
nicklas |
return; |
6357 |
26 Aug 21 |
nicklas |
256 |
} |
6357 |
26 Aug 21 |
nicklas |
selectionIsValid = true; |
6357 |
26 Aug 21 |
nicklas |
258 |
|
6357 |
26 Aug 21 |
nicklas |
if (numDoNotUse > 0) |
6357 |
26 Aug 21 |
nicklas |
260 |
{ |
6357 |
26 Aug 21 |
nicklas |
Wizard.setInputStatus('rawBioAssays', 'warning', numDoNotUse + ' selected items marked as DoNotUse'); |
6357 |
26 Aug 21 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Confirm ' + numDoNotUse + ' items marked as DoNotUse'); |
6357 |
26 Aug 21 |
nicklas |
263 |
} |
6357 |
26 Aug 21 |
nicklas |
else |
6357 |
26 Aug 21 |
nicklas |
265 |
{ |
6357 |
26 Aug 21 |
nicklas |
Wizard.setInputStatus('rawBioAssays', 'valid'); |
6357 |
26 Aug 21 |
nicklas |
267 |
} |
6357 |
26 Aug 21 |
nicklas |
268 |
} |
6357 |
26 Aug 21 |
nicklas |
269 |
|
6357 |
26 Aug 21 |
nicklas |
gt.initializeStep2 = function() |
6357 |
26 Aug 21 |
nicklas |
271 |
{ |
6357 |
26 Aug 21 |
nicklas |
// Check debug by default if debug is set or not on a secure server (=production server) |
6357 |
26 Aug 21 |
nicklas |
var frm = document.forms['reggie']; |
6357 |
26 Aug 21 |
nicklas |
frm.debug.checked = debug || location.protocol != 'https:'; |
6357 |
26 Aug 21 |
nicklas |
275 |
|
6357 |
26 Aug 21 |
nicklas |
Reggie.loadSoftware('VARIANT_CALLING_SOFTWARE', 'gtSoftware', 'VARIANT_CALL_TYPE,PARAMETER_SET', 'TargetedGenotype'); |
6357 |
26 Aug 21 |
nicklas |
277 |
|
6735 |
09 May 22 |
nicklas |
// Load clusters |
6657 |
30 Mar 22 |
nicklas |
var url = '../OpenGrid.servlet?ID='+App.getSessionId() + '&cmd=GetHostInfo&config=targeted-genotyping'; |
6357 |
26 Aug 21 |
nicklas |
Doc.addClass('clusters', 'list-loading'); |
6357 |
26 Aug 21 |
nicklas |
frm.clusters[0] = new Option('loading...'); |
6357 |
26 Aug 21 |
nicklas |
Wizard.asyncJsonRequest(url, gt.clustersLoaded); |
6360 |
27 Aug 21 |
nicklas |
283 |
|
6360 |
27 Aug 21 |
nicklas |
gt.onTargetSelected(); |
6360 |
27 Aug 21 |
nicklas |
Wizard.setCurrentStep(2); |
6360 |
27 Aug 21 |
nicklas |
Doc.show('goregister'); |
6360 |
27 Aug 21 |
nicklas |
Doc.show('gocancel'); |
6357 |
26 Aug 21 |
nicklas |
288 |
} |
6357 |
26 Aug 21 |
nicklas |
289 |
|
6357 |
26 Aug 21 |
nicklas |
gt.clustersLoaded = function(response) |
6357 |
26 Aug 21 |
nicklas |
291 |
{ |
6357 |
26 Aug 21 |
nicklas |
Doc.removeClass('clusters', 'list-loading'); |
6357 |
26 Aug 21 |
nicklas |
var frm = document.forms['reggie']; |
6357 |
26 Aug 21 |
nicklas |
var clusters = response.hosts; |
6357 |
26 Aug 21 |
nicklas |
frm.clusters.length = 0; |
6357 |
26 Aug 21 |
nicklas |
for (var i = 0; i < clusters.length; i++) |
6357 |
26 Aug 21 |
nicklas |
297 |
{ |
6357 |
26 Aug 21 |
nicklas |
var cl = clusters[i]; |
6357 |
26 Aug 21 |
nicklas |
var option = new Option(cl.connection.name, cl.id); |
6357 |
26 Aug 21 |
nicklas |
option.cluster = cl; |
6357 |
26 Aug 21 |
nicklas |
frm.clusters[frm.clusters.length] = option; |
6357 |
26 Aug 21 |
nicklas |
Wizard.setInputStatus('clusters', 'valid'); |
6357 |
26 Aug 21 |
nicklas |
clusterIsValid = true; |
6357 |
26 Aug 21 |
nicklas |
304 |
} |
6357 |
26 Aug 21 |
nicklas |
if (frm.clusters.length == 0) |
6357 |
26 Aug 21 |
nicklas |
306 |
{ |
6735 |
09 May 22 |
nicklas |
Wizard.setInputStatus('clusters', 'invalid', 'No available clusters'); |
6357 |
26 Aug 21 |
nicklas |
clusterIsValid = false; |
6357 |
26 Aug 21 |
nicklas |
309 |
} |
6357 |
26 Aug 21 |
nicklas |
else |
6357 |
26 Aug 21 |
nicklas |
311 |
{ |
6357 |
26 Aug 21 |
nicklas |
gt.clusterOnChange(); |
6357 |
26 Aug 21 |
nicklas |
313 |
} |
6357 |
26 Aug 21 |
nicklas |
314 |
} |
6357 |
26 Aug 21 |
nicklas |
315 |
|
6357 |
26 Aug 21 |
nicklas |
gt.clusterOnChange = function() |
6357 |
26 Aug 21 |
nicklas |
317 |
{ |
6357 |
26 Aug 21 |
nicklas |
var frm = document.forms['reggie']; |
6357 |
26 Aug 21 |
nicklas |
var cluster = frm.clusters[frm.clusters.selectedIndex].cluster; |
6357 |
26 Aug 21 |
nicklas |
if (cluster.priorities && cluster.priorities.length > 0) |
6357 |
26 Aug 21 |
nicklas |
321 |
{ |
6357 |
26 Aug 21 |
nicklas |
frm.priority.length = 0; |
6357 |
26 Aug 21 |
nicklas |
for (var pNo = 0; pNo < cluster.priorities.length; pNo++) |
6357 |
26 Aug 21 |
nicklas |
324 |
{ |
6357 |
26 Aug 21 |
nicklas |
var p = cluster.priorities[pNo]; |
6357 |
26 Aug 21 |
nicklas |
frm.priority[frm.priority.length] = new Option(p.name + ' ('+p.value+')', p.value, p['default'], p['default']); |
6357 |
26 Aug 21 |
nicklas |
327 |
} |
6357 |
26 Aug 21 |
nicklas |
Doc.show('job-priority'); |
6357 |
26 Aug 21 |
nicklas |
329 |
} |
6357 |
26 Aug 21 |
nicklas |
else |
6357 |
26 Aug 21 |
nicklas |
331 |
{ |
6357 |
26 Aug 21 |
nicklas |
Doc.hide('job-priority'); |
6357 |
26 Aug 21 |
nicklas |
333 |
} |
6980 |
17 Jan 23 |
nicklas |
if (cluster.partitions && cluster.partitions.length > 0) |
6980 |
17 Jan 23 |
nicklas |
335 |
{ |
6980 |
17 Jan 23 |
nicklas |
frm.partition.length = 0; |
6980 |
17 Jan 23 |
nicklas |
for (var pNo = 0; pNo < cluster.partitions.length; pNo++) |
6980 |
17 Jan 23 |
nicklas |
338 |
{ |
6980 |
17 Jan 23 |
nicklas |
var p = cluster.partitions[pNo]; |
6980 |
17 Jan 23 |
nicklas |
var title = p.name; |
6980 |
17 Jan 23 |
nicklas |
if (p.description) title += ' ('+p.description+')'; |
6980 |
17 Jan 23 |
nicklas |
frm.partition[frm.partition.length] = new Option(title, p.value, p['default'], p['default']); |
6980 |
17 Jan 23 |
nicklas |
343 |
} |
6980 |
17 Jan 23 |
nicklas |
Doc.show('job-partition'); |
6980 |
17 Jan 23 |
nicklas |
345 |
} |
6980 |
17 Jan 23 |
nicklas |
else |
6980 |
17 Jan 23 |
nicklas |
347 |
{ |
6980 |
17 Jan 23 |
nicklas |
Doc.hide('job-partition'); |
6980 |
17 Jan 23 |
nicklas |
349 |
} |
7372 |
06 Oct 23 |
nicklas |
gt.updateSubmitOptions(); |
6357 |
26 Aug 21 |
nicklas |
351 |
} |
7372 |
06 Oct 23 |
nicklas |
352 |
|
7372 |
06 Oct 23 |
nicklas |
gt.debugOnChange = function() |
7372 |
06 Oct 23 |
nicklas |
354 |
{ |
7372 |
06 Oct 23 |
nicklas |
gt.updateSubmitOptions(); |
7372 |
06 Oct 23 |
nicklas |
356 |
} |
7372 |
06 Oct 23 |
nicklas |
357 |
|
7372 |
06 Oct 23 |
nicklas |
gt.updateSubmitOptions = function() |
7372 |
06 Oct 23 |
nicklas |
359 |
{ |
7372 |
06 Oct 23 |
nicklas |
var frm = document.forms['reggie']; |
7372 |
06 Oct 23 |
nicklas |
var config = frm.clusters[frm.clusters.selectedIndex]?.cluster?.config?.['targeted-genotyping']; |
7372 |
06 Oct 23 |
nicklas |
if (config) |
7372 |
06 Oct 23 |
nicklas |
363 |
{ |
7372 |
06 Oct 23 |
nicklas |
var parameterSet = frm.gtSoftware[frm.gtSoftware.selectedIndex]?.item?.ParameterSet; |
7372 |
06 Oct 23 |
nicklas |
Doc.element('submitOptions').innerHTML = Reggie.getSubmitOptions(config, frm.debug.checked, parameterSet); |
7372 |
06 Oct 23 |
nicklas |
frm.override.disabled = false; |
7372 |
06 Oct 23 |
nicklas |
367 |
} |
7372 |
06 Oct 23 |
nicklas |
368 |
} |
7372 |
06 Oct 23 |
nicklas |
369 |
|
7372 |
06 Oct 23 |
nicklas |
gt.overrideOnChange = function() |
7372 |
06 Oct 23 |
nicklas |
371 |
{ |
7372 |
06 Oct 23 |
nicklas |
var frm = document.forms['reggie']; |
7372 |
06 Oct 23 |
nicklas |
Doc.showHide('submitOptions', !frm.override.checked); |
7372 |
06 Oct 23 |
nicklas |
Doc.showHide('submitOptionsOverride', frm.override.checked); |
7372 |
06 Oct 23 |
nicklas |
if (frm.submitOptionsOverride.value=='') |
7372 |
06 Oct 23 |
nicklas |
376 |
{ |
7372 |
06 Oct 23 |
nicklas |
frm.submitOptionsOverride.value = Doc.element('submitOptions').innerHTML; |
7372 |
06 Oct 23 |
nicklas |
378 |
} |
7372 |
06 Oct 23 |
nicklas |
379 |
} |
6357 |
26 Aug 21 |
nicklas |
380 |
|
6357 |
26 Aug 21 |
nicklas |
gt.softwareOnChange = function(event) |
6357 |
26 Aug 21 |
nicklas |
382 |
{ |
6357 |
26 Aug 21 |
nicklas |
var target = event.currentTarget; |
6357 |
26 Aug 21 |
nicklas |
var item = target[target.selectedIndex].item; |
6357 |
26 Aug 21 |
nicklas |
if (!item) item = {}; |
6357 |
26 Aug 21 |
nicklas |
386 |
|
6357 |
26 Aug 21 |
nicklas |
Doc.element(target.id+'.parameterSet').innerHTML = Strings.encodeTags(item.ParameterSet || 'default'); |
6357 |
26 Aug 21 |
nicklas |
Doc.element(target.id+'.description').innerHTML = Strings.encodeTags(item.description); |
6357 |
26 Aug 21 |
nicklas |
Wizard.setInputStatus(target.id, 'valid'); |
6357 |
26 Aug 21 |
nicklas |
390 |
|
6357 |
26 Aug 21 |
nicklas |
if (item.ParameterSet) |
6357 |
26 Aug 21 |
nicklas |
392 |
{ |
6357 |
26 Aug 21 |
nicklas |
var url = '../Install.servlet?ID='+App.getSessionId(); |
6357 |
26 Aug 21 |
nicklas |
url += '&cmd=GetParameterSetInfo'; |
6357 |
26 Aug 21 |
nicklas |
url += '¶meterSet='+encodeURIComponent(item.ParameterSet); |
6357 |
26 Aug 21 |
nicklas |
url += '&targetId='+target.id; |
6357 |
26 Aug 21 |
nicklas |
Wizard.asyncJsonRequest(url, gt.parameterSetInfoLoaded); |
6357 |
26 Aug 21 |
nicklas |
398 |
} |
7372 |
06 Oct 23 |
nicklas |
gt.updateSubmitOptions(); |
6357 |
26 Aug 21 |
nicklas |
400 |
} |
6357 |
26 Aug 21 |
nicklas |
401 |
|
6357 |
26 Aug 21 |
nicklas |
gt.parameterSetInfoLoaded = function(response) |
6357 |
26 Aug 21 |
nicklas |
403 |
{ |
6357 |
26 Aug 21 |
nicklas |
if (!response.parameters || response.parameters.length == 0) |
6357 |
26 Aug 21 |
nicklas |
405 |
{ |
6357 |
26 Aug 21 |
nicklas |
Wizard.setInputStatus(response.targetId, 'warning', 'Can\'t find \'' + Strings.encodeTags(response.parameterSet) + '\' parameter set in reggie-config.xml'); |
6357 |
26 Aug 21 |
nicklas |
407 |
} |
6357 |
26 Aug 21 |
nicklas |
408 |
} |
6357 |
26 Aug 21 |
nicklas |
409 |
|
6357 |
26 Aug 21 |
nicklas |
gt.onTargetSelected = function() |
6357 |
26 Aug 21 |
nicklas |
411 |
{ |
6357 |
26 Aug 21 |
nicklas |
var frm = document.forms['reggie']; |
6357 |
26 Aug 21 |
nicklas |
numTargetsSelected = 0; |
6357 |
26 Aug 21 |
nicklas |
for (var tNo = 0; tNo < targets.length; tNo++) |
6357 |
26 Aug 21 |
nicklas |
415 |
{ |
6357 |
26 Aug 21 |
nicklas |
if (frm['target.'+tNo].checked) numTargetsSelected++; |
6357 |
26 Aug 21 |
nicklas |
Doc.addOrRemoveClass('targetrow.'+tNo, 'selected', frm['target.'+tNo].checked); |
6357 |
26 Aug 21 |
nicklas |
418 |
} |
6357 |
26 Aug 21 |
nicklas |
419 |
|
6357 |
26 Aug 21 |
nicklas |
if (numTargetsSelected > 0) |
6357 |
26 Aug 21 |
nicklas |
421 |
{ |
6357 |
26 Aug 21 |
nicklas |
Wizard.setInputStatus('targets', 'valid'); |
6357 |
26 Aug 21 |
nicklas |
Doc.removeClass('targets', 'invalid'); |
6357 |
26 Aug 21 |
nicklas |
424 |
} |
6357 |
26 Aug 21 |
nicklas |
else |
6357 |
26 Aug 21 |
nicklas |
426 |
{ |
6357 |
26 Aug 21 |
nicklas |
Wizard.setInputStatus('targets', 'invalid', 'Select at least one target!'); |
6357 |
26 Aug 21 |
nicklas |
Doc.addClass('targets', 'invalid'); |
6357 |
26 Aug 21 |
nicklas |
429 |
} |
6357 |
26 Aug 21 |
nicklas |
430 |
} |
6357 |
26 Aug 21 |
nicklas |
431 |
|
6357 |
26 Aug 21 |
nicklas |
gt.validateStep2 = function(event) |
6357 |
26 Aug 21 |
nicklas |
433 |
{ |
6357 |
26 Aug 21 |
nicklas |
if (numTargetsSelected == 0) event.preventDefault(); |
6357 |
26 Aug 21 |
nicklas |
435 |
} |
6357 |
26 Aug 21 |
nicklas |
436 |
|
6357 |
26 Aug 21 |
nicklas |
gt.submit = function() |
6357 |
26 Aug 21 |
nicklas |
438 |
{ |
6357 |
26 Aug 21 |
nicklas |
var frm = document.forms['reggie']; |
6357 |
26 Aug 21 |
nicklas |
var submitInfo = {}; |
6357 |
26 Aug 21 |
nicklas |
441 |
|
6357 |
26 Aug 21 |
nicklas |
var selectedRba = []; |
6357 |
26 Aug 21 |
nicklas |
var selectedTargets = []; |
6357 |
26 Aug 21 |
nicklas |
submitInfo.rawBioAssays = selectedRba; |
6357 |
26 Aug 21 |
nicklas |
submitInfo.targets = selectedTargets; |
6357 |
26 Aug 21 |
nicklas |
submitInfo.gtSoftware = parseInt(frm.gtSoftware.value); |
6357 |
26 Aug 21 |
nicklas |
submitInfo.cluster = frm.clusters.value; |
6357 |
26 Aug 21 |
nicklas |
if (frm.priority.selectedIndex >= 0) |
6357 |
26 Aug 21 |
nicklas |
449 |
{ |
6357 |
26 Aug 21 |
nicklas |
submitInfo.priority = parseInt(frm.priority.value); |
6357 |
26 Aug 21 |
nicklas |
451 |
} |
6980 |
17 Jan 23 |
nicklas |
if (frm.partition.selectedIndex >= 0) |
6980 |
17 Jan 23 |
nicklas |
453 |
{ |
6980 |
17 Jan 23 |
nicklas |
submitInfo.partition = frm.partition.value; |
6980 |
17 Jan 23 |
nicklas |
455 |
} |
7372 |
06 Oct 23 |
nicklas |
if (frm.override.checked) |
7372 |
06 Oct 23 |
nicklas |
457 |
{ |
7372 |
06 Oct 23 |
nicklas |
submitInfo.submitOptionsOverride = frm.submitOptionsOverride.value; |
7372 |
06 Oct 23 |
nicklas |
459 |
} |
6357 |
26 Aug 21 |
nicklas |
submitInfo.debug = frm.debug.checked; |
6357 |
26 Aug 21 |
nicklas |
submitInfo.autoConfirm = frm.autoConfirm.checked; |
6357 |
26 Aug 21 |
nicklas |
462 |
|
6357 |
26 Aug 21 |
nicklas |
for (var rawNo = 0; rawNo < frm.rawBioAssays.length; rawNo++) |
6357 |
26 Aug 21 |
nicklas |
464 |
{ |
6357 |
26 Aug 21 |
nicklas |
if (frm.rawBioAssays[rawNo].selected) |
6357 |
26 Aug 21 |
nicklas |
466 |
{ |
6357 |
26 Aug 21 |
nicklas |
selectedRba[selectedRba.length] = frm.rawBioAssays[rawNo].rawBioAssay.id; |
6357 |
26 Aug 21 |
nicklas |
468 |
} |
6357 |
26 Aug 21 |
nicklas |
469 |
} |
6357 |
26 Aug 21 |
nicklas |
for (var tNo = 0; tNo < targets.length; tNo++) |
6357 |
26 Aug 21 |
nicklas |
471 |
{ |
6357 |
26 Aug 21 |
nicklas |
if (frm['target.'+tNo].checked) |
6357 |
26 Aug 21 |
nicklas |
473 |
{ |
6357 |
26 Aug 21 |
nicklas |
selectedTargets[selectedTargets.length] = targets[tNo].name; |
6357 |
26 Aug 21 |
nicklas |
475 |
} |
6357 |
26 Aug 21 |
nicklas |
476 |
} |
6357 |
26 Aug 21 |
nicklas |
477 |
|
6357 |
26 Aug 21 |
nicklas |
var url = '../VariantCalling.servlet?ID='+App.getSessionId(); |
6357 |
26 Aug 21 |
nicklas |
url += '&cmd=StartTargetedGenotypeAnalysis'; |
6357 |
26 Aug 21 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
6357 |
26 Aug 21 |
nicklas |
Wizard.asyncJsonRequest(url, gt.submissionResults, 'POST', JSON.stringify(submitInfo)); |
6357 |
26 Aug 21 |
nicklas |
482 |
} |
6357 |
26 Aug 21 |
nicklas |
483 |
|
6357 |
26 Aug 21 |
nicklas |
gt.submissionResults = function(response) |
6357 |
26 Aug 21 |
nicklas |
485 |
{ |
6357 |
26 Aug 21 |
nicklas |
Wizard.showFinalMessage(response.messages); |
6357 |
26 Aug 21 |
nicklas |
Doc.show('gorestart'); |
6357 |
26 Aug 21 |
nicklas |
488 |
} |
6357 |
26 Aug 21 |
nicklas |
489 |
|
6357 |
26 Aug 21 |
nicklas |
return gt; |
6357 |
26 Aug 21 |
nicklas |
491 |
}(); |
6357 |
26 Aug 21 |
nicklas |
492 |
|
6357 |
26 Aug 21 |
nicklas |
Doc.onLoad(TargetedGT.initPage); |
6357 |
26 Aug 21 |
nicklas |
494 |
|