7289 |
18 Aug 23 |
nicklas |
var Ascat = function() |
7289 |
18 Aug 23 |
nicklas |
2 |
{ |
7289 |
18 Aug 23 |
nicklas |
var ascat = {}; |
7289 |
18 Aug 23 |
nicklas |
var debug = 0; |
7289 |
18 Aug 23 |
nicklas |
5 |
|
7289 |
18 Aug 23 |
nicklas |
var JOB_IMAGE = { 'DONE': 'ok.png', 'ERROR': 'error.png'}; |
7289 |
18 Aug 23 |
nicklas |
7 |
|
7313 |
29 Aug 23 |
nicklas |
var selectionIsValid = false; |
7289 |
18 Aug 23 |
nicklas |
var ascatItems; |
7289 |
18 Aug 23 |
nicklas |
10 |
|
7289 |
18 Aug 23 |
nicklas |
// Page initialization |
7289 |
18 Aug 23 |
nicklas |
ascat.initPage = function() |
7289 |
18 Aug 23 |
nicklas |
13 |
{ |
7289 |
18 Aug 23 |
nicklas |
14 |
|
7289 |
18 Aug 23 |
nicklas |
// Step 1 |
7313 |
29 Aug 23 |
nicklas |
Events.addEventHandler('ascatItems', 'change', ascat.selectedItemsOnChange); |
7313 |
29 Aug 23 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', ascat.validateStep1); |
7313 |
29 Aug 23 |
nicklas |
18 |
|
7313 |
29 Aug 23 |
nicklas |
// Step 2 |
7313 |
29 Aug 23 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', ascat.initializeStep2); |
7289 |
18 Aug 23 |
nicklas |
21 |
|
7289 |
18 Aug 23 |
nicklas |
// Navigation |
7289 |
18 Aug 23 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
7289 |
18 Aug 23 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
7289 |
18 Aug 23 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
7289 |
18 Aug 23 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
7289 |
18 Aug 23 |
nicklas |
27 |
|
7289 |
18 Aug 23 |
nicklas |
// Final registration |
7289 |
18 Aug 23 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', ascat.submit); |
7289 |
18 Aug 23 |
nicklas |
30 |
|
7289 |
18 Aug 23 |
nicklas |
Wizard.showLoadingAnimation('Loading bioassays...'); |
7289 |
18 Aug 23 |
nicklas |
var url = '../Ascat.servlet?ID='+App.getSessionId(); |
7289 |
18 Aug 23 |
nicklas |
url += '&cmd=GetUnconfirmedAscatItems'; |
7289 |
18 Aug 23 |
nicklas |
Wizard.asyncJsonRequest(url, ascat.initializeStep1); |
7289 |
18 Aug 23 |
nicklas |
35 |
} |
7289 |
18 Aug 23 |
nicklas |
36 |
|
7289 |
18 Aug 23 |
nicklas |
// --- Step 1 ----------------------------------- |
7289 |
18 Aug 23 |
nicklas |
ascat.initializeStep1 = function(response) |
7289 |
18 Aug 23 |
nicklas |
39 |
{ |
7289 |
18 Aug 23 |
nicklas |
ascatItems = response.ascatItems; |
7289 |
18 Aug 23 |
nicklas |
if (ascatItems.length == 0) |
7289 |
18 Aug 23 |
nicklas |
42 |
{ |
7289 |
18 Aug 23 |
nicklas |
Wizard.setFatalError('No ASCAT results available for processing.'); |
7289 |
18 Aug 23 |
nicklas |
return; |
7289 |
18 Aug 23 |
nicklas |
45 |
} |
7313 |
29 Aug 23 |
nicklas |
46 |
|
7313 |
29 Aug 23 |
nicklas |
var frm = document.forms['reggie']; |
7313 |
29 Aug 23 |
nicklas |
var lastTumorId = 0; |
7313 |
29 Aug 23 |
nicklas |
var MAX_SELECTED = 10; |
7313 |
29 Aug 23 |
nicklas |
for (var ascatNo = 0; ascatNo < ascatItems.length; ascatNo++) |
7313 |
29 Aug 23 |
nicklas |
51 |
{ |
7313 |
29 Aug 23 |
nicklas |
var item = ascatItems[ascatNo]; |
7313 |
29 Aug 23 |
nicklas |
var name = (ascatNo+1)+': '+item.name; |
7313 |
29 Aug 23 |
nicklas |
var job = item.job; |
7313 |
29 Aug 23 |
nicklas |
55 |
|
7313 |
29 Aug 23 |
nicklas |
if (item.AscatResult) |
7313 |
29 Aug 23 |
nicklas |
57 |
{ |
7313 |
29 Aug 23 |
nicklas |
name += ' ['+Strings.encodeTags(item.AscatResult)+']'; |
7313 |
29 Aug 23 |
nicklas |
59 |
} |
7313 |
29 Aug 23 |
nicklas |
else if (job.status == 'ERROR') |
7313 |
29 Aug 23 |
nicklas |
61 |
{ |
7313 |
29 Aug 23 |
nicklas |
name += ' [Failed]'; |
7313 |
29 Aug 23 |
nicklas |
63 |
} |
7313 |
29 Aug 23 |
nicklas |
64 |
|
7313 |
29 Aug 23 |
nicklas |
if (ascatNo < MAX_SELECTED) lastTumorId = item.tumor.id; |
7313 |
29 Aug 23 |
nicklas |
var option = new Option(name, item.id, false, ascatNo < MAX_SELECTED || item.tumor.id == lastTumorId); |
7313 |
29 Aug 23 |
nicklas |
frm.ascatItems.options[frm.ascatItems.length] = option; |
7313 |
29 Aug 23 |
nicklas |
68 |
} |
7313 |
29 Aug 23 |
nicklas |
selectionIsValid = true; |
7313 |
29 Aug 23 |
nicklas |
Wizard.setInputStatus('ascatItems', 'valid'); |
7313 |
29 Aug 23 |
nicklas |
Doc.show('step-1'); |
7313 |
29 Aug 23 |
nicklas |
Doc.show('gonext'); |
7313 |
29 Aug 23 |
nicklas |
frm.ascatItems.focus(); |
7313 |
29 Aug 23 |
nicklas |
74 |
} |
7313 |
29 Aug 23 |
nicklas |
75 |
|
7313 |
29 Aug 23 |
nicklas |
ascat.selectedItemsOnChange = function() |
7313 |
29 Aug 23 |
nicklas |
77 |
{ |
7313 |
29 Aug 23 |
nicklas |
var frm = document.forms['reggie']; |
7313 |
29 Aug 23 |
nicklas |
selectionIsValid = false; |
7313 |
29 Aug 23 |
nicklas |
var numSelected = 0; |
7313 |
29 Aug 23 |
nicklas |
Wizard.setInputStatus('ascatItems'); |
7289 |
18 Aug 23 |
nicklas |
82 |
|
7313 |
29 Aug 23 |
nicklas |
for (var ascatNo = 0; ascatNo < frm.ascatItems.length; ascatNo++) |
7313 |
29 Aug 23 |
nicklas |
84 |
{ |
7313 |
29 Aug 23 |
nicklas |
if (frm.ascatItems[ascatNo].selected) |
7313 |
29 Aug 23 |
nicklas |
86 |
{ |
7313 |
29 Aug 23 |
nicklas |
numSelected++; |
7313 |
29 Aug 23 |
nicklas |
break; // We only need to know that at least one item is selected |
7313 |
29 Aug 23 |
nicklas |
89 |
} |
7313 |
29 Aug 23 |
nicklas |
90 |
} |
7313 |
29 Aug 23 |
nicklas |
if (numSelected == 0) |
7313 |
29 Aug 23 |
nicklas |
92 |
{ |
7313 |
29 Aug 23 |
nicklas |
Wizard.setInputStatus('ascatItems', 'invalid', 'Select at least one item'); |
7313 |
29 Aug 23 |
nicklas |
return; |
7313 |
29 Aug 23 |
nicklas |
95 |
} |
7313 |
29 Aug 23 |
nicklas |
selectionIsValid = true; |
7313 |
29 Aug 23 |
nicklas |
Wizard.setInputStatus('ascatItems', 'valid'); |
7313 |
29 Aug 23 |
nicklas |
98 |
} |
7313 |
29 Aug 23 |
nicklas |
99 |
|
7313 |
29 Aug 23 |
nicklas |
ascat.validateStep1 = function(event) |
7313 |
29 Aug 23 |
nicklas |
101 |
{ |
7313 |
29 Aug 23 |
nicklas |
if (!selectionIsValid) event.preventDefault(); |
7313 |
29 Aug 23 |
nicklas |
103 |
} |
7313 |
29 Aug 23 |
nicklas |
104 |
|
7313 |
29 Aug 23 |
nicklas |
// --- Step 2 ----------------------------------- |
7313 |
29 Aug 23 |
nicklas |
ascat.initializeStep2 = function(response) |
7313 |
29 Aug 23 |
nicklas |
107 |
{ |
7313 |
29 Aug 23 |
nicklas |
var frm = document.forms['reggie']; |
7313 |
29 Aug 23 |
nicklas |
var selectedItems = []; |
7313 |
29 Aug 23 |
nicklas |
for (var ascatNo = 0; ascatNo < frm.ascatItems.length; ascatNo++) |
7313 |
29 Aug 23 |
nicklas |
111 |
{ |
7313 |
29 Aug 23 |
nicklas |
if (frm.ascatItems[ascatNo].selected) |
7313 |
29 Aug 23 |
nicklas |
113 |
{ |
7313 |
29 Aug 23 |
nicklas |
selectedItems[selectedItems.length] = frm.ascatItems[ascatNo].value; |
7313 |
29 Aug 23 |
nicklas |
115 |
} |
7313 |
29 Aug 23 |
nicklas |
116 |
} |
7313 |
29 Aug 23 |
nicklas |
117 |
|
7313 |
29 Aug 23 |
nicklas |
Wizard.showLoadingAnimation('Loading bioassays...'); |
7313 |
29 Aug 23 |
nicklas |
var url = '../Ascat.servlet?ID='+App.getSessionId(); |
7313 |
29 Aug 23 |
nicklas |
url += '&cmd=GetUnconfirmedAscatItems&items='+selectedItems.join(','); |
7313 |
29 Aug 23 |
nicklas |
Wizard.asyncJsonRequest(url, ascat.ascatDetailsLoaded); |
7313 |
29 Aug 23 |
nicklas |
122 |
} |
7313 |
29 Aug 23 |
nicklas |
123 |
|
7313 |
29 Aug 23 |
nicklas |
ascat.ascatDetailsLoaded = function(response) |
7313 |
29 Aug 23 |
nicklas |
125 |
{ |
7313 |
29 Aug 23 |
nicklas |
ascatItems = response.ascatItems; |
7313 |
29 Aug 23 |
nicklas |
if (ascatItems.length == 0) |
7313 |
29 Aug 23 |
nicklas |
128 |
{ |
7313 |
29 Aug 23 |
nicklas |
Wizard.setFatalError('No ASCAT results available for processing.'); |
7313 |
29 Aug 23 |
nicklas |
return; |
7313 |
29 Aug 23 |
nicklas |
131 |
} |
7313 |
29 Aug 23 |
nicklas |
132 |
|
7289 |
18 Aug 23 |
nicklas |
var html = '<table id="ascatTable">'; |
7289 |
18 Aug 23 |
nicklas |
html += '<thead class="bg-filled-100">'; |
7289 |
18 Aug 23 |
nicklas |
// Header row |
7289 |
18 Aug 23 |
nicklas |
html += '<tr>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<th>ASCAT Item</th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft"></th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft"></th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft" colspan="3">Images</th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft"></th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft"></th>'; |
7293 |
22 Aug 23 |
nicklas |
html += '<th class="dottedleft" colspan="3">Actions</th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft"></th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '</tr>'; |
7289 |
18 Aug 23 |
nicklas |
146 |
|
7289 |
18 Aug 23 |
nicklas |
html += '<tr>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<th>Parent items - Tumor / Normal</th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft">Parameters</th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft">Results</th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft">Sunrise plot</th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th>ASCAT profile</th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th>Segmentation plot</th>'; |
7289 |
18 Aug 23 |
nicklas |
154 |
|
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft">Job</th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft">Files</th>'; |
7289 |
18 Aug 23 |
nicklas |
157 |
|
7293 |
22 Aug 23 |
nicklas |
html += '<th class="dottedleft">Results</th>'; |
7293 |
22 Aug 23 |
nicklas |
html += '<th>Re-analyze</th>'; |
7293 |
22 Aug 23 |
nicklas |
html += '<th>Delete</th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<th class="dottedleft">Comments</th>'; |
7289 |
18 Aug 23 |
nicklas |
html += '</tr>'; |
7289 |
18 Aug 23 |
nicklas |
html += '</thead>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<tbody>'; |
7289 |
18 Aug 23 |
nicklas |
var numWithError = 0; |
7289 |
18 Aug 23 |
nicklas |
for (var ascatNo = 0; ascatNo < ascatItems.length; ascatNo++) |
7289 |
18 Aug 23 |
nicklas |
167 |
{ |
7289 |
18 Aug 23 |
nicklas |
var item = ascatItems[ascatNo]; |
7289 |
18 Aug 23 |
nicklas |
var job = item.job; |
7341 |
11 Sep 23 |
nicklas |
var tumor = item.tumor; |
7341 |
11 Sep 23 |
nicklas |
var normal = item.normal; |
7289 |
18 Aug 23 |
nicklas |
var isError = job.status == 'ERROR'; |
7289 |
18 Aug 23 |
nicklas |
173 |
|
7289 |
18 Aug 23 |
nicklas |
html += '<tr class="highlight ' + (ascatNo % 4 < 2 ? 'evenrow' : 'oddrow') + '">'; |
7341 |
11 Sep 23 |
nicklas |
html += '<td class="prompt if-yellow"><b>'+Strings.encodeTags(item.name)+'</b>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<span class="link case-summary" data-name="'+Strings.encodeTags(item.name)+'" title="Show case summary"><img src="../images/case_summary.png"></span>'; |
7341 |
11 Sep 23 |
nicklas |
// Parent tumor and normal alignments |
7341 |
11 Sep 23 |
nicklas |
html += '<div class="aligned-table">'; |
7341 |
11 Sep 23 |
nicklas |
html += '<div>Aligned pairs</div>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<div>'+Reggie.formatCount(tumor.ALIGNED_PAIRS)+'</div>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<div>'+Reggie.formatCount(normal.ALIGNED_PAIRS)+'</div>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<div>Coverage</div>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<div>'+Reggie.formatNumber(tumor.MEAN_COVERAGE)+' ± '+Reggie.formatNumber(tumor.SD_COVERAGE)+'</div>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<div>'+Reggie.formatNumber(normal.MEAN_COVERAGE)+' ± '+Reggie.formatNumber(normal.SD_COVERAGE)+'</div>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<div>Duplication</div>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<div>'+Reggie.formatNumber(tumor.FRACTION_DUPLICATION*100, '%', 0)+' (<span title="Optical duplicates">'+Reggie.formatNumber(tumor.FRACTION_OPTICAL_DUPLICATION*100, '%', 0)+'</span>)</div>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<div>'+Reggie.formatNumber(normal.FRACTION_DUPLICATION*100, '%', 0)+' (<span title="Optical duplicates">'+Reggie.formatNumber(normal.FRACTION_OPTICAL_DUPLICATION*100, '%', 0)+'</span>)</div>'; |
7341 |
11 Sep 23 |
nicklas |
html += '</div>'; |
7341 |
11 Sep 23 |
nicklas |
html += '</td>'; |
7289 |
18 Aug 23 |
nicklas |
// Parameters |
7289 |
18 Aug 23 |
nicklas |
html += '<td class="dottedleft">'; |
7289 |
18 Aug 23 |
nicklas |
html += '<div class="smalltable">'; |
7341 |
11 Sep 23 |
nicklas |
if (item.MinDepth) html += '<div>Min depth</div><div>'+Numbers.formatNumber(item.MinDepth)+'</div>'; |
7341 |
11 Sep 23 |
nicklas |
if (item.Penalty) html += '<div>Penalty</div><div>'+Numbers.formatNumber(item.Penalty)+'</div>'; |
7341 |
11 Sep 23 |
nicklas |
if (item.ImbalanceTest) html += '<div>Imbalance test</div><div>'+Strings.encodeTags(item.ImbalanceTest)+'</div>'; |
7289 |
18 Aug 23 |
nicklas |
if (item.TauManual) html += '<div>Tau</div><div>'+Numbers.formatNumber(item.TauManual, 2)+'</div>'; |
7289 |
18 Aug 23 |
nicklas |
if (item.RhoManual) html += '<div>Rho</div><div>'+Numbers.formatNumber(item.RhoManual, 2)+'</div>'; |
7289 |
18 Aug 23 |
nicklas |
if (item.PsiManual) html += '<div>Psi</div><div>'+Numbers.formatNumber(item.PsiManual, 2)+'</div>'; |
7289 |
18 Aug 23 |
nicklas |
html += '</div>'; |
7289 |
18 Aug 23 |
nicklas |
html += '</td>'; |
7289 |
18 Aug 23 |
nicklas |
201 |
|
7289 |
18 Aug 23 |
nicklas |
// Results |
7289 |
18 Aug 23 |
nicklas |
html += '<td class="dottedleft">'; |
7289 |
18 Aug 23 |
nicklas |
html += '<div class="smalltable">'; |
7421 |
14 Nov 23 |
nicklas |
if (item.Purity == null && item.Ploidy == null) |
7421 |
14 Nov 23 |
nicklas |
206 |
{ |
7421 |
14 Nov 23 |
nicklas |
html += '<div>No solution</div>'; |
7421 |
14 Nov 23 |
nicklas |
208 |
} |
7421 |
14 Nov 23 |
nicklas |
else |
7421 |
14 Nov 23 |
nicklas |
210 |
{ |
7421 |
14 Nov 23 |
nicklas |
html += '<div>Purity</div><div>'+(item.Purity != null ? Numbers.formatNumber(item.Purity*100, 0, '%'):'')+'</div>'; |
7421 |
14 Nov 23 |
nicklas |
html += '<div>Ploidy</div><div>'+Numbers.formatNumber(item.Ploidy, 2)+'</div>'; |
7421 |
14 Nov 23 |
nicklas |
html += '<div title="Goodness of fit">GoF</div><div>'+Numbers.formatNumber(item.GoodnessOfFit, 1, '%')+'</div>'; |
7421 |
14 Nov 23 |
nicklas |
html += '<div title="Normal contamination">NC</div><div>'+(item.NormalContamination != null ? Numbers.formatNumber(item.NormalContamination*100, 0, '%'):'')+'</div>'; |
7421 |
14 Nov 23 |
nicklas |
if (item.NonAberrant=='Yes') html += '<div style="grid-column-start: 1; grid-column-end: 3;">Non-aberrant</div>'; |
7421 |
14 Nov 23 |
nicklas |
216 |
} |
7289 |
18 Aug 23 |
nicklas |
html += '</div>'; |
7289 |
18 Aug 23 |
nicklas |
218 |
|
7289 |
18 Aug 23 |
nicklas |
html += '<td class="dottedleft">'; |
7289 |
18 Aug 23 |
nicklas |
if (item.sunrisePlot) |
7289 |
18 Aug 23 |
nicklas |
221 |
{ |
7295 |
23 Aug 23 |
nicklas |
html += '<img class="link plot-link" data-file-id="'+item.sunrisePlot.id+'" data-width="800" data-height="800" title="View full image" src="../../thumbnails.jar/Thumbnails.servlet?ID='+App.getSessionId()+'&file='+item.sunrisePlot.id+'&size=MEDIUM">'; |
7289 |
18 Aug 23 |
nicklas |
223 |
} |
7289 |
18 Aug 23 |
nicklas |
html += '</td>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<td>'; |
7289 |
18 Aug 23 |
nicklas |
if (item.ascatPlot) |
7289 |
18 Aug 23 |
nicklas |
227 |
{ |
7295 |
23 Aug 23 |
nicklas |
html += '<img class="link plot-link" data-file-id="'+item.ascatPlot.id+'" data-width="1500" data-height="800" title="View full image" src="../../thumbnails.jar/Thumbnails.servlet?ID='+App.getSessionId()+'&file='+item.ascatPlot.id+'&size=XLARGE">'; |
7289 |
18 Aug 23 |
nicklas |
229 |
} |
7289 |
18 Aug 23 |
nicklas |
html += '</td>'; |
7289 |
18 Aug 23 |
nicklas |
html += '<td>'; |
7289 |
18 Aug 23 |
nicklas |
if (item.segmentationPlot) |
7289 |
18 Aug 23 |
nicklas |
233 |
{ |
7295 |
23 Aug 23 |
nicklas |
html += '<img class="link plot-link" data-file-id="'+item.segmentationPlot.id+'" data-width="1200" data-height="800" title="View full image" src="../../thumbnails.jar/Thumbnails.servlet?ID='+App.getSessionId()+'&file='+item.segmentationPlot.id+'&size=LARGE">'; |
7289 |
18 Aug 23 |
nicklas |
235 |
} |
7289 |
18 Aug 23 |
nicklas |
html += '</td>'; |
7289 |
18 Aug 23 |
nicklas |
237 |
|
7289 |
18 Aug 23 |
nicklas |
html += '<td class="dottedleft">'; |
7289 |
18 Aug 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>'; |
7289 |
18 Aug 23 |
nicklas |
if (job.debug) |
7289 |
18 Aug 23 |
nicklas |
241 |
{ |
7289 |
18 Aug 23 |
nicklas |
html += '<img src="../images/'+(isError?'bug-red':'bug-green')+'.png" title="This job was run in DEBUG mode">' |
7289 |
18 Aug 23 |
nicklas |
243 |
} |
7289 |
18 Aug 23 |
nicklas |
html += '</td>'; |
7341 |
11 Sep 23 |
nicklas |
html += '<td class="dottedleft">'; |
7289 |
18 Aug 23 |
nicklas |
if (item.DataFilesFolder && job.server) |
7289 |
18 Aug 23 |
nicklas |
247 |
{ |
7289 |
18 Aug 23 |
nicklas |
html += '<span class="link file-link" data-server="'+Strings.encodeTags(job.server)+'" data-folder="'+Strings.encodeTags(item.DataFilesFolder)+'" data-item-id="'+item.id+'" title="View generated files"><img src="../images/remote_folder.png"></span>'; |
7289 |
18 Aug 23 |
nicklas |
249 |
} |
7341 |
11 Sep 23 |
nicklas |
if (item.imbalanceTest) |
7289 |
18 Aug 23 |
nicklas |
251 |
{ |
7405 |
08 Nov 23 |
nicklas |
html += '<span class="link view-tabular" data-file-id="'+item.imbalanceTest.id+'" data-width="600" data-height="800" title="View allelic imbalance test scores"><img src="../images/report.png"></span>'; |
7289 |
18 Aug 23 |
nicklas |
253 |
} |
7405 |
08 Nov 23 |
nicklas |
if (item.stats) |
7405 |
08 Nov 23 |
nicklas |
255 |
{ |
7405 |
08 Nov 23 |
nicklas |
html += '<span class="link view-tabular" data-file-id="'+item.stats.id+'" data-width="600" data-height="800" title="View more metrics"><img src="../images/metrics.png"></span>'; |
7405 |
08 Nov 23 |
nicklas |
257 |
} |
7341 |
11 Sep 23 |
nicklas |
html += '</td>'; |
7289 |
18 Aug 23 |
nicklas |
259 |
|
7289 |
18 Aug 23 |
nicklas |
var reanalyzeChecked = isError ? ' checked' : ''; |
7289 |
18 Aug 23 |
nicklas |
var deleteChecked = reanalyzeChecked; |
7293 |
22 Aug 23 |
nicklas |
var commentDisabled = isError ? ' disabled' : ''; |
7289 |
18 Aug 23 |
nicklas |
if (isError) numWithError++; |
7289 |
18 Aug 23 |
nicklas |
264 |
|
7293 |
22 Aug 23 |
nicklas |
html += '<td class="dottedleft ascat-results">'; |
7293 |
22 Aug 23 |
nicklas |
if (!isError) |
7293 |
22 Aug 23 |
nicklas |
267 |
{ |
7293 |
22 Aug 23 |
nicklas |
html += '<label><input type="radio" id="undecided.'+item.id+'" name="results.'+item.id+'" checked value="Undecided">Undecided</label><br>'; |
7293 |
22 Aug 23 |
nicklas |
html += '<label><input type="radio" id="accept.'+item.id+'" name="results.'+item.id+'" value="Accepted">Accepted</label><br>'; |
7293 |
22 Aug 23 |
nicklas |
html += '<label><input type="radio" id="noaccept.'+item.id+'" name="results.'+item.id+'" value="NotAccepted">Not accepted</label><br>'; |
7293 |
22 Aug 23 |
nicklas |
271 |
} |
7293 |
22 Aug 23 |
nicklas |
html += '</td>'; |
7293 |
22 Aug 23 |
nicklas |
html += '<td><input type="checkbox" id="reanalyze.'+item.id+'" name="reanalyze.'+item.id+'"'+reanalyzeChecked+'></td>'; |
7293 |
22 Aug 23 |
nicklas |
html += '<td><input type="checkbox" id="delete.'+item.id+'" name="delete.'+item.id+'" data-item-id="'+item.id+'" '+deleteChecked+'></td>'; |
7293 |
22 Aug 23 |
nicklas |
html += '<td class="dottedleft comment"><input type="text" id="comment.'+item.id+'" name="comment.'+item.id+'" '+commentDisabled+' value="'+Strings.encodeTags(item.comment)+'"></td>'; |
7289 |
18 Aug 23 |
nicklas |
html += '</tr>'; |
7289 |
18 Aug 23 |
nicklas |
277 |
} |
7289 |
18 Aug 23 |
nicklas |
html += '</tbody>'; |
7289 |
18 Aug 23 |
nicklas |
html += '</table>'; |
7313 |
29 Aug 23 |
nicklas |
Doc.element('ascatResults').innerHTML = html; |
7289 |
18 Aug 23 |
nicklas |
281 |
|
7313 |
29 Aug 23 |
nicklas |
Forms.linkCheckboxesWithLabels(Doc.element('ascatResults')); |
7289 |
18 Aug 23 |
nicklas |
283 |
|
7341 |
11 Sep 23 |
nicklas |
// Case summary links |
7341 |
11 Sep 23 |
nicklas |
var cs = document.getElementsByClassName('case-summary'); |
7341 |
11 Sep 23 |
nicklas |
for (var i = 0; i < cs.length; i++) |
7341 |
11 Sep 23 |
nicklas |
287 |
{ |
7341 |
11 Sep 23 |
nicklas |
Events.addEventHandler(cs[i], 'click', Reggie.openCaseSummaryPopupOnEvent); |
7341 |
11 Sep 23 |
nicklas |
289 |
} |
7341 |
11 Sep 23 |
nicklas |
290 |
|
7293 |
22 Aug 23 |
nicklas |
// If 'delete' is active the other options should be disabled |
7293 |
22 Aug 23 |
nicklas |
for (var ascatNo = 0; ascatNo < ascatItems.length; ascatNo++) |
7293 |
22 Aug 23 |
nicklas |
293 |
{ |
7293 |
22 Aug 23 |
nicklas |
var item = ascatItems[ascatNo]; |
7293 |
22 Aug 23 |
nicklas |
Events.addEventHandler('delete.'+item.id, 'click', ascat.deleteOnChange); |
7293 |
22 Aug 23 |
nicklas |
296 |
} |
7293 |
22 Aug 23 |
nicklas |
297 |
|
7341 |
11 Sep 23 |
nicklas |
// Add click handler to tabular files |
7341 |
11 Sep 23 |
nicklas |
var tabular = document.getElementsByClassName('view-tabular'); |
7341 |
11 Sep 23 |
nicklas |
for (var i = 0; i < tabular.length; i++) |
7341 |
11 Sep 23 |
nicklas |
301 |
{ |
7341 |
11 Sep 23 |
nicklas |
Events.addEventHandler(tabular[i], 'click', ascat.viewTabular); |
7341 |
11 Sep 23 |
nicklas |
303 |
} |
7341 |
11 Sep 23 |
nicklas |
304 |
|
7289 |
18 Aug 23 |
nicklas |
// Add click handler to plot |
7289 |
18 Aug 23 |
nicklas |
var plots = document.getElementsByClassName('plot-link'); |
7289 |
18 Aug 23 |
nicklas |
for (var i = 0; i < plots.length; i++) |
7289 |
18 Aug 23 |
nicklas |
308 |
{ |
7289 |
18 Aug 23 |
nicklas |
Events.addEventHandler(plots[i], 'click', ascat.plotOnClick); |
7289 |
18 Aug 23 |
nicklas |
310 |
} |
7289 |
18 Aug 23 |
nicklas |
311 |
|
7289 |
18 Aug 23 |
nicklas |
// Add click handler to items |
7289 |
18 Aug 23 |
nicklas |
var clickableItems = document.getElementsByClassName('item-link'); |
7289 |
18 Aug 23 |
nicklas |
for (var i = 0; i < clickableItems.length; i++) |
7289 |
18 Aug 23 |
nicklas |
315 |
{ |
7289 |
18 Aug 23 |
nicklas |
Events.addEventHandler(clickableItems[i], 'click', Items.itemOnClick); |
7289 |
18 Aug 23 |
nicklas |
317 |
} |
7289 |
18 Aug 23 |
nicklas |
318 |
|
7289 |
18 Aug 23 |
nicklas |
// Add click handler to file links |
7289 |
18 Aug 23 |
nicklas |
var clickableItems = document.getElementsByClassName('file-link'); |
7289 |
18 Aug 23 |
nicklas |
for (var i = 0; i < clickableItems.length; i++) |
7289 |
18 Aug 23 |
nicklas |
322 |
{ |
7289 |
18 Aug 23 |
nicklas |
Events.addEventHandler(clickableItems[i], 'click', ascat.fileLinkOnClick); |
7289 |
18 Aug 23 |
nicklas |
324 |
} |
7289 |
18 Aug 23 |
nicklas |
325 |
|
7313 |
29 Aug 23 |
nicklas |
Wizard.setCurrentStep(2); |
7313 |
29 Aug 23 |
nicklas |
Doc.show('step-2'); |
7289 |
18 Aug 23 |
nicklas |
Doc.show('goregister'); |
7313 |
29 Aug 23 |
nicklas |
Doc.show('gocancel'); |
7289 |
18 Aug 23 |
nicklas |
330 |
} |
7289 |
18 Aug 23 |
nicklas |
331 |
|
7293 |
22 Aug 23 |
nicklas |
ascat.deleteOnChange = function(event) |
7293 |
22 Aug 23 |
nicklas |
333 |
{ |
7293 |
22 Aug 23 |
nicklas |
var itemId = Data.get(event.currentTarget, 'item-id'); |
7293 |
22 Aug 23 |
nicklas |
var disable = event.currentTarget.checked; |
7293 |
22 Aug 23 |
nicklas |
ascat.disableElement('undecided.'+itemId, disable); |
7293 |
22 Aug 23 |
nicklas |
ascat.disableElement('accept.'+itemId, disable); |
7293 |
22 Aug 23 |
nicklas |
ascat.disableElement('noaccept.'+itemId, disable); |
7293 |
22 Aug 23 |
nicklas |
ascat.disableElement('comment.'+itemId, disable); |
7293 |
22 Aug 23 |
nicklas |
340 |
} |
7293 |
22 Aug 23 |
nicklas |
341 |
|
7293 |
22 Aug 23 |
nicklas |
ascat.disableElement = function(element, disable) |
7293 |
22 Aug 23 |
nicklas |
343 |
{ |
7293 |
22 Aug 23 |
nicklas |
element = Doc.element(element); |
7293 |
22 Aug 23 |
nicklas |
if (element) element.disabled = disable; |
7293 |
22 Aug 23 |
nicklas |
346 |
} |
7293 |
22 Aug 23 |
nicklas |
347 |
|
7341 |
11 Sep 23 |
nicklas |
ascat.viewTabular = function(event) |
7341 |
11 Sep 23 |
nicklas |
349 |
{ |
7341 |
11 Sep 23 |
nicklas |
var fileId = Data.int(event.currentTarget, 'file-id'); |
7341 |
11 Sep 23 |
nicklas |
var width = Data.get(event.currentTarget, 'width', 900); |
7341 |
11 Sep 23 |
nicklas |
var height = Data.get(event.currentTarget, 'height', 600); |
7341 |
11 Sep 23 |
nicklas |
var url = '../Session.servlet?ID=' + App.getSessionId(); |
7341 |
11 Sep 23 |
nicklas |
url += '&cmd=ViewTabular'; |
7341 |
11 Sep 23 |
nicklas |
url += '&fileId='+fileId; |
7341 |
11 Sep 23 |
nicklas |
Dialogs.openPopup(url, 'ViewTabular'+fileId, width, height); |
7341 |
11 Sep 23 |
nicklas |
357 |
} |
7341 |
11 Sep 23 |
nicklas |
358 |
|
7289 |
18 Aug 23 |
nicklas |
ascat.plotOnClick = function(event) |
7289 |
18 Aug 23 |
nicklas |
360 |
{ |
7289 |
18 Aug 23 |
nicklas |
var fileId = Data.get(event.currentTarget, 'file-id'); |
7295 |
23 Aug 23 |
nicklas |
var width = Data.get(event.currentTarget, 'width', 900); |
7295 |
23 Aug 23 |
nicklas |
var height = Data.get(event.currentTarget, 'height', 600); |
7289 |
18 Aug 23 |
nicklas |
var controller = Items.getController('FILE'); |
7289 |
18 Aug 23 |
nicklas |
var url = App.getRoot() + controller.url; |
7289 |
18 Aug 23 |
nicklas |
url += '?ID='+App.getSessionId(); |
7289 |
18 Aug 23 |
nicklas |
url += '&cmd=ViewFile&item_id='+fileId; |
7295 |
23 Aug 23 |
nicklas |
Dialogs.openPopup(url, 'AscatPlot'+fileId, width, height); |
7289 |
18 Aug 23 |
nicklas |
369 |
} |
7289 |
18 Aug 23 |
nicklas |
370 |
|
7289 |
18 Aug 23 |
nicklas |
ascat.fileLinkOnClick = function(event) |
7289 |
18 Aug 23 |
nicklas |
372 |
{ |
7289 |
18 Aug 23 |
nicklas |
var folder = Data.get(event.currentTarget, 'folder'); |
7289 |
18 Aug 23 |
nicklas |
var server = Data.get(event.currentTarget, 'server'); |
7289 |
18 Aug 23 |
nicklas |
var itemId = Data.get(event.currentTarget, 'item-id'); |
7289 |
18 Aug 23 |
nicklas |
server = server.replace(/\s*\[.*\]/, ''); |
7289 |
18 Aug 23 |
nicklas |
var url = '../analysis/view_remote_files.jsp?ID=' + App.getSessionId(); |
7289 |
18 Aug 23 |
nicklas |
url += '&clusterId='+server; |
7289 |
18 Aug 23 |
nicklas |
url += '&archive=project-archive-dna'; |
7289 |
18 Aug 23 |
nicklas |
url += '&path='+encodeURIComponent(folder); |
7289 |
18 Aug 23 |
nicklas |
url += '&itemType=DERIVEDBIOASSAY&itemId='+itemId; |
7289 |
18 Aug 23 |
nicklas |
Dialogs.openPopup(url, 'ViewProjectFiles', 750, 500); |
7289 |
18 Aug 23 |
nicklas |
383 |
} |
7289 |
18 Aug 23 |
nicklas |
384 |
|
7289 |
18 Aug 23 |
nicklas |
ascat.submit = function() |
7289 |
18 Aug 23 |
nicklas |
386 |
{ |
7289 |
18 Aug 23 |
nicklas |
var frm = document.forms['reggie']; |
7289 |
18 Aug 23 |
nicklas |
var submitInfo = {}; |
7289 |
18 Aug 23 |
nicklas |
389 |
|
7289 |
18 Aug 23 |
nicklas |
var all = []; |
7289 |
18 Aug 23 |
nicklas |
submitInfo.ascatItems = all; |
7289 |
18 Aug 23 |
nicklas |
for (var ascatNo = 0; ascatNo < ascatItems.length; ascatNo++) |
7289 |
18 Aug 23 |
nicklas |
393 |
{ |
7289 |
18 Aug 23 |
nicklas |
var item = ascatItems[ascatNo]; |
7289 |
18 Aug 23 |
nicklas |
var tmp = {}; |
7289 |
18 Aug 23 |
nicklas |
tmp.id = item.id; |
7289 |
18 Aug 23 |
nicklas |
397 |
|
7293 |
22 Aug 23 |
nicklas |
tmp.reAnalyze = frm['reanalyze.'+item.id].checked; |
7289 |
18 Aug 23 |
nicklas |
tmp.delete = frm['delete.'+item.id].checked; |
7289 |
18 Aug 23 |
nicklas |
tmp.comment = frm['comment.'+item.id].value; |
7293 |
22 Aug 23 |
nicklas |
if (frm['results.'+item.id]) |
7293 |
22 Aug 23 |
nicklas |
402 |
{ |
7293 |
22 Aug 23 |
nicklas |
tmp.ascatResult = frm['results.'+item.id].value; |
7293 |
22 Aug 23 |
nicklas |
404 |
} |
7289 |
18 Aug 23 |
nicklas |
405 |
|
7289 |
18 Aug 23 |
nicklas |
all[all.length] = tmp; |
7289 |
18 Aug 23 |
nicklas |
407 |
} |
7289 |
18 Aug 23 |
nicklas |
408 |
|
7289 |
18 Aug 23 |
nicklas |
var url = '../Ascat.servlet?ID='+App.getSessionId(); |
7289 |
18 Aug 23 |
nicklas |
url += '&cmd=RegisterAscatResults'; |
7289 |
18 Aug 23 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
7289 |
18 Aug 23 |
nicklas |
Wizard.asyncJsonRequest(url, ascat.submissionResults, 'POST', JSON.stringify(submitInfo)); |
7289 |
18 Aug 23 |
nicklas |
413 |
} |
7289 |
18 Aug 23 |
nicklas |
414 |
|
7289 |
18 Aug 23 |
nicklas |
ascat.submissionResults = function(response) |
7289 |
18 Aug 23 |
nicklas |
416 |
{ |
7289 |
18 Aug 23 |
nicklas |
Wizard.showFinalMessage(response.messages); |
7289 |
18 Aug 23 |
nicklas |
Doc.show('gorestart'); |
7289 |
18 Aug 23 |
nicklas |
419 |
} |
7289 |
18 Aug 23 |
nicklas |
420 |
|
7289 |
18 Aug 23 |
nicklas |
return ascat; |
7289 |
18 Aug 23 |
nicklas |
422 |
}(); |
7289 |
18 Aug 23 |
nicklas |
423 |
|
7289 |
18 Aug 23 |
nicklas |
Doc.onLoad(Ascat.initPage); |
7289 |
18 Aug 23 |
nicklas |
425 |
|