2829 |
17 Oct 14 |
nicklas |
var CreatePool = function() |
2829 |
17 Oct 14 |
nicklas |
2 |
{ |
2829 |
17 Oct 14 |
nicklas |
var createpool = {}; |
2853 |
23 Oct 14 |
nicklas |
var debug = 0; |
2829 |
17 Oct 14 |
nicklas |
5 |
|
2829 |
17 Oct 14 |
nicklas |
var targetVolumePerLibIsValid = []; |
2829 |
17 Oct 14 |
nicklas |
var POOL_DATA = []; |
2837 |
20 Oct 14 |
nicklas |
var USED_POOL_NAMES = []; |
2829 |
17 Oct 14 |
nicklas |
9 |
|
2829 |
17 Oct 14 |
nicklas |
// Loaded from servlet when getting Library information |
2829 |
17 Oct 14 |
nicklas |
var LIMIT_FOR_AUTO_EXCLUDE = 0.25; |
2829 |
17 Oct 14 |
nicklas |
var LIMIT_FOR_EXTRA_LARGE_MIX; |
2829 |
17 Oct 14 |
nicklas |
var MAX_TARGET_VOLUME = 20; |
2829 |
17 Oct 14 |
nicklas |
var MIN_TARGET_VOLUME = 2; |
2829 |
17 Oct 14 |
nicklas |
15 |
|
2829 |
17 Oct 14 |
nicklas |
var LIBRARY_FRAC_ADPT_LIMIT = 10; // percent |
2829 |
17 Oct 14 |
nicklas |
17 |
|
2829 |
17 Oct 14 |
nicklas |
18 |
|
2829 |
17 Oct 14 |
nicklas |
// Page initialization |
2829 |
17 Oct 14 |
nicklas |
createpool.initPage = function() |
2829 |
17 Oct 14 |
nicklas |
21 |
{ |
2829 |
17 Oct 14 |
nicklas |
// Step 1 |
2829 |
17 Oct 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', createpool.validateStep1); |
2829 |
17 Oct 14 |
nicklas |
Buttons.addClickHandler('btnCreateManualPool', createpool.createManualPool); |
3307 |
05 May 15 |
nicklas |
Buttons.addClickHandler('btnCreateManualPool2', createpool.createManualPool); |
2829 |
17 Oct 14 |
nicklas |
26 |
|
2829 |
17 Oct 14 |
nicklas |
// Step 2 |
2829 |
17 Oct 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', createpool.initializeStep2); |
2829 |
17 Oct 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', createpool.validateStep2); |
2829 |
17 Oct 14 |
nicklas |
Buttons.addClickHandler('btnExcludeFromPool', createpool.excludeSelected); |
2829 |
17 Oct 14 |
nicklas |
Buttons.addClickHandler('btnIncludeInPool', createpool.includeSelected); |
2829 |
17 Oct 14 |
nicklas |
Buttons.addClickHandler('btnSetTargetVolume', createpool.setTargetVolume); |
2829 |
17 Oct 14 |
nicklas |
Buttons.addClickHandler('btnFlag', createpool.toggleFlag); |
2829 |
17 Oct 14 |
nicklas |
Buttons.addClickHandler('btnComment', createpool.commentSelected); |
2931 |
14 Nov 14 |
nicklas |
35 |
|
2931 |
14 Nov 14 |
nicklas |
// Right-click menu |
2931 |
14 Nov 14 |
nicklas |
Events.addEventHandler('plate', 'mouseup', createpool.contextEvent); |
2931 |
14 Nov 14 |
nicklas |
Events.addEventHandler('plate', 'contextmenu', createpool.contextEvent); |
2931 |
14 Nov 14 |
nicklas |
Events.addEventHandler('mnuExcludeFromPool', 'click', createpool.excludeSelected); |
2931 |
14 Nov 14 |
nicklas |
Events.addEventHandler('mnuIncludeInPool', 'click', createpool.includeSelected); |
2931 |
14 Nov 14 |
nicklas |
Events.addEventHandler('mnuSetTargetVolume', 'click', createpool.setTargetVolume); |
2931 |
14 Nov 14 |
nicklas |
Events.addEventHandler('mnuFlag', 'click', createpool.toggleFlag); |
2931 |
14 Nov 14 |
nicklas |
Events.addEventHandler('mnuComment', 'click', createpool.commentSelected); |
2931 |
14 Nov 14 |
nicklas |
Events.addEventHandler('mnuCaseSummary', 'click', createpool.showCaseSummary); |
2931 |
14 Nov 14 |
nicklas |
Events.addEventHandler(document, 'click', createpool.forgetContext); |
2931 |
14 Nov 14 |
nicklas |
46 |
|
2829 |
17 Oct 14 |
nicklas |
// Navigation |
2829 |
17 Oct 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2829 |
17 Oct 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2829 |
17 Oct 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2829 |
17 Oct 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2829 |
17 Oct 14 |
nicklas |
52 |
|
2829 |
17 Oct 14 |
nicklas |
// Final registration |
2829 |
17 Oct 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', createpool.submit); |
2829 |
17 Oct 14 |
nicklas |
55 |
|
2829 |
17 Oct 14 |
nicklas |
var url = '../Pool.servlet?ID='+App.getSessionId(); |
2829 |
17 Oct 14 |
nicklas |
url += '&cmd=GetLibraryPlatesForPooling'; |
2829 |
17 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading library plates...'); |
2829 |
17 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, createpool.libPlateInfoLoaded); |
2829 |
17 Oct 14 |
nicklas |
60 |
} |
2829 |
17 Oct 14 |
nicklas |
61 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.libPlateInfoLoaded = function(response) |
2829 |
17 Oct 14 |
nicklas |
63 |
{ |
2829 |
17 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2829 |
17 Oct 14 |
nicklas |
65 |
|
2829 |
17 Oct 14 |
nicklas |
var bioplates = response.bioplates; |
2829 |
17 Oct 14 |
nicklas |
var plates = frm.bioplate; |
2829 |
17 Oct 14 |
nicklas |
if (bioplates.length > 0) |
2829 |
17 Oct 14 |
nicklas |
69 |
{ |
2829 |
17 Oct 14 |
nicklas |
for (var i=0; i < bioplates.length; i++) |
2829 |
17 Oct 14 |
nicklas |
71 |
{ |
2829 |
17 Oct 14 |
nicklas |
var bioplate = bioplates[i]; |
2829 |
17 Oct 14 |
nicklas |
var option = new Option(bioplate.name, bioplate.id); |
2829 |
17 Oct 14 |
nicklas |
option.bioplate = bioplate; |
2829 |
17 Oct 14 |
nicklas |
plates.options[plates.length] = option; |
2829 |
17 Oct 14 |
nicklas |
76 |
} |
2829 |
17 Oct 14 |
nicklas |
bioplateIsValid = true; |
2829 |
17 Oct 14 |
nicklas |
Wizard.setInputStatus('bioplate', 'valid'); |
2829 |
17 Oct 14 |
nicklas |
79 |
} |
2829 |
17 Oct 14 |
nicklas |
else |
2829 |
17 Oct 14 |
nicklas |
81 |
{ |
2829 |
17 Oct 14 |
nicklas |
Wizard.setFatalError('No Library bioplates available for processing.'); |
3307 |
05 May 15 |
nicklas |
Doc.show('btnCreateManualPool2'); |
3307 |
05 May 15 |
nicklas |
Doc.hide('gorestart'); |
2829 |
17 Oct 14 |
nicklas |
return; |
2829 |
17 Oct 14 |
nicklas |
86 |
} |
2829 |
17 Oct 14 |
nicklas |
87 |
|
2829 |
17 Oct 14 |
nicklas |
Doc.show('step-1'); |
2829 |
17 Oct 14 |
nicklas |
Doc.show('gonext'); |
2829 |
17 Oct 14 |
nicklas |
90 |
} |
2829 |
17 Oct 14 |
nicklas |
91 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.createManualPool = function() |
2829 |
17 Oct 14 |
nicklas |
93 |
{ |
2829 |
17 Oct 14 |
nicklas |
location.replace('create_manual_pool.jsp?ID='+App.getSessionId()); |
2829 |
17 Oct 14 |
nicklas |
95 |
} |
2829 |
17 Oct 14 |
nicklas |
96 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.validateStep1 = function(event) |
2829 |
17 Oct 14 |
nicklas |
98 |
{} |
2829 |
17 Oct 14 |
nicklas |
99 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.initializeStep2 = function() |
2829 |
17 Oct 14 |
nicklas |
101 |
{ |
2829 |
17 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2829 |
17 Oct 14 |
nicklas |
var libPlate = frm.bioplate[frm.bioplate.selectedIndex].bioplate; |
2829 |
17 Oct 14 |
nicklas |
var schema = PoolSchema.getById(libPlate.poolSchema); |
3310 |
07 May 15 |
nicklas |
var columns = libPlate.columns; |
3310 |
07 May 15 |
nicklas |
var rows = libPlate.rows; |
2829 |
17 Oct 14 |
nicklas |
107 |
|
3310 |
07 May 15 |
nicklas |
var html = '<tr id="pool-row"></tr>'; |
3310 |
07 May 15 |
nicklas |
html += '<tr class="header">'; |
3310 |
07 May 15 |
nicklas |
html += '<th></th>'; |
3310 |
07 May 15 |
nicklas |
for (var c = 0; c < columns; c++) |
3310 |
07 May 15 |
nicklas |
112 |
{ |
3310 |
07 May 15 |
nicklas |
html += '<th id="col.'+c+'">'+(c+1)+'</th>'; |
3310 |
07 May 15 |
nicklas |
114 |
} |
3310 |
07 May 15 |
nicklas |
html += '</tr>'; |
3310 |
07 May 15 |
nicklas |
html += '<tbody>'; |
3310 |
07 May 15 |
nicklas |
117 |
|
3310 |
07 May 15 |
nicklas |
for (var r = 0; r < rows; r++) |
3310 |
07 May 15 |
nicklas |
119 |
{ |
3310 |
07 May 15 |
nicklas |
html += '<tr class="row-'+r+'">'; |
5883 |
26 Mar 20 |
nicklas |
html += '<th id="row.'+r+'" class="rowheader">'+(Reggie.wellToAlpha(r))+'</th>'; |
3310 |
07 May 15 |
nicklas |
122 |
|
3310 |
07 May 15 |
nicklas |
for (var c = 0; c < columns; c++) |
3310 |
07 May 15 |
nicklas |
124 |
{ |
3310 |
07 May 15 |
nicklas |
html += '<td class="well col-'+c+'" id="well.'+r+'.'+c+'"'; |
3310 |
07 May 15 |
nicklas |
html += ' data-col="'+c+'" data-row="'+r+'"'; |
3310 |
07 May 15 |
nicklas |
html += ' title="Select/deselect this well"></td>'; |
3310 |
07 May 15 |
nicklas |
128 |
} |
3310 |
07 May 15 |
nicklas |
html += '</tr>'; |
3310 |
07 May 15 |
nicklas |
130 |
} |
3310 |
07 May 15 |
nicklas |
html += '</tbody>'; |
3310 |
07 May 15 |
nicklas |
Doc.element('plate').innerHTML = html; |
3310 |
07 May 15 |
nicklas |
133 |
|
3310 |
07 May 15 |
nicklas |
var wells = Doc.element('plate').getElementsByClassName('well'); |
3310 |
07 May 15 |
nicklas |
for (var i = 0; i < wells.length; i++) |
3310 |
07 May 15 |
nicklas |
136 |
{ |
3310 |
07 May 15 |
nicklas |
Events.addEventHandler(wells[i], 'click', createpool.toggleWell); |
3310 |
07 May 15 |
nicklas |
138 |
} |
3310 |
07 May 15 |
nicklas |
139 |
|
2829 |
17 Oct 14 |
nicklas |
var url = '../Pool.servlet?ID='+App.getSessionId(); |
2829 |
17 Oct 14 |
nicklas |
url += '&cmd=GetNextAutoGeneratedPoolNames&numNames='+schema.numPools; |
3109 |
04 Feb 15 |
nicklas |
Wizard.showLoadingAnimation('Loading information about pools...'); |
2829 |
17 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, createpool.poolNamesLoaded); |
3109 |
04 Feb 15 |
nicklas |
144 |
} |
2829 |
17 Oct 14 |
nicklas |
145 |
|
3109 |
04 Feb 15 |
nicklas |
createpool.poolNamesLoaded = function(response) |
3109 |
04 Feb 15 |
nicklas |
147 |
{ |
3109 |
04 Feb 15 |
nicklas |
var list = response.names; |
3109 |
04 Feb 15 |
nicklas |
for (var i = 0; i < list.length; i++) |
3109 |
04 Feb 15 |
nicklas |
150 |
{ |
3109 |
04 Feb 15 |
nicklas |
POOL_NAMES[i] = list[i]; |
3109 |
04 Feb 15 |
nicklas |
152 |
} |
3109 |
04 Feb 15 |
nicklas |
153 |
|
3109 |
04 Feb 15 |
nicklas |
var frm = document.forms['reggie']; |
3109 |
04 Feb 15 |
nicklas |
var libPlate = frm.bioplate[frm.bioplate.selectedIndex].bioplate; |
2829 |
17 Oct 14 |
nicklas |
var url = '../Pool.servlet?ID='+App.getSessionId(); |
2829 |
17 Oct 14 |
nicklas |
url += '&cmd=GetLibraryInfoForPlate&bioplate='+libPlate.id; |
2829 |
17 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading information about libraries...'); |
2829 |
17 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, createpool.libraryInfoLoaded); |
2829 |
17 Oct 14 |
nicklas |
160 |
} |
2829 |
17 Oct 14 |
nicklas |
161 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.libraryInfoLoaded = function(response) |
2829 |
17 Oct 14 |
nicklas |
163 |
{ |
2829 |
17 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2829 |
17 Oct 14 |
nicklas |
var libPlate = frm.bioplate[frm.bioplate.selectedIndex].bioplate; |
2829 |
17 Oct 14 |
nicklas |
166 |
|
2829 |
17 Oct 14 |
nicklas |
var schema = PoolSchema.getById(libPlate.poolSchema); |
2829 |
17 Oct 14 |
nicklas |
var barcodeVariant = PoolSchema.getBarcodeVariantByName(schema, libPlate.barcodeVariant); |
2829 |
17 Oct 14 |
nicklas |
Plate.setPoolSchema(schema); |
2829 |
17 Oct 14 |
nicklas |
WellPainter.barcodeVariant = barcodeVariant; |
3310 |
07 May 15 |
nicklas |
WellPainter.plate = libPlate; |
3310 |
07 May 15 |
nicklas |
Plate.init(libPlate.rows, libPlate.columns, schema, WellPainter); |
2829 |
17 Oct 14 |
nicklas |
173 |
|
2829 |
17 Oct 14 |
nicklas |
var poolInfo = response.poolInfo; |
2829 |
17 Oct 14 |
nicklas |
LIMIT_FOR_EXTRA_LARGE_MIX = poolInfo.limitForExtraLargeMix; |
2829 |
17 Oct 14 |
nicklas |
var libs = response.libraries; |
3107 |
27 Jan 15 |
nicklas |
var molarityLimit = poolInfo.targetMolarity * LIMIT_FOR_AUTO_EXCLUDE; |
2829 |
17 Oct 14 |
nicklas |
for (var i = 0; i < libs.length; i++) |
2829 |
17 Oct 14 |
nicklas |
179 |
{ |
2829 |
17 Oct 14 |
nicklas |
var lib = libs[i]; |
2829 |
17 Oct 14 |
nicklas |
var well = lib.bioWell; |
2829 |
17 Oct 14 |
nicklas |
lib.excludeFromPool = false; |
3762 |
19 Feb 16 |
nicklas |
lib.isYellow = lib.specimen && lib.specimen.YellowLabel != null; |
2829 |
17 Oct 14 |
nicklas |
184 |
|
2829 |
17 Oct 14 |
nicklas |
if (lib.molarity != null && lib.molarity < molarityLimit) |
2829 |
17 Oct 14 |
nicklas |
186 |
{ |
2829 |
17 Oct 14 |
nicklas |
lib.excludeFromPool = true; |
2829 |
17 Oct 14 |
nicklas |
lib.flag = 'ExcludedFromPool'; |
2829 |
17 Oct 14 |
nicklas |
lib.comment = 'Not enough DNA'; |
2829 |
17 Oct 14 |
nicklas |
190 |
} |
2829 |
17 Oct 14 |
nicklas |
191 |
|
2829 |
17 Oct 14 |
nicklas |
Plate.getWell(well.row, well.column).setExtract(lib); |
2829 |
17 Oct 14 |
nicklas |
193 |
} |
2829 |
17 Oct 14 |
nicklas |
194 |
|
2829 |
17 Oct 14 |
nicklas |
Wizard.setCurrentStep(2); |
2829 |
17 Oct 14 |
nicklas |
Doc.show('gocancel'); |
2829 |
17 Oct 14 |
nicklas |
Doc.show('goregister'); |
2829 |
17 Oct 14 |
nicklas |
198 |
|
5883 |
26 Mar 20 |
nicklas |
PoolSchema.buildPoolTableRow(schema, libPlate.columns, false, null, null); |
2829 |
17 Oct 14 |
nicklas |
createpool.initPoolData(poolInfo.targetVolumePerLib); |
2829 |
17 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2829 |
17 Oct 14 |
nicklas |
202 |
} |
2829 |
17 Oct 14 |
nicklas |
203 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.initPoolData = function(targetVolumePerLib) |
2829 |
17 Oct 14 |
nicklas |
205 |
{ |
2837 |
20 Oct 14 |
nicklas |
var usePoolNo = -1; |
2829 |
17 Oct 14 |
nicklas |
for (var poolNo = 0; poolNo < Plate.getPools(); poolNo++) |
2829 |
17 Oct 14 |
nicklas |
208 |
{ |
2837 |
20 Oct 14 |
nicklas |
// Count libs |
2837 |
20 Oct 14 |
nicklas |
var numLibs = 0; |
2837 |
20 Oct 14 |
nicklas |
var wells = Plate.getPool(poolNo); |
2837 |
20 Oct 14 |
nicklas |
for (var wellNo = 0; wellNo < wells.length; wellNo++) |
2837 |
20 Oct 14 |
nicklas |
213 |
{ |
2837 |
20 Oct 14 |
nicklas |
var well = wells[wellNo]; |
2837 |
20 Oct 14 |
nicklas |
var lib = well.extract; |
2837 |
20 Oct 14 |
nicklas |
if (lib) |
2837 |
20 Oct 14 |
nicklas |
217 |
{ |
2837 |
20 Oct 14 |
nicklas |
numLibs++; |
2837 |
20 Oct 14 |
nicklas |
219 |
} |
2837 |
20 Oct 14 |
nicklas |
220 |
} |
2837 |
20 Oct 14 |
nicklas |
221 |
|
2829 |
17 Oct 14 |
nicklas |
var poolDiv = Doc.element('pool.'+poolNo); |
2837 |
20 Oct 14 |
nicklas |
if (numLibs > 0) |
2837 |
20 Oct 14 |
nicklas |
224 |
{ |
2837 |
20 Oct 14 |
nicklas |
usePoolNo++; |
2837 |
20 Oct 14 |
nicklas |
USED_POOL_NAMES[poolNo] = POOL_NAMES[usePoolNo]; |
2837 |
20 Oct 14 |
nicklas |
var html = ''; |
2837 |
20 Oct 14 |
nicklas |
html += '<div class="pool-name">'+Strings.encodeTags(USED_POOL_NAMES[poolNo])+'</div>'; |
2837 |
20 Oct 14 |
nicklas |
html += '<div class="pool-data">'; |
2837 |
20 Oct 14 |
nicklas |
html += '<table class="step-form">'; |
3107 |
27 Jan 15 |
nicklas |
html += '<tr><td class="prompt">Pool molarity</td>'; |
3107 |
27 Jan 15 |
nicklas |
html += '<td><select name="target_molarity.'+poolNo+'" id="target_molarity.'+poolNo+'" style="width: 4em;">'; |
3107 |
27 Jan 15 |
nicklas |
html += '<option value="1">1.0'; |
3107 |
27 Jan 15 |
nicklas |
html += '<option value="2" selected>2.0'; |
3107 |
27 Jan 15 |
nicklas |
html += '</select> nM</td>'; |
3107 |
27 Jan 15 |
nicklas |
html += '<td id="target_molarity.'+poolNo+'.status" class="status"> </td></tr>'; |
2837 |
20 Oct 14 |
nicklas |
html += '<tr><td class="prompt">Volume/lib</td>'; |
2837 |
20 Oct 14 |
nicklas |
html += '<td><input type="text" name="target_volume.'+poolNo+'" id="target_volume.'+poolNo+'"'; |
2837 |
20 Oct 14 |
nicklas |
html += ' style="width: 4em;" value="'+targetVolumePerLib+'">'; |
3107 |
27 Jan 15 |
nicklas |
html += ' µl ('+MIN_TARGET_VOLUME+'--'+MAX_TARGET_VOLUME+')</td>'; |
2837 |
20 Oct 14 |
nicklas |
html += '<td id="target_volume.'+poolNo+'.status" class="status"> </td></tr>'; |
2837 |
20 Oct 14 |
nicklas |
html += '<tr><td class="prompt">Mixing strategy</td>'; |
2837 |
20 Oct 14 |
nicklas |
html += '<td colspan="2">'; |
2837 |
20 Oct 14 |
nicklas |
html += '<label><input type="radio" name="mixing_strategy.'+poolNo+'" id="mixing_strategy.'+poolNo+'.dynamic"'; |
2837 |
20 Oct 14 |
nicklas |
html += ' value="dynamic" checked>Dynamic</label> '; |
2837 |
20 Oct 14 |
nicklas |
html += '<label><input type="radio" name="mixing_strategy.'+poolNo+'" id="mixing_strategy.'+poolNo+'.fixed"'; |
2837 |
20 Oct 14 |
nicklas |
html += ' value="fixed">Fixed</label>'; |
2837 |
20 Oct 14 |
nicklas |
html += '</td></tr>'; |
2837 |
20 Oct 14 |
nicklas |
html += '</table>'; |
2837 |
20 Oct 14 |
nicklas |
250 |
|
2837 |
20 Oct 14 |
nicklas |
html += '<textarea name="comment.'+poolNo+'"></textarea>'; |
2837 |
20 Oct 14 |
nicklas |
html += '</div>'; |
2837 |
20 Oct 14 |
nicklas |
html += '<div class="pool-summary" id="pool-summary.'+poolNo+'"></div>'; |
2837 |
20 Oct 14 |
nicklas |
poolDiv.innerHTML = html; |
2837 |
20 Oct 14 |
nicklas |
createpool.setTargetVolumePerLib(poolNo, targetVolumePerLib); |
2837 |
20 Oct 14 |
nicklas |
256 |
} |
2837 |
20 Oct 14 |
nicklas |
else |
2837 |
20 Oct 14 |
nicklas |
258 |
{ |
2837 |
20 Oct 14 |
nicklas |
poolDiv.innerHTML = ''; |
2837 |
20 Oct 14 |
nicklas |
260 |
} |
2829 |
17 Oct 14 |
nicklas |
261 |
} |
2829 |
17 Oct 14 |
nicklas |
262 |
|
2829 |
17 Oct 14 |
nicklas |
for (var poolNo = 0; poolNo < Plate.getPools(); poolNo++) |
2829 |
17 Oct 14 |
nicklas |
264 |
{ |
3107 |
27 Jan 15 |
nicklas |
Events.addEventHandler('target_molarity.'+poolNo, 'change', createpool.targetMolarityOnChange); |
2829 |
17 Oct 14 |
nicklas |
Events.addEventHandler('target_volume.'+poolNo, 'keypress', Events.numberOnly); |
2829 |
17 Oct 14 |
nicklas |
Events.addEventHandler('target_volume.'+poolNo, 'change', createpool.targetVolumeOnChange); |
2829 |
17 Oct 14 |
nicklas |
Events.doOnEnter('target_volume.'+poolNo, createpool.targetVolumeOnChange); |
2829 |
17 Oct 14 |
nicklas |
269 |
|
2829 |
17 Oct 14 |
nicklas |
Events.addEventHandler('mixing_strategy.'+poolNo+'.dynamic', 'click', createpool.mixingStrategyOnChange); |
2829 |
17 Oct 14 |
nicklas |
Events.addEventHandler('mixing_strategy.'+poolNo+'.fixed', 'click', createpool.mixingStrategyOnChange); |
2829 |
17 Oct 14 |
nicklas |
272 |
} |
2829 |
17 Oct 14 |
nicklas |
273 |
} |
2829 |
17 Oct 14 |
nicklas |
274 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.setTargetVolumePerLib = function(poolNo, targetVolumePerLib) |
2829 |
17 Oct 14 |
nicklas |
276 |
{ |
2829 |
17 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2829 |
17 Oct 14 |
nicklas |
if (targetVolumePerLib) |
2829 |
17 Oct 14 |
nicklas |
279 |
{ |
2829 |
17 Oct 14 |
nicklas |
frm['target_volume.'+poolNo].value = targetVolumePerLib; |
2829 |
17 Oct 14 |
nicklas |
281 |
} |
2829 |
17 Oct 14 |
nicklas |
else |
2829 |
17 Oct 14 |
nicklas |
283 |
{ |
2829 |
17 Oct 14 |
nicklas |
targetVolumePerLib = parseInt(frm['target_volume.'+poolNo].value); |
2829 |
17 Oct 14 |
nicklas |
285 |
} |
2829 |
17 Oct 14 |
nicklas |
286 |
|
2829 |
17 Oct 14 |
nicklas |
targetVolumePerLibIsValid[poolNo] = false; |
2829 |
17 Oct 14 |
nicklas |
if (targetVolumePerLib < MIN_TARGET_VOLUME || targetVolumePerLib > MAX_TARGET_VOLUME) |
2829 |
17 Oct 14 |
nicklas |
289 |
{ |
2829 |
17 Oct 14 |
nicklas |
Wizard.setInputStatus('target_volume.'+poolNo, 'invalid', 'Must be between '+MIN_TARGET_VOLUME+' and '+MAX_TARGET_VOLUME+'µl'); |
2829 |
17 Oct 14 |
nicklas |
return; |
2829 |
17 Oct 14 |
nicklas |
292 |
} |
2829 |
17 Oct 14 |
nicklas |
293 |
|
2829 |
17 Oct 14 |
nicklas |
Wizard.setInputStatus('target_volume.'+poolNo, 'valid'); |
2829 |
17 Oct 14 |
nicklas |
targetVolumePerLibIsValid[poolNo] = true; |
2829 |
17 Oct 14 |
nicklas |
296 |
|
2829 |
17 Oct 14 |
nicklas |
// Pre-process the Library items |
2829 |
17 Oct 14 |
nicklas |
var mixingStrategy = Forms.getCheckedRadio(frm['mixing_strategy.'+poolNo]).value; |
3107 |
27 Jan 15 |
nicklas |
var targetMolarityInPool = parseFloat(frm['target_molarity.'+poolNo].value); |
2829 |
17 Oct 14 |
nicklas |
var wells = Plate.getPool(poolNo); |
2829 |
17 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2829 |
17 Oct 14 |
nicklas |
302 |
{ |
2829 |
17 Oct 14 |
nicklas |
var lib = wells[i].extract; |
2829 |
17 Oct 14 |
nicklas |
if (lib) |
2829 |
17 Oct 14 |
nicklas |
305 |
{ |
2829 |
17 Oct 14 |
nicklas |
if (lib.remainingQuantity == null) |
2829 |
17 Oct 14 |
nicklas |
307 |
{ |
2829 |
17 Oct 14 |
nicklas |
lib.excludeFromPool = true; |
2829 |
17 Oct 14 |
nicklas |
309 |
} |
2829 |
17 Oct 14 |
nicklas |
else |
2829 |
17 Oct 14 |
nicklas |
311 |
{ |
3107 |
27 Jan 15 |
nicklas |
PoolMix.calculateLibVolume(lib, targetMolarityInPool, targetVolumePerLib, mixingStrategy); |
3107 |
27 Jan 15 |
nicklas |
PoolMix.calculateEbVolume(lib, targetMolarityInPool, targetVolumePerLib, mixingStrategy); |
2829 |
17 Oct 14 |
nicklas |
314 |
} |
2829 |
17 Oct 14 |
nicklas |
315 |
} |
2829 |
17 Oct 14 |
nicklas |
316 |
} |
2829 |
17 Oct 14 |
nicklas |
317 |
} |
2829 |
17 Oct 14 |
nicklas |
318 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.targetVolumeOnChange = function(event) |
2829 |
17 Oct 14 |
nicklas |
320 |
{ |
2829 |
17 Oct 14 |
nicklas |
var poolNo = parseInt(event.target.name.substr(-1)); |
2829 |
17 Oct 14 |
nicklas |
createpool.setTargetVolumePerLib(poolNo); |
2829 |
17 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2829 |
17 Oct 14 |
nicklas |
324 |
} |
2829 |
17 Oct 14 |
nicklas |
325 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.mixingStrategyOnChange = function(event) |
2829 |
17 Oct 14 |
nicklas |
327 |
{ |
2829 |
17 Oct 14 |
nicklas |
createpool.targetVolumeOnChange(event); |
2829 |
17 Oct 14 |
nicklas |
329 |
} |
2829 |
17 Oct 14 |
nicklas |
330 |
|
3107 |
27 Jan 15 |
nicklas |
createpool.targetMolarityOnChange = function(event) |
3107 |
27 Jan 15 |
nicklas |
332 |
{ |
3107 |
27 Jan 15 |
nicklas |
createpool.targetVolumeOnChange(event); |
3107 |
27 Jan 15 |
nicklas |
334 |
} |
3107 |
27 Jan 15 |
nicklas |
335 |
|
3310 |
07 May 15 |
nicklas |
createpool.calculateRemarks = function(plate, lib, schema, barcodeVariant) |
2829 |
17 Oct 14 |
nicklas |
337 |
{ |
2829 |
17 Oct 14 |
nicklas |
var well = lib.bioWell; |
2829 |
17 Oct 14 |
nicklas |
var remarks = []; |
2829 |
17 Oct 14 |
nicklas |
340 |
|
2829 |
17 Oct 14 |
nicklas |
// Check if default barcode has been modified |
2829 |
17 Oct 14 |
nicklas |
var indexSet = barcodeVariant.indexSets[well.column]; |
2829 |
17 Oct 14 |
nicklas |
if (indexSet) |
2829 |
17 Oct 14 |
nicklas |
344 |
{ |
2829 |
17 Oct 14 |
nicklas |
var defaultBarcode = indexSet.barcodes[well.row]; |
2829 |
17 Oct 14 |
nicklas |
if (defaultBarcode && lib.barcode.name != defaultBarcode) |
2829 |
17 Oct 14 |
nicklas |
347 |
{ |
2829 |
17 Oct 14 |
nicklas |
remarks[remarks.length] = 'Modified barcode'; |
2829 |
17 Oct 14 |
nicklas |
lib.barcode.modified = true; |
2829 |
17 Oct 14 |
nicklas |
350 |
} |
2829 |
17 Oct 14 |
nicklas |
351 |
} |
2829 |
17 Oct 14 |
nicklas |
352 |
|
2829 |
17 Oct 14 |
nicklas |
if (lib.molarity != null) |
2829 |
17 Oct 14 |
nicklas |
354 |
{ |
2829 |
17 Oct 14 |
nicklas |
if (lib.volume != lib.actualVolume) |
2829 |
17 Oct 14 |
nicklas |
356 |
{ |
2829 |
17 Oct 14 |
nicklas |
if (lib.volume > lib.remainingVolume) |
2829 |
17 Oct 14 |
nicklas |
358 |
{ |
2829 |
17 Oct 14 |
nicklas |
remarks[remarks.length] = 'Low quantity'; |
2829 |
17 Oct 14 |
nicklas |
360 |
} |
2829 |
17 Oct 14 |
nicklas |
else |
2829 |
17 Oct 14 |
nicklas |
362 |
{ |
2829 |
17 Oct 14 |
nicklas |
remarks[remarks.length] = 'Low molarity'; |
2829 |
17 Oct 14 |
nicklas |
364 |
} |
2829 |
17 Oct 14 |
nicklas |
365 |
} |
2829 |
17 Oct 14 |
nicklas |
366 |
|
2829 |
17 Oct 14 |
nicklas |
if (lib.speedVacConc != null) |
2829 |
17 Oct 14 |
nicklas |
368 |
{ |
2829 |
17 Oct 14 |
nicklas |
remarks[remarks.length] = 'SpeedVac'; |
2829 |
17 Oct 14 |
nicklas |
370 |
} |
2829 |
17 Oct 14 |
nicklas |
371 |
|
2829 |
17 Oct 14 |
nicklas |
if (lib.mixFactor > 1) |
2829 |
17 Oct 14 |
nicklas |
373 |
{ |
2829 |
17 Oct 14 |
nicklas |
// Larger mix than default |
2829 |
17 Oct 14 |
nicklas |
remarks[remarks.length] = 'Use ' + Numbers.formatNumber(lib.actualVolume+lib.actualEb, 1, 'µl') + ' in pool'; |
2829 |
17 Oct 14 |
nicklas |
376 |
} |
2829 |
17 Oct 14 |
nicklas |
377 |
|
2829 |
17 Oct 14 |
nicklas |
378 |
} |
2829 |
17 Oct 14 |
nicklas |
379 |
|
5883 |
26 Mar 20 |
nicklas |
if (lib.libraryFracAdpt == null) |
2829 |
17 Oct 14 |
nicklas |
381 |
{ |
5883 |
26 Mar 20 |
nicklas |
remarks[remarks.length] = 'Unknown adapter fraction'; |
2829 |
17 Oct 14 |
nicklas |
383 |
} |
5883 |
26 Mar 20 |
nicklas |
else if (lib.libraryFracAdpt > LIBRARY_FRAC_ADPT_LIMIT) |
5883 |
26 Mar 20 |
nicklas |
385 |
{ |
5883 |
26 Mar 20 |
nicklas |
remarks[remarks.length] = 'High adapter fraction'; |
5883 |
26 Mar 20 |
nicklas |
387 |
} |
2829 |
17 Oct 14 |
nicklas |
388 |
|
2829 |
17 Oct 14 |
nicklas |
lib.stratagene = Reggie.isStratagene(lib.name); |
2829 |
17 Oct 14 |
nicklas |
lib.external = Reggie.isExternal(lib.name); |
2829 |
17 Oct 14 |
nicklas |
lib.remarks = remarks; |
2829 |
17 Oct 14 |
nicklas |
392 |
} |
2829 |
17 Oct 14 |
nicklas |
393 |
|
2829 |
17 Oct 14 |
nicklas |
394 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.updatePoolData = function() |
2829 |
17 Oct 14 |
nicklas |
396 |
{ |
2829 |
17 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2829 |
17 Oct 14 |
nicklas |
398 |
|
2829 |
17 Oct 14 |
nicklas |
var libPlate = frm.bioplate[frm.bioplate.selectedIndex].bioplate; |
2829 |
17 Oct 14 |
nicklas |
var schema = PoolSchema.getById(libPlate.poolSchema); |
2829 |
17 Oct 14 |
nicklas |
var barcodeVariant = PoolSchema.getBarcodeVariantByName(schema, libPlate.barcodeVariant); |
2829 |
17 Oct 14 |
nicklas |
402 |
|
2829 |
17 Oct 14 |
nicklas |
for (var poolNo = 0; poolNo < Plate.getPools(); poolNo++) |
2829 |
17 Oct 14 |
nicklas |
404 |
{ |
2829 |
17 Oct 14 |
nicklas |
var numSeparateMix = 0; |
2829 |
17 Oct 14 |
nicklas |
var numLowQuantity = 0; |
2829 |
17 Oct 14 |
nicklas |
var numExcluded = 0; |
2829 |
17 Oct 14 |
nicklas |
408 |
|
2829 |
17 Oct 14 |
nicklas |
// Get all libs into an array |
2829 |
17 Oct 14 |
nicklas |
var libs = []; |
2829 |
17 Oct 14 |
nicklas |
var wells = Plate.getPool(poolNo); |
2829 |
17 Oct 14 |
nicklas |
for (var wellNo = 0; wellNo < wells.length; wellNo++) |
2829 |
17 Oct 14 |
nicklas |
413 |
{ |
2829 |
17 Oct 14 |
nicklas |
var well = wells[wellNo]; |
2829 |
17 Oct 14 |
nicklas |
var lib = well.extract; |
2829 |
17 Oct 14 |
nicklas |
if (lib) |
2829 |
17 Oct 14 |
nicklas |
417 |
{ |
2829 |
17 Oct 14 |
nicklas |
if (lib.excludeFromPool) |
2829 |
17 Oct 14 |
nicklas |
419 |
{ |
2829 |
17 Oct 14 |
nicklas |
numExcluded++; |
2829 |
17 Oct 14 |
nicklas |
421 |
} |
2829 |
17 Oct 14 |
nicklas |
else |
2829 |
17 Oct 14 |
nicklas |
423 |
{ |
2829 |
17 Oct 14 |
nicklas |
libs[libs.length] = lib; |
2829 |
17 Oct 14 |
nicklas |
425 |
} |
2829 |
17 Oct 14 |
nicklas |
426 |
} |
2829 |
17 Oct 14 |
nicklas |
427 |
} |
2829 |
17 Oct 14 |
nicklas |
428 |
|
2837 |
20 Oct 14 |
nicklas |
if (libs.length == 0) |
2837 |
20 Oct 14 |
nicklas |
430 |
{ |
2837 |
20 Oct 14 |
nicklas |
// There are no libs in this pool... |
2837 |
20 Oct 14 |
nicklas |
Plate.paint(wells); |
2837 |
20 Oct 14 |
nicklas |
continue; |
2837 |
20 Oct 14 |
nicklas |
434 |
} |
2837 |
20 Oct 14 |
nicklas |
435 |
|
2829 |
17 Oct 14 |
nicklas |
// Calculate final pool volumes, molarity, etc. |
2829 |
17 Oct 14 |
nicklas |
var targetVolumePerLib = parseFloat(frm['target_volume.'+poolNo].value); |
2829 |
17 Oct 14 |
nicklas |
var mixingStrategy = Forms.getCheckedRadio(frm['mixing_strategy.'+poolNo]).value; |
3107 |
27 Jan 15 |
nicklas |
var targetMolarityInPool = parseFloat(frm['target_molarity.'+poolNo].value); |
3107 |
27 Jan 15 |
nicklas |
var poolInfo = PoolMix.calculateFinalPoolInfo(libs, targetMolarityInPool, targetVolumePerLib, mixingStrategy); |
2829 |
17 Oct 14 |
nicklas |
POOL_DATA[poolNo] = poolInfo; |
2829 |
17 Oct 14 |
nicklas |
442 |
|
2829 |
17 Oct 14 |
nicklas |
// Make remarks for each lib |
2829 |
17 Oct 14 |
nicklas |
for (var libNo = 0; libNo < libs.length; libNo++) |
2829 |
17 Oct 14 |
nicklas |
445 |
{ |
2829 |
17 Oct 14 |
nicklas |
var lib = libs[libNo]; |
3310 |
07 May 15 |
nicklas |
createpool.calculateRemarks(libPlate, lib, schema, barcodeVariant); |
2829 |
17 Oct 14 |
nicklas |
if (lib.eb != 0 || mixingStrategy == 'fixed') numSeparateMix++; |
2829 |
17 Oct 14 |
nicklas |
if (lib.volume > lib.actualVolume) numLowQuantity++; |
2829 |
17 Oct 14 |
nicklas |
450 |
} |
2829 |
17 Oct 14 |
nicklas |
451 |
|
2829 |
17 Oct 14 |
nicklas |
Plate.paint(wells); |
2829 |
17 Oct 14 |
nicklas |
453 |
|
2829 |
17 Oct 14 |
nicklas |
var warnMsg = null; |
2829 |
17 Oct 14 |
nicklas |
if (poolInfo.ebVolumeExtra < 0) |
2829 |
17 Oct 14 |
nicklas |
456 |
{ |
2829 |
17 Oct 14 |
nicklas |
warnMsg = 'Too many libs with low molarity'; |
2829 |
17 Oct 14 |
nicklas |
458 |
} |
2829 |
17 Oct 14 |
nicklas |
459 |
|
2829 |
17 Oct 14 |
nicklas |
var poolDiv = Doc.element('pool.'+poolNo); |
2829 |
17 Oct 14 |
nicklas |
var summaryDiv = Doc.element('pool-summary.'+poolNo); |
2829 |
17 Oct 14 |
nicklas |
var poolData = ''; |
2829 |
17 Oct 14 |
nicklas |
poolData += libs.length + ' libs • '; |
2829 |
17 Oct 14 |
nicklas |
poolData += Numbers.formatNumber(poolInfo.molarity, 2, 'nM')+' • '; |
2829 |
17 Oct 14 |
nicklas |
poolData += Numbers.formatNumber(poolInfo.totalVolume, 1, 'µl'); |
2829 |
17 Oct 14 |
nicklas |
if (mixingStrategy == 'dynamic') |
2829 |
17 Oct 14 |
nicklas |
467 |
{ |
2829 |
17 Oct 14 |
nicklas |
poolData += ' • <span class="pool-eb">'+Numbers.formatNumber(poolInfo.ebVolumeExtra, 1, 'µl')+'</span>'; |
2829 |
17 Oct 14 |
nicklas |
469 |
} |
2829 |
17 Oct 14 |
nicklas |
if (numSeparateMix > 0 || numLowQuantity) |
2829 |
17 Oct 14 |
nicklas |
471 |
{ |
2829 |
17 Oct 14 |
nicklas |
poolData += '<br>Separate mix: ' + numSeparateMix; |
2829 |
17 Oct 14 |
nicklas |
poolData += ' • Low quantity: ' + numLowQuantity; |
2829 |
17 Oct 14 |
nicklas |
poolData += ''; |
2829 |
17 Oct 14 |
nicklas |
475 |
} |
2829 |
17 Oct 14 |
nicklas |
476 |
|
2829 |
17 Oct 14 |
nicklas |
if (warnMsg) |
2829 |
17 Oct 14 |
nicklas |
478 |
{ |
2829 |
17 Oct 14 |
nicklas |
Doc.addClass(poolDiv, 'warning'); |
2829 |
17 Oct 14 |
nicklas |
poolData += '<div class="warning-message">'+warnMsg+'</div>'; |
2829 |
17 Oct 14 |
nicklas |
481 |
} |
2829 |
17 Oct 14 |
nicklas |
else |
2829 |
17 Oct 14 |
nicklas |
483 |
{ |
2829 |
17 Oct 14 |
nicklas |
Doc.removeClass(poolDiv, 'warning'); |
2829 |
17 Oct 14 |
nicklas |
485 |
} |
2829 |
17 Oct 14 |
nicklas |
summaryDiv.innerHTML = poolData; |
2829 |
17 Oct 14 |
nicklas |
487 |
} |
2829 |
17 Oct 14 |
nicklas |
488 |
} |
2829 |
17 Oct 14 |
nicklas |
489 |
|
2931 |
14 Nov 14 |
nicklas |
var contextWell = null; |
2931 |
14 Nov 14 |
nicklas |
var contextX; |
2931 |
14 Nov 14 |
nicklas |
var contextY; |
2931 |
14 Nov 14 |
nicklas |
createpool.forgetContext = function() |
2931 |
14 Nov 14 |
nicklas |
494 |
{ |
2931 |
14 Nov 14 |
nicklas |
contextWell = null; |
2931 |
14 Nov 14 |
nicklas |
496 |
} |
2931 |
14 Nov 14 |
nicklas |
497 |
|
2931 |
14 Nov 14 |
nicklas |
498 |
/** |
2931 |
14 Nov 14 |
nicklas |
Reacts to 'mouseup' and 'contextmenu' events for the bioplate. |
2931 |
14 Nov 14 |
nicklas |
This should bring up the cut/copy/paste context menu depending on which |
2931 |
14 Nov 14 |
nicklas |
mouse button that was clicked. |
2931 |
14 Nov 14 |
nicklas |
502 |
*/ |
2931 |
14 Nov 14 |
nicklas |
createpool.contextEvent = function(event) |
2931 |
14 Nov 14 |
nicklas |
504 |
{ |
2931 |
14 Nov 14 |
nicklas |
// Context menu on 'right' mouse button |
2931 |
14 Nov 14 |
nicklas |
// Can't just check the button since two events are sent ('mouseup' and 'contextmenu') |
2931 |
14 Nov 14 |
nicklas |
var showContext = event.type == 'contextmenu' && event.button == 2; |
2931 |
14 Nov 14 |
nicklas |
508 |
|
2931 |
14 Nov 14 |
nicklas |
if (showContext) |
2931 |
14 Nov 14 |
nicklas |
510 |
{ |
2931 |
14 Nov 14 |
nicklas |
event.preventDefault(); // Prevents the default right-click menu from appearing |
2931 |
14 Nov 14 |
nicklas |
512 |
|
2931 |
14 Nov 14 |
nicklas |
// Get the well that is right-clicked and the Library that is in it |
2931 |
14 Nov 14 |
nicklas |
contextWell = null; |
2931 |
14 Nov 14 |
nicklas |
var well = event.target; |
2931 |
14 Nov 14 |
nicklas |
while (well && (!well.id || well.id.indexOf('well') != 0)) |
2931 |
14 Nov 14 |
nicklas |
517 |
{ |
2931 |
14 Nov 14 |
nicklas |
well = well.parentNode; |
2931 |
14 Nov 14 |
nicklas |
519 |
} |
2931 |
14 Nov 14 |
nicklas |
if (well) |
2931 |
14 Nov 14 |
nicklas |
521 |
{ |
2931 |
14 Nov 14 |
nicklas |
var c = well.id.split(/\./); |
2931 |
14 Nov 14 |
nicklas |
var tmp = Plate.getWell(parseInt(c[1]), parseInt(c[2])); |
2931 |
14 Nov 14 |
nicklas |
if (tmp.extract) contextWell = tmp; |
2931 |
14 Nov 14 |
nicklas |
525 |
} |
2931 |
14 Nov 14 |
nicklas |
526 |
|
2931 |
14 Nov 14 |
nicklas |
if (!contextWell) return; |
2931 |
14 Nov 14 |
nicklas |
528 |
|
2931 |
14 Nov 14 |
nicklas |
// Update the context meny |
2931 |
14 Nov 14 |
nicklas |
var caseSummaryMenu = Doc.element('mnuCaseSummary'); |
2931 |
14 Nov 14 |
nicklas |
if (contextWell) |
2931 |
14 Nov 14 |
nicklas |
532 |
{ |
2931 |
14 Nov 14 |
nicklas |
caseSummaryMenu.title = 'Show case summary for ' + Strings.encodeTags(contextWell.extract.name); |
2931 |
14 Nov 14 |
nicklas |
Doc.show('sepCaseSummary'); |
2931 |
14 Nov 14 |
nicklas |
Doc.show('mnuCaseSummary'); |
2931 |
14 Nov 14 |
nicklas |
536 |
} |
2931 |
14 Nov 14 |
nicklas |
else |
2931 |
14 Nov 14 |
nicklas |
538 |
{ |
2931 |
14 Nov 14 |
nicklas |
Doc.hide('sepCaseSummary'); |
2931 |
14 Nov 14 |
nicklas |
Doc.hide('mnuCaseSummary'); |
2931 |
14 Nov 14 |
nicklas |
541 |
} |
2931 |
14 Nov 14 |
nicklas |
542 |
|
2931 |
14 Nov 14 |
nicklas |
var menu = Doc.element('menuContext'); |
2931 |
14 Nov 14 |
nicklas |
// 1 pixel offset to avoid losing well focus outline |
2931 |
14 Nov 14 |
nicklas |
contextX = event.clientX+1; |
2931 |
14 Nov 14 |
nicklas |
contextY = event.clientY+1; |
2931 |
14 Nov 14 |
nicklas |
// Need short delay since 'mouseup' are also sent as 'click' events |
2931 |
14 Nov 14 |
nicklas |
// to the 'document' object which BASE already have a Menu.hideAll() |
2931 |
14 Nov 14 |
nicklas |
// call which would hide the menu immediately |
2931 |
14 Nov 14 |
nicklas |
App.debug('show-context:'+contextX+':'+contextY+':'+contextWell); |
2931 |
14 Nov 14 |
nicklas |
setTimeout(createpool.showContextMenu, 100); |
2931 |
14 Nov 14 |
nicklas |
552 |
} |
2931 |
14 Nov 14 |
nicklas |
553 |
} |
2829 |
17 Oct 14 |
nicklas |
554 |
|
2931 |
14 Nov 14 |
nicklas |
createpool.showContextMenu = function() |
2931 |
14 Nov 14 |
nicklas |
556 |
{ |
2931 |
14 Nov 14 |
nicklas |
Menu.showTopMenu('menuContext', contextX, contextY); |
2931 |
14 Nov 14 |
nicklas |
558 |
} |
2931 |
14 Nov 14 |
nicklas |
559 |
|
2931 |
14 Nov 14 |
nicklas |
createpool.showCaseSummary = function() |
2931 |
14 Nov 14 |
nicklas |
561 |
{ |
2931 |
14 Nov 14 |
nicklas |
if (!contextWell) return; |
5019 |
10 Oct 18 |
nicklas |
Reggie.openCaseSummaryPopup(contextWell.extract.name); |
2931 |
14 Nov 14 |
nicklas |
564 |
} |
2931 |
14 Nov 14 |
nicklas |
565 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.validateStep2 = function(event) |
2829 |
17 Oct 14 |
nicklas |
567 |
{ |
2829 |
17 Oct 14 |
nicklas |
var numPools = Plate.getPools(); |
2829 |
17 Oct 14 |
nicklas |
for (var poolNo = 0; poolNo < numPools; poolNo++) |
2829 |
17 Oct 14 |
nicklas |
570 |
{ |
2837 |
20 Oct 14 |
nicklas |
if (USED_POOL_NAMES[poolNo] && !targetVolumePerLibIsValid[poolNo]) |
2829 |
17 Oct 14 |
nicklas |
572 |
{ |
2829 |
17 Oct 14 |
nicklas |
event.preventDefault(); |
2829 |
17 Oct 14 |
nicklas |
return; |
2829 |
17 Oct 14 |
nicklas |
575 |
} |
2829 |
17 Oct 14 |
nicklas |
576 |
} |
2829 |
17 Oct 14 |
nicklas |
577 |
} |
2829 |
17 Oct 14 |
nicklas |
578 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.submit = function() |
2829 |
17 Oct 14 |
nicklas |
580 |
{ |
2829 |
17 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2829 |
17 Oct 14 |
nicklas |
582 |
|
2829 |
17 Oct 14 |
nicklas |
var submitInfo = {}; |
2829 |
17 Oct 14 |
nicklas |
submitInfo.pools = []; |
2829 |
17 Oct 14 |
nicklas |
submitInfo.flagged = []; |
2829 |
17 Oct 14 |
nicklas |
586 |
|
2829 |
17 Oct 14 |
nicklas |
var libPlate = frm.bioplate[frm.bioplate.selectedIndex].bioplate; |
2829 |
17 Oct 14 |
nicklas |
588 |
|
2829 |
17 Oct 14 |
nicklas |
var numPools = Plate.getPools(); |
2829 |
17 Oct 14 |
nicklas |
for (var poolNo = 0; poolNo < numPools; poolNo++) |
2829 |
17 Oct 14 |
nicklas |
591 |
{ |
2837 |
20 Oct 14 |
nicklas |
if (!USED_POOL_NAMES[poolNo]) |
2837 |
20 Oct 14 |
nicklas |
593 |
{ |
2837 |
20 Oct 14 |
nicklas |
continue; |
2837 |
20 Oct 14 |
nicklas |
595 |
} |
2829 |
17 Oct 14 |
nicklas |
var wells = Plate.getPool(poolNo); |
2837 |
20 Oct 14 |
nicklas |
597 |
|
2829 |
17 Oct 14 |
nicklas |
var poolInfo = {}; |
2837 |
20 Oct 14 |
nicklas |
poolInfo.name = USED_POOL_NAMES[poolNo]; |
3107 |
27 Jan 15 |
nicklas |
poolInfo.targetPoolMolarity = parseFloat(frm['target_molarity.'+poolNo].value); |
2829 |
17 Oct 14 |
nicklas |
poolInfo.targetVolumeInPoolPerLib = parseFloat(frm['target_volume.'+poolNo].value); |
2829 |
17 Oct 14 |
nicklas |
var mixingStrategy = Forms.getCheckedRadio(frm['mixing_strategy.'+poolNo]).value; |
2829 |
17 Oct 14 |
nicklas |
poolInfo.mixingStrategy = mixingStrategy; |
2829 |
17 Oct 14 |
nicklas |
poolInfo.comment = frm['comment.'+poolNo].value; |
2829 |
17 Oct 14 |
nicklas |
poolInfo.ebVolumeExtra = POOL_DATA[poolNo].ebVolumeExtra; |
2829 |
17 Oct 14 |
nicklas |
poolInfo.libPlate = libPlate.id; |
2829 |
17 Oct 14 |
nicklas |
poolInfo.libs = []; |
2829 |
17 Oct 14 |
nicklas |
poolInfo.excluded = []; |
2829 |
17 Oct 14 |
nicklas |
609 |
|
2829 |
17 Oct 14 |
nicklas |
for (var wellNo = 0; wellNo < wells.length; wellNo++) |
2829 |
17 Oct 14 |
nicklas |
611 |
{ |
2829 |
17 Oct 14 |
nicklas |
var lib = wells[wellNo].extract; |
2829 |
17 Oct 14 |
nicklas |
if (lib) |
2829 |
17 Oct 14 |
nicklas |
614 |
{ |
2829 |
17 Oct 14 |
nicklas |
// We send library id, name and mixin volumes |
2829 |
17 Oct 14 |
nicklas |
var tmp = {}; |
2829 |
17 Oct 14 |
nicklas |
tmp.id = lib.id; |
2829 |
17 Oct 14 |
nicklas |
tmp.name = lib.name; |
2829 |
17 Oct 14 |
nicklas |
tmp.volume = lib.actualVolume; |
2829 |
17 Oct 14 |
nicklas |
tmp.eb = lib.actualEb; |
2829 |
17 Oct 14 |
nicklas |
tmp.mixFactor = lib.mixFactor; |
2829 |
17 Oct 14 |
nicklas |
if (lib.mixFactor > 1 && lib.targetVolume && mixingStrategy == 'dynamic') |
2829 |
17 Oct 14 |
nicklas |
623 |
{ |
2829 |
17 Oct 14 |
nicklas |
tmp.targetVolume = lib.targetVolume; |
2829 |
17 Oct 14 |
nicklas |
625 |
} |
2829 |
17 Oct 14 |
nicklas |
tmp.comment = lib.comment; |
2829 |
17 Oct 14 |
nicklas |
627 |
|
2829 |
17 Oct 14 |
nicklas |
if (lib.excludeFromPool) |
2829 |
17 Oct 14 |
nicklas |
629 |
{ |
2829 |
17 Oct 14 |
nicklas |
poolInfo.excluded[poolInfo.excluded.length] = tmp; |
2829 |
17 Oct 14 |
nicklas |
631 |
} |
2829 |
17 Oct 14 |
nicklas |
else |
2829 |
17 Oct 14 |
nicklas |
633 |
{ |
2829 |
17 Oct 14 |
nicklas |
poolInfo.libs[poolInfo.libs.length] = tmp; |
2829 |
17 Oct 14 |
nicklas |
635 |
} |
2829 |
17 Oct 14 |
nicklas |
636 |
|
2829 |
17 Oct 14 |
nicklas |
if (lib.flag) |
2829 |
17 Oct 14 |
nicklas |
638 |
{ |
2829 |
17 Oct 14 |
nicklas |
tmp.flag = lib.flag; |
2829 |
17 Oct 14 |
nicklas |
submitInfo.flagged[submitInfo.flagged.length] = tmp; |
2829 |
17 Oct 14 |
nicklas |
641 |
} |
2829 |
17 Oct 14 |
nicklas |
642 |
} |
2829 |
17 Oct 14 |
nicklas |
643 |
} |
2829 |
17 Oct 14 |
nicklas |
644 |
|
2829 |
17 Oct 14 |
nicklas |
submitInfo.pools[submitInfo.pools.length] = poolInfo; |
2829 |
17 Oct 14 |
nicklas |
646 |
} |
2829 |
17 Oct 14 |
nicklas |
647 |
|
2829 |
17 Oct 14 |
nicklas |
var url = '../Pool.servlet?ID='+App.getSessionId(); |
2829 |
17 Oct 14 |
nicklas |
url += '&cmd=CreatePools'; |
2829 |
17 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2829 |
17 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, createpool.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2829 |
17 Oct 14 |
nicklas |
652 |
} |
2829 |
17 Oct 14 |
nicklas |
653 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.submissionResults = function(response) |
2829 |
17 Oct 14 |
nicklas |
655 |
{ |
2829 |
17 Oct 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2829 |
17 Oct 14 |
nicklas |
Doc.show('gorestart'); |
2829 |
17 Oct 14 |
nicklas |
658 |
} |
2829 |
17 Oct 14 |
nicklas |
659 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.initElements = function(element, autoInit) |
2829 |
17 Oct 14 |
nicklas |
661 |
{ |
2829 |
17 Oct 14 |
nicklas |
if (autoInit == 'plate-well') |
2829 |
17 Oct 14 |
nicklas |
663 |
{ |
2829 |
17 Oct 14 |
nicklas |
Events.addEventHandler(element, 'click', createpool.toggleWell); |
2829 |
17 Oct 14 |
nicklas |
665 |
} |
2829 |
17 Oct 14 |
nicklas |
666 |
} |
2829 |
17 Oct 14 |
nicklas |
667 |
|
2829 |
17 Oct 14 |
nicklas |
//Toggle the selected status of a single well |
2829 |
17 Oct 14 |
nicklas |
createpool.toggleWell = function(event) |
2829 |
17 Oct 14 |
nicklas |
670 |
{ |
2829 |
17 Oct 14 |
nicklas |
var row = Data.int(event.currentTarget, 'row'); |
2829 |
17 Oct 14 |
nicklas |
var column = Data.int(event.currentTarget, 'col'); |
2829 |
17 Oct 14 |
nicklas |
var well = Plate.getWell(row, column); |
2829 |
17 Oct 14 |
nicklas |
Plate.toggleSelected([well]); |
2829 |
17 Oct 14 |
nicklas |
675 |
} |
2829 |
17 Oct 14 |
nicklas |
676 |
|
2829 |
17 Oct 14 |
nicklas |
var lastComment = ''; |
2829 |
17 Oct 14 |
nicklas |
createpool.excludeSelected = function(event) |
2829 |
17 Oct 14 |
nicklas |
679 |
{ |
2829 |
17 Oct 14 |
nicklas |
var wells = Plate.getSelected(); |
2931 |
14 Nov 14 |
nicklas |
if (wells.length == 0 && contextWell) wells = [ contextWell ]; |
2829 |
17 Oct 14 |
nicklas |
if (wells.length == 0) |
2829 |
17 Oct 14 |
nicklas |
683 |
{ |
2829 |
17 Oct 14 |
nicklas |
Forms.showNotification(event.currentTarget, 'No wells have been selected'); |
2829 |
17 Oct 14 |
nicklas |
return; |
2829 |
17 Oct 14 |
nicklas |
686 |
} |
2829 |
17 Oct 14 |
nicklas |
687 |
|
2829 |
17 Oct 14 |
nicklas |
// See if there is an existing comment |
2829 |
17 Oct 14 |
nicklas |
var comment; |
2829 |
17 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2829 |
17 Oct 14 |
nicklas |
691 |
{ |
2829 |
17 Oct 14 |
nicklas |
var lib = wells[i].extract; |
2829 |
17 Oct 14 |
nicklas |
if (lib && lib.comment) |
2829 |
17 Oct 14 |
nicklas |
694 |
{ |
2829 |
17 Oct 14 |
nicklas |
comment = lib.comment; |
2829 |
17 Oct 14 |
nicklas |
696 |
} |
2829 |
17 Oct 14 |
nicklas |
697 |
} |
2829 |
17 Oct 14 |
nicklas |
698 |
|
2829 |
17 Oct 14 |
nicklas |
comment = prompt('Comment on reason for exclusion', comment || lastComment); |
2829 |
17 Oct 14 |
nicklas |
if (comment == null) return; |
2829 |
17 Oct 14 |
nicklas |
lastComment = comment; |
2829 |
17 Oct 14 |
nicklas |
702 |
|
2829 |
17 Oct 14 |
nicklas |
if (comment == '') comment = null; |
2829 |
17 Oct 14 |
nicklas |
704 |
|
2829 |
17 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2829 |
17 Oct 14 |
nicklas |
706 |
{ |
2829 |
17 Oct 14 |
nicklas |
var well = wells[i]; |
2829 |
17 Oct 14 |
nicklas |
var lib = well.extract; |
2829 |
17 Oct 14 |
nicklas |
if (lib) |
2829 |
17 Oct 14 |
nicklas |
710 |
{ |
2829 |
17 Oct 14 |
nicklas |
lib.excludeFromPool = true; |
2829 |
17 Oct 14 |
nicklas |
if (!lib.stratagene && !lib.external) |
2829 |
17 Oct 14 |
nicklas |
713 |
{ |
2829 |
17 Oct 14 |
nicklas |
lib.flag = 'ExcludedFromPool'; |
2829 |
17 Oct 14 |
nicklas |
lib.comment = comment; |
2829 |
17 Oct 14 |
nicklas |
716 |
} |
2829 |
17 Oct 14 |
nicklas |
717 |
} |
2829 |
17 Oct 14 |
nicklas |
well.selected = false; |
2829 |
17 Oct 14 |
nicklas |
719 |
} |
2829 |
17 Oct 14 |
nicklas |
720 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2829 |
17 Oct 14 |
nicklas |
722 |
} |
2829 |
17 Oct 14 |
nicklas |
723 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.includeSelected = function(event) |
2829 |
17 Oct 14 |
nicklas |
725 |
{ |
2829 |
17 Oct 14 |
nicklas |
var wells = Plate.getSelected(); |
2931 |
14 Nov 14 |
nicklas |
if (wells.length == 0 && contextWell) wells = [ contextWell ]; |
2829 |
17 Oct 14 |
nicklas |
if (wells.length == 0) |
2829 |
17 Oct 14 |
nicklas |
729 |
{ |
2829 |
17 Oct 14 |
nicklas |
Forms.showNotification(event.currentTarget, 'No wells have been selected'); |
2829 |
17 Oct 14 |
nicklas |
return; |
2829 |
17 Oct 14 |
nicklas |
732 |
} |
2829 |
17 Oct 14 |
nicklas |
733 |
|
2829 |
17 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2829 |
17 Oct 14 |
nicklas |
735 |
{ |
2829 |
17 Oct 14 |
nicklas |
var well = wells[i]; |
2829 |
17 Oct 14 |
nicklas |
var lib = well.extract; |
2829 |
17 Oct 14 |
nicklas |
if (lib) |
2829 |
17 Oct 14 |
nicklas |
739 |
{ |
2829 |
17 Oct 14 |
nicklas |
lib.excludeFromPool = false; |
2829 |
17 Oct 14 |
nicklas |
lib.flag = null; |
2829 |
17 Oct 14 |
nicklas |
lib.oldComment = lib.comment; |
2829 |
17 Oct 14 |
nicklas |
lib.comment = null; |
2829 |
17 Oct 14 |
nicklas |
744 |
} |
2829 |
17 Oct 14 |
nicklas |
well.selected = false; |
2829 |
17 Oct 14 |
nicklas |
746 |
} |
2829 |
17 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2829 |
17 Oct 14 |
nicklas |
748 |
} |
2829 |
17 Oct 14 |
nicklas |
749 |
|
2829 |
17 Oct 14 |
nicklas |
750 |
|
2829 |
17 Oct 14 |
nicklas |
//Flag the selected RNA |
2829 |
17 Oct 14 |
nicklas |
createpool.toggleFlag = function(event) |
2829 |
17 Oct 14 |
nicklas |
753 |
{ |
2829 |
17 Oct 14 |
nicklas |
var wells = Plate.getSelected(); |
2931 |
14 Nov 14 |
nicklas |
if (wells.length == 0 && contextWell) wells = [ contextWell ]; |
2829 |
17 Oct 14 |
nicklas |
if (wells.length == 0) |
2829 |
17 Oct 14 |
nicklas |
757 |
{ |
2829 |
17 Oct 14 |
nicklas |
Forms.showNotification(event.currentTarget, 'No wells have been selected'); |
2829 |
17 Oct 14 |
nicklas |
return; |
2829 |
17 Oct 14 |
nicklas |
760 |
} |
2829 |
17 Oct 14 |
nicklas |
761 |
|
2829 |
17 Oct 14 |
nicklas |
var flag = null; |
2829 |
17 Oct 14 |
nicklas |
var firstLib = true; |
2829 |
17 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2829 |
17 Oct 14 |
nicklas |
765 |
{ |
2829 |
17 Oct 14 |
nicklas |
var well = wells[i]; |
2829 |
17 Oct 14 |
nicklas |
var lib = well.extract; |
2829 |
17 Oct 14 |
nicklas |
if (lib) |
2829 |
17 Oct 14 |
nicklas |
769 |
{ |
2829 |
17 Oct 14 |
nicklas |
if (firstLib && !lib.excludeFromPool) |
2829 |
17 Oct 14 |
nicklas |
771 |
{ |
2829 |
17 Oct 14 |
nicklas |
flag = lib.flag ? null : 'ManualFlag'; |
2829 |
17 Oct 14 |
nicklas |
firstLib = false; |
2829 |
17 Oct 14 |
nicklas |
774 |
} |
2829 |
17 Oct 14 |
nicklas |
lib.flag = lib.excludeFromPool ? 'ExcludedFromPool' : flag; |
2829 |
17 Oct 14 |
nicklas |
776 |
} |
2829 |
17 Oct 14 |
nicklas |
//well.selected = false; |
2829 |
17 Oct 14 |
nicklas |
778 |
} |
2829 |
17 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2829 |
17 Oct 14 |
nicklas |
780 |
} |
2829 |
17 Oct 14 |
nicklas |
781 |
|
2829 |
17 Oct 14 |
nicklas |
//Set a comment on the selected wells |
2829 |
17 Oct 14 |
nicklas |
createpool.commentSelected = function(event) |
2829 |
17 Oct 14 |
nicklas |
784 |
{ |
2829 |
17 Oct 14 |
nicklas |
var wells = Plate.getSelected(); |
2931 |
14 Nov 14 |
nicklas |
if (wells.length == 0 && contextWell) wells = [ contextWell ]; |
2829 |
17 Oct 14 |
nicklas |
if (wells.length == 0) |
2829 |
17 Oct 14 |
nicklas |
788 |
{ |
2829 |
17 Oct 14 |
nicklas |
Forms.showNotification(event.currentTarget, 'No wells have been selected'); |
2829 |
17 Oct 14 |
nicklas |
return; |
2829 |
17 Oct 14 |
nicklas |
791 |
} |
2829 |
17 Oct 14 |
nicklas |
792 |
|
2829 |
17 Oct 14 |
nicklas |
var count = 0; |
2829 |
17 Oct 14 |
nicklas |
var comment; |
2829 |
17 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2829 |
17 Oct 14 |
nicklas |
796 |
{ |
2829 |
17 Oct 14 |
nicklas |
var well = wells[i]; |
2829 |
17 Oct 14 |
nicklas |
if (well.extract) |
2829 |
17 Oct 14 |
nicklas |
799 |
{ |
2829 |
17 Oct 14 |
nicklas |
if (well.extract.comment) comment = well.extract.comment; |
2829 |
17 Oct 14 |
nicklas |
count++; |
2829 |
17 Oct 14 |
nicklas |
802 |
} |
2829 |
17 Oct 14 |
nicklas |
803 |
} |
2829 |
17 Oct 14 |
nicklas |
804 |
|
2829 |
17 Oct 14 |
nicklas |
if (count == 0) |
2829 |
17 Oct 14 |
nicklas |
806 |
{ |
2829 |
17 Oct 14 |
nicklas |
Forms.showNotification(event.currentTarget, 'Only empty wells have been selected'); |
2829 |
17 Oct 14 |
nicklas |
return; |
2829 |
17 Oct 14 |
nicklas |
809 |
} |
2829 |
17 Oct 14 |
nicklas |
810 |
|
2829 |
17 Oct 14 |
nicklas |
comment = prompt('Comment', comment || lastComment); |
2829 |
17 Oct 14 |
nicklas |
if (comment == null) return; |
2829 |
17 Oct 14 |
nicklas |
813 |
|
2829 |
17 Oct 14 |
nicklas |
lastComment = comment; |
2829 |
17 Oct 14 |
nicklas |
815 |
|
2829 |
17 Oct 14 |
nicklas |
if (comment == '') comment = null; |
2829 |
17 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2829 |
17 Oct 14 |
nicklas |
818 |
{ |
2829 |
17 Oct 14 |
nicklas |
var well = wells[i]; |
2829 |
17 Oct 14 |
nicklas |
if (well.extract) |
2829 |
17 Oct 14 |
nicklas |
821 |
{ |
2829 |
17 Oct 14 |
nicklas |
well.extract.comment = comment; |
2829 |
17 Oct 14 |
nicklas |
823 |
} |
2829 |
17 Oct 14 |
nicklas |
well.selected = false; |
2829 |
17 Oct 14 |
nicklas |
825 |
} |
2829 |
17 Oct 14 |
nicklas |
826 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2829 |
17 Oct 14 |
nicklas |
828 |
} |
2829 |
17 Oct 14 |
nicklas |
829 |
|
2829 |
17 Oct 14 |
nicklas |
//Set target volume on the selected wells |
2829 |
17 Oct 14 |
nicklas |
var lastTargetVolume = null; |
2829 |
17 Oct 14 |
nicklas |
createpool.setTargetVolume = function(event) |
2829 |
17 Oct 14 |
nicklas |
833 |
{ |
2829 |
17 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2829 |
17 Oct 14 |
nicklas |
835 |
|
2829 |
17 Oct 14 |
nicklas |
var wells = Plate.getSelected(); |
2931 |
14 Nov 14 |
nicklas |
if (wells.length == 0 && contextWell) wells = [ contextWell ]; |
2829 |
17 Oct 14 |
nicklas |
if (wells.length == 0) |
2829 |
17 Oct 14 |
nicklas |
839 |
{ |
2829 |
17 Oct 14 |
nicklas |
Forms.showNotification(event.currentTarget, 'No wells have been selected'); |
2829 |
17 Oct 14 |
nicklas |
return; |
2829 |
17 Oct 14 |
nicklas |
842 |
} |
2829 |
17 Oct 14 |
nicklas |
843 |
|
2829 |
17 Oct 14 |
nicklas |
var count = 0; |
2829 |
17 Oct 14 |
nicklas |
var targetVolume; |
2829 |
17 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2829 |
17 Oct 14 |
nicklas |
847 |
{ |
2829 |
17 Oct 14 |
nicklas |
var well = wells[i]; |
2829 |
17 Oct 14 |
nicklas |
if (well.extract && well.extract.mixFactor > 1) |
2829 |
17 Oct 14 |
nicklas |
850 |
{ |
2829 |
17 Oct 14 |
nicklas |
if (well.extract.targetVolume) |
2829 |
17 Oct 14 |
nicklas |
852 |
{ |
2829 |
17 Oct 14 |
nicklas |
targetVolume = well.extract.targetVolume; |
2829 |
17 Oct 14 |
nicklas |
854 |
} |
2829 |
17 Oct 14 |
nicklas |
else |
2829 |
17 Oct 14 |
nicklas |
856 |
{ |
2829 |
17 Oct 14 |
nicklas |
var poolNo = Plate.poolSchema.getPoolNumForColumn(well.column); |
2829 |
17 Oct 14 |
nicklas |
targetVolume = parseFloat(frm['target_volume.'+poolNo].value); |
2829 |
17 Oct 14 |
nicklas |
859 |
} |
2829 |
17 Oct 14 |
nicklas |
count++; |
2829 |
17 Oct 14 |
nicklas |
861 |
} |
2829 |
17 Oct 14 |
nicklas |
862 |
} |
2829 |
17 Oct 14 |
nicklas |
863 |
|
2829 |
17 Oct 14 |
nicklas |
if (count == 0) |
2829 |
17 Oct 14 |
nicklas |
865 |
{ |
2829 |
17 Oct 14 |
nicklas |
Forms.showNotification(event.currentTarget, 'Only empty or dynamic-mixed wells have been selected'); |
2829 |
17 Oct 14 |
nicklas |
return; |
2829 |
17 Oct 14 |
nicklas |
868 |
} |
2829 |
17 Oct 14 |
nicklas |
869 |
|
2829 |
17 Oct 14 |
nicklas |
targetVolume = parseFloat(prompt('Volume to use in pool ('+LIMIT_FOR_EXTRA_LARGE_MIX+'--'+MAX_TARGET_VOLUME+' µl)', targetVolume || lastTargetVolume || D)); |
2829 |
17 Oct 14 |
nicklas |
if (isNaN(targetVolume)) |
2829 |
17 Oct 14 |
nicklas |
872 |
{ |
2829 |
17 Oct 14 |
nicklas |
targetVolume = null; |
2829 |
17 Oct 14 |
nicklas |
874 |
} |
2829 |
17 Oct 14 |
nicklas |
else if (targetVolume > MAX_TARGET_VOLUME) |
2829 |
17 Oct 14 |
nicklas |
876 |
{ |
2829 |
17 Oct 14 |
nicklas |
targetVolume = MAX_TARGET_VOLUME; |
2829 |
17 Oct 14 |
nicklas |
878 |
} |
2829 |
17 Oct 14 |
nicklas |
else if (targetVolume < LIMIT_FOR_EXTRA_LARGE_MIX) |
2829 |
17 Oct 14 |
nicklas |
880 |
{ |
2829 |
17 Oct 14 |
nicklas |
targetVolume = LIMIT_FOR_EXTRA_LARGE_MIX |
2829 |
17 Oct 14 |
nicklas |
882 |
} |
2829 |
17 Oct 14 |
nicklas |
883 |
|
2829 |
17 Oct 14 |
nicklas |
884 |
|
2829 |
17 Oct 14 |
nicklas |
lastTargetVolume = targetVolume; |
2829 |
17 Oct 14 |
nicklas |
886 |
|
2829 |
17 Oct 14 |
nicklas |
if (targetVolume == '') targetVolume = null; |
2829 |
17 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2829 |
17 Oct 14 |
nicklas |
for (var i = 0; i < wells.length; i++) |
2829 |
17 Oct 14 |
nicklas |
890 |
{ |
2829 |
17 Oct 14 |
nicklas |
var well = wells[i]; |
2829 |
17 Oct 14 |
nicklas |
if (well.extract) |
2829 |
17 Oct 14 |
nicklas |
893 |
{ |
2829 |
17 Oct 14 |
nicklas |
var lib = well.extract; |
2829 |
17 Oct 14 |
nicklas |
lib.targetVolume = targetVolume; |
2829 |
17 Oct 14 |
nicklas |
var poolNo = Plate.poolSchema.getPoolNumForColumn(lib.bioWell.column); |
2829 |
17 Oct 14 |
nicklas |
897 |
|
2829 |
17 Oct 14 |
nicklas |
var targetVolumePerLib = parseFloat(frm['target_volume.'+poolNo].value); |
2829 |
17 Oct 14 |
nicklas |
var mixingStrategy = Forms.getCheckedRadio(frm['mixing_strategy.'+poolNo]).value; |
3107 |
27 Jan 15 |
nicklas |
var targetMolarityInPool = parseFloat(frm['target_molarity.'+poolNo].value); |
3107 |
27 Jan 15 |
nicklas |
PoolMix.calculateEbVolume(lib, targetMolarityInPool, targetVolumePerLib, mixingStrategy); |
2829 |
17 Oct 14 |
nicklas |
902 |
} |
2829 |
17 Oct 14 |
nicklas |
well.selected = false; |
2829 |
17 Oct 14 |
nicklas |
904 |
} |
2829 |
17 Oct 14 |
nicklas |
905 |
|
2829 |
17 Oct 14 |
nicklas |
createpool.updatePoolData(); |
2829 |
17 Oct 14 |
nicklas |
907 |
} |
2829 |
17 Oct 14 |
nicklas |
908 |
|
2829 |
17 Oct 14 |
nicklas |
909 |
|
2829 |
17 Oct 14 |
nicklas |
return createpool; |
2829 |
17 Oct 14 |
nicklas |
911 |
}(); |
2829 |
17 Oct 14 |
nicklas |
912 |
|
2829 |
17 Oct 14 |
nicklas |
Doc.onLoad(CreatePool.initPage); |
2829 |
17 Oct 14 |
nicklas |
Doc.addElementInitializer(CreatePool.initElements); |
2829 |
17 Oct 14 |
nicklas |
915 |
|
2829 |
17 Oct 14 |
nicklas |
var WellPainter = function() |
2829 |
17 Oct 14 |
nicklas |
917 |
{ |
2829 |
17 Oct 14 |
nicklas |
var painter = {}; |
2829 |
17 Oct 14 |
nicklas |
919 |
|
2829 |
17 Oct 14 |
nicklas |
painter.getClassNameForWell = function(well, schema) |
2829 |
17 Oct 14 |
nicklas |
921 |
{ |
2829 |
17 Oct 14 |
nicklas |
var indexSet = painter.barcodeVariant.indexSets[well.column]; |
2829 |
17 Oct 14 |
nicklas |
var cls = ''; |
2829 |
17 Oct 14 |
nicklas |
var lib = well.extract; |
2829 |
17 Oct 14 |
nicklas |
925 |
|
2829 |
17 Oct 14 |
nicklas |
if (lib) |
2829 |
17 Oct 14 |
nicklas |
927 |
{ |
2829 |
17 Oct 14 |
nicklas |
if (lib.excludeFromPool) |
2829 |
17 Oct 14 |
nicklas |
929 |
{ |
2829 |
17 Oct 14 |
nicklas |
cls += ' exclude-from-pool'; |
2829 |
17 Oct 14 |
nicklas |
931 |
} |
2829 |
17 Oct 14 |
nicklas |
else if (indexSet) |
2829 |
17 Oct 14 |
nicklas |
933 |
{ |
2829 |
17 Oct 14 |
nicklas |
cls += ' ' + (lib && lib.barcode.modified ? 'bg-modified' : indexSet.color); |
2829 |
17 Oct 14 |
nicklas |
935 |
} |
2829 |
17 Oct 14 |
nicklas |
if (lib.flag) |
2829 |
17 Oct 14 |
nicklas |
937 |
{ |
2829 |
17 Oct 14 |
nicklas |
cls += ' flagged'; |
2829 |
17 Oct 14 |
nicklas |
939 |
} |
2829 |
17 Oct 14 |
nicklas |
if (!lib.flag && lib.actualVolume < lib.volume) |
2829 |
17 Oct 14 |
nicklas |
941 |
{ |
2829 |
17 Oct 14 |
nicklas |
cls += ' low-volume'; |
2829 |
17 Oct 14 |
nicklas |
943 |
} |
5883 |
26 Mar 20 |
nicklas |
if (lib.libraryFracAdpt == null || lib.libraryFracAdpt > CreatePool.LIBRARY_FRAC_ADPT_LIMIT) |
2829 |
17 Oct 14 |
nicklas |
945 |
{ |
2829 |
17 Oct 14 |
nicklas |
cls += ' high-adapter'; |
2829 |
17 Oct 14 |
nicklas |
947 |
} |
3762 |
19 Feb 16 |
nicklas |
if (lib.isYellow) |
3762 |
19 Feb 16 |
nicklas |
949 |
{ |
3762 |
19 Feb 16 |
nicklas |
cls += ' yellow-specimen'; |
3762 |
19 Feb 16 |
nicklas |
951 |
} |
2829 |
17 Oct 14 |
nicklas |
952 |
|
2829 |
17 Oct 14 |
nicklas |
953 |
} |
2829 |
17 Oct 14 |
nicklas |
else if (indexSet) |
2829 |
17 Oct 14 |
nicklas |
955 |
{ |
2829 |
17 Oct 14 |
nicklas |
cls += indexSet.color; |
2829 |
17 Oct 14 |
nicklas |
957 |
} |
2829 |
17 Oct 14 |
nicklas |
return cls; |
2829 |
17 Oct 14 |
nicklas |
959 |
} |
2829 |
17 Oct 14 |
nicklas |
960 |
|
2829 |
17 Oct 14 |
nicklas |
painter.getWellText = function(well, schema) |
2829 |
17 Oct 14 |
nicklas |
962 |
{ |
2829 |
17 Oct 14 |
nicklas |
var text = ''; |
2829 |
17 Oct 14 |
nicklas |
var lib = well.extract; |
2829 |
17 Oct 14 |
nicklas |
if (lib) |
2829 |
17 Oct 14 |
nicklas |
966 |
{ |
2829 |
17 Oct 14 |
nicklas |
var name = lib.name; |
2829 |
17 Oct 14 |
nicklas |
var i = name.indexOf('.m'); |
3762 |
19 Feb 16 |
nicklas |
if (i < 0) i = name.indexOf('.lib'); |
2829 |
17 Oct 14 |
nicklas |
var mixFactor = lib.mixFactor; |
3310 |
07 May 15 |
nicklas |
var displayName = i == -1 ? Strings.encodeTags(name) : Strings.encodeTags(name.substring(0, i+1))+'<br> '+Strings.encodeTags(name.substring(i)); |
3762 |
19 Feb 16 |
nicklas |
text += '<div class="lib if-yellow">'+displayName+'</div>'; |
2829 |
17 Oct 14 |
nicklas |
text += '<div>'; |
2829 |
17 Oct 14 |
nicklas |
// text += '<span class="barcode">'+lib.barcode.name+'</span>'; |
2829 |
17 Oct 14 |
nicklas |
text += '<span class="adapter">'+(lib.libraryFracAdpt != null ? lib.libraryFracAdpt + '%' : '—') + '</span>'; |
2829 |
17 Oct 14 |
nicklas |
if (lib.molarity != null) |
2829 |
17 Oct 14 |
nicklas |
977 |
{ |
2829 |
17 Oct 14 |
nicklas |
text += '<span class="molarity">'+Numbers.formatNumber(lib.molarity, 2, 'nM')+'</span>'; |
2829 |
17 Oct 14 |
nicklas |
979 |
} |
2829 |
17 Oct 14 |
nicklas |
text += '</div>'; |
2829 |
17 Oct 14 |
nicklas |
if (!lib.excludeFromPool) |
2829 |
17 Oct 14 |
nicklas |
982 |
{ |
2829 |
17 Oct 14 |
nicklas |
mark = (lib.volume > lib.actualVolume) ? '*' : ''; |
2829 |
17 Oct 14 |
nicklas |
text += '<div>'; |
2829 |
17 Oct 14 |
nicklas |
text += '<span class="volume">'+(isFinite(lib.volume) ? Numbers.formatNumber(lib.volume*mixFactor, 1, 'µl'+mark) : '∞')+'</span>'; |
2829 |
17 Oct 14 |
nicklas |
if (lib.mixingStrategy == 'fixed' || lib.mixFactor > 1) |
2829 |
17 Oct 14 |
nicklas |
987 |
{ |
2829 |
17 Oct 14 |
nicklas |
text += '<span class="eb">'+(isFinite(lib.eb) ? Numbers.formatNumber(lib.eb*mixFactor, 1, 'µl') : '-∞')+'</span>'; |
2829 |
17 Oct 14 |
nicklas |
989 |
} |
2829 |
17 Oct 14 |
nicklas |
else |
2829 |
17 Oct 14 |
nicklas |
991 |
{ |
2829 |
17 Oct 14 |
nicklas |
text += '<span class="eb">—</span>'; |
2829 |
17 Oct 14 |
nicklas |
993 |
} |
2829 |
17 Oct 14 |
nicklas |
text += '</div>'; |
2829 |
17 Oct 14 |
nicklas |
995 |
} |
2829 |
17 Oct 14 |
nicklas |
if (lib.remarks) text += '<div class="remarks">'+ lib.remarks.join('; ') + '</div>'; |
2829 |
17 Oct 14 |
nicklas |
if (lib.comment) |
2829 |
17 Oct 14 |
nicklas |
998 |
{ |
2829 |
17 Oct 14 |
nicklas |
text += '<div class="remarks">'+ lib.comment + '</div>'; |
2829 |
17 Oct 14 |
nicklas |
1000 |
} |
2829 |
17 Oct 14 |
nicklas |
1001 |
} |
2829 |
17 Oct 14 |
nicklas |
return text; |
2829 |
17 Oct 14 |
nicklas |
1003 |
} |
2829 |
17 Oct 14 |
nicklas |
1004 |
|
2829 |
17 Oct 14 |
nicklas |
return painter; |
2829 |
17 Oct 14 |
nicklas |
1006 |
}(); |
2829 |
17 Oct 14 |
nicklas |
1007 |
|