5728 |
15 Nov 19 |
nicklas |
var VCall = function() |
5728 |
15 Nov 19 |
nicklas |
2 |
{ |
5728 |
15 Nov 19 |
nicklas |
var vcall = {}; |
5728 |
15 Nov 19 |
nicklas |
var debug = 0; |
5728 |
15 Nov 19 |
nicklas |
5 |
|
5728 |
15 Nov 19 |
nicklas |
var JOB_IMAGE = { 'DONE': 'ok.png', 'ERROR': 'error.png'}; |
5728 |
15 Nov 19 |
nicklas |
var rawBioAssays; |
5728 |
15 Nov 19 |
nicklas |
8 |
|
5728 |
15 Nov 19 |
nicklas |
// Page initialization |
5728 |
15 Nov 19 |
nicklas |
vcall.initPage = function() |
5728 |
15 Nov 19 |
nicklas |
11 |
{ |
5728 |
15 Nov 19 |
nicklas |
12 |
|
5728 |
15 Nov 19 |
nicklas |
// Step 1 |
5728 |
15 Nov 19 |
nicklas |
14 |
|
5728 |
15 Nov 19 |
nicklas |
// Navigation |
5728 |
15 Nov 19 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
5728 |
15 Nov 19 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
5728 |
15 Nov 19 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
5728 |
15 Nov 19 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
5728 |
15 Nov 19 |
nicklas |
20 |
|
5728 |
15 Nov 19 |
nicklas |
// Final registration |
5728 |
15 Nov 19 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', vcall.submit); |
5728 |
15 Nov 19 |
nicklas |
23 |
|
5728 |
15 Nov 19 |
nicklas |
Wizard.showLoadingAnimation('Loading bioassays...'); |
5728 |
15 Nov 19 |
nicklas |
var url = '../VariantCalling.servlet?ID='+App.getSessionId(); |
5728 |
15 Nov 19 |
nicklas |
url += '&cmd=GetUnconfirmed'; |
5728 |
15 Nov 19 |
nicklas |
Wizard.asyncJsonRequest(url, vcall.initializeStep1); |
5728 |
15 Nov 19 |
nicklas |
28 |
} |
5728 |
15 Nov 19 |
nicklas |
29 |
|
5728 |
15 Nov 19 |
nicklas |
// --- Step 1 ----------------------------------- |
5728 |
15 Nov 19 |
nicklas |
vcall.initializeStep1 = function(response) |
5728 |
15 Nov 19 |
nicklas |
32 |
{ |
5728 |
15 Nov 19 |
nicklas |
rawBioAssays = response.rawBioAssays; |
5728 |
15 Nov 19 |
nicklas |
if (rawBioAssays.length == 0) |
5728 |
15 Nov 19 |
nicklas |
35 |
{ |
5728 |
15 Nov 19 |
nicklas |
Wizard.setFatalError('No raw bioassays available for processing.'); |
5728 |
15 Nov 19 |
nicklas |
return; |
5728 |
15 Nov 19 |
nicklas |
38 |
} |
5728 |
15 Nov 19 |
nicklas |
39 |
|
5728 |
15 Nov 19 |
nicklas |
var html = '<table id="rawBioAssaysTable">'; |
5728 |
15 Nov 19 |
nicklas |
html += '<thead class="bg-filled-100">'; |
5728 |
15 Nov 19 |
nicklas |
// Header row |
5728 |
15 Nov 19 |
nicklas |
html += '<tr>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<th></th>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<th class="dottedleft"></th>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<th class="dottedleft" colspan="5">Variant calling</th>' |
5728 |
15 Nov 19 |
nicklas |
html += '<th class="dottedleft" colspan="3">Actions</th>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<th class="dottedleft">Comment</th>'; |
5728 |
15 Nov 19 |
nicklas |
html += '</tr>'; |
5728 |
15 Nov 19 |
nicklas |
50 |
|
5728 |
15 Nov 19 |
nicklas |
html += '<tr>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<th>Library</th>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<th class="dottedleft">Plate</th>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<th class="dottedleft">Job</th>' |
5728 |
15 Nov 19 |
nicklas |
html += '<th>Callable</th>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<th>Raw</th>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<th>Filtered</th>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<th>Files</th>'; |
6670 |
07 Apr 22 |
nicklas |
html += '<th class="dottedleft"><span id="flagrna" data-prefix="flag" class="interactable link" title="Toggle selection – use CTRL, ALT or SHIFT to clear">Flag RNA</span></th>'; |
6670 |
07 Apr 22 |
nicklas |
html += '<th><span id="rerun" data-prefix="rerun" class="interactable link" title="Toggle selection – use CTRL, ALT or SHIFT to clear">Re-run</span></th>'; |
6670 |
07 Apr 22 |
nicklas |
html += '<th><span id="confirm" data-prefix="confirm" class="interactable link" title="Toggle selection – use CTRL, ALT or SHIFT to clear">Confirm</span></th>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<th class="dottedleft"></th>'; |
5728 |
15 Nov 19 |
nicklas |
html += '</tr>'; |
5728 |
15 Nov 19 |
nicklas |
html += '</thead>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<tbody>'; |
5728 |
15 Nov 19 |
nicklas |
var numWithError = 0; |
5728 |
15 Nov 19 |
nicklas |
var yellowImg = '<img src="../images/yellow-label.png">'; |
5728 |
15 Nov 19 |
nicklas |
for (var rawNo = 0; rawNo < rawBioAssays.length; rawNo++) |
5728 |
15 Nov 19 |
nicklas |
69 |
{ |
5728 |
15 Nov 19 |
nicklas |
var raw = rawBioAssays[rawNo]; |
5728 |
15 Nov 19 |
nicklas |
71 |
|
5728 |
15 Nov 19 |
nicklas |
var lib = raw.lib; |
5728 |
15 Nov 19 |
nicklas |
lib.stratagene = Reggie.isStratagene(lib.name); |
5728 |
15 Nov 19 |
nicklas |
lib.external = Reggie.isExternal(lib.name); |
5728 |
15 Nov 19 |
nicklas |
var isYellow = lib.specimen && lib.specimen.YellowLabel != null; |
5728 |
15 Nov 19 |
nicklas |
var img = isYellow ? yellowImg : ''; |
5728 |
15 Nov 19 |
nicklas |
var libPlate = lib.bioWell ? lib.bioWell.bioPlate : null; |
5728 |
15 Nov 19 |
nicklas |
78 |
|
5728 |
15 Nov 19 |
nicklas |
var vcallJob = raw.vcallJob; |
5776 |
06 Dec 19 |
nicklas |
var isError = !raw.vcfFile || raw.VariantsPassedFilter == null; |
5728 |
15 Nov 19 |
nicklas |
var flagChecked = false; |
5728 |
15 Nov 19 |
nicklas |
82 |
|
5728 |
15 Nov 19 |
nicklas |
html += '<tr class="highlight ' + (rawNo % 4 < 2 ? 'evenrow' : 'oddrow') + (isYellow ? ' yellow-specimen' : '') + '">'; |
5728 |
15 Nov 19 |
nicklas |
html += '<td class="prompt if-yellow">'+img+Strings.encodeTags(raw.name)+'</td>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<td class="dottedleft">'+(libPlate ? Strings.encodeTags(libPlate.name) : '-') +'</td>'; |
5728 |
15 Nov 19 |
nicklas |
86 |
|
5728 |
15 Nov 19 |
nicklas |
html += '<td class="dottedleft">'; |
5728 |
15 Nov 19 |
nicklas |
if (vcallJob) |
5728 |
15 Nov 19 |
nicklas |
89 |
{ |
5728 |
15 Nov 19 |
nicklas |
isError |= vcallJob.status == 'ERROR'; |
5728 |
15 Nov 19 |
nicklas |
var image = JOB_IMAGE[vcallJob.status]; |
5728 |
15 Nov 19 |
nicklas |
if (!isError && !raw.vcfFile) image = 'warning.png'; |
5728 |
15 Nov 19 |
nicklas |
html += '<span class="link item-link" data-item-type="JOB" data-item-id="'+vcallJob.id+'" title="'+Strings.encodeTags(vcallJob.statusMessage)+'"><img src="../images/'+image+'"></span>'; |
5728 |
15 Nov 19 |
nicklas |
94 |
} |
5728 |
15 Nov 19 |
nicklas |
html += '</td>'; |
6716 |
29 Apr 22 |
nicklas |
html += '<td>'+Reggie.formatCount(raw.CallableBases, '-')+'</td>'; |
6716 |
29 Apr 22 |
nicklas |
html += '<td>'+Reggie.formatCount(raw.VariantsRaw, '-')+'</td>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<td>'; |
5730 |
18 Nov 19 |
nicklas |
if (raw.vcfFile) |
5730 |
18 Nov 19 |
nicklas |
100 |
{ |
5776 |
06 Dec 19 |
nicklas |
html += raw.VariantsPassedFilter + '<span class="link vcf-link" data-file-id="'+raw.vcfFile.id+'" data-item-id="'+raw.id+'" title="View summary for the variants"><img src="../images/vcf_file.png" style="margin-left: 2px;"></span>'; |
5730 |
18 Nov 19 |
nicklas |
102 |
} |
5728 |
15 Nov 19 |
nicklas |
html += '</td>'; |
5728 |
15 Nov 19 |
nicklas |
104 |
|
5728 |
15 Nov 19 |
nicklas |
if (raw.DataFilesFolder && vcallJob && vcallJob.server) |
5728 |
15 Nov 19 |
nicklas |
106 |
{ |
5728 |
15 Nov 19 |
nicklas |
html += '<td>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<span class="link file-link" data-server="'+Strings.encodeTags(vcallJob.server)+'" data-folder="'+Strings.encodeTags(raw.DataFilesFolder)+'" data-item-id="'+raw.id+'" title="View generated files"><img src="../images/remote_folder.png"></span>'; |
5728 |
15 Nov 19 |
nicklas |
html += '</td>'; |
5728 |
15 Nov 19 |
nicklas |
110 |
} |
5728 |
15 Nov 19 |
nicklas |
else |
5728 |
15 Nov 19 |
nicklas |
112 |
{ |
5728 |
15 Nov 19 |
nicklas |
html += '<td>-</td>'; |
5728 |
15 Nov 19 |
nicklas |
114 |
} |
5728 |
15 Nov 19 |
nicklas |
// Do not allow flagging external or stratagene |
5728 |
15 Nov 19 |
nicklas |
var confirmChecked = !isError ? ' checked' : ''; |
5728 |
15 Nov 19 |
nicklas |
var reRunChecked = isError ? ' checked' : ''; |
5728 |
15 Nov 19 |
nicklas |
var confirmDisabled = isError ? ' disabled' : ''; |
5728 |
15 Nov 19 |
nicklas |
if (isError) numWithError++; |
5728 |
15 Nov 19 |
nicklas |
120 |
|
5728 |
15 Nov 19 |
nicklas |
if (lib.stratagene || lib.external) |
5728 |
15 Nov 19 |
nicklas |
122 |
{ |
5728 |
15 Nov 19 |
nicklas |
html += '<td class="dottedleft">-</td>'; |
5728 |
15 Nov 19 |
nicklas |
124 |
} |
5728 |
15 Nov 19 |
nicklas |
else |
5728 |
15 Nov 19 |
nicklas |
126 |
{ |
5728 |
15 Nov 19 |
nicklas |
html += '<td class="dottedleft"><input type="checkbox" name="flag.'+raw.id+'"'+(flagChecked ? ' checked':'')+'></td>'; |
5728 |
15 Nov 19 |
nicklas |
128 |
} |
5728 |
15 Nov 19 |
nicklas |
129 |
|
5728 |
15 Nov 19 |
nicklas |
html += '<td><input type="checkbox" name="rerun.'+raw.id+'"'+reRunChecked+'></td>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<td><input type="checkbox" name="confirm.'+raw.id+'"'+confirmChecked+confirmDisabled+'></td>'; |
5728 |
15 Nov 19 |
nicklas |
html += '<td class="dottedleft comment"><input type="text" name="comment.'+raw.id+'"></td>'; |
5728 |
15 Nov 19 |
nicklas |
html += '</tr>'; |
5728 |
15 Nov 19 |
nicklas |
134 |
|
5728 |
15 Nov 19 |
nicklas |
135 |
} |
5728 |
15 Nov 19 |
nicklas |
html += '</tbody>'; |
5728 |
15 Nov 19 |
nicklas |
html += '</table>'; |
5728 |
15 Nov 19 |
nicklas |
Doc.element('rawBioAssays').innerHTML = html; |
6670 |
07 Apr 22 |
nicklas |
139 |
|
6670 |
07 Apr 22 |
nicklas |
Events.addEventHandler('flagrna', 'click', vcall.toggleSelection); |
6670 |
07 Apr 22 |
nicklas |
Events.addEventHandler('rerun', 'click', vcall.toggleSelection); |
6670 |
07 Apr 22 |
nicklas |
Events.addEventHandler('confirm', 'click', vcall.toggleSelection); |
6670 |
07 Apr 22 |
nicklas |
143 |
|
5728 |
15 Nov 19 |
nicklas |
// Add click handler to items |
5728 |
15 Nov 19 |
nicklas |
var clickableItems = document.getElementsByClassName('item-link'); |
5728 |
15 Nov 19 |
nicklas |
for (var i = 0; i < clickableItems.length; i++) |
5728 |
15 Nov 19 |
nicklas |
147 |
{ |
5728 |
15 Nov 19 |
nicklas |
Events.addEventHandler(clickableItems[i], 'click', Items.itemOnClick); |
5728 |
15 Nov 19 |
nicklas |
149 |
} |
5728 |
15 Nov 19 |
nicklas |
150 |
|
5728 |
15 Nov 19 |
nicklas |
// Add click handler to file links |
5728 |
15 Nov 19 |
nicklas |
var clickableItems = document.getElementsByClassName('file-link'); |
5728 |
15 Nov 19 |
nicklas |
for (var i = 0; i < clickableItems.length; i++) |
5728 |
15 Nov 19 |
nicklas |
154 |
{ |
5728 |
15 Nov 19 |
nicklas |
Events.addEventHandler(clickableItems[i], 'click', vcall.fileLinkOnClick); |
5728 |
15 Nov 19 |
nicklas |
156 |
} |
5728 |
15 Nov 19 |
nicklas |
157 |
|
5730 |
18 Nov 19 |
nicklas |
var linkedVcf = document.getElementsByClassName('vcf-link'); |
5730 |
18 Nov 19 |
nicklas |
for (var i = 0; i < linkedVcf.length; i++) |
5730 |
18 Nov 19 |
nicklas |
160 |
{ |
5730 |
18 Nov 19 |
nicklas |
Events.addEventHandler(linkedVcf[i], 'click', vcall.vcfLinkOnClick); |
5730 |
18 Nov 19 |
nicklas |
162 |
} |
5730 |
18 Nov 19 |
nicklas |
163 |
|
5730 |
18 Nov 19 |
nicklas |
164 |
|
5728 |
15 Nov 19 |
nicklas |
Doc.show('step-1'); |
5728 |
15 Nov 19 |
nicklas |
Doc.show('goregister'); |
5728 |
15 Nov 19 |
nicklas |
167 |
} |
5728 |
15 Nov 19 |
nicklas |
168 |
|
5728 |
15 Nov 19 |
nicklas |
vcall.fileLinkOnClick = function(event) |
5728 |
15 Nov 19 |
nicklas |
170 |
{ |
5728 |
15 Nov 19 |
nicklas |
var folder = Data.get(event.currentTarget, 'folder'); |
5728 |
15 Nov 19 |
nicklas |
var server = Data.get(event.currentTarget, 'server'); |
5728 |
15 Nov 19 |
nicklas |
var itemId = Data.get(event.currentTarget, 'item-id'); |
5728 |
15 Nov 19 |
nicklas |
server = server.replace(/\s*\[.*\]/, ''); |
5728 |
15 Nov 19 |
nicklas |
var url = 'view_remote_files.jsp?ID=' + App.getSessionId(); |
5728 |
15 Nov 19 |
nicklas |
url += '&clusterId='+server; |
5728 |
15 Nov 19 |
nicklas |
url += '&path='+encodeURIComponent(folder); |
5728 |
15 Nov 19 |
nicklas |
url += '&itemType=RAWBIOASSAY&itemId='+itemId; |
5728 |
15 Nov 19 |
nicklas |
Dialogs.openPopup(url, 'ViewProjectFiles', 750, 500); |
5728 |
15 Nov 19 |
nicklas |
180 |
} |
5728 |
15 Nov 19 |
nicklas |
181 |
|
5730 |
18 Nov 19 |
nicklas |
vcall.vcfLinkOnClick = function(event) |
5730 |
18 Nov 19 |
nicklas |
183 |
{ |
5730 |
18 Nov 19 |
nicklas |
var fileId = Data.int(event.currentTarget, 'file-id'); |
5730 |
18 Nov 19 |
nicklas |
var itemId = Data.int(event.currentTarget, 'item-id'); |
5730 |
18 Nov 19 |
nicklas |
var url = 'view_variants.jsp?ID=' + App.getSessionId(); |
5730 |
18 Nov 19 |
nicklas |
url += '&fileId='+fileId; |
5730 |
18 Nov 19 |
nicklas |
url += '&itemId='+itemId; |
5730 |
18 Nov 19 |
nicklas |
Dialogs.openPopup(url, 'ViewVcf', 900, 600); |
5730 |
18 Nov 19 |
nicklas |
190 |
} |
6670 |
07 Apr 22 |
nicklas |
191 |
|
6670 |
07 Apr 22 |
nicklas |
vcall.toggleSelection = function(event) |
6670 |
07 Apr 22 |
nicklas |
193 |
{ |
6670 |
07 Apr 22 |
nicklas |
var prefix = Data.get(event.currentTarget, 'prefix'); |
6670 |
07 Apr 22 |
nicklas |
var specialKey = event.altKey || event.ctrlKey || event.shiftKey; |
6670 |
07 Apr 22 |
nicklas |
196 |
|
6670 |
07 Apr 22 |
nicklas |
var frm = document.forms['reggie']; |
6670 |
07 Apr 22 |
nicklas |
for (var rawNo = 0; rawNo < rawBioAssays.length; rawNo++) |
6670 |
07 Apr 22 |
nicklas |
199 |
{ |
6670 |
07 Apr 22 |
nicklas |
var raw = rawBioAssays[rawNo]; |
6670 |
07 Apr 22 |
nicklas |
var chk = frm[prefix+'.'+raw.id]; |
6670 |
07 Apr 22 |
nicklas |
if (chk && !chk.disabled) |
6670 |
07 Apr 22 |
nicklas |
203 |
{ |
6670 |
07 Apr 22 |
nicklas |
chk.checked = specialKey ? false : !chk.checked; |
6670 |
07 Apr 22 |
nicklas |
205 |
} |
6670 |
07 Apr 22 |
nicklas |
206 |
} |
6670 |
07 Apr 22 |
nicklas |
207 |
} |
5730 |
18 Nov 19 |
nicklas |
208 |
|
5728 |
15 Nov 19 |
nicklas |
vcall.submit = function() |
5728 |
15 Nov 19 |
nicklas |
210 |
{ |
5728 |
15 Nov 19 |
nicklas |
var frm = document.forms['reggie']; |
5728 |
15 Nov 19 |
nicklas |
var submitInfo = {}; |
5728 |
15 Nov 19 |
nicklas |
submitInfo.deleteItemsCreatedByFailedJobs = frm.deleteItemsCreatedByFailedJobs.checked; |
5728 |
15 Nov 19 |
nicklas |
214 |
|
5728 |
15 Nov 19 |
nicklas |
var all = []; |
5728 |
15 Nov 19 |
nicklas |
submitInfo.rawBioAssays = all; |
5728 |
15 Nov 19 |
nicklas |
for (var rawNo = 0; rawNo < rawBioAssays.length; rawNo++) |
5728 |
15 Nov 19 |
nicklas |
218 |
{ |
5728 |
15 Nov 19 |
nicklas |
var raw = rawBioAssays[rawNo]; |
5728 |
15 Nov 19 |
nicklas |
var tmp = {}; |
5728 |
15 Nov 19 |
nicklas |
tmp.id = raw.id; |
5728 |
15 Nov 19 |
nicklas |
222 |
|
5728 |
15 Nov 19 |
nicklas |
tmp.flag = frm['flag.'+raw.id] && frm['flag.'+raw.id].checked; |
5728 |
15 Nov 19 |
nicklas |
tmp.rerun = frm['rerun.'+raw.id].checked; |
5728 |
15 Nov 19 |
nicklas |
tmp.confirm = frm['confirm.'+raw.id].checked; |
5728 |
15 Nov 19 |
nicklas |
tmp.comment = frm['comment.'+raw.id].value; |
5728 |
15 Nov 19 |
nicklas |
227 |
|
5728 |
15 Nov 19 |
nicklas |
all[all.length] = tmp; |
5728 |
15 Nov 19 |
nicklas |
229 |
} |
5728 |
15 Nov 19 |
nicklas |
230 |
|
5728 |
15 Nov 19 |
nicklas |
var url = '../VariantCalling.servlet?ID='+App.getSessionId(); |
5728 |
15 Nov 19 |
nicklas |
url += '&cmd=ConfirmVariantCalling'; |
5728 |
15 Nov 19 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
5728 |
15 Nov 19 |
nicklas |
Wizard.asyncJsonRequest(url, vcall.submissionResults, 'POST', JSON.stringify(submitInfo)); |
5728 |
15 Nov 19 |
nicklas |
235 |
} |
5728 |
15 Nov 19 |
nicklas |
236 |
|
5728 |
15 Nov 19 |
nicklas |
vcall.submissionResults = function(response) |
5728 |
15 Nov 19 |
nicklas |
238 |
{ |
5728 |
15 Nov 19 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5728 |
15 Nov 19 |
nicklas |
Doc.show('gorestart'); |
5728 |
15 Nov 19 |
nicklas |
241 |
} |
5728 |
15 Nov 19 |
nicklas |
242 |
|
5728 |
15 Nov 19 |
nicklas |
243 |
|
5728 |
15 Nov 19 |
nicklas |
return vcall; |
5728 |
15 Nov 19 |
nicklas |
245 |
}(); |
5728 |
15 Nov 19 |
nicklas |
246 |
|
5728 |
15 Nov 19 |
nicklas |
Doc.onLoad(VCall.initPage); |
5728 |
15 Nov 19 |
nicklas |
248 |
|