5359 |
12 Apr 19 |
nicklas |
var DnaNormalize = function() |
5359 |
12 Apr 19 |
nicklas |
2 |
{ |
5359 |
12 Apr 19 |
nicklas |
var normalize = {}; |
5359 |
12 Apr 19 |
nicklas |
4 |
|
5359 |
12 Apr 19 |
nicklas |
// The minial volume of DNA we want to take when normalizing |
5359 |
12 Apr 19 |
nicklas |
// For DNA with high concentration we must make a larger mix to reach the target concentation |
5359 |
12 Apr 19 |
nicklas |
var MINIMAL_DNA_VOLUME = 1; // µl |
5359 |
12 Apr 19 |
nicklas |
var hasInitProtocols = false; |
5449 |
27 May 19 |
nicklas |
var protocolIsValid = false; |
5359 |
12 Apr 19 |
nicklas |
10 |
|
5359 |
12 Apr 19 |
nicklas |
var selectedDna; |
5359 |
12 Apr 19 |
nicklas |
var subtypeDna = null; |
5359 |
12 Apr 19 |
nicklas |
13 |
|
5359 |
12 Apr 19 |
nicklas |
var newDna = []; |
5359 |
12 Apr 19 |
nicklas |
15 |
|
5359 |
12 Apr 19 |
nicklas |
// Page initialization |
5359 |
12 Apr 19 |
nicklas |
normalize.initPage = function() |
5359 |
12 Apr 19 |
nicklas |
18 |
{ |
5359 |
12 Apr 19 |
nicklas |
// Step 1 |
5359 |
12 Apr 19 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', normalize.validateStep1); |
5359 |
12 Apr 19 |
nicklas |
Buttons.addClickHandler('btnSelectDna', normalize.selectDna); |
5359 |
12 Apr 19 |
nicklas |
Events.addEventHandler('dna', 'base-selected', normalize.onDnaSelected); |
5359 |
12 Apr 19 |
nicklas |
23 |
|
5359 |
12 Apr 19 |
nicklas |
// Step 2 |
5359 |
12 Apr 19 |
nicklas |
Events.addEventHandler('normalizationProtocol', 'change', normalize.protocolOnChange); |
5359 |
12 Apr 19 |
nicklas |
Events.addEventHandler('normalizationProtocol', 'keyup', normalize.protocolOnChange); |
5361 |
15 Apr 19 |
nicklas |
Events.addEventHandler('normalizedPlate', 'change', normalize.normalizedPlateOnChange); |
5361 |
15 Apr 19 |
nicklas |
Events.addEventHandler('normalizedPlate', 'keyup', normalize.normalizedPlateOnChange); |
5359 |
12 Apr 19 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', normalize.initializeStep2); |
5359 |
12 Apr 19 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', normalize.validateStep2); |
5359 |
12 Apr 19 |
nicklas |
31 |
|
5359 |
12 Apr 19 |
nicklas |
// Step 3 |
5359 |
12 Apr 19 |
nicklas |
Events.addEventHandler('step-3', 'wizard-initialize', normalize.initializeStep3); |
5359 |
12 Apr 19 |
nicklas |
Events.addEventHandler('normalizationDate', 'blur', Wizard.validateDate); |
5359 |
12 Apr 19 |
nicklas |
35 |
|
5359 |
12 Apr 19 |
nicklas |
// Navigation |
5359 |
12 Apr 19 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
5359 |
12 Apr 19 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
5359 |
12 Apr 19 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
5359 |
12 Apr 19 |
nicklas |
Buttons.addClickHandler('goprint', normalize.printVersion); |
5359 |
12 Apr 19 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
5359 |
12 Apr 19 |
nicklas |
42 |
|
5359 |
12 Apr 19 |
nicklas |
// Final registration |
5359 |
12 Apr 19 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', normalize.submit); |
5359 |
12 Apr 19 |
nicklas |
45 |
|
5359 |
12 Apr 19 |
nicklas |
var url = '../Extraction.servlet?ID='+App.getSessionId(); |
5359 |
12 Apr 19 |
nicklas |
url += '&cmd=GetDNAToNormalize'; |
5359 |
12 Apr 19 |
nicklas |
Wizard.showLoadingAnimation('Loading DNA extracts...'); |
5359 |
12 Apr 19 |
nicklas |
Wizard.asyncJsonRequest(url, normalize.onDnaLoaded); |
5359 |
12 Apr 19 |
nicklas |
50 |
} |
5359 |
12 Apr 19 |
nicklas |
51 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.onDnaLoaded = function(response) |
5359 |
12 Apr 19 |
nicklas |
53 |
{ |
5359 |
12 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5359 |
12 Apr 19 |
nicklas |
var dnaExtracts = response.dnaExtracts; |
5359 |
12 Apr 19 |
nicklas |
56 |
|
5359 |
12 Apr 19 |
nicklas |
dnaExtracts.sort(normalize.sortByQiacubePosition); |
5359 |
12 Apr 19 |
nicklas |
58 |
|
5359 |
12 Apr 19 |
nicklas |
if (dnaExtracts.length > 0) |
5359 |
12 Apr 19 |
nicklas |
60 |
{ |
5359 |
12 Apr 19 |
nicklas |
var qiacubeRun = dnaExtracts[0].QiacubeDate + '#' + dnaExtracts[0].QiacubeRunNo; |
5359 |
12 Apr 19 |
nicklas |
for (var i=0; i < dnaExtracts.length; i++) |
5359 |
12 Apr 19 |
nicklas |
63 |
{ |
5359 |
12 Apr 19 |
nicklas |
var dna = dnaExtracts[i]; |
5359 |
12 Apr 19 |
nicklas |
var selected = (dna.QiacubeDate + '#' + dna.QiacubeRunNo) == qiacubeRun; |
5359 |
12 Apr 19 |
nicklas |
normalize.addDnaOption(frm.dna, dna, selected); |
5359 |
12 Apr 19 |
nicklas |
67 |
} |
5449 |
27 May 19 |
nicklas |
Wizard.setInputStatus('dna', 'valid'); |
5359 |
12 Apr 19 |
nicklas |
69 |
} |
5359 |
12 Apr 19 |
nicklas |
else |
5359 |
12 Apr 19 |
nicklas |
71 |
{ |
5359 |
12 Apr 19 |
nicklas |
Wizard.setInputStatus('dna', 'invalid', 'No DNA available for normalization.'); |
5359 |
12 Apr 19 |
nicklas |
73 |
} |
5359 |
12 Apr 19 |
nicklas |
74 |
|
5359 |
12 Apr 19 |
nicklas |
Doc.show('step-1'); |
5359 |
12 Apr 19 |
nicklas |
Doc.show('gonext'); |
5359 |
12 Apr 19 |
nicklas |
77 |
} |
5359 |
12 Apr 19 |
nicklas |
78 |
|
5359 |
12 Apr 19 |
nicklas |
79 |
/** |
5359 |
12 Apr 19 |
nicklas |
Sort by qiacube date, run number and position |
5359 |
12 Apr 19 |
nicklas |
81 |
*/ |
5359 |
12 Apr 19 |
nicklas |
normalize.sortByQiacubePosition = function(a, b) |
5359 |
12 Apr 19 |
nicklas |
83 |
{ |
5359 |
12 Apr 19 |
nicklas |
if (a.QiacubeDate == b.QiacubeDate) |
5359 |
12 Apr 19 |
nicklas |
85 |
{ |
5359 |
12 Apr 19 |
nicklas |
if (a.QiacubeRunNo == b.QiacubeRunNo) |
5359 |
12 Apr 19 |
nicklas |
87 |
{ |
5359 |
12 Apr 19 |
nicklas |
return a.QiacubePosition-b.QiacubePosition; |
5359 |
12 Apr 19 |
nicklas |
89 |
} |
5359 |
12 Apr 19 |
nicklas |
else |
5359 |
12 Apr 19 |
nicklas |
91 |
{ |
5359 |
12 Apr 19 |
nicklas |
return a.QiacubeRunNo - b.QiacubeRunNo; |
5359 |
12 Apr 19 |
nicklas |
93 |
} |
5359 |
12 Apr 19 |
nicklas |
94 |
} |
5359 |
12 Apr 19 |
nicklas |
else |
5359 |
12 Apr 19 |
nicklas |
96 |
{ |
5359 |
12 Apr 19 |
nicklas |
return a.QiacubeDate < b.QiacubeDate ? -1 : 1; |
5359 |
12 Apr 19 |
nicklas |
98 |
} |
5359 |
12 Apr 19 |
nicklas |
99 |
|
5359 |
12 Apr 19 |
nicklas |
return a.id - b.id; |
5359 |
12 Apr 19 |
nicklas |
101 |
} |
5359 |
12 Apr 19 |
nicklas |
102 |
|
5359 |
12 Apr 19 |
nicklas |
103 |
|
5359 |
12 Apr 19 |
nicklas |
104 |
/** |
5359 |
12 Apr 19 |
nicklas |
Sort by qiacube date, run number and position |
5359 |
12 Apr 19 |
nicklas |
106 |
*/ |
5359 |
12 Apr 19 |
nicklas |
normalize.sortByStorageLocation = function(a, b) |
5359 |
12 Apr 19 |
nicklas |
108 |
{ |
6219 |
20 Apr 21 |
nicklas |
if (a.bioWell && b.bioWell) |
5359 |
12 Apr 19 |
nicklas |
110 |
{ |
6219 |
20 Apr 21 |
nicklas |
if (a.bioWell.bioPlate.name == b.bioWell.bioPlate.name) |
6219 |
20 Apr 21 |
nicklas |
112 |
{ |
6219 |
20 Apr 21 |
nicklas |
return a.bioWell.location < b.bioWell.location ? -1 : 1; |
6219 |
20 Apr 21 |
nicklas |
114 |
} |
6219 |
20 Apr 21 |
nicklas |
else |
6219 |
20 Apr 21 |
nicklas |
116 |
{ |
6219 |
20 Apr 21 |
nicklas |
return a.bioWell.bioPlate.name < b.bioWell.bioPlate.name ? -1 : 1; |
6219 |
20 Apr 21 |
nicklas |
118 |
} |
6219 |
20 Apr 21 |
nicklas |
119 |
} |
5359 |
12 Apr 19 |
nicklas |
return a.id - b.id; |
5359 |
12 Apr 19 |
nicklas |
121 |
} |
5359 |
12 Apr 19 |
nicklas |
122 |
|
5361 |
15 Apr 19 |
nicklas |
123 |
/** |
5361 |
15 Apr 19 |
nicklas |
Sort wells by column and row |
5361 |
15 Apr 19 |
nicklas |
125 |
*/ |
5361 |
15 Apr 19 |
nicklas |
normalize.sortWellsByColumnAndRow = function(a, b) |
5361 |
15 Apr 19 |
nicklas |
127 |
{ |
5361 |
15 Apr 19 |
nicklas |
if (a.column == b.column) |
5361 |
15 Apr 19 |
nicklas |
129 |
{ |
5361 |
15 Apr 19 |
nicklas |
return a.row - b.row; |
5361 |
15 Apr 19 |
nicklas |
131 |
} |
5361 |
15 Apr 19 |
nicklas |
else |
5361 |
15 Apr 19 |
nicklas |
133 |
{ |
5361 |
15 Apr 19 |
nicklas |
return a.column - b.column; |
5361 |
15 Apr 19 |
nicklas |
135 |
} |
5361 |
15 Apr 19 |
nicklas |
136 |
} |
5361 |
15 Apr 19 |
nicklas |
137 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.selectDna = function() |
5359 |
12 Apr 19 |
nicklas |
139 |
{ |
5359 |
12 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5359 |
12 Apr 19 |
nicklas |
if (frm.dna.disabled) return; |
5359 |
12 Apr 19 |
nicklas |
142 |
|
5359 |
12 Apr 19 |
nicklas |
if (subtypeDna == null) |
5359 |
12 Apr 19 |
nicklas |
144 |
{ |
5359 |
12 Apr 19 |
nicklas |
subtypeDna = Reggie.getSubtypeInfo('DNA'); |
5359 |
12 Apr 19 |
nicklas |
146 |
} |
5359 |
12 Apr 19 |
nicklas |
147 |
|
5359 |
12 Apr 19 |
nicklas |
newDna = []; |
5359 |
12 Apr 19 |
nicklas |
var url = '&resetTemporary=1'; |
5359 |
12 Apr 19 |
nicklas |
url += '&tmpfilter:INT:itemSubtype='+subtypeDna.id; |
5359 |
12 Apr 19 |
nicklas |
Dialogs.selectItem('EXTRACT', 'dna', 1, url); |
5359 |
12 Apr 19 |
nicklas |
152 |
} |
5359 |
12 Apr 19 |
nicklas |
153 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.onDnaSelected = function(event) |
5359 |
12 Apr 19 |
nicklas |
155 |
{ |
5359 |
12 Apr 19 |
nicklas |
var dna = event.detail; |
5359 |
12 Apr 19 |
nicklas |
157 |
|
5359 |
12 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5359 |
12 Apr 19 |
nicklas |
var dnaList = frm.dna; |
5359 |
12 Apr 19 |
nicklas |
var isNew = true; |
5359 |
12 Apr 19 |
nicklas |
for (var i = 0; i < dnaList.length; i++) |
5359 |
12 Apr 19 |
nicklas |
162 |
{ |
5359 |
12 Apr 19 |
nicklas |
if (dnaList[i].value == dna.id) |
5359 |
12 Apr 19 |
nicklas |
164 |
{ |
5359 |
12 Apr 19 |
nicklas |
dnaList[i].selected = true; |
5359 |
12 Apr 19 |
nicklas |
isNew = false; |
5359 |
12 Apr 19 |
nicklas |
167 |
} |
5359 |
12 Apr 19 |
nicklas |
168 |
} |
5359 |
12 Apr 19 |
nicklas |
169 |
|
5359 |
12 Apr 19 |
nicklas |
if (isNew) newDna[newDna.length] = dna.id; |
5359 |
12 Apr 19 |
nicklas |
171 |
|
5359 |
12 Apr 19 |
nicklas |
if (event.detail.remaining == 0 && newDna.length > 0) |
5359 |
12 Apr 19 |
nicklas |
173 |
{ |
5359 |
12 Apr 19 |
nicklas |
// Get more information about the selected dna |
5359 |
12 Apr 19 |
nicklas |
var url = '../Extraction.servlet?ID='+App.getSessionId(); |
5359 |
12 Apr 19 |
nicklas |
url += '&cmd=GetDNAInfoForNormalize&dnaIds=' + newDna.join(','); |
5359 |
12 Apr 19 |
nicklas |
Wizard.asyncJsonRequest(url, normalize.onDnaInfoLoaded); |
5359 |
12 Apr 19 |
nicklas |
178 |
} |
5359 |
12 Apr 19 |
nicklas |
179 |
} |
5359 |
12 Apr 19 |
nicklas |
180 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.onDnaInfoLoaded = function(response) |
5359 |
12 Apr 19 |
nicklas |
182 |
{ |
5359 |
12 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5359 |
12 Apr 19 |
nicklas |
var dnaExtracts = response.dnaExtracts; |
5359 |
12 Apr 19 |
nicklas |
dnaExtracts.sort(normalize.sortByQiacubePosition); |
5359 |
12 Apr 19 |
nicklas |
186 |
|
5359 |
12 Apr 19 |
nicklas |
for (var dnaNo = 0; dnaNo < dnaExtracts.length; dnaNo++) |
5359 |
12 Apr 19 |
nicklas |
188 |
{ |
5359 |
12 Apr 19 |
nicklas |
var dna = dnaExtracts[dnaNo]; |
5359 |
12 Apr 19 |
nicklas |
normalize.addDnaOption(frm.dna, dna, true); |
5359 |
12 Apr 19 |
nicklas |
191 |
} |
5449 |
27 May 19 |
nicklas |
Wizard.setInputStatus('dna', 'valid'); |
5359 |
12 Apr 19 |
nicklas |
193 |
} |
5359 |
12 Apr 19 |
nicklas |
194 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.addDnaOption = function(list, dna, selected) |
5359 |
12 Apr 19 |
nicklas |
196 |
{ |
5359 |
12 Apr 19 |
nicklas |
var name = dna.name; |
6726 |
04 May 22 |
nicklas |
if (dna.QiacubeDate) |
5359 |
12 Apr 19 |
nicklas |
199 |
{ |
6726 |
04 May 22 |
nicklas |
name += ' -- ' + Reggie.reformatDate(dna.QiacubeDate); |
6726 |
04 May 22 |
nicklas |
if (dna.QiacubeRunNo) name += '; Run ' + dna.QiacubeRunNo; |
6726 |
04 May 22 |
nicklas |
if (dna.QiacubePosition) name += '; Pos ' + dna.QiacubePosition; |
5359 |
12 Apr 19 |
nicklas |
203 |
} |
5359 |
12 Apr 19 |
nicklas |
204 |
|
5359 |
12 Apr 19 |
nicklas |
var option = new Option(name, dna.id, selected, selected); |
5359 |
12 Apr 19 |
nicklas |
if (dna.specimen && dna.specimen.YellowLabel != null) option.className = 'yellow'; |
5359 |
12 Apr 19 |
nicklas |
option.dna = dna; |
5359 |
12 Apr 19 |
nicklas |
list[list.length] = option; |
5359 |
12 Apr 19 |
nicklas |
209 |
} |
5359 |
12 Apr 19 |
nicklas |
210 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.validateStep1 = function(event) |
5359 |
12 Apr 19 |
nicklas |
212 |
{ |
5359 |
12 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5359 |
12 Apr 19 |
nicklas |
var dnaList = frm.dna; |
5359 |
12 Apr 19 |
nicklas |
215 |
|
5359 |
12 Apr 19 |
nicklas |
selectedDna = []; |
5359 |
12 Apr 19 |
nicklas |
for (var i=0; i < dnaList.length; i++) |
5359 |
12 Apr 19 |
nicklas |
218 |
{ |
5359 |
12 Apr 19 |
nicklas |
if (dnaList[i].selected) |
5359 |
12 Apr 19 |
nicklas |
220 |
{ |
5359 |
12 Apr 19 |
nicklas |
selectedDna[selectedDna.length] = dnaList[i].dna; |
5359 |
12 Apr 19 |
nicklas |
222 |
} |
5359 |
12 Apr 19 |
nicklas |
223 |
} |
5359 |
12 Apr 19 |
nicklas |
224 |
|
5359 |
12 Apr 19 |
nicklas |
if (selectedDna.length == 0) |
5359 |
12 Apr 19 |
nicklas |
226 |
{ |
5359 |
12 Apr 19 |
nicklas |
Wizard.setInputStatus('dna', 'invalid', 'Not selected', 'invalid'); |
5359 |
12 Apr 19 |
nicklas |
event.preventDefault(); |
5359 |
12 Apr 19 |
nicklas |
229 |
} |
5359 |
12 Apr 19 |
nicklas |
else |
5359 |
12 Apr 19 |
nicklas |
231 |
{ |
5359 |
12 Apr 19 |
nicklas |
Wizard.setInputStatus('dna', 'valid'); |
5359 |
12 Apr 19 |
nicklas |
233 |
} |
5359 |
12 Apr 19 |
nicklas |
234 |
} |
5359 |
12 Apr 19 |
nicklas |
235 |
|
5359 |
12 Apr 19 |
nicklas |
236 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.initializeStep2 = function() |
5359 |
12 Apr 19 |
nicklas |
238 |
{ |
5361 |
15 Apr 19 |
nicklas |
normalize.buildProtocol(); |
5361 |
15 Apr 19 |
nicklas |
240 |
|
5361 |
15 Apr 19 |
nicklas |
var url = '../Extraction.servlet?ID='+App.getSessionId(); |
5361 |
15 Apr 19 |
nicklas |
url += '&cmd=GetActivePreNormalizedDNAPlates&numFreeWells=' + selectedDna.length; |
5361 |
15 Apr 19 |
nicklas |
Wizard.asyncJsonRequest(url, normalize.onPlateInfoLoaded); |
5361 |
15 Apr 19 |
nicklas |
244 |
} |
5361 |
15 Apr 19 |
nicklas |
245 |
|
5361 |
15 Apr 19 |
nicklas |
normalize.onPlateInfoLoaded = function(response) |
5361 |
15 Apr 19 |
nicklas |
247 |
{ |
5359 |
12 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5361 |
15 Apr 19 |
nicklas |
var plates = response.plates; |
5361 |
15 Apr 19 |
nicklas |
for (var plateNo = 0; plateNo < plates.length; plateNo++) |
5361 |
15 Apr 19 |
nicklas |
251 |
{ |
5361 |
15 Apr 19 |
nicklas |
var plate = plates[plateNo]; |
5361 |
15 Apr 19 |
nicklas |
var title = ''; |
5361 |
15 Apr 19 |
nicklas |
if (plate.id == 0) |
5361 |
15 Apr 19 |
nicklas |
255 |
{ |
5361 |
15 Apr 19 |
nicklas |
title = 'Create: ' + plate.name; |
5361 |
15 Apr 19 |
nicklas |
257 |
} |
5361 |
15 Apr 19 |
nicklas |
else |
5361 |
15 Apr 19 |
nicklas |
259 |
{ |
5361 |
15 Apr 19 |
nicklas |
title = plate.name + ' -- ' + plate.freeWells + ' free wells'; |
5361 |
15 Apr 19 |
nicklas |
261 |
} |
5361 |
15 Apr 19 |
nicklas |
var option = new Option(title, plate.id); |
5361 |
15 Apr 19 |
nicklas |
plate.bioWells.sort(normalize.sortWellsByColumnAndRow); |
5361 |
15 Apr 19 |
nicklas |
option.plate = plate; |
5361 |
15 Apr 19 |
nicklas |
frm.normalizedPlate[frm.normalizedPlate.length] = option; |
5361 |
15 Apr 19 |
nicklas |
266 |
} |
5361 |
15 Apr 19 |
nicklas |
Wizard.setInputStatus('normalizedPlate', 'valid'); |
5361 |
15 Apr 19 |
nicklas |
268 |
|
5361 |
15 Apr 19 |
nicklas |
Wizard.setCurrentStep(2); |
5361 |
15 Apr 19 |
nicklas |
Doc.show('gonext'); |
5361 |
15 Apr 19 |
nicklas |
Doc.show('goprint'); |
5361 |
15 Apr 19 |
nicklas |
Doc.show('gocancel'); |
5361 |
15 Apr 19 |
nicklas |
Wizard.keepSessionAlive(); |
5602 |
13 Sep 19 |
nicklas |
Reggie.loadProtocols('DNA_NORMALIZATION_PROTOCOL', 'normalizationProtocol', 'DNA_TARGET_AMOUNT,DNA_MINIMAL_AMOUNT,DNA_TARGET_VOLUME,MIPS_PANEL'); |
5361 |
15 Apr 19 |
nicklas |
frm.normalizationProtocol.focus(); |
5361 |
15 Apr 19 |
nicklas |
276 |
} |
5361 |
15 Apr 19 |
nicklas |
277 |
|
5361 |
15 Apr 19 |
nicklas |
normalize.buildProtocol = function() |
5361 |
15 Apr 19 |
nicklas |
279 |
{ |
5359 |
12 Apr 19 |
nicklas |
// Check if all DNA from same Qiacube run |
5359 |
12 Apr 19 |
nicklas |
var qiacubeRun = selectedDna[0].QiacubeDate + '#' + selectedDna[0].QiacubeRunNo; |
5359 |
12 Apr 19 |
nicklas |
var sameQiacubeRun = true; |
6726 |
04 May 22 |
nicklas |
var showLabelColumn = false; |
6726 |
04 May 22 |
nicklas |
for (var i=0; i < selectedDna.length; i++) |
5359 |
12 Apr 19 |
nicklas |
285 |
{ |
5359 |
12 Apr 19 |
nicklas |
var dna = selectedDna[i]; |
5359 |
12 Apr 19 |
nicklas |
if (qiacubeRun != dna.QiacubeDate+'#'+dna.QiacubeRunNo) |
5359 |
12 Apr 19 |
nicklas |
288 |
{ |
5359 |
12 Apr 19 |
nicklas |
sameQiacubeRun = false; |
5359 |
12 Apr 19 |
nicklas |
290 |
} |
6726 |
04 May 22 |
nicklas |
if (dna.label) showLabelColumn = true; |
5359 |
12 Apr 19 |
nicklas |
292 |
} |
5359 |
12 Apr 19 |
nicklas |
293 |
|
5359 |
12 Apr 19 |
nicklas |
if (sameQiacubeRun) |
5359 |
12 Apr 19 |
nicklas |
295 |
{ |
5359 |
12 Apr 19 |
nicklas |
selectedDna.sort(normalize.sortByQiacubePosition); |
5359 |
12 Apr 19 |
nicklas |
Doc.show('qiacube-info'); |
5359 |
12 Apr 19 |
nicklas |
Doc.element('qiacube-date').innerHTML = Reggie.reformatDate(selectedDna[0].QiacubeDate); |
5359 |
12 Apr 19 |
nicklas |
Doc.element('qiacube-run').innerHTML = selectedDna[0].QiacubeRunNo; |
5359 |
12 Apr 19 |
nicklas |
300 |
} |
5359 |
12 Apr 19 |
nicklas |
else |
5359 |
12 Apr 19 |
nicklas |
302 |
{ |
5359 |
12 Apr 19 |
nicklas |
selectedDna.sort(normalize.sortByStorageLocation); |
5359 |
12 Apr 19 |
nicklas |
304 |
} |
5359 |
12 Apr 19 |
nicklas |
305 |
|
5359 |
12 Apr 19 |
nicklas |
var html = '<table id="extractTable">'; |
5359 |
12 Apr 19 |
nicklas |
html += '<thead class="bg-filled-100">'; |
5359 |
12 Apr 19 |
nicklas |
// First header row |
5359 |
12 Apr 19 |
nicklas |
html += '<tr>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<th>DNA</th>'; |
6726 |
04 May 22 |
nicklas |
if (showLabelColumn) |
6726 |
04 May 22 |
nicklas |
312 |
{ |
6726 |
04 May 22 |
nicklas |
html += '<th>Label¹</th>'; |
6726 |
04 May 22 |
nicklas |
314 |
} |
5359 |
12 Apr 19 |
nicklas |
if (sameQiacubeRun) |
5359 |
12 Apr 19 |
nicklas |
316 |
{ |
5359 |
12 Apr 19 |
nicklas |
html += '<th>Qiacube</th>'; |
5359 |
12 Apr 19 |
nicklas |
318 |
} |
5359 |
12 Apr 19 |
nicklas |
html += '<th>Storage</th>'; |
6219 |
20 Apr 21 |
nicklas |
html += '<th>Conc.</th>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<th>Remain</th>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<th colspan="2">Volumes</th>'; |
5361 |
15 Apr 19 |
nicklas |
html += '<th>Normalized</th>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<th></th>'; |
5359 |
12 Apr 19 |
nicklas |
html += '</tr>'; |
5359 |
12 Apr 19 |
nicklas |
// Second header row |
5359 |
12 Apr 19 |
nicklas |
html += '<tr>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<th></th>'; |
6726 |
04 May 22 |
nicklas |
if (showLabelColumn) |
6726 |
04 May 22 |
nicklas |
330 |
{ |
6726 |
04 May 22 |
nicklas |
html += '<th></th>'; |
6726 |
04 May 22 |
nicklas |
332 |
} |
5359 |
12 Apr 19 |
nicklas |
if (sameQiacubeRun) |
5359 |
12 Apr 19 |
nicklas |
334 |
{ |
5359 |
12 Apr 19 |
nicklas |
html += '<th>position</th>'; |
5359 |
12 Apr 19 |
nicklas |
336 |
} |
5359 |
12 Apr 19 |
nicklas |
html += '<th>box</th>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<th>(ng/µl)</th>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<th>(µg)</th>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<th>(µl)</th>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<th>H<sub>2</sub>O</th>'; |
5361 |
15 Apr 19 |
nicklas |
html += '<th>plate</th>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<th>Remarks</th>'; |
5359 |
12 Apr 19 |
nicklas |
html += '</tr>'; |
5359 |
12 Apr 19 |
nicklas |
html += '</thead>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<tbody>'; |
5359 |
12 Apr 19 |
nicklas |
347 |
|
5359 |
12 Apr 19 |
nicklas |
var expectedQiacubePosition = 0; |
5359 |
12 Apr 19 |
nicklas |
var homeUrl = Data.get('page-data', 'home-url'); |
5359 |
12 Apr 19 |
nicklas |
var yellowImg = '<img src="'+homeUrl+'/images/yellow-label.png">'; |
5359 |
12 Apr 19 |
nicklas |
for (var i=0; i < selectedDna.length; i++) |
5359 |
12 Apr 19 |
nicklas |
352 |
{ |
5359 |
12 Apr 19 |
nicklas |
var dna = selectedDna[i]; |
5359 |
12 Apr 19 |
nicklas |
var isYellow = dna.specimen && dna.specimen.YellowLabel != null; |
5359 |
12 Apr 19 |
nicklas |
if (sameQiacubeRun) |
5359 |
12 Apr 19 |
nicklas |
356 |
{ |
5359 |
12 Apr 19 |
nicklas |
expectedQiacubePosition++; |
5359 |
12 Apr 19 |
nicklas |
while (expectedQiacubePosition != dna.QiacubePosition && expectedQiacubePosition <= 12) |
5359 |
12 Apr 19 |
nicklas |
359 |
{ |
6726 |
04 May 22 |
nicklas |
html += normalize.insertEmpty(expectedQiacubePosition, showLabelColumn); |
5359 |
12 Apr 19 |
nicklas |
expectedQiacubePosition++; |
5359 |
12 Apr 19 |
nicklas |
362 |
} |
5359 |
12 Apr 19 |
nicklas |
363 |
} |
5359 |
12 Apr 19 |
nicklas |
364 |
|
5359 |
12 Apr 19 |
nicklas |
var img = isYellow ? yellowImg : ''; |
5361 |
15 Apr 19 |
nicklas |
html += '<tr class="highlight'+(isYellow ? ' yellow-specimen' : '')+'" id="dnaRow.'+dna.id+'">'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="extract if-yellow">'+img+Strings.encodeTags(dna.nextAliquotName)+'</td>'; |
6726 |
04 May 22 |
nicklas |
if (showLabelColumn) |
6726 |
04 May 22 |
nicklas |
369 |
{ |
6726 |
04 May 22 |
nicklas |
html += '<td class="label if-yellow">'+Strings.encodeTags(dna.label)+'</td>'; |
6726 |
04 May 22 |
nicklas |
371 |
} |
5359 |
12 Apr 19 |
nicklas |
if (sameQiacubeRun) |
5359 |
12 Apr 19 |
nicklas |
373 |
{ |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="qiacubepos">'+dna.QiacubePosition+'</td>'; |
5359 |
12 Apr 19 |
nicklas |
375 |
} |
6219 |
20 Apr 21 |
nicklas |
html += '<td class="box">'+(dna.bioWell?Strings.encodeTags(dna.bioWell.bioPlate.name + ' ' + dna.bioWell.location):'unknown')+'</td>'; |
6219 |
20 Apr 21 |
nicklas |
html += '<td class="conc">'+ Numbers.formatNumber(dna.conc, 1) + '</td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="remain">'+ Numbers.formatNumber(dna.remainingQuantity, 2) + '</td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="volume" id="dnaVolume.'+dna.id+'"></td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="water" id="dnaWater.'+dna.id+'"></td>'; |
5361 |
15 Apr 19 |
nicklas |
html += '<td class="plate" id="dnaLocation.'+dna.id+'"></td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="remarks" id="remarks.'+dna.id+'"></td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '</tr>' |
5359 |
12 Apr 19 |
nicklas |
384 |
} |
5359 |
12 Apr 19 |
nicklas |
if (sameQiacubeRun) |
5359 |
12 Apr 19 |
nicklas |
386 |
{ |
5359 |
12 Apr 19 |
nicklas |
expectedQiacubePosition++; |
5359 |
12 Apr 19 |
nicklas |
while (expectedQiacubePosition <= 12) |
5359 |
12 Apr 19 |
nicklas |
389 |
{ |
6726 |
04 May 22 |
nicklas |
html += normalize.insertEmpty(expectedQiacubePosition, showLabelColumn); |
5359 |
12 Apr 19 |
nicklas |
expectedQiacubePosition++; |
5359 |
12 Apr 19 |
nicklas |
392 |
} |
5359 |
12 Apr 19 |
nicklas |
393 |
} |
5359 |
12 Apr 19 |
nicklas |
html += '</tbody>'; |
5359 |
12 Apr 19 |
nicklas |
html += '</table>'; |
6726 |
04 May 22 |
nicklas |
if (showLabelColumn) |
6726 |
04 May 22 |
nicklas |
397 |
{ |
6726 |
04 May 22 |
nicklas |
html += '<div id="protocol-footer">'; |
6726 |
04 May 22 |
nicklas |
html += '¹ Some SCAN-B tubes have a non-standard label.'; |
6726 |
04 May 22 |
nicklas |
html += '</div>'; |
6726 |
04 May 22 |
nicklas |
401 |
} |
5359 |
12 Apr 19 |
nicklas |
402 |
|
5359 |
12 Apr 19 |
nicklas |
Doc.element('dnaNormalize').innerHTML = html; |
5361 |
15 Apr 19 |
nicklas |
404 |
} |
5361 |
15 Apr 19 |
nicklas |
405 |
|
5361 |
15 Apr 19 |
nicklas |
normalize.normalizedPlateOnChange = function() |
5361 |
15 Apr 19 |
nicklas |
407 |
{ |
5361 |
15 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5361 |
15 Apr 19 |
nicklas |
Doc.element('normalized-plate-name').innerHTML = Strings.encodeTags(frm.normalizedPlate[frm.normalizedPlate.selectedIndex].text); |
5359 |
12 Apr 19 |
nicklas |
410 |
|
5361 |
15 Apr 19 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Print the lab protocol before continuing with the registration!'); |
5361 |
15 Apr 19 |
nicklas |
412 |
|
5361 |
15 Apr 19 |
nicklas |
var plate = frm.normalizedPlate[frm.normalizedPlate.selectedIndex].plate; |
5361 |
15 Apr 19 |
nicklas |
var wells = plate.bioWells; |
5361 |
15 Apr 19 |
nicklas |
415 |
|
5361 |
15 Apr 19 |
nicklas |
var wellNo = 0; |
5361 |
15 Apr 19 |
nicklas |
for (var i=0; i < selectedDna.length; i++) |
5361 |
15 Apr 19 |
nicklas |
418 |
{ |
5361 |
15 Apr 19 |
nicklas |
var dna = selectedDna[i]; |
5361 |
15 Apr 19 |
nicklas |
if (!dna.notEnoughQuantity) |
5361 |
15 Apr 19 |
nicklas |
421 |
{ |
5361 |
15 Apr 19 |
nicklas |
while (!wells[wellNo].canAdd) wellNo++; |
5361 |
15 Apr 19 |
nicklas |
Doc.element('dnaLocation.'+dna.id).innerHTML = wells[wellNo].location; |
5361 |
15 Apr 19 |
nicklas |
dna.well = wells[wellNo]; |
5361 |
15 Apr 19 |
nicklas |
wellNo++; |
5361 |
15 Apr 19 |
nicklas |
426 |
} |
5361 |
15 Apr 19 |
nicklas |
else |
5361 |
15 Apr 19 |
nicklas |
428 |
{ |
5361 |
15 Apr 19 |
nicklas |
Doc.element('dnaLocation.'+dna.id).innerHTML = ''; |
5361 |
15 Apr 19 |
nicklas |
dna.well = null; |
5361 |
15 Apr 19 |
nicklas |
431 |
} |
5361 |
15 Apr 19 |
nicklas |
432 |
} |
5359 |
12 Apr 19 |
nicklas |
433 |
} |
5359 |
12 Apr 19 |
nicklas |
434 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.protocolOnChange = function() |
5359 |
12 Apr 19 |
nicklas |
436 |
{ |
5359 |
12 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5359 |
12 Apr 19 |
nicklas |
438 |
|
5359 |
12 Apr 19 |
nicklas |
if (!hasInitProtocols) |
5359 |
12 Apr 19 |
nicklas |
440 |
{ |
5359 |
12 Apr 19 |
nicklas |
hasInitProtocols = true; |
5359 |
12 Apr 19 |
nicklas |
if (frm.normalizationProtocol.length == 0) |
5359 |
12 Apr 19 |
nicklas |
443 |
{ |
5359 |
12 Apr 19 |
nicklas |
Wizard.setFatalError('No DNA normalization protocols found. Please ask the server administrator to create at least one protocol.'); |
5359 |
12 Apr 19 |
nicklas |
return; |
5359 |
12 Apr 19 |
nicklas |
446 |
} |
5359 |
12 Apr 19 |
nicklas |
for (var i=0; i < frm.normalizationProtocol.length; i++) |
5359 |
12 Apr 19 |
nicklas |
448 |
{ |
5359 |
12 Apr 19 |
nicklas |
var p = frm.normalizationProtocol[i].item; |
5359 |
12 Apr 19 |
nicklas |
450 |
|
5359 |
12 Apr 19 |
nicklas |
var unit = 'µg'; |
5359 |
12 Apr 19 |
nicklas |
var factor = 1; |
5359 |
12 Apr 19 |
nicklas |
if (p.DNATargetAmount <= 0.5) |
5359 |
12 Apr 19 |
nicklas |
454 |
{ |
5359 |
12 Apr 19 |
nicklas |
unit = 'ng'; |
5359 |
12 Apr 19 |
nicklas |
factor = 1000; |
5359 |
12 Apr 19 |
nicklas |
457 |
} |
5359 |
12 Apr 19 |
nicklas |
458 |
|
5359 |
12 Apr 19 |
nicklas |
var text = p.name + ' ('; |
5602 |
13 Sep 19 |
nicklas |
text += (p.MIPS_Panel ? Strings.encodeTags(p.MIPS_Panel) : 'NO MIPS_Panel!') + '; '; |
5359 |
12 Apr 19 |
nicklas |
if (p.DNAMinimalAmount) text += Reggie.formatNumber(p.DNAMinimalAmount * factor, '', 1) + '-'; |
5359 |
12 Apr 19 |
nicklas |
text += p.DNATargetAmount ? Reggie.formatNumber(p.DNATargetAmount * factor, '', 1) : '? '; |
5359 |
12 Apr 19 |
nicklas |
text += unit; |
5359 |
12 Apr 19 |
nicklas |
text += ' in '+(p.DNATargetVolume || '? ')+'µl)'; |
5359 |
12 Apr 19 |
nicklas |
frm.normalizationProtocol[i].text = text; |
5359 |
12 Apr 19 |
nicklas |
466 |
} |
5359 |
12 Apr 19 |
nicklas |
467 |
} |
5359 |
12 Apr 19 |
nicklas |
468 |
|
5449 |
27 May 19 |
nicklas |
Wizard.setInputStatus('normalizationProtocol'); |
5449 |
27 May 19 |
nicklas |
protocolIsValid = true; |
5359 |
12 Apr 19 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Print the lab protocol before continuing with the registration!'); |
5359 |
12 Apr 19 |
nicklas |
472 |
|
5359 |
12 Apr 19 |
nicklas |
var protocol = frm.normalizationProtocol[frm.normalizationProtocol.selectedIndex].item; |
5602 |
13 Sep 19 |
nicklas |
if (!protocol.MIPS_Panel) |
5359 |
12 Apr 19 |
nicklas |
475 |
{ |
5602 |
13 Sep 19 |
nicklas |
Wizard.setInputStatus('normalizationProtocol', 'invalid', 'No MIPS_Panel!'); |
5449 |
27 May 19 |
nicklas |
protocolIsValid = false; |
5449 |
27 May 19 |
nicklas |
478 |
} |
5449 |
27 May 19 |
nicklas |
if (!protocol.DNATargetAmount || !protocol.DNATargetVolume) |
5449 |
27 May 19 |
nicklas |
480 |
{ |
5359 |
12 Apr 19 |
nicklas |
protocol = {}; |
5449 |
27 May 19 |
nicklas |
protocol.DNATargetAmount = 0.5; |
5449 |
27 May 19 |
nicklas |
protocol.DNATargetVolume = 10; |
5449 |
27 May 19 |
nicklas |
protocolIsValid = true; |
5359 |
12 Apr 19 |
nicklas |
485 |
|
5449 |
27 May 19 |
nicklas |
if (protocolIsValid) |
5449 |
27 May 19 |
nicklas |
487 |
{ |
5449 |
27 May 19 |
nicklas |
var msg = 'Missing normalization data; assuming '; |
5449 |
27 May 19 |
nicklas |
msg += protocol.DNATargetAmount+ 'µg in '+protocol.DNATargetVolume+'µl.'; |
5449 |
27 May 19 |
nicklas |
Wizard.setInputStatus('normalizationProtocol', 'warning', msg); |
5449 |
27 May 19 |
nicklas |
491 |
} |
5359 |
12 Apr 19 |
nicklas |
492 |
} |
5449 |
27 May 19 |
nicklas |
else if (protocolIsValid) |
5359 |
12 Apr 19 |
nicklas |
494 |
{ |
5359 |
12 Apr 19 |
nicklas |
Wizard.setInputStatus('normalizationProtocol', 'valid'); |
5359 |
12 Apr 19 |
nicklas |
496 |
} |
5359 |
12 Apr 19 |
nicklas |
if (!protocol.DNAMinimalAmount) protocol.DNAMinimalAmount = protocol.DNATargetAmount; |
5359 |
12 Apr 19 |
nicklas |
Doc.element('normalization-protocol').innerHTML = Strings.encodeTags(frm.normalizationProtocol[frm.normalizationProtocol.selectedIndex].text); |
5359 |
12 Apr 19 |
nicklas |
499 |
|
5359 |
12 Apr 19 |
nicklas |
// The concentration of the normalized DNA |
5359 |
12 Apr 19 |
nicklas |
var normalizedConc = protocol.DNATargetAmount / protocol.DNATargetVolume; // µg/µl |
5359 |
12 Apr 19 |
nicklas |
502 |
|
5359 |
12 Apr 19 |
nicklas |
for (var i=0; i < selectedDna.length; i++) |
5359 |
12 Apr 19 |
nicklas |
504 |
{ |
5359 |
12 Apr 19 |
nicklas |
var dna = selectedDna[i]; |
5359 |
12 Apr 19 |
nicklas |
506 |
|
5359 |
12 Apr 19 |
nicklas |
// Aim for DNATargetAmount but not more than remiaingQuantity or less than DNAMinimalAmount |
5359 |
12 Apr 19 |
nicklas |
dna.usedQuantity = Math.max(Math.min(dna.remainingQuantity, protocol.DNATargetAmount), protocol.DNAMinimalAmount); // µg |
6219 |
20 Apr 21 |
nicklas |
dna.volume = Math.ceil(10000*dna.usedQuantity/dna.conc) / 10; |
5359 |
12 Apr 19 |
nicklas |
dna.water = protocol.DNATargetVolume-dna.volume; // µl |
5359 |
12 Apr 19 |
nicklas |
511 |
|
5359 |
12 Apr 19 |
nicklas |
var remarks = []; |
5359 |
12 Apr 19 |
nicklas |
if (dna.volume < MINIMAL_DNA_VOLUME) |
5359 |
12 Apr 19 |
nicklas |
514 |
{ |
5359 |
12 Apr 19 |
nicklas |
// Large mix since we do not want to take less than 1µl |
5359 |
12 Apr 19 |
nicklas |
dna.volume = MINIMAL_DNA_VOLUME; |
6219 |
20 Apr 21 |
nicklas |
dna.usedQuantity = dna.volume * dna.conc / 1000; // µg |
5359 |
12 Apr 19 |
nicklas |
var totalVolume = dna.usedQuantity / normalizedConc; // µl |
5359 |
12 Apr 19 |
nicklas |
dna.water = totalVolume - dna.volume; |
5359 |
12 Apr 19 |
nicklas |
remarks[remarks.length] = 'Large mix'; |
5359 |
12 Apr 19 |
nicklas |
521 |
} |
5359 |
12 Apr 19 |
nicklas |
else if (dna.volume > protocol.DNATargetVolume) |
5359 |
12 Apr 19 |
nicklas |
523 |
{ |
5359 |
12 Apr 19 |
nicklas |
// The DNA has too low concentration so we can't reach the target amount |
5359 |
12 Apr 19 |
nicklas |
// with the target volume. The protocol may allow us to use a lesser amount |
5359 |
12 Apr 19 |
nicklas |
// so we try this |
5359 |
12 Apr 19 |
nicklas |
dna.volume = protocol.DNATargetVolume; |
5359 |
12 Apr 19 |
nicklas |
dna.water = 0; |
6219 |
20 Apr 21 |
nicklas |
dna.usedQuantity = dna.volume * dna.conc / 1000; |
5359 |
12 Apr 19 |
nicklas |
530 |
} |
5359 |
12 Apr 19 |
nicklas |
531 |
|
5359 |
12 Apr 19 |
nicklas |
dna.notEnoughQuantity = dna.remainingQuantity < dna.usedQuantity || dna.usedQuantity < protocol.DNAMinimalAmount; |
5359 |
12 Apr 19 |
nicklas |
if (dna.notEnoughQuantity) |
5359 |
12 Apr 19 |
nicklas |
534 |
{ |
5359 |
12 Apr 19 |
nicklas |
remarks[remarks.length] = '<span class="flag">Not enough quantity</span>'; |
5359 |
12 Apr 19 |
nicklas |
536 |
} |
5359 |
12 Apr 19 |
nicklas |
else if (dna.usedQuantity < protocol.DNATargetAmount) |
5359 |
12 Apr 19 |
nicklas |
538 |
{ |
5359 |
12 Apr 19 |
nicklas |
remarks[remarks.length] = Numbers.formatNumber(dna.usedQuantity * 1000, 0) + 'ng'; |
5359 |
12 Apr 19 |
nicklas |
540 |
} |
5359 |
12 Apr 19 |
nicklas |
541 |
|
5359 |
12 Apr 19 |
nicklas |
Doc.element('dnaVolume.'+dna.id).innerHTML = dna.notEnoughQuantity ? '' : Numbers.formatNumber(dna.volume, 1); |
5359 |
12 Apr 19 |
nicklas |
Doc.element('dnaWater.'+dna.id).innerHTML = dna.notEnoughQuantity ? '' : (dna.water > 0 ? Numbers.formatNumber(dna.water, 1) : '—'); |
5359 |
12 Apr 19 |
nicklas |
Doc.element('remarks.'+dna.id).innerHTML = remarks.join(', '); |
5361 |
15 Apr 19 |
nicklas |
Doc.addOrRemoveClass('dnaRow.'+dna.id, 'not-enough-quantity', dna.notEnoughQuantity); |
5359 |
12 Apr 19 |
nicklas |
546 |
} |
5361 |
15 Apr 19 |
nicklas |
normalize.normalizedPlateOnChange(); |
5359 |
12 Apr 19 |
nicklas |
548 |
} |
5359 |
12 Apr 19 |
nicklas |
549 |
|
6726 |
04 May 22 |
nicklas |
normalize.insertEmpty = function(qiacubePosition, showLabelColumn) |
5359 |
12 Apr 19 |
nicklas |
551 |
{ |
5359 |
12 Apr 19 |
nicklas |
var html = '<tr class="highlight empty">'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="extract"></td>'; |
6726 |
04 May 22 |
nicklas |
if (showLabelColumn) html += '<td class="label"></td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="qiacubepos">'+qiacubePosition+'</td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="box"></td>'; |
6219 |
20 Apr 21 |
nicklas |
html += '<td class="conc"></td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="remain"></td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="volume"></td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="water"></td>'; |
5361 |
15 Apr 19 |
nicklas |
html += '<td class="plate"></td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '<td class="remarks">Not selected for pre-normalization</td>'; |
5359 |
12 Apr 19 |
nicklas |
html += '</tr>' |
5359 |
12 Apr 19 |
nicklas |
return html; |
5359 |
12 Apr 19 |
nicklas |
565 |
} |
5359 |
12 Apr 19 |
nicklas |
566 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.printVersion = function() |
5359 |
12 Apr 19 |
nicklas |
568 |
{ |
5359 |
12 Apr 19 |
nicklas |
Wizard.hideGoNextConfirmation(); |
5359 |
12 Apr 19 |
nicklas |
Doc.removeClass('gonext', 'disabled'); |
5359 |
12 Apr 19 |
nicklas |
var reportName = 'DNA Normalization Protocol'; |
5359 |
12 Apr 19 |
nicklas |
var printNote = '<b>Note!</b> For better printing set page orientation to <i>portrait</i>.'; |
5359 |
12 Apr 19 |
nicklas |
Reggie.openPrintWindow('full-protocol', reportName, 'portrait', printNote, '../', 'normalize_extract.css'); |
5359 |
12 Apr 19 |
nicklas |
574 |
} |
5359 |
12 Apr 19 |
nicklas |
575 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.validateStep2 = function(event) |
5449 |
27 May 19 |
nicklas |
577 |
{ |
5449 |
27 May 19 |
nicklas |
var valid = protocolIsValid; |
5449 |
27 May 19 |
nicklas |
if (!valid) event.preventDefault(); |
5449 |
27 May 19 |
nicklas |
580 |
} |
5359 |
12 Apr 19 |
nicklas |
581 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.initializeStep3 = function() |
5359 |
12 Apr 19 |
nicklas |
583 |
{ |
5359 |
12 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5359 |
12 Apr 19 |
nicklas |
Wizard.setCurrentStep(3); |
5359 |
12 Apr 19 |
nicklas |
Doc.show('goregister'); |
5359 |
12 Apr 19 |
nicklas |
Doc.show('gocancel'); |
5359 |
12 Apr 19 |
nicklas |
Events.sendChangeEvent('normalizationDate'); |
5359 |
12 Apr 19 |
nicklas |
frm.normalizationDate.focus(); |
5359 |
12 Apr 19 |
nicklas |
590 |
} |
5359 |
12 Apr 19 |
nicklas |
591 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.submit = function() |
5359 |
12 Apr 19 |
nicklas |
593 |
{ |
5359 |
12 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5359 |
12 Apr 19 |
nicklas |
595 |
|
5359 |
12 Apr 19 |
nicklas |
var submitInfo = {}; |
5359 |
12 Apr 19 |
nicklas |
submitInfo.normalizationProtocol = parseInt(frm.normalizationProtocol.value, 10); |
5359 |
12 Apr 19 |
nicklas |
submitInfo.normalizationDate = frm.normalizationDate.value; |
5359 |
12 Apr 19 |
nicklas |
submitInfo.normalizationOperator = frm.normalizationOperator.value; |
5361 |
15 Apr 19 |
nicklas |
submitInfo.normalizedPlate = parseInt(frm.normalizedPlate.value, 10); |
5359 |
12 Apr 19 |
nicklas |
601 |
|
5359 |
12 Apr 19 |
nicklas |
var dnaAliquots = []; |
5359 |
12 Apr 19 |
nicklas |
for (var i=0; i < selectedDna.length; i++) |
5359 |
12 Apr 19 |
nicklas |
604 |
{ |
5359 |
12 Apr 19 |
nicklas |
var dna = selectedDna[i]; |
5359 |
12 Apr 19 |
nicklas |
if (!dna.notEnoughQuantity) |
5359 |
12 Apr 19 |
nicklas |
607 |
{ |
5359 |
12 Apr 19 |
nicklas |
var normalizedDna = {}; |
5359 |
12 Apr 19 |
nicklas |
normalizedDna.parentId = dna.id; |
5359 |
12 Apr 19 |
nicklas |
normalizedDna.name = dna.nextAliquotName; |
5359 |
12 Apr 19 |
nicklas |
611 |
|
5359 |
12 Apr 19 |
nicklas |
normalizedDna.usedQuantity = dna.usedQuantity; // µg |
6219 |
20 Apr 21 |
nicklas |
normalizedDna.conc = 1000 * dna.usedQuantity / (dna.volume+dna.water); // ng/µl |
6219 |
20 Apr 21 |
nicklas |
normalizedDna.ConcType = dna.NDConc ? 'ND_CONC' : 'QUBIT_CONC'; |
5359 |
12 Apr 19 |
nicklas |
615 |
|
5361 |
15 Apr 19 |
nicklas |
normalizedDna.row = dna.well.row; |
5361 |
15 Apr 19 |
nicklas |
normalizedDna.column = dna.well.column; |
5361 |
15 Apr 19 |
nicklas |
618 |
|
5359 |
12 Apr 19 |
nicklas |
dnaAliquots[dnaAliquots.length] = normalizedDna; |
5359 |
12 Apr 19 |
nicklas |
620 |
} |
5359 |
12 Apr 19 |
nicklas |
else |
5359 |
12 Apr 19 |
nicklas |
622 |
{ |
5359 |
12 Apr 19 |
nicklas |
var flaggedDna = {}; |
5359 |
12 Apr 19 |
nicklas |
flaggedDna.id = dna.id; |
5359 |
12 Apr 19 |
nicklas |
flaggedDna.flag = 'NotEnoughRemainingQuantity'; |
5359 |
12 Apr 19 |
nicklas |
dnaAliquots[dnaAliquots.length] = flaggedDna; |
5359 |
12 Apr 19 |
nicklas |
627 |
} |
5359 |
12 Apr 19 |
nicklas |
628 |
} |
5359 |
12 Apr 19 |
nicklas |
629 |
|
5359 |
12 Apr 19 |
nicklas |
submitInfo.dnaAliquots = dnaAliquots; |
5359 |
12 Apr 19 |
nicklas |
631 |
|
5359 |
12 Apr 19 |
nicklas |
var url = '../Extraction.servlet?ID='+App.getSessionId(); |
5359 |
12 Apr 19 |
nicklas |
url += '&cmd=RegisterNormalizedDNA'; |
5359 |
12 Apr 19 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
5359 |
12 Apr 19 |
nicklas |
Wizard.asyncJsonRequest(url, normalize.submissionResults, 'POST', JSON.stringify(submitInfo)); |
5359 |
12 Apr 19 |
nicklas |
636 |
} |
5359 |
12 Apr 19 |
nicklas |
637 |
|
5359 |
12 Apr 19 |
nicklas |
normalize.submissionResults = function(response) |
5359 |
12 Apr 19 |
nicklas |
639 |
{ |
5359 |
12 Apr 19 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5359 |
12 Apr 19 |
nicklas |
Doc.show('gorestart'); |
5359 |
12 Apr 19 |
nicklas |
642 |
} |
5359 |
12 Apr 19 |
nicklas |
643 |
|
5359 |
12 Apr 19 |
nicklas |
return normalize; |
5359 |
12 Apr 19 |
nicklas |
645 |
}(); |
5359 |
12 Apr 19 |
nicklas |
646 |
|
5359 |
12 Apr 19 |
nicklas |
Doc.onLoad(DnaNormalize.initPage); |
5359 |
12 Apr 19 |
nicklas |
648 |
|