2805 |
15 Oct 14 |
nicklas |
var CreatePool = function() |
2805 |
15 Oct 14 |
nicklas |
2 |
{ |
2805 |
15 Oct 14 |
nicklas |
var createpool = {}; |
2805 |
15 Oct 14 |
nicklas |
var debug = 0; |
2805 |
15 Oct 14 |
nicklas |
5 |
|
2805 |
15 Oct 14 |
nicklas |
var subtypeLibrary; |
5436 |
17 May 19 |
nicklas |
var annotationTypePipeline; |
5436 |
17 May 19 |
nicklas |
8 |
|
2805 |
15 Oct 14 |
nicklas |
var selectedLibraries = []; |
2805 |
15 Oct 14 |
nicklas |
var newLibraries; |
2805 |
15 Oct 14 |
nicklas |
11 |
|
2805 |
15 Oct 14 |
nicklas |
var LIMIT_FOR_AUTO_EXCLUDE = 0.25; |
2805 |
15 Oct 14 |
nicklas |
var LIMIT_FOR_EXTRA_LARGE_MIX; |
2805 |
15 Oct 14 |
nicklas |
var MAX_TARGET_VOLUME = 20; |
2805 |
15 Oct 14 |
nicklas |
var MIN_TARGET_VOLUME = 2; |
2805 |
15 Oct 14 |
nicklas |
var LIBRARY_FRAC_ADPT_LIMIT = 10; // percent |
2805 |
15 Oct 14 |
nicklas |
17 |
|
2805 |
15 Oct 14 |
nicklas |
var targetVolumePerLibIsValid = true; |
2805 |
15 Oct 14 |
nicklas |
var lastTargetVolume = null; |
2805 |
15 Oct 14 |
nicklas |
var lastComment = ''; |
2805 |
15 Oct 14 |
nicklas |
21 |
|
2805 |
15 Oct 14 |
nicklas |
// Page initialization |
2805 |
15 Oct 14 |
nicklas |
createpool.initPage = function() |
2805 |
15 Oct 14 |
nicklas |
24 |
{ |
2805 |
15 Oct 14 |
nicklas |
// Step 1 |
2805 |
15 Oct 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', createpool.validateStep1); |
3107 |
27 Jan 15 |
nicklas |
Events.addEventHandler('target_molarity', 'change', createpool.updatePoolData); |
2805 |
15 Oct 14 |
nicklas |
Events.addEventHandler('target_volume', 'change', createpool.targetVolumeOnChange); |
2805 |
15 Oct 14 |
nicklas |
Events.doOnEnter('target_volume', createpool.targetVolumeOnChange); |
2805 |
15 Oct 14 |
nicklas |
Events.addEventHandler('target_volume', 'keypress', Events.numberOnly); |
2805 |
15 Oct 14 |
nicklas |
31 |
|
2805 |
15 Oct 14 |
nicklas |
Events.addEventHandler('mixing_strategy_dynamic', 'change', createpool.updatePoolData); |
2805 |
15 Oct 14 |
nicklas |
Events.addEventHandler('mixing_strategy_fixed', 'change', createpool.updatePoolData); |
2805 |
15 Oct 14 |
nicklas |
34 |
|
2805 |
15 Oct 14 |
nicklas |
Buttons.addClickHandler('btnSelectLibraries', createpool.selectLibraries); |
2805 |
15 Oct 14 |
nicklas |
Events.addEventHandler('lib-table', 'base-selected', createpool.librarySelected); |
2805 |
15 Oct 14 |
nicklas |
Buttons.addClickHandler('btnRemove', createpool.removeSelected); |
2805 |
15 Oct 14 |
nicklas |
Buttons.addClickHandler('btnTargetVolume', createpool.setTargetVolume); |
2805 |
15 Oct 14 |
nicklas |
Buttons.addClickHandler('btnComment', createpool.commentChecked); |
2805 |
15 Oct 14 |
nicklas |
40 |
|
2805 |
15 Oct 14 |
nicklas |
Events.addEventHandler('checkAll', 'click', createpool.checkAll); |
2805 |
15 Oct 14 |
nicklas |
42 |
|
2805 |
15 Oct 14 |
nicklas |
// Navigation |
2805 |
15 Oct 14 |
nicklas |
Buttons.addClickHandler('gocancel', createpool.cancelWizard); |
2805 |
15 Oct 14 |
nicklas |
Buttons.addClickHandler('gorestart', createpool.cancelWizard); |
2805 |
15 Oct 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2805 |
15 Oct 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2805 |
15 Oct 14 |
nicklas |
48 |
|
2805 |
15 Oct 14 |
nicklas |
// Final registration |
2805 |
15 Oct 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', createpool.submit); |
2805 |
15 Oct 14 |
nicklas |
51 |
|
2805 |
15 Oct 14 |
nicklas |
var url = '../Pool.servlet?ID='+App.getSessionId(); |
2805 |
15 Oct 14 |
nicklas |
url += '&cmd=GetNextAutoGeneratedPoolNames&numNames=1'; |
2805 |
15 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading pool information...'); |
2805 |
15 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, createpool.poolInfoLoaded); |
2805 |
15 Oct 14 |
nicklas |
56 |
} |
2805 |
15 Oct 14 |
nicklas |
57 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.poolInfoLoaded = function(response) |
2805 |
15 Oct 14 |
nicklas |
59 |
{ |
2805 |
15 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2805 |
15 Oct 14 |
nicklas |
61 |
|
2805 |
15 Oct 14 |
nicklas |
// Load some default pooling options and the auto-generated name for the next pool |
2805 |
15 Oct 14 |
nicklas |
var poolInfo = response.poolInfo; |
2805 |
15 Oct 14 |
nicklas |
LIMIT_FOR_EXTRA_LARGE_MIX = poolInfo.limitForExtraLargeMix; |
2805 |
15 Oct 14 |
nicklas |
Doc.element('pool-name').innerHTML = Strings.encodeTags(response.names[0]); |
2805 |
15 Oct 14 |
nicklas |
66 |
|
2805 |
15 Oct 14 |
nicklas |
frm.target_volume.value = poolInfo.targetVolumePerLib; |
2805 |
15 Oct 14 |
nicklas |
frm.poolName.value = response.names[0]; |
2805 |
15 Oct 14 |
nicklas |
69 |
|
2805 |
15 Oct 14 |
nicklas |
Doc.show('step-1'); |
2805 |
15 Oct 14 |
nicklas |
Doc.show('gocancel'); |
2805 |
15 Oct 14 |
nicklas |
Doc.show('goregister'); |
2805 |
15 Oct 14 |
nicklas |
Wizard.setNoConfirmOnFirstStep(false); |
2805 |
15 Oct 14 |
nicklas |
74 |
} |
2805 |
15 Oct 14 |
nicklas |
75 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.cancelWizard = function() |
2805 |
15 Oct 14 |
nicklas |
77 |
{ |
2805 |
15 Oct 14 |
nicklas |
location.href = 'create_pools.jsp?ID='+App.getSessionId(); |
2805 |
15 Oct 14 |
nicklas |
79 |
} |
2805 |
15 Oct 14 |
nicklas |
80 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.selectLibraries = function() |
2805 |
15 Oct 14 |
nicklas |
82 |
{ |
2805 |
15 Oct 14 |
nicklas |
if (subtypeLibrary == null) subtypeLibrary = Reggie.getSubtypeInfo('LIBRARY'); |
5436 |
17 May 19 |
nicklas |
if (annotationTypePipeline == null) annotationTypePipeline = Reggie.getAnnotationTypeInfo('PIPELINE'); |
2805 |
15 Oct 14 |
nicklas |
85 |
|
2805 |
15 Oct 14 |
nicklas |
var url = '&resetTemporary=1'; |
2805 |
15 Oct 14 |
nicklas |
url += '&tmpfilter:INT:itemSubtype='+subtypeLibrary.id; |
2805 |
15 Oct 14 |
nicklas |
url += '&tmpfilter:DATE:creationEvent.eventDate='+encodeURIComponent('<>'); |
2805 |
15 Oct 14 |
nicklas |
url += '&tmpfilter:STRING:bioWell.bioPlate.name='+encodeURIComponent('<>');; |
5436 |
17 May 19 |
nicklas |
url += '&tmpfilter:STRING:'+encodeURIComponent('#')+annotationTypePipeline.id+'=RNAseq'; |
2805 |
15 Oct 14 |
nicklas |
91 |
|
2805 |
15 Oct 14 |
nicklas |
var exclude = []; |
2805 |
15 Oct 14 |
nicklas |
for (var libNo = 0; libNo < selectedLibraries.length; libNo++) |
2805 |
15 Oct 14 |
nicklas |
94 |
{ |
2805 |
15 Oct 14 |
nicklas |
exclude[exclude.length] = selectedLibraries[libNo].id; |
2805 |
15 Oct 14 |
nicklas |
96 |
} |
2805 |
15 Oct 14 |
nicklas |
if (exclude.length > 0) url += '&exclude='+exclude.join(','); |
2805 |
15 Oct 14 |
nicklas |
98 |
|
2805 |
15 Oct 14 |
nicklas |
newLibraries = []; |
2805 |
15 Oct 14 |
nicklas |
Dialogs.selectItem('EXTRACT', 'lib-table', 1, url); |
2805 |
15 Oct 14 |
nicklas |
101 |
} |
2805 |
15 Oct 14 |
nicklas |
102 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.librarySelected = function(event) |
2805 |
15 Oct 14 |
nicklas |
104 |
{ |
2805 |
15 Oct 14 |
nicklas |
var id = event.detail.id; |
2805 |
15 Oct 14 |
nicklas |
106 |
|
2805 |
15 Oct 14 |
nicklas |
// Check if this library has already been selected |
2805 |
15 Oct 14 |
nicklas |
var isNew = true; |
2805 |
15 Oct 14 |
nicklas |
for (var i = 0; i < selectedLibraries.length; i++) |
2805 |
15 Oct 14 |
nicklas |
110 |
{ |
2805 |
15 Oct 14 |
nicklas |
if (selectedLibraries[i].id == id) |
2805 |
15 Oct 14 |
nicklas |
112 |
{ |
2805 |
15 Oct 14 |
nicklas |
isNew = false; |
2805 |
15 Oct 14 |
nicklas |
break; |
2805 |
15 Oct 14 |
nicklas |
115 |
} |
2805 |
15 Oct 14 |
nicklas |
116 |
} |
2805 |
15 Oct 14 |
nicklas |
if (isNew) newLibraries[newLibraries.length] = id; |
2805 |
15 Oct 14 |
nicklas |
118 |
|
2808 |
15 Oct 14 |
nicklas |
if (event.detail.remaining == 0 && newLibraries.length > 0) |
2805 |
15 Oct 14 |
nicklas |
120 |
{ |
2805 |
15 Oct 14 |
nicklas |
// Get more information about the selected library |
2805 |
15 Oct 14 |
nicklas |
var url = '../Pool.servlet?ID='+App.getSessionId(); |
2805 |
15 Oct 14 |
nicklas |
url += '&cmd=GetLibraryInfo&libraries=' + newLibraries.join(','); |
2805 |
15 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, createpool.libraryInfoLoaded); |
2805 |
15 Oct 14 |
nicklas |
125 |
} |
2805 |
15 Oct 14 |
nicklas |
126 |
} |
2805 |
15 Oct 14 |
nicklas |
127 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.removeSelected = function() |
2805 |
15 Oct 14 |
nicklas |
129 |
{ |
2805 |
15 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2805 |
15 Oct 14 |
nicklas |
var tbody = Doc.element('lib-table-rows'); |
2805 |
15 Oct 14 |
nicklas |
var numRemoved = 0; |
2805 |
15 Oct 14 |
nicklas |
for (var libNo = selectedLibraries.length-1; libNo >= 0; libNo--) |
2805 |
15 Oct 14 |
nicklas |
134 |
{ |
2805 |
15 Oct 14 |
nicklas |
var lib = selectedLibraries[libNo]; |
2805 |
15 Oct 14 |
nicklas |
if (frm['check.'+lib.id].checked) |
2805 |
15 Oct 14 |
nicklas |
137 |
{ |
2805 |
15 Oct 14 |
nicklas |
var tr = document.getElementById('lib.'+lib.id); |
2805 |
15 Oct 14 |
nicklas |
tbody.removeChild(tr); |
2805 |
15 Oct 14 |
nicklas |
selectedLibraries.splice(libNo, 1); |
2805 |
15 Oct 14 |
nicklas |
numRemoved++; |
2805 |
15 Oct 14 |
nicklas |
142 |
} |
2805 |
15 Oct 14 |
nicklas |
143 |
} |
2805 |
15 Oct 14 |
nicklas |
144 |
|
2805 |
15 Oct 14 |
nicklas |
if (numRemoved > 0) |
2805 |
15 Oct 14 |
nicklas |
146 |
{ |
2805 |
15 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2805 |
15 Oct 14 |
nicklas |
148 |
} |
2805 |
15 Oct 14 |
nicklas |
149 |
|
2805 |
15 Oct 14 |
nicklas |
if (selectedLibraries.length == 0) |
2805 |
15 Oct 14 |
nicklas |
151 |
{ |
2805 |
15 Oct 14 |
nicklas |
Doc.show('not-selected'); |
2805 |
15 Oct 14 |
nicklas |
Doc.hide('lib-table'); |
2805 |
15 Oct 14 |
nicklas |
154 |
} |
2805 |
15 Oct 14 |
nicklas |
155 |
} |
2805 |
15 Oct 14 |
nicklas |
156 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.checkAll = function() |
2805 |
15 Oct 14 |
nicklas |
158 |
{ |
2805 |
15 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2805 |
15 Oct 14 |
nicklas |
var check = null; |
2805 |
15 Oct 14 |
nicklas |
for (var i = 0; i < frm.elements.length; i++) |
2805 |
15 Oct 14 |
nicklas |
162 |
{ |
2805 |
15 Oct 14 |
nicklas |
var e = frm.elements[i]; |
2805 |
15 Oct 14 |
nicklas |
if (e.type == 'checkbox') |
2805 |
15 Oct 14 |
nicklas |
165 |
{ |
2805 |
15 Oct 14 |
nicklas |
if (check == null) check = !e.checked; |
2805 |
15 Oct 14 |
nicklas |
e.checked = check; |
2805 |
15 Oct 14 |
nicklas |
168 |
} |
2805 |
15 Oct 14 |
nicklas |
169 |
} |
2805 |
15 Oct 14 |
nicklas |
170 |
} |
2805 |
15 Oct 14 |
nicklas |
171 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.libraryInfoLoaded = function(response) |
2805 |
15 Oct 14 |
nicklas |
173 |
{ |
2805 |
15 Oct 14 |
nicklas |
var libraries = response.libraries; |
2805 |
15 Oct 14 |
nicklas |
for (var libNo = 0; libNo < libraries.length; libNo++) |
2805 |
15 Oct 14 |
nicklas |
176 |
{ |
2805 |
15 Oct 14 |
nicklas |
var lib = libraries[libNo]; |
2805 |
15 Oct 14 |
nicklas |
selectedLibraries[selectedLibraries.length] = lib; |
5436 |
17 May 19 |
nicklas |
if (lib.pipeline == 'RNAseq') |
5436 |
17 May 19 |
nicklas |
180 |
{ |
5436 |
17 May 19 |
nicklas |
// We do not make this check if the pipeline is not RNAseq since we will catch that as an error in updatePoolData() |
5436 |
17 May 19 |
nicklas |
lib.excludeFromPool = lib.molarity > 0 && lib.remainingQuantity > 0 ? false : true; |
5436 |
17 May 19 |
nicklas |
183 |
} |
2805 |
15 Oct 14 |
nicklas |
createpool.addLibraryToTable(lib); |
2805 |
15 Oct 14 |
nicklas |
185 |
} |
2805 |
15 Oct 14 |
nicklas |
186 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2805 |
15 Oct 14 |
nicklas |
188 |
|
2805 |
15 Oct 14 |
nicklas |
Doc.hide('not-selected'); |
2805 |
15 Oct 14 |
nicklas |
Doc.show('lib-table'); |
2805 |
15 Oct 14 |
nicklas |
191 |
} |
2805 |
15 Oct 14 |
nicklas |
192 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.addLibraryToTable = function(lib) |
2805 |
15 Oct 14 |
nicklas |
194 |
{ |
2805 |
15 Oct 14 |
nicklas |
var tr = document.createElement('tr'); |
2805 |
15 Oct 14 |
nicklas |
tr.id = 'lib.'+lib.id; |
2805 |
15 Oct 14 |
nicklas |
var className = 'highlight'; |
2805 |
15 Oct 14 |
nicklas |
if (lib.excludeFromPool) className += ' excluded'; |
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn(tr, 'check', '<input type="checkbox" name="check.'+lib.id+'" value="'+lib.id+'">'); |
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn(tr, 'name', Strings.encodeTags(lib.name)); |
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn(tr, 'barcode', lib.barcode ? Strings.encodeTags(lib.barcode.name) : '-'); |
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn(tr, 'location', lib.bioWell ? Strings.encodeTags(lib.bioWell.bioPlate.name + ' ' + lib.bioWell.location) : '-'); |
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn(tr, 'remain', lib.remainingVolume ? Numbers.formatNumber(lib.remainingVolume, 1) : '-'); |
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn(tr, 'adapter', lib.libraryFracAdpt != null ? lib.libraryFracAdpt + '%' : '-'); |
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn(tr, 'molarity', lib.molarity ? Numbers.formatNumber(lib.molarity, 2) : '-'); |
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn(tr, 'volume', ''); |
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn(tr, 'eb', ''); |
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn(tr, 'status', ''); |
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn(tr, 'remarks', ''); |
2805 |
15 Oct 14 |
nicklas |
tr.className = className; |
2805 |
15 Oct 14 |
nicklas |
211 |
|
2805 |
15 Oct 14 |
nicklas |
// Rows should be sorted by barcode |
2805 |
15 Oct 14 |
nicklas |
// Locate existing row |
2805 |
15 Oct 14 |
nicklas |
tr.sortBy = lib.barcode ? lib.barcode.name : lib.name; |
2805 |
15 Oct 14 |
nicklas |
var tbody = Doc.element('lib-table-rows'); |
2805 |
15 Oct 14 |
nicklas |
216 |
|
2805 |
15 Oct 14 |
nicklas |
var target = null; |
2805 |
15 Oct 14 |
nicklas |
for (var i = 0; i < tbody.childNodes.length; i++) |
2805 |
15 Oct 14 |
nicklas |
219 |
{ |
2805 |
15 Oct 14 |
nicklas |
var row = tbody.childNodes[i]; |
2805 |
15 Oct 14 |
nicklas |
if (row.sortBy && (row.sortBy > tr.sortBy)) |
2805 |
15 Oct 14 |
nicklas |
222 |
{ |
2805 |
15 Oct 14 |
nicklas |
// Found it! |
2805 |
15 Oct 14 |
nicklas |
target = row; |
2805 |
15 Oct 14 |
nicklas |
break; |
2805 |
15 Oct 14 |
nicklas |
226 |
}; |
2805 |
15 Oct 14 |
nicklas |
227 |
} |
2805 |
15 Oct 14 |
nicklas |
228 |
|
2805 |
15 Oct 14 |
nicklas |
tbody.insertBefore(tr, target); |
2805 |
15 Oct 14 |
nicklas |
230 |
} |
2805 |
15 Oct 14 |
nicklas |
231 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.addColumn = function(tr, idSuffix, text) |
2805 |
15 Oct 14 |
nicklas |
233 |
{ |
2805 |
15 Oct 14 |
nicklas |
var td = document.createElement('td'); |
2805 |
15 Oct 14 |
nicklas |
td.id = tr.id+'.'+idSuffix; |
2805 |
15 Oct 14 |
nicklas |
td.className = idSuffix; |
2805 |
15 Oct 14 |
nicklas |
td.innerHTML = text; |
2805 |
15 Oct 14 |
nicklas |
tr.appendChild(td); |
2805 |
15 Oct 14 |
nicklas |
239 |
} |
2805 |
15 Oct 14 |
nicklas |
240 |
|
2805 |
15 Oct 14 |
nicklas |
241 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.updatePoolData = function() |
2805 |
15 Oct 14 |
nicklas |
243 |
{ |
2805 |
15 Oct 14 |
nicklas |
if (!targetVolumePerLibIsValid || selectedLibraries.length == 0) return; |
2805 |
15 Oct 14 |
nicklas |
245 |
|
2805 |
15 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2805 |
15 Oct 14 |
nicklas |
var targetVolumePerLib = parseFloat(frm.target_volume.value); |
2805 |
15 Oct 14 |
nicklas |
var mixingStrategy = Forms.getCheckedRadio(frm.mixing_strategy).value; |
3107 |
27 Jan 15 |
nicklas |
var targetMolarityInPool = parseFloat(frm.target_molarity.value); |
2805 |
15 Oct 14 |
nicklas |
250 |
|
2805 |
15 Oct 14 |
nicklas |
var numSeparateMix = 0; |
2805 |
15 Oct 14 |
nicklas |
var numLowQuantity = 0; |
2805 |
15 Oct 14 |
nicklas |
var numExcluded = 0; |
2805 |
15 Oct 14 |
nicklas |
254 |
|
2805 |
15 Oct 14 |
nicklas |
// Get all libs into an array |
2805 |
15 Oct 14 |
nicklas |
var libs = []; |
2805 |
15 Oct 14 |
nicklas |
var usedBarcodes = []; |
2805 |
15 Oct 14 |
nicklas |
var duplicateBarcodes = []; |
2805 |
15 Oct 14 |
nicklas |
for (var selectedNo = 0; selectedNo < selectedLibraries.length; selectedNo++) |
2805 |
15 Oct 14 |
nicklas |
260 |
{ |
2805 |
15 Oct 14 |
nicklas |
var lib = selectedLibraries[selectedNo]; |
2805 |
15 Oct 14 |
nicklas |
if (!lib.excludeFromPool) |
2805 |
15 Oct 14 |
nicklas |
263 |
{ |
2805 |
15 Oct 14 |
nicklas |
libs[libs.length] = lib; |
2805 |
15 Oct 14 |
nicklas |
if (usedBarcodes[lib.barcode.name]) |
2805 |
15 Oct 14 |
nicklas |
266 |
{ |
2805 |
15 Oct 14 |
nicklas |
duplicateBarcodes[lib.barcode.name] = 1; |
2805 |
15 Oct 14 |
nicklas |
268 |
} |
2805 |
15 Oct 14 |
nicklas |
else |
2805 |
15 Oct 14 |
nicklas |
270 |
{ |
2805 |
15 Oct 14 |
nicklas |
usedBarcodes[lib.barcode.name] = 1; |
2805 |
15 Oct 14 |
nicklas |
272 |
} |
3107 |
27 Jan 15 |
nicklas |
PoolMix.calculateLibVolume(lib, targetMolarityInPool, targetVolumePerLib, mixingStrategy); |
3107 |
27 Jan 15 |
nicklas |
PoolMix.calculateEbVolume(lib, targetMolarityInPool, targetVolumePerLib, mixingStrategy); |
2805 |
15 Oct 14 |
nicklas |
275 |
} |
2805 |
15 Oct 14 |
nicklas |
else |
2805 |
15 Oct 14 |
nicklas |
277 |
{ |
2805 |
15 Oct 14 |
nicklas |
numExcluded++; |
2805 |
15 Oct 14 |
nicklas |
279 |
} |
2805 |
15 Oct 14 |
nicklas |
280 |
} |
2805 |
15 Oct 14 |
nicklas |
281 |
|
2805 |
15 Oct 14 |
nicklas |
// Calculate final pool volumes, molarity, etc. |
3107 |
27 Jan 15 |
nicklas |
poolInfo = PoolMix.calculateFinalPoolInfo(libs, targetMolarityInPool, targetVolumePerLib, mixingStrategy); |
2805 |
15 Oct 14 |
nicklas |
284 |
|
2805 |
15 Oct 14 |
nicklas |
// Make remarks for each lib |
2805 |
15 Oct 14 |
nicklas |
for (var libNo = 0; libNo < selectedLibraries.length; libNo++) |
2805 |
15 Oct 14 |
nicklas |
287 |
{ |
2805 |
15 Oct 14 |
nicklas |
var lib = selectedLibraries[libNo]; |
2805 |
15 Oct 14 |
nicklas |
if (!lib.excludeFromPool) |
2805 |
15 Oct 14 |
nicklas |
290 |
{ |
2805 |
15 Oct 14 |
nicklas |
var mark = ''; |
2805 |
15 Oct 14 |
nicklas |
var tr = Doc.element('lib.'+lib.id); |
5436 |
17 May 19 |
nicklas |
if (duplicateBarcodes[lib.barcode.name] || lib.pipeline != 'RNAseq') |
2805 |
15 Oct 14 |
nicklas |
294 |
{ |
2805 |
15 Oct 14 |
nicklas |
Doc.addClass(tr, 'lib-error'); |
2805 |
15 Oct 14 |
nicklas |
lib.hasError = true; |
2805 |
15 Oct 14 |
nicklas |
297 |
} |
2805 |
15 Oct 14 |
nicklas |
else |
2805 |
15 Oct 14 |
nicklas |
299 |
{ |
2805 |
15 Oct 14 |
nicklas |
Doc.removeClass(tr, 'lib-error'); |
2805 |
15 Oct 14 |
nicklas |
lib.hasError = false; |
2805 |
15 Oct 14 |
nicklas |
302 |
} |
2805 |
15 Oct 14 |
nicklas |
Doc.removeClass(tr, 'warning'); |
2805 |
15 Oct 14 |
nicklas |
if (lib.volume != lib.actualVolume) |
2805 |
15 Oct 14 |
nicklas |
305 |
{ |
2805 |
15 Oct 14 |
nicklas |
mark = '*'; |
2805 |
15 Oct 14 |
nicklas |
Doc.addClass(tr, 'warning'); |
2805 |
15 Oct 14 |
nicklas |
308 |
} |
2805 |
15 Oct 14 |
nicklas |
if (lib.libraryFracAdpt == null || lib.libraryFracAdpt > LIBRARY_FRAC_ADPT_LIMIT) |
2805 |
15 Oct 14 |
nicklas |
310 |
{ |
2805 |
15 Oct 14 |
nicklas |
Doc.addClass(tr, 'warning'); |
2805 |
15 Oct 14 |
nicklas |
312 |
} |
2805 |
15 Oct 14 |
nicklas |
313 |
|
2805 |
15 Oct 14 |
nicklas |
Doc.element('lib.'+lib.id+'.volume').innerHTML = lib.mixFactor > 1 ? '-' : Numbers.formatNumber(lib.volume, 1)+mark; |
2805 |
15 Oct 14 |
nicklas |
if (mixingStrategy == 'fixed' && lib.mixFactor < 1.001) |
2805 |
15 Oct 14 |
nicklas |
316 |
{ |
2805 |
15 Oct 14 |
nicklas |
Doc.element('lib.'+lib.id+'.eb').innerHTML = Numbers.formatNumber(lib.eb, 1); |
2805 |
15 Oct 14 |
nicklas |
318 |
} |
2805 |
15 Oct 14 |
nicklas |
else |
2805 |
15 Oct 14 |
nicklas |
320 |
{ |
2805 |
15 Oct 14 |
nicklas |
Doc.element('lib.'+lib.id+'.eb').innerHTML = '-'; |
2805 |
15 Oct 14 |
nicklas |
322 |
} |
2805 |
15 Oct 14 |
nicklas |
if (lib.eb != 0 || mixingStrategy == 'fixed') numSeparateMix++; |
2805 |
15 Oct 14 |
nicklas |
if (lib.volume > lib.actualVolume) numLowQuantity++; |
2805 |
15 Oct 14 |
nicklas |
325 |
} |
2805 |
15 Oct 14 |
nicklas |
326 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.calculateRemarks(lib, mixingStrategy, duplicateBarcodes); |
2805 |
15 Oct 14 |
nicklas |
Doc.element('lib.'+lib.id+'.remarks').innerHTML = lib.remarks.join('; '); |
2805 |
15 Oct 14 |
nicklas |
329 |
} |
2805 |
15 Oct 14 |
nicklas |
330 |
|
2805 |
15 Oct 14 |
nicklas |
var warnMsg = null; |
2805 |
15 Oct 14 |
nicklas |
if (poolInfo.ebVolumeExtra < 0) |
2805 |
15 Oct 14 |
nicklas |
333 |
{ |
2805 |
15 Oct 14 |
nicklas |
warnMsg = 'Too many libs with low molarity'; |
2805 |
15 Oct 14 |
nicklas |
335 |
} |
2805 |
15 Oct 14 |
nicklas |
336 |
|
2805 |
15 Oct 14 |
nicklas |
Doc.element('pool.eb').innerHTML = Numbers.formatNumber(poolInfo.ebVolumeExtra, 1); |
2805 |
15 Oct 14 |
nicklas |
338 |
|
2805 |
15 Oct 14 |
nicklas |
var poolDiv = Doc.element('pool-summary'); |
2805 |
15 Oct 14 |
nicklas |
var poolRow = Doc.element('lib-table-pool-summary'); |
2805 |
15 Oct 14 |
nicklas |
var poolData = '<div class="pool-data">'; |
2805 |
15 Oct 14 |
nicklas |
poolData += libs.length + ' libs • '; |
2805 |
15 Oct 14 |
nicklas |
poolData += Numbers.formatNumber(poolInfo.molarity, 2, 'nM')+' • '; |
2805 |
15 Oct 14 |
nicklas |
poolData += Numbers.formatNumber(poolInfo.totalVolume, 1, 'µl'); |
2805 |
15 Oct 14 |
nicklas |
if (mixingStrategy == 'dynamic') |
2805 |
15 Oct 14 |
nicklas |
346 |
{ |
2805 |
15 Oct 14 |
nicklas |
poolData += ' • <span class="eb">'+Numbers.formatNumber(Math.max(0, poolInfo.ebVolumeExtra), 1, 'µl')+'</span>'; |
2805 |
15 Oct 14 |
nicklas |
348 |
} |
2805 |
15 Oct 14 |
nicklas |
if (warnMsg) |
2805 |
15 Oct 14 |
nicklas |
350 |
{ |
2805 |
15 Oct 14 |
nicklas |
Doc.addClass(poolRow, 'warning'); |
2805 |
15 Oct 14 |
nicklas |
Doc.element('pool.remarks').innerHTML = warnMsg; |
2805 |
15 Oct 14 |
nicklas |
353 |
} |
2805 |
15 Oct 14 |
nicklas |
else |
2805 |
15 Oct 14 |
nicklas |
355 |
{ |
2805 |
15 Oct 14 |
nicklas |
Doc.removeClass(poolRow, 'warning'); |
2805 |
15 Oct 14 |
nicklas |
Doc.element('pool.remarks').innerHTML = ''; |
2805 |
15 Oct 14 |
nicklas |
358 |
} |
2805 |
15 Oct 14 |
nicklas |
359 |
|
2805 |
15 Oct 14 |
nicklas |
poolData += '</div>'; |
2805 |
15 Oct 14 |
nicklas |
poolDiv.innerHTML = poolData; |
2805 |
15 Oct 14 |
nicklas |
362 |
|
2805 |
15 Oct 14 |
nicklas |
Doc.element('num_separate_mix').innerHTML = numSeparateMix; |
2805 |
15 Oct 14 |
nicklas |
Doc.element('num_low_quantity').innerHTML = numLowQuantity; |
2805 |
15 Oct 14 |
nicklas |
Doc.element('num_excluded').innerHTML = numExcluded; |
2805 |
15 Oct 14 |
nicklas |
366 |
} |
2805 |
15 Oct 14 |
nicklas |
367 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.calculateRemarks = function(lib, mixingStrategy, duplicateBarcodes) |
2805 |
15 Oct 14 |
nicklas |
369 |
{ |
2805 |
15 Oct 14 |
nicklas |
var remarks = []; |
2805 |
15 Oct 14 |
nicklas |
371 |
|
4984 |
27 Sep 18 |
nicklas |
if (lib.DO_NOT_USE) |
4984 |
27 Sep 18 |
nicklas |
373 |
{ |
4984 |
27 Sep 18 |
nicklas |
remarks[remarks.length] = 'DoNotUse-'+Strings.encodeTags(lib.DO_NOT_USE + ': ' + lib.DO_NOT_USE_COMMENT); |
4984 |
27 Sep 18 |
nicklas |
375 |
} |
4984 |
27 Sep 18 |
nicklas |
376 |
|
5436 |
17 May 19 |
nicklas |
if (lib.pipeline != 'RNAseq') |
5436 |
17 May 19 |
nicklas |
378 |
{ |
5436 |
17 May 19 |
nicklas |
remarks[remarks.length] = 'Invalid pipeline: ' + Strings.encodeTags(lib.pipeline); |
5436 |
17 May 19 |
nicklas |
380 |
} |
5436 |
17 May 19 |
nicklas |
381 |
|
2805 |
15 Oct 14 |
nicklas |
// Check if default barcode has been modified |
2805 |
15 Oct 14 |
nicklas |
if (lib.molarity != null) |
2805 |
15 Oct 14 |
nicklas |
384 |
{ |
2805 |
15 Oct 14 |
nicklas |
if (duplicateBarcodes[lib.barcode.name]) |
2805 |
15 Oct 14 |
nicklas |
386 |
{ |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = 'Duplicate barcode: ' + Strings.encodeTags(lib.barcode.name); |
2805 |
15 Oct 14 |
nicklas |
388 |
} |
2805 |
15 Oct 14 |
nicklas |
389 |
|
2805 |
15 Oct 14 |
nicklas |
if (lib.volume != lib.actualVolume) |
2805 |
15 Oct 14 |
nicklas |
391 |
{ |
2805 |
15 Oct 14 |
nicklas |
if (lib.volume > lib.remainingVolume) |
2805 |
15 Oct 14 |
nicklas |
393 |
{ |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = 'Low quantity'; |
2805 |
15 Oct 14 |
nicklas |
395 |
} |
2805 |
15 Oct 14 |
nicklas |
else |
2805 |
15 Oct 14 |
nicklas |
397 |
{ |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = 'Low molarity'; |
2805 |
15 Oct 14 |
nicklas |
399 |
} |
2805 |
15 Oct 14 |
nicklas |
if (mixingStrategy == 'fixed') |
2805 |
15 Oct 14 |
nicklas |
401 |
{ |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = 'Mix <span class="volume">'+Numbers.formatNumber(lib.actualVolume, 1) + '</span>+<span class="eb">' + Numbers.formatNumber(lib.actualEb, 1)+'µl</span>'; |
2805 |
15 Oct 14 |
nicklas |
403 |
} |
2805 |
15 Oct 14 |
nicklas |
else |
2805 |
15 Oct 14 |
nicklas |
405 |
{ |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = 'Use <span class="volume">'+Numbers.formatNumber(lib.actualVolume, 1) + 'µl</span>'; |
2805 |
15 Oct 14 |
nicklas |
407 |
} |
2805 |
15 Oct 14 |
nicklas |
408 |
} |
2805 |
15 Oct 14 |
nicklas |
409 |
|
2805 |
15 Oct 14 |
nicklas |
if (lib.libraryFracAdpt == null) |
2805 |
15 Oct 14 |
nicklas |
411 |
{ |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = 'Unknown adapter fraction'; |
2805 |
15 Oct 14 |
nicklas |
413 |
} |
2805 |
15 Oct 14 |
nicklas |
else if (lib.libraryFracAdpt > LIBRARY_FRAC_ADPT_LIMIT) |
2805 |
15 Oct 14 |
nicklas |
415 |
{ |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = 'High adapter fraction'; |
2805 |
15 Oct 14 |
nicklas |
417 |
} |
2805 |
15 Oct 14 |
nicklas |
418 |
|
2805 |
15 Oct 14 |
nicklas |
if (lib.speedVacConc != null) |
2805 |
15 Oct 14 |
nicklas |
420 |
{ |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = 'SpeedVac'; |
2805 |
15 Oct 14 |
nicklas |
422 |
} |
2805 |
15 Oct 14 |
nicklas |
423 |
|
2805 |
15 Oct 14 |
nicklas |
if (lib.mixFactor > 1) |
2805 |
15 Oct 14 |
nicklas |
425 |
{ |
2805 |
15 Oct 14 |
nicklas |
// Larger mix than default |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = 'Mix <span class="volume">'+Numbers.formatNumber(lib.volume*lib.mixFactor, 1) + '</span>+<span class="eb">' + Numbers.formatNumber(lib.eb*lib.mixFactor, 1)+'µl</span>'; |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = 'Use <b>' + Numbers.formatNumber(lib.volume+lib.eb, 1) + 'µl</b> in pool'; |
2805 |
15 Oct 14 |
nicklas |
429 |
} |
2805 |
15 Oct 14 |
nicklas |
430 |
} |
2805 |
15 Oct 14 |
nicklas |
if (lib.excludeFromPool) |
2805 |
15 Oct 14 |
nicklas |
432 |
{ |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = 'Excluded'; |
2805 |
15 Oct 14 |
nicklas |
434 |
} |
2805 |
15 Oct 14 |
nicklas |
if (lib.comment) |
2805 |
15 Oct 14 |
nicklas |
436 |
{ |
2805 |
15 Oct 14 |
nicklas |
remarks[remarks.length] = Strings.encodeTags(lib.comment); |
2805 |
15 Oct 14 |
nicklas |
438 |
} |
2805 |
15 Oct 14 |
nicklas |
lib.stratagene = Reggie.isStratagene(lib.name); |
2805 |
15 Oct 14 |
nicklas |
lib.external = Reggie.isExternal(lib.name); |
2805 |
15 Oct 14 |
nicklas |
lib.remarks = remarks; |
2805 |
15 Oct 14 |
nicklas |
442 |
} |
2805 |
15 Oct 14 |
nicklas |
443 |
|
2805 |
15 Oct 14 |
nicklas |
444 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.targetVolumeOnChange = function() |
2805 |
15 Oct 14 |
nicklas |
446 |
{ |
2805 |
15 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2805 |
15 Oct 14 |
nicklas |
var targetVolumePerLib = parseFloat(frm.target_volume.value); |
2805 |
15 Oct 14 |
nicklas |
449 |
|
2805 |
15 Oct 14 |
nicklas |
targetVolumePerLibIsValid = false; |
2805 |
15 Oct 14 |
nicklas |
if (targetVolumePerLib < MIN_TARGET_VOLUME || targetVolumePerLib > MAX_TARGET_VOLUME) |
2805 |
15 Oct 14 |
nicklas |
452 |
{ |
2805 |
15 Oct 14 |
nicklas |
Wizard.setInputStatus('target_volume', 'invalid', 'Must be between '+MIN_TARGET_VOLUME+' and '+MAX_TARGET_VOLUME+'µl'); |
2805 |
15 Oct 14 |
nicklas |
return; |
2805 |
15 Oct 14 |
nicklas |
455 |
} |
2805 |
15 Oct 14 |
nicklas |
456 |
|
2805 |
15 Oct 14 |
nicklas |
Wizard.setInputStatus('target_volume', 'valid'); |
2805 |
15 Oct 14 |
nicklas |
targetVolumePerLibIsValid = true; |
2805 |
15 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2805 |
15 Oct 14 |
nicklas |
460 |
} |
2805 |
15 Oct 14 |
nicklas |
461 |
|
2805 |
15 Oct 14 |
nicklas |
//Set target volume on the selected wells |
2805 |
15 Oct 14 |
nicklas |
createpool.setTargetVolume = function(event) |
2805 |
15 Oct 14 |
nicklas |
464 |
{ |
2805 |
15 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2805 |
15 Oct 14 |
nicklas |
var checked = []; |
2805 |
15 Oct 14 |
nicklas |
var targetVolume; |
2805 |
15 Oct 14 |
nicklas |
for (var libNo = 0; libNo < selectedLibraries.length; libNo++) |
2805 |
15 Oct 14 |
nicklas |
469 |
{ |
2805 |
15 Oct 14 |
nicklas |
var lib = selectedLibraries[libNo]; |
2805 |
15 Oct 14 |
nicklas |
if (frm['check.'+lib.id].checked && lib.mixFactor > 1) |
2805 |
15 Oct 14 |
nicklas |
472 |
{ |
2805 |
15 Oct 14 |
nicklas |
checked[checked.length] = lib; |
2805 |
15 Oct 14 |
nicklas |
if (!targetVolume) targetVolume = lib.targetVolume; |
2805 |
15 Oct 14 |
nicklas |
475 |
} |
2805 |
15 Oct 14 |
nicklas |
476 |
} |
2805 |
15 Oct 14 |
nicklas |
477 |
|
2805 |
15 Oct 14 |
nicklas |
if (checked.length == 0) |
2805 |
15 Oct 14 |
nicklas |
479 |
{ |
2805 |
15 Oct 14 |
nicklas |
Forms.showNotification(event.currentTarget, 'No libraries with separate mix have been selected'); |
2805 |
15 Oct 14 |
nicklas |
return; |
2805 |
15 Oct 14 |
nicklas |
482 |
} |
2805 |
15 Oct 14 |
nicklas |
483 |
|
2805 |
15 Oct 14 |
nicklas |
targetVolume = parseFloat(prompt('Volume to use in pool ('+LIMIT_FOR_EXTRA_LARGE_MIX+'--'+MAX_TARGET_VOLUME+' µl)', targetVolume || lastTargetVolume || frm.target_volume.value)); |
2805 |
15 Oct 14 |
nicklas |
if (isNaN(targetVolume)) |
2805 |
15 Oct 14 |
nicklas |
486 |
{ |
2805 |
15 Oct 14 |
nicklas |
targetVolume = null; |
2805 |
15 Oct 14 |
nicklas |
488 |
} |
2805 |
15 Oct 14 |
nicklas |
else if (targetVolume > MAX_TARGET_VOLUME) |
2805 |
15 Oct 14 |
nicklas |
490 |
{ |
2805 |
15 Oct 14 |
nicklas |
targetVolume = MAX_TARGET_VOLUME; |
2805 |
15 Oct 14 |
nicklas |
492 |
} |
2805 |
15 Oct 14 |
nicklas |
else if (targetVolume < LIMIT_FOR_EXTRA_LARGE_MIX) |
2805 |
15 Oct 14 |
nicklas |
494 |
{ |
2805 |
15 Oct 14 |
nicklas |
targetVolume = LIMIT_FOR_EXTRA_LARGE_MIX |
2805 |
15 Oct 14 |
nicklas |
496 |
} |
2805 |
15 Oct 14 |
nicklas |
lastTargetVolume = targetVolume; |
2805 |
15 Oct 14 |
nicklas |
if (targetVolume == '') targetVolume = null; |
2805 |
15 Oct 14 |
nicklas |
499 |
|
2805 |
15 Oct 14 |
nicklas |
var targetVolumePerLib = parseFloat(frm.target_volume.value); |
2805 |
15 Oct 14 |
nicklas |
var mixingStrategy = Forms.getCheckedRadio(frm.mixing_strategy).value; |
3107 |
27 Jan 15 |
nicklas |
var targetMolarityInPool = parseFloat(frm.target_molarity.value); |
3107 |
27 Jan 15 |
nicklas |
503 |
|
2805 |
15 Oct 14 |
nicklas |
for (var libNo = 0; libNo < checked.length; libNo++) |
2805 |
15 Oct 14 |
nicklas |
505 |
{ |
2805 |
15 Oct 14 |
nicklas |
var lib = checked[libNo]; |
2805 |
15 Oct 14 |
nicklas |
lib.targetVolume = targetVolume; |
3107 |
27 Jan 15 |
nicklas |
PoolMix.calculateEbVolume(lib, targetMolarityInPool, targetVolumePerLib, mixingStrategy); |
2805 |
15 Oct 14 |
nicklas |
509 |
} |
2805 |
15 Oct 14 |
nicklas |
510 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2805 |
15 Oct 14 |
nicklas |
512 |
} |
2805 |
15 Oct 14 |
nicklas |
513 |
|
2805 |
15 Oct 14 |
nicklas |
//Set a comment on the checked libraries |
2805 |
15 Oct 14 |
nicklas |
createpool.commentChecked = function(event) |
2805 |
15 Oct 14 |
nicklas |
516 |
{ |
2805 |
15 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2805 |
15 Oct 14 |
nicklas |
518 |
|
2805 |
15 Oct 14 |
nicklas |
// Get array with checked libs |
2805 |
15 Oct 14 |
nicklas |
var checked = []; |
2805 |
15 Oct 14 |
nicklas |
var comment; |
2805 |
15 Oct 14 |
nicklas |
for (var libNo = 0; libNo < selectedLibraries.length; libNo++) |
2805 |
15 Oct 14 |
nicklas |
523 |
{ |
2805 |
15 Oct 14 |
nicklas |
var lib = selectedLibraries[libNo]; |
2805 |
15 Oct 14 |
nicklas |
if (frm['check.'+lib.id].checked) |
2805 |
15 Oct 14 |
nicklas |
526 |
{ |
2805 |
15 Oct 14 |
nicklas |
checked[checked.length] = lib; |
2805 |
15 Oct 14 |
nicklas |
if (!comment) comment = lib.comment; |
2805 |
15 Oct 14 |
nicklas |
529 |
} |
2805 |
15 Oct 14 |
nicklas |
530 |
} |
2805 |
15 Oct 14 |
nicklas |
531 |
|
2805 |
15 Oct 14 |
nicklas |
if (checked.length == 0) |
2805 |
15 Oct 14 |
nicklas |
533 |
{ |
2805 |
15 Oct 14 |
nicklas |
Forms.showNotification(event.currentTarget, 'No libraries have been selected'); |
2805 |
15 Oct 14 |
nicklas |
return; |
2805 |
15 Oct 14 |
nicklas |
536 |
} |
2805 |
15 Oct 14 |
nicklas |
537 |
|
2805 |
15 Oct 14 |
nicklas |
comment = prompt('Comment', comment || lastComment); |
2805 |
15 Oct 14 |
nicklas |
if (comment == null) return; |
2805 |
15 Oct 14 |
nicklas |
540 |
|
2805 |
15 Oct 14 |
nicklas |
lastComment = comment; |
2805 |
15 Oct 14 |
nicklas |
542 |
|
2805 |
15 Oct 14 |
nicklas |
if (comment == '') comment = null; |
2805 |
15 Oct 14 |
nicklas |
for (var libNo = 0; libNo < checked.length; libNo++) |
2805 |
15 Oct 14 |
nicklas |
545 |
{ |
2805 |
15 Oct 14 |
nicklas |
var lib = checked[libNo]; |
2805 |
15 Oct 14 |
nicklas |
lib.comment = comment; |
2805 |
15 Oct 14 |
nicklas |
548 |
} |
2805 |
15 Oct 14 |
nicklas |
549 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2805 |
15 Oct 14 |
nicklas |
551 |
} |
2805 |
15 Oct 14 |
nicklas |
552 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.validateStep1 = function(event) |
2805 |
15 Oct 14 |
nicklas |
554 |
{ |
2805 |
15 Oct 14 |
nicklas |
var valid = true; |
2805 |
15 Oct 14 |
nicklas |
556 |
|
2805 |
15 Oct 14 |
nicklas |
valid &= targetVolumePerLibIsValid; |
2805 |
15 Oct 14 |
nicklas |
valid &= (selectedLibraries.length > 0); |
2805 |
15 Oct 14 |
nicklas |
559 |
|
5436 |
17 May 19 |
nicklas |
var numIncluded = 0; |
2805 |
15 Oct 14 |
nicklas |
for (var libNo = 0; libNo < selectedLibraries.length; libNo++) |
2805 |
15 Oct 14 |
nicklas |
562 |
{ |
2805 |
15 Oct 14 |
nicklas |
var lib = selectedLibraries[libNo]; |
2805 |
15 Oct 14 |
nicklas |
valid &= !lib.hasError; |
5436 |
17 May 19 |
nicklas |
if (!lib.excludeFromPool) numIncluded++; |
2805 |
15 Oct 14 |
nicklas |
566 |
} |
2805 |
15 Oct 14 |
nicklas |
567 |
|
5436 |
17 May 19 |
nicklas |
valid &= (numIncluded > 0); |
5436 |
17 May 19 |
nicklas |
569 |
|
2805 |
15 Oct 14 |
nicklas |
if (!valid) event.preventDefault(); |
2805 |
15 Oct 14 |
nicklas |
571 |
} |
2805 |
15 Oct 14 |
nicklas |
572 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.submit = function() |
2805 |
15 Oct 14 |
nicklas |
574 |
{ |
2805 |
15 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2805 |
15 Oct 14 |
nicklas |
576 |
|
2805 |
15 Oct 14 |
nicklas |
var submitInfo = {}; |
2805 |
15 Oct 14 |
nicklas |
submitInfo.pools = []; |
2805 |
15 Oct 14 |
nicklas |
submitInfo.flagged = []; // Always empty |
2805 |
15 Oct 14 |
nicklas |
var mixingStrategy = Forms.getCheckedRadio(frm.mixing_strategy).value; |
2805 |
15 Oct 14 |
nicklas |
581 |
|
2805 |
15 Oct 14 |
nicklas |
var pool = {}; |
2805 |
15 Oct 14 |
nicklas |
pool.name = frm.poolName.value; |
2805 |
15 Oct 14 |
nicklas |
pool.comment = frm.poolComments.value; |
2805 |
15 Oct 14 |
nicklas |
pool.ebVolumeExtra = Math.max(0, poolInfo.ebVolumeExtra); |
2805 |
15 Oct 14 |
nicklas |
pool.targetVolumeInPoolPerLib = parseFloat(frm.target_volume.value); |
3107 |
27 Jan 15 |
nicklas |
pool.targetPoolMolarity = parseFloat(frm.target_molarity.value); |
2805 |
15 Oct 14 |
nicklas |
pool.mixingStrategy = mixingStrategy; |
2805 |
15 Oct 14 |
nicklas |
pool.libs = []; |
2805 |
15 Oct 14 |
nicklas |
pool.excluded = []; |
2805 |
15 Oct 14 |
nicklas |
591 |
|
2805 |
15 Oct 14 |
nicklas |
for (var libNo = 0; libNo < selectedLibraries.length; libNo++) |
2805 |
15 Oct 14 |
nicklas |
593 |
{ |
2805 |
15 Oct 14 |
nicklas |
var lib = selectedLibraries[libNo]; |
2805 |
15 Oct 14 |
nicklas |
595 |
|
2805 |
15 Oct 14 |
nicklas |
// We send library id, name and mixing volumes |
2805 |
15 Oct 14 |
nicklas |
if (!lib.excludeFromPool) |
2805 |
15 Oct 14 |
nicklas |
598 |
{ |
2805 |
15 Oct 14 |
nicklas |
var tmp = {}; |
2805 |
15 Oct 14 |
nicklas |
tmp.id = lib.id; |
2805 |
15 Oct 14 |
nicklas |
tmp.name = lib.name; |
2805 |
15 Oct 14 |
nicklas |
tmp.volume = lib.actualVolume; |
2805 |
15 Oct 14 |
nicklas |
tmp.eb = lib.actualEb; |
2805 |
15 Oct 14 |
nicklas |
tmp.mixFactor = lib.mixFactor; |
2805 |
15 Oct 14 |
nicklas |
if (lib.mixFactor > 1 && lib.targetVolume && mixingStrategy == 'dynamic') |
2805 |
15 Oct 14 |
nicklas |
606 |
{ |
2805 |
15 Oct 14 |
nicklas |
tmp.targetVolume = lib.targetVolume; |
2805 |
15 Oct 14 |
nicklas |
608 |
} |
2805 |
15 Oct 14 |
nicklas |
tmp.comment = lib.comment; |
2805 |
15 Oct 14 |
nicklas |
pool.libs[pool.libs.length] = tmp; |
2805 |
15 Oct 14 |
nicklas |
611 |
} |
2805 |
15 Oct 14 |
nicklas |
612 |
} |
2805 |
15 Oct 14 |
nicklas |
submitInfo.pools[submitInfo.pools.length] = pool; |
2805 |
15 Oct 14 |
nicklas |
614 |
|
2805 |
15 Oct 14 |
nicklas |
var url = '../Pool.servlet?ID='+App.getSessionId(); |
2805 |
15 Oct 14 |
nicklas |
url += '&cmd=CreatePools'; |
2805 |
15 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2805 |
15 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, createpool.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2805 |
15 Oct 14 |
nicklas |
619 |
} |
2805 |
15 Oct 14 |
nicklas |
620 |
|
2805 |
15 Oct 14 |
nicklas |
createpool.submissionResults = function(response) |
2805 |
15 Oct 14 |
nicklas |
622 |
{ |
2805 |
15 Oct 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2805 |
15 Oct 14 |
nicklas |
Doc.show('gorestart'); |
2805 |
15 Oct 14 |
nicklas |
625 |
} |
2805 |
15 Oct 14 |
nicklas |
626 |
|
2805 |
15 Oct 14 |
nicklas |
return createpool; |
2805 |
15 Oct 14 |
nicklas |
628 |
}(); |
2805 |
15 Oct 14 |
nicklas |
629 |
|
2805 |
15 Oct 14 |
nicklas |
Doc.onLoad(CreatePool.initPage); |
2805 |
15 Oct 14 |
nicklas |
631 |
|