7392 |
03 Nov 23 |
nicklas |
var PoN = function() |
7392 |
03 Nov 23 |
nicklas |
2 |
{ |
7392 |
03 Nov 23 |
nicklas |
var pon = {}; |
7392 |
03 Nov 23 |
nicklas |
var debug = 0; |
7392 |
03 Nov 23 |
nicklas |
5 |
|
7392 |
03 Nov 23 |
nicklas |
var JOB_IMAGE = { 'DONE': 'ok.png', 'ERROR': 'error.png'}; |
7392 |
03 Nov 23 |
nicklas |
7 |
|
7392 |
03 Nov 23 |
nicklas |
var panelOfNormals; |
7392 |
03 Nov 23 |
nicklas |
9 |
|
7392 |
03 Nov 23 |
nicklas |
// Page initialization |
7392 |
03 Nov 23 |
nicklas |
pon.initPage = function() |
7392 |
03 Nov 23 |
nicklas |
12 |
{ |
7392 |
03 Nov 23 |
nicklas |
13 |
|
7392 |
03 Nov 23 |
nicklas |
// Step 1 |
7392 |
03 Nov 23 |
nicklas |
15 |
|
7392 |
03 Nov 23 |
nicklas |
// Navigation |
7392 |
03 Nov 23 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
7392 |
03 Nov 23 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
7392 |
03 Nov 23 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
7392 |
03 Nov 23 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
7392 |
03 Nov 23 |
nicklas |
21 |
|
7392 |
03 Nov 23 |
nicklas |
// Final registration |
7392 |
03 Nov 23 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', pon.submit); |
7392 |
03 Nov 23 |
nicklas |
24 |
|
7392 |
03 Nov 23 |
nicklas |
Wizard.showLoadingAnimation('Loading bioassays...'); |
7392 |
03 Nov 23 |
nicklas |
var url = '../WgsVariantCalling.servlet?ID='+App.getSessionId(); |
7392 |
03 Nov 23 |
nicklas |
url += '&cmd=GetUnconfirmedPanelOfNormals'; |
7392 |
03 Nov 23 |
nicklas |
Wizard.asyncJsonRequest(url, pon.initializeStep1); |
7392 |
03 Nov 23 |
nicklas |
29 |
} |
7392 |
03 Nov 23 |
nicklas |
30 |
|
7392 |
03 Nov 23 |
nicklas |
// --- Step 1 ----------------------------------- |
7392 |
03 Nov 23 |
nicklas |
pon.initializeStep1 = function(response) |
7392 |
03 Nov 23 |
nicklas |
33 |
{ |
7392 |
03 Nov 23 |
nicklas |
var frm = document.forms['reggie']; |
7392 |
03 Nov 23 |
nicklas |
panelOfNormals = response.panelOfNormals; |
7392 |
03 Nov 23 |
nicklas |
if (panelOfNormals.length == 0) |
7392 |
03 Nov 23 |
nicklas |
37 |
{ |
7392 |
03 Nov 23 |
nicklas |
Wizard.setFatalError('No panel-of-normals available for processing.'); |
7392 |
03 Nov 23 |
nicklas |
return; |
7392 |
03 Nov 23 |
nicklas |
40 |
} |
7392 |
03 Nov 23 |
nicklas |
41 |
|
7392 |
03 Nov 23 |
nicklas |
var html = '<table id="ponTable">'; |
7392 |
03 Nov 23 |
nicklas |
html += '<thead class="bg-filled-100">'; |
7392 |
03 Nov 23 |
nicklas |
// Header row |
7392 |
03 Nov 23 |
nicklas |
html += '<tr>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th></th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th class="dottedleft" colspan="3">Alignment</th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th class="dottedleft" colspan="2">Variant call</th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th class="dottedleft"></th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th class="dottedleft" colspan="2">Actions</th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th class="dottedleft">Comment</th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '</tr>'; |
7392 |
03 Nov 23 |
nicklas |
53 |
|
7392 |
03 Nov 23 |
nicklas |
html += '<tr>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th>Item</th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th class="dottedleft">Aligned pairs</th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th>Duplicates</th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th>Mean coverage</th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th class="dottedleft">Callable bases</th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th>Variants</th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th class="dottedleft">Job</th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th><span id="deletePoN" data-prefix="delete" class="interactable link" title="Toggle selection – use CTRL, ALT or SHIFT to clear">Delete</span></th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th><span id="confirmPoN" data-prefix="confirm" class="interactable link" title="Toggle selection – use CTRL, ALT or SHIFT to clear">Confirm</span></th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<th class="dottedleft"></th>'; |
7392 |
03 Nov 23 |
nicklas |
html += '</tr>'; |
7392 |
03 Nov 23 |
nicklas |
html += '</thead>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<tbody>'; |
7392 |
03 Nov 23 |
nicklas |
var numWithError = 0; |
7392 |
03 Nov 23 |
nicklas |
for (var ponNo = 0; ponNo < panelOfNormals.length; ponNo++) |
7392 |
03 Nov 23 |
nicklas |
70 |
{ |
7392 |
03 Nov 23 |
nicklas |
var pn = panelOfNormals[ponNo]; |
7392 |
03 Nov 23 |
nicklas |
var aligned = pn.aligned; |
7392 |
03 Nov 23 |
nicklas |
var job = pn.job; |
7392 |
03 Nov 23 |
nicklas |
74 |
|
7392 |
03 Nov 23 |
nicklas |
var variants = pn.VARIANTS_RAW == null ? '-' : Numbers.formatNumber(pn.VARIANTS_RAW/1000000, 1, ' M'); |
7392 |
03 Nov 23 |
nicklas |
var callableBases = pn.CALLABLE_BASES == null ? '-' : Numbers.formatNumber(pn.CALLABLE_BASES/1000000000, 2, ' G'); |
7392 |
03 Nov 23 |
nicklas |
77 |
|
7392 |
03 Nov 23 |
nicklas |
var alignedReads = aligned.ALIGNED_PAIRS == null ? '-' : Numbers.formatNumber(aligned.ALIGNED_PAIRS/1000000, 1, ' M'); |
7392 |
03 Nov 23 |
nicklas |
var percentDuplicates = aligned.FRACTION_DUPLICATION == null ? '-' : Numbers.formatNumber(100*aligned.FRACTION_DUPLICATION, 1, ' %'); |
7392 |
03 Nov 23 |
nicklas |
var meanCoverage = aligned.MEAN_COVERAGE == null ? '-' : Numbers.formatNumber(aligned.MEAN_COVERAGE, 1); |
7392 |
03 Nov 23 |
nicklas |
81 |
|
7392 |
03 Nov 23 |
nicklas |
var isError = job.status == 'ERROR'; |
7392 |
03 Nov 23 |
nicklas |
83 |
|
7392 |
03 Nov 23 |
nicklas |
// Warnings |
7392 |
03 Nov 23 |
nicklas |
var callableWarning = ''; |
7392 |
03 Nov 23 |
nicklas |
if (!job.debug) |
7392 |
03 Nov 23 |
nicklas |
87 |
{ |
7392 |
03 Nov 23 |
nicklas |
if (pn.CALLABLE_BASES != null && pn.CALLABLE_BASES < 2_500_000_000) |
7392 |
03 Nov 23 |
nicklas |
89 |
{ |
7392 |
03 Nov 23 |
nicklas |
callableWarning = ' <img src="../images/warning.png" title="Less than '+Reggie.formatCount(2_500_000_000) + ' callable bases">'; |
7392 |
03 Nov 23 |
nicklas |
91 |
} |
7392 |
03 Nov 23 |
nicklas |
92 |
} |
7392 |
03 Nov 23 |
nicklas |
93 |
|
7392 |
03 Nov 23 |
nicklas |
html += '<tr class="highlight ' + (ponNo % 4 < 2 ? 'evenrow' : 'oddrow') + '">'; |
7392 |
03 Nov 23 |
nicklas |
html += '<td class="prompt if-yellow">'+Strings.encodeTags(pn.name)+'</td>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<td class="dottedleft">'+alignedReads+'</td>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<td>'+percentDuplicates+'</td>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<td>'+meanCoverage+'</td>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<td class="dottedleft">'+callableBases+callableWarning+'</td>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<td>'+variants+'</td>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<td class="dottedleft">'; |
7392 |
03 Nov 23 |
nicklas |
html += '<span class="link item-link" data-item-type="JOB" data-item-id="'+job.id+'" title="'+Strings.encodeTags(job.statusMessage)+'"><img src="../images/'+JOB_IMAGE[job.status]+'"></span>'; |
7392 |
03 Nov 23 |
nicklas |
if (job.debug) |
7392 |
03 Nov 23 |
nicklas |
104 |
{ |
7392 |
03 Nov 23 |
nicklas |
html += '<img src="../images/'+(isError?'bug-red':'bug-green')+'.png" title="This job was run in DEBUG mode">' |
7392 |
03 Nov 23 |
nicklas |
106 |
} |
7392 |
03 Nov 23 |
nicklas |
html += '</td>'; |
7392 |
03 Nov 23 |
nicklas |
108 |
|
7392 |
03 Nov 23 |
nicklas |
var confirmChecked = !isError ? ' checked' : ''; |
7392 |
03 Nov 23 |
nicklas |
var deleteChecked = isError ? ' checked' : ''; |
7392 |
03 Nov 23 |
nicklas |
var confirmDisabled = isError ? ' disabled' : ''; |
7392 |
03 Nov 23 |
nicklas |
if (isError) numWithError++; |
7392 |
03 Nov 23 |
nicklas |
113 |
|
7392 |
03 Nov 23 |
nicklas |
html += '<td><input type="checkbox" name="delete.'+pn.id+'" id="delete.'+pn.id+'" data-item-id="'+pn.id+'"'+deleteChecked+'></td>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<td><input type="checkbox" name="confirm.'+pn.id+'" id="confirm.'+pn.id+'" data-item-id="'+pn.id+'"'+confirmChecked+confirmDisabled+'></td>'; |
7392 |
03 Nov 23 |
nicklas |
html += '<td class="dottedleft comment"><input type="text" name="comment.'+pn.id+'" id="comment.'+pn.id+'" data-item-id="'+pn.id+'"></td>'; |
7392 |
03 Nov 23 |
nicklas |
html += '</tr>'; |
7392 |
03 Nov 23 |
nicklas |
118 |
} |
7392 |
03 Nov 23 |
nicklas |
html += '</tbody>'; |
7392 |
03 Nov 23 |
nicklas |
html += '</table>'; |
7392 |
03 Nov 23 |
nicklas |
Doc.element('panelOfNormals').innerHTML = html; |
7392 |
03 Nov 23 |
nicklas |
122 |
|
7392 |
03 Nov 23 |
nicklas |
// Add click handler to items |
7392 |
03 Nov 23 |
nicklas |
var clickableItems = document.getElementsByClassName('item-link'); |
7392 |
03 Nov 23 |
nicklas |
for (var i = 0; i < clickableItems.length; i++) |
7392 |
03 Nov 23 |
nicklas |
126 |
{ |
7392 |
03 Nov 23 |
nicklas |
Events.addEventHandler(clickableItems[i], 'click', Items.itemOnClick); |
7392 |
03 Nov 23 |
nicklas |
128 |
} |
7392 |
03 Nov 23 |
nicklas |
129 |
|
7392 |
03 Nov 23 |
nicklas |
// If 'delete' is active the other options should be disabled |
7392 |
03 Nov 23 |
nicklas |
for (var ponNo = 0; ponNo < panelOfNormals.length; ponNo++) |
7392 |
03 Nov 23 |
nicklas |
132 |
{ |
7392 |
03 Nov 23 |
nicklas |
var pn = panelOfNormals[ponNo]; |
7392 |
03 Nov 23 |
nicklas |
Events.addEventHandler('delete.'+pn.id, 'change', pon.deleteOnChange); |
7392 |
03 Nov 23 |
nicklas |
135 |
} |
7392 |
03 Nov 23 |
nicklas |
136 |
|
7392 |
03 Nov 23 |
nicklas |
Events.addEventHandler('deletePoN', 'click', pon.toggleSelection); |
7392 |
03 Nov 23 |
nicklas |
Events.addEventHandler('confirmPoN', 'click', pon.toggleSelection); |
7392 |
03 Nov 23 |
nicklas |
139 |
|
7392 |
03 Nov 23 |
nicklas |
Doc.show('step-1'); |
7392 |
03 Nov 23 |
nicklas |
Doc.show('goregister'); |
7392 |
03 Nov 23 |
nicklas |
142 |
} |
7392 |
03 Nov 23 |
nicklas |
143 |
|
7392 |
03 Nov 23 |
nicklas |
pon.deleteOnChange = function(event) |
7392 |
03 Nov 23 |
nicklas |
145 |
{ |
7392 |
03 Nov 23 |
nicklas |
var itemId = Data.get(event.currentTarget, 'item-id'); |
7392 |
03 Nov 23 |
nicklas |
var disable = event.currentTarget.checked; |
7392 |
03 Nov 23 |
nicklas |
pon.disableElement('confirm.'+itemId, disable); |
7392 |
03 Nov 23 |
nicklas |
pon.disableElement('comment.'+itemId, disable); |
7392 |
03 Nov 23 |
nicklas |
150 |
} |
7392 |
03 Nov 23 |
nicklas |
151 |
|
7392 |
03 Nov 23 |
nicklas |
pon.disableElement = function(element, disable) |
7392 |
03 Nov 23 |
nicklas |
153 |
{ |
7392 |
03 Nov 23 |
nicklas |
element = Doc.element(element); |
7392 |
03 Nov 23 |
nicklas |
if (element) element.disabled = disable; |
7392 |
03 Nov 23 |
nicklas |
156 |
} |
7392 |
03 Nov 23 |
nicklas |
157 |
|
7392 |
03 Nov 23 |
nicklas |
pon.toggleSelection = function(event) |
7392 |
03 Nov 23 |
nicklas |
159 |
{ |
7392 |
03 Nov 23 |
nicklas |
var prefix = Data.get(event.currentTarget, 'prefix'); |
7392 |
03 Nov 23 |
nicklas |
var specialKey = event.altKey || event.ctrlKey || event.shiftKey; |
7392 |
03 Nov 23 |
nicklas |
162 |
|
7392 |
03 Nov 23 |
nicklas |
var frm = document.forms['reggie']; |
7392 |
03 Nov 23 |
nicklas |
for (var ponNo = 0; ponNo < panelOfNormals.length; ponNo++) |
7392 |
03 Nov 23 |
nicklas |
165 |
{ |
7392 |
03 Nov 23 |
nicklas |
var pn = panelOfNormals[ponNo]; |
7392 |
03 Nov 23 |
nicklas |
var chk = frm[prefix+'.'+pn.id]; |
7392 |
03 Nov 23 |
nicklas |
if (chk && !chk.disabled) |
7392 |
03 Nov 23 |
nicklas |
169 |
{ |
7392 |
03 Nov 23 |
nicklas |
chk.checked = specialKey ? false : !chk.checked; |
7392 |
03 Nov 23 |
nicklas |
if (prefix=='delete') Events.sendChangeEvent(chk); |
7392 |
03 Nov 23 |
nicklas |
172 |
} |
7392 |
03 Nov 23 |
nicklas |
173 |
} |
7392 |
03 Nov 23 |
nicklas |
174 |
} |
7392 |
03 Nov 23 |
nicklas |
175 |
|
7392 |
03 Nov 23 |
nicklas |
pon.submit = function() |
7392 |
03 Nov 23 |
nicklas |
177 |
{ |
7392 |
03 Nov 23 |
nicklas |
var frm = document.forms['reggie']; |
7392 |
03 Nov 23 |
nicklas |
var submitInfo = {}; |
7392 |
03 Nov 23 |
nicklas |
180 |
|
7392 |
03 Nov 23 |
nicklas |
var all = []; |
7392 |
03 Nov 23 |
nicklas |
submitInfo.panelOfNormals = all; |
7392 |
03 Nov 23 |
nicklas |
for (var ponNo = 0; ponNo < panelOfNormals.length; ponNo++) |
7392 |
03 Nov 23 |
nicklas |
184 |
{ |
7392 |
03 Nov 23 |
nicklas |
var pn = panelOfNormals[ponNo]; |
7392 |
03 Nov 23 |
nicklas |
var tmp = {}; |
7392 |
03 Nov 23 |
nicklas |
tmp.id = pn.id; |
7392 |
03 Nov 23 |
nicklas |
188 |
|
7392 |
03 Nov 23 |
nicklas |
tmp.delete = frm['delete.'+pn.id].checked; |
7392 |
03 Nov 23 |
nicklas |
tmp.confirm = frm['confirm.'+pn.id].checked; |
7392 |
03 Nov 23 |
nicklas |
tmp.comment = frm['comment.'+pn.id].value; |
7392 |
03 Nov 23 |
nicklas |
192 |
|
7392 |
03 Nov 23 |
nicklas |
all[all.length] = tmp; |
7392 |
03 Nov 23 |
nicklas |
194 |
} |
7392 |
03 Nov 23 |
nicklas |
195 |
|
7392 |
03 Nov 23 |
nicklas |
var url = '../WgsVariantCalling.servlet?ID='+App.getSessionId(); |
7392 |
03 Nov 23 |
nicklas |
url += '&cmd=RegisterPanelOfNormals'; |
7392 |
03 Nov 23 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
7392 |
03 Nov 23 |
nicklas |
Wizard.asyncJsonRequest(url, pon.submissionResults, 'POST', JSON.stringify(submitInfo)); |
7392 |
03 Nov 23 |
nicklas |
200 |
} |
7392 |
03 Nov 23 |
nicklas |
201 |
|
7392 |
03 Nov 23 |
nicklas |
pon.submissionResults = function(response) |
7392 |
03 Nov 23 |
nicklas |
203 |
{ |
7392 |
03 Nov 23 |
nicklas |
Wizard.showFinalMessage(response.messages); |
7392 |
03 Nov 23 |
nicklas |
Doc.show('gorestart'); |
7392 |
03 Nov 23 |
nicklas |
206 |
} |
7392 |
03 Nov 23 |
nicklas |
207 |
|
7392 |
03 Nov 23 |
nicklas |
208 |
|
7392 |
03 Nov 23 |
nicklas |
return pon; |
7392 |
03 Nov 23 |
nicklas |
210 |
}(); |
7392 |
03 Nov 23 |
nicklas |
211 |
|
7392 |
03 Nov 23 |
nicklas |
Doc.onLoad(PoN.initPage); |
7392 |
03 Nov 23 |
nicklas |
213 |
|