2639 |
08 Sep 14 |
nicklas |
var Sequencing = function() |
2639 |
08 Sep 14 |
nicklas |
2 |
{ |
2639 |
08 Sep 14 |
nicklas |
var sequencing = {}; |
2656 |
11 Sep 14 |
nicklas |
var debug = 0; |
2639 |
08 Sep 14 |
nicklas |
5 |
|
2639 |
08 Sep 14 |
nicklas |
6 |
|
2639 |
08 Sep 14 |
nicklas |
// Page initialization |
2639 |
08 Sep 14 |
nicklas |
sequencing.initPage = function() |
2639 |
08 Sep 14 |
nicklas |
9 |
{ |
2639 |
08 Sep 14 |
nicklas |
// Step 1 |
2639 |
08 Sep 14 |
nicklas |
Events.addEventHandler('seqRuns', 'change', sequencing.sequencingRunOnChange); |
2641 |
09 Sep 14 |
nicklas |
Buttons.addClickHandler('btnCheck', sequencing.checkDataFilesOnClick); |
2639 |
08 Sep 14 |
nicklas |
Events.addEventHandler('outcomeSuccess', 'click', sequencing.outcomeOnChange); |
2639 |
08 Sep 14 |
nicklas |
Events.addEventHandler('outcomeFailed', 'click', sequencing.outcomeOnChange); |
2639 |
08 Sep 14 |
nicklas |
15 |
|
2639 |
08 Sep 14 |
nicklas |
// Step 2 |
2639 |
08 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', sequencing.initializeStep2); |
2639 |
08 Sep 14 |
nicklas |
18 |
|
2639 |
08 Sep 14 |
nicklas |
// Navigation |
2639 |
08 Sep 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2639 |
08 Sep 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2639 |
08 Sep 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2639 |
08 Sep 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2639 |
08 Sep 14 |
nicklas |
24 |
|
2639 |
08 Sep 14 |
nicklas |
// Final registration |
2639 |
08 Sep 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', sequencing.submit); |
2639 |
08 Sep 14 |
nicklas |
27 |
|
2639 |
08 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Loading sequencing runs...'); |
2639 |
08 Sep 14 |
nicklas |
var url = '../SequencingRun.servlet?ID='+App.getSessionId(); |
5478 |
10 Jun 19 |
nicklas |
url += '&cmd=GetUnconfirmedSequencingRuns&pipeline='+encodeURIComponent(Data.get('page-data', 'pipeline')); |
2639 |
08 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, sequencing.initializeStep1); |
2639 |
08 Sep 14 |
nicklas |
32 |
} |
2639 |
08 Sep 14 |
nicklas |
33 |
|
2639 |
08 Sep 14 |
nicklas |
sequencing.initializeStep1 = function(response) |
2639 |
08 Sep 14 |
nicklas |
35 |
{ |
2639 |
08 Sep 14 |
nicklas |
var seqRuns = response.sequencingRuns; |
2639 |
08 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2639 |
08 Sep 14 |
nicklas |
38 |
|
2639 |
08 Sep 14 |
nicklas |
if (seqRuns.length > 0) |
2639 |
08 Sep 14 |
nicklas |
40 |
{ |
2639 |
08 Sep 14 |
nicklas |
for (var runNo=0; runNo < seqRuns.length; runNo++) |
2639 |
08 Sep 14 |
nicklas |
42 |
{ |
2639 |
08 Sep 14 |
nicklas |
var seqRun = seqRuns[runNo]; |
2639 |
08 Sep 14 |
nicklas |
var option = sequencing.getOptionForSeqRun(seqRun); |
2639 |
08 Sep 14 |
nicklas |
frm.seqRuns.options[frm.seqRuns.length] = option; |
2639 |
08 Sep 14 |
nicklas |
46 |
} |
2639 |
08 Sep 14 |
nicklas |
47 |
} |
2639 |
08 Sep 14 |
nicklas |
else |
2639 |
08 Sep 14 |
nicklas |
49 |
{ |
2639 |
08 Sep 14 |
nicklas |
Wizard.setFatalError('No sequencing runs available for processing.'); |
2639 |
08 Sep 14 |
nicklas |
return; |
2639 |
08 Sep 14 |
nicklas |
52 |
} |
2639 |
08 Sep 14 |
nicklas |
53 |
|
2639 |
08 Sep 14 |
nicklas |
Doc.show('step-1'); |
2639 |
08 Sep 14 |
nicklas |
Doc.show('gonext'); |
2639 |
08 Sep 14 |
nicklas |
56 |
|
2639 |
08 Sep 14 |
nicklas |
sequencing.sequencingRunOnChange(); |
2639 |
08 Sep 14 |
nicklas |
frm.seqRuns.focus(); |
2639 |
08 Sep 14 |
nicklas |
59 |
} |
2639 |
08 Sep 14 |
nicklas |
60 |
|
2639 |
08 Sep 14 |
nicklas |
sequencing.sequencingRunOnChange = function() |
2639 |
08 Sep 14 |
nicklas |
62 |
{ |
2639 |
08 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2639 |
08 Sep 14 |
nicklas |
var seqRun = frm.seqRuns[frm.seqRuns.selectedIndex].seqRun; |
2639 |
08 Sep 14 |
nicklas |
65 |
|
2639 |
08 Sep 14 |
nicklas |
Doc.element('startDate').innerHTML = Reggie.reformatDate(seqRun.SequencingStart); |
2639 |
08 Sep 14 |
nicklas |
Doc.element('endDate').innerHTML = Reggie.reformatDate(seqRun.SequencingEnd); |
2639 |
08 Sep 14 |
nicklas |
68 |
|
2639 |
08 Sep 14 |
nicklas |
Forms.checkRadio(frm.outcome, seqRun.SequencingResult || 'Successful'); |
2639 |
08 Sep 14 |
nicklas |
sequencing.outcomeOnChange(); |
2639 |
08 Sep 14 |
nicklas |
71 |
|
2639 |
08 Sep 14 |
nicklas |
var fc = seqRun.flowCell; |
2639 |
08 Sep 14 |
nicklas |
Doc.element('flowCellInRun').innerHTML = '<b>['+seqRun.HiSeqPosition+']</b> ' + Strings.encodeTags(fc.FlowCellID); |
2639 |
08 Sep 14 |
nicklas |
Doc.element('flowCellType').innerHTML = fc.FlowCellType || ''; |
2639 |
08 Sep 14 |
nicklas |
75 |
|
2639 |
08 Sep 14 |
nicklas |
var pools = fc.pools; |
5473 |
05 Jun 19 |
nicklas |
var poolNames = []; |
5473 |
05 Jun 19 |
nicklas |
var libPlateNames = []; |
2639 |
08 Sep 14 |
nicklas |
for (var poolNo = 0; poolNo < pools.length; poolNo++) |
2639 |
08 Sep 14 |
nicklas |
80 |
{ |
2639 |
08 Sep 14 |
nicklas |
var pool = pools[poolNo]; |
5473 |
05 Jun 19 |
nicklas |
poolNames[poolNames.length] = pool.name; |
5473 |
05 Jun 19 |
nicklas |
if (pool.libPlates) |
2639 |
08 Sep 14 |
nicklas |
84 |
{ |
5473 |
05 Jun 19 |
nicklas |
for (var plateNo = 0; plateNo < pool.libPlates.length; plateNo++) |
5473 |
05 Jun 19 |
nicklas |
86 |
{ |
5473 |
05 Jun 19 |
nicklas |
var plateName = pool.libPlates[plateNo].name; |
5473 |
05 Jun 19 |
nicklas |
if (libPlateNames.indexOf(plateName) == -1) |
5473 |
05 Jun 19 |
nicklas |
89 |
{ |
5473 |
05 Jun 19 |
nicklas |
libPlateNames[libPlateNames.length] = plateName; |
5473 |
05 Jun 19 |
nicklas |
91 |
} |
5473 |
05 Jun 19 |
nicklas |
92 |
} |
2639 |
08 Sep 14 |
nicklas |
93 |
} |
2639 |
08 Sep 14 |
nicklas |
94 |
} |
5473 |
05 Jun 19 |
nicklas |
Doc.element('pools').innerHTML = Strings.encodeTags(poolNames.join(', ')); |
5473 |
05 Jun 19 |
nicklas |
Doc.element('libPlates').innerHTML = Strings.encodeTags(libPlateNames.join(', ')) || 'n/a'; |
2639 |
08 Sep 14 |
nicklas |
Doc.element('comments').innerHTML = Strings.encodeTags(seqRun.comments); |
2639 |
08 Sep 14 |
nicklas |
98 |
} |
2639 |
08 Sep 14 |
nicklas |
99 |
|
2639 |
08 Sep 14 |
nicklas |
100 |
|
2639 |
08 Sep 14 |
nicklas |
sequencing.outcomeOnChange = function() |
2639 |
08 Sep 14 |
nicklas |
102 |
{ |
2639 |
08 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2639 |
08 Sep 14 |
nicklas |
frm.flagPools.disabled = !Doc.element('outcomeFailed').checked; |
2639 |
08 Sep 14 |
nicklas |
105 |
} |
2639 |
08 Sep 14 |
nicklas |
106 |
|
2639 |
08 Sep 14 |
nicklas |
sequencing.getOptionForSeqRun = function(seqRun) |
2639 |
08 Sep 14 |
nicklas |
108 |
{ |
2639 |
08 Sep 14 |
nicklas |
var flowCell = seqRun.flowCell; |
2639 |
08 Sep 14 |
nicklas |
var name = seqRun.name+': '; |
2639 |
08 Sep 14 |
nicklas |
var numPools = flowCell.pools.length; |
2639 |
08 Sep 14 |
nicklas |
var firstPoolNum = sequencing.getPoolNum(flowCell.pools[0].name); |
2639 |
08 Sep 14 |
nicklas |
var lastPoolNum = sequencing.getPoolNum(flowCell.pools[flowCell.pools.length-1].name); |
2639 |
08 Sep 14 |
nicklas |
114 |
|
2639 |
08 Sep 14 |
nicklas |
if (lastPoolNum - firstPoolNum == numPools - 1) |
2639 |
08 Sep 14 |
nicklas |
116 |
{ |
2639 |
08 Sep 14 |
nicklas |
if (numPools > 1) |
2639 |
08 Sep 14 |
nicklas |
118 |
{ |
2639 |
08 Sep 14 |
nicklas |
// Display: PoolN -- PoolY |
2639 |
08 Sep 14 |
nicklas |
name += flowCell.pools[0].name + ' — ' + flowCell.pools[flowCell.pools.length-1].name; |
2639 |
08 Sep 14 |
nicklas |
121 |
} |
2639 |
08 Sep 14 |
nicklas |
else |
2639 |
08 Sep 14 |
nicklas |
123 |
{ |
2639 |
08 Sep 14 |
nicklas |
name += flowCell.pools[0].name; |
2639 |
08 Sep 14 |
nicklas |
125 |
} |
2639 |
08 Sep 14 |
nicklas |
126 |
} |
2639 |
08 Sep 14 |
nicklas |
else |
2639 |
08 Sep 14 |
nicklas |
128 |
{ |
2639 |
08 Sep 14 |
nicklas |
// Display: PoolN + x more... |
2639 |
08 Sep 14 |
nicklas |
name += flowCell.pools[0].name + ' + ' + (numPools-1) + ' more...'; |
2639 |
08 Sep 14 |
nicklas |
131 |
} |
2648 |
10 Sep 14 |
nicklas |
132 |
|
5478 |
10 Jun 19 |
nicklas |
var opt = []; |
5478 |
10 Jun 19 |
nicklas |
if (flowCell.FlowCellType) opt[opt.length] = flowCell.FlowCellType; |
5478 |
10 Jun 19 |
nicklas |
opt[opt.length] = seqRun.pipeline; |
5478 |
10 Jun 19 |
nicklas |
name += ' [' + opt.join('; ') + ']'; |
2639 |
08 Sep 14 |
nicklas |
137 |
|
2639 |
08 Sep 14 |
nicklas |
// Tooltip is always all pools |
2639 |
08 Sep 14 |
nicklas |
var title = ''; |
2639 |
08 Sep 14 |
nicklas |
for (var poolNo=0; poolNo < numPools; poolNo++) |
2639 |
08 Sep 14 |
nicklas |
141 |
{ |
2639 |
08 Sep 14 |
nicklas |
var pool = flowCell.pools[poolNo]; |
2639 |
08 Sep 14 |
nicklas |
if (poolNo > 0) title += ', '; |
2639 |
08 Sep 14 |
nicklas |
title += pool.name; |
2639 |
08 Sep 14 |
nicklas |
145 |
} |
2639 |
08 Sep 14 |
nicklas |
146 |
|
2639 |
08 Sep 14 |
nicklas |
var option = new Option(name, seqRun.id); |
2639 |
08 Sep 14 |
nicklas |
option.title = title; |
2639 |
08 Sep 14 |
nicklas |
option.seqRun = seqRun; |
2639 |
08 Sep 14 |
nicklas |
return option; |
2639 |
08 Sep 14 |
nicklas |
151 |
} |
2639 |
08 Sep 14 |
nicklas |
152 |
|
2639 |
08 Sep 14 |
nicklas |
sequencing.getPoolNum = function(poolName) |
2639 |
08 Sep 14 |
nicklas |
154 |
{ |
2639 |
08 Sep 14 |
nicklas |
var num = poolName.match(/Pool(\d+)/); |
2639 |
08 Sep 14 |
nicklas |
return num ? parseInt(num[1], 10) : null; |
2639 |
08 Sep 14 |
nicklas |
157 |
} |
2639 |
08 Sep 14 |
nicklas |
158 |
|
2641 |
09 Sep 14 |
nicklas |
sequencing.checkDataFilesOnClick = function() |
2641 |
09 Sep 14 |
nicklas |
160 |
{ |
2641 |
09 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
5488 |
12 Jun 19 |
nicklas |
var url = '../analysis/check_data_files.jsp?ID='+App.getSessionId(); |
2641 |
09 Sep 14 |
nicklas |
url += '&seqrun='+frm.seqRuns.value; |
2641 |
09 Sep 14 |
nicklas |
Dialogs.openPopup(url, 'CheckDataFiles', 900, 600); |
2641 |
09 Sep 14 |
nicklas |
165 |
} |
2641 |
09 Sep 14 |
nicklas |
166 |
|
2639 |
08 Sep 14 |
nicklas |
sequencing.initializeStep2 = function() |
2639 |
08 Sep 14 |
nicklas |
168 |
{ |
2639 |
08 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2639 |
08 Sep 14 |
nicklas |
var seqRun = frm.seqRuns[frm.seqRuns.selectedIndex].seqRun; |
2639 |
08 Sep 14 |
nicklas |
var outcome = Forms.getCheckedRadio(frm, 'outcome').value; |
2639 |
08 Sep 14 |
nicklas |
172 |
|
2639 |
08 Sep 14 |
nicklas |
frm.sequencingComments.value = seqRun.comments; |
2657 |
11 Sep 14 |
nicklas |
Doc.element('step-2-title').innerHTML = Strings.encodeTags(frm.seqRuns[frm.seqRuns.selectedIndex].text); |
2639 |
08 Sep 14 |
nicklas |
175 |
|
2639 |
08 Sep 14 |
nicklas |
var fc = seqRun.flowCell; |
2639 |
08 Sep 14 |
nicklas |
if (outcome != 'Successful') |
2639 |
08 Sep 14 |
nicklas |
178 |
{ |
2665 |
15 Sep 14 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Check to verify registration of failure.'); |
2639 |
08 Sep 14 |
nicklas |
Doc.hide('failedLanesRow'); |
2639 |
08 Sep 14 |
nicklas |
181 |
} |
2639 |
08 Sep 14 |
nicklas |
else |
2639 |
08 Sep 14 |
nicklas |
183 |
{ |
2639 |
08 Sep 14 |
nicklas |
// Failed lanes |
2639 |
08 Sep 14 |
nicklas |
var html = ''; |
2639 |
08 Sep 14 |
nicklas |
for (var laneNo = 1; laneNo <= fc.numLanes; laneNo++) |
2639 |
08 Sep 14 |
nicklas |
187 |
{ |
2639 |
08 Sep 14 |
nicklas |
html += '<label><input type="checkbox" name="failedLanes" value="'+laneNo+'">'+laneNo+'</label> '; |
2639 |
08 Sep 14 |
nicklas |
189 |
} |
2639 |
08 Sep 14 |
nicklas |
Doc.element('failedLanes').innerHTML = html; |
2639 |
08 Sep 14 |
nicklas |
Doc.show('failedLanesRow'); |
2639 |
08 Sep 14 |
nicklas |
192 |
} |
2639 |
08 Sep 14 |
nicklas |
193 |
|
2639 |
08 Sep 14 |
nicklas |
Wizard.setCurrentStep(2); |
2639 |
08 Sep 14 |
nicklas |
Doc.show('goregister'); |
2639 |
08 Sep 14 |
nicklas |
Doc.show('gocancel'); |
2639 |
08 Sep 14 |
nicklas |
197 |
} |
2639 |
08 Sep 14 |
nicklas |
198 |
|
2639 |
08 Sep 14 |
nicklas |
sequencing.submit = function() |
2639 |
08 Sep 14 |
nicklas |
200 |
{ |
2639 |
08 Sep 14 |
nicklas |
201 |
|
2639 |
08 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2639 |
08 Sep 14 |
nicklas |
203 |
|
2639 |
08 Sep 14 |
nicklas |
var seqRun = frm.seqRuns[frm.seqRuns.selectedIndex].seqRun; |
2639 |
08 Sep 14 |
nicklas |
var outcome = Forms.getCheckedRadio(frm, 'outcome').value; |
2639 |
08 Sep 14 |
nicklas |
206 |
|
2639 |
08 Sep 14 |
nicklas |
var submitInfo = {}; |
2639 |
08 Sep 14 |
nicklas |
submitInfo.flagPools = frm.flagPools.checked ? true : false; |
2639 |
08 Sep 14 |
nicklas |
209 |
|
2639 |
08 Sep 14 |
nicklas |
seqRun.comments = frm.sequencingComments.value; |
2639 |
08 Sep 14 |
nicklas |
seqRun.SequencingResult = outcome; |
2639 |
08 Sep 14 |
nicklas |
submitInfo.sequencingRun = seqRun; |
2639 |
08 Sep 14 |
nicklas |
213 |
|
2639 |
08 Sep 14 |
nicklas |
if (outcome == 'Successful') |
2639 |
08 Sep 14 |
nicklas |
215 |
{ |
2639 |
08 Sep 14 |
nicklas |
var fc = seqRun.flowCell; |
2639 |
08 Sep 14 |
nicklas |
var failedLanes = []; |
2639 |
08 Sep 14 |
nicklas |
var checkboxes = frm['failedLanes']; |
2639 |
08 Sep 14 |
nicklas |
for (var i = 0; i < checkboxes.length; i++) |
2639 |
08 Sep 14 |
nicklas |
220 |
{ |
2639 |
08 Sep 14 |
nicklas |
if (checkboxes[i].checked) failedLanes[failedLanes.length] = parseInt(checkboxes[i].value); |
2639 |
08 Sep 14 |
nicklas |
222 |
} |
2639 |
08 Sep 14 |
nicklas |
fc.failedLanes = failedLanes; |
2639 |
08 Sep 14 |
nicklas |
224 |
} |
2639 |
08 Sep 14 |
nicklas |
225 |
|
2639 |
08 Sep 14 |
nicklas |
var url = '../SequencingRun.servlet?ID='+App.getSessionId(); |
5488 |
12 Jun 19 |
nicklas |
url += '&cmd=ConfirmSequencingEnded&pipeline='+encodeURIComponent(Data.get('page-data', 'pipeline')); |
2639 |
08 Sep 14 |
nicklas |
228 |
|
2639 |
08 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2639 |
08 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, sequencing.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2639 |
08 Sep 14 |
nicklas |
231 |
} |
2639 |
08 Sep 14 |
nicklas |
232 |
|
2639 |
08 Sep 14 |
nicklas |
sequencing.submissionResults = function(response) |
2639 |
08 Sep 14 |
nicklas |
234 |
{ |
2639 |
08 Sep 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2639 |
08 Sep 14 |
nicklas |
Doc.show('gorestart'); |
2639 |
08 Sep 14 |
nicklas |
237 |
} |
2639 |
08 Sep 14 |
nicklas |
238 |
|
2639 |
08 Sep 14 |
nicklas |
return sequencing; |
2639 |
08 Sep 14 |
nicklas |
240 |
}(); |
2639 |
08 Sep 14 |
nicklas |
241 |
|
2639 |
08 Sep 14 |
nicklas |
Doc.onLoad(Sequencing.initPage); |
2639 |
08 Sep 14 |
nicklas |
243 |
|