3520 |
01 Oct 15 |
olle |
var SelectDnaRefCode = function() |
3449 |
28 Jul 15 |
olle |
2 |
{ |
3449 |
28 Jul 15 |
olle |
var selectdna = {}; |
3449 |
28 Jul 15 |
olle |
var barcodesByName = []; |
3449 |
28 Jul 15 |
olle |
5 |
|
3449 |
28 Jul 15 |
olle |
var EXTERNAL_DNA_NAME = 'External.d'; |
3449 |
28 Jul 15 |
olle |
var debug = 0; |
4200 |
01 Nov 16 |
olle |
var startPlatePrefix; |
3449 |
28 Jul 15 |
olle |
9 |
|
3449 |
28 Jul 15 |
olle |
var graphics; |
3449 |
28 Jul 15 |
olle |
var pen; |
3449 |
28 Jul 15 |
olle |
12 |
|
3449 |
28 Jul 15 |
olle |
var quantitiesAreValid = false; |
3449 |
28 Jul 15 |
olle |
var subtypeDna; |
3449 |
28 Jul 15 |
olle |
var subtypeDnaNormalized |
3449 |
28 Jul 15 |
olle |
16 |
|
3449 |
28 Jul 15 |
olle |
// Page initialization |
3449 |
28 Jul 15 |
olle |
selectdna.initPage = function() |
3449 |
28 Jul 15 |
olle |
19 |
{ |
3449 |
28 Jul 15 |
olle |
// Step 1 |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('step-1', 'wizard-validate', selectdna.validateStep1); |
3449 |
28 Jul 15 |
olle |
22 |
|
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('pool_schema', 'change', selectdna.poolSchemaOnChange); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('barcode_variant', 'change', selectdna.barcodeVariantOnChange); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('quantity_regular', 'change', selectdna.quantityOnChange); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('quantity_qc', 'change', selectdna.quantityOnChange); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('quantity_regular', 'keypress', Events.numberOnly); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('quantity_qc', 'keypress', Events.numberOnly); |
3449 |
28 Jul 15 |
olle |
29 |
|
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('warning_quantity', 'change', selectdna.warningLevelOnChange); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('warning_quality_score', 'change', selectdna.warningLevelOnChange); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('warning_quantity', 'keypress', Events.numberOnly); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('warning_quality_score', 'keypress', Events.numberOnly); |
3449 |
28 Jul 15 |
olle |
34 |
|
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('location', 'click', selectdna.toggleInfo); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('quantity', 'click', selectdna.toggleInfo); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('quality-score', 'click', selectdna.toggleInfo); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('qubitconc', 'click', selectdna.toggleInfo); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('volumes', 'click', selectdna.toggleInfo); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('qiacube-date', 'click', selectdna.toggleInfo); |
3449 |
28 Jul 15 |
olle |
41 |
|
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('pool-row', 'click', selectdna.togglePool); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('pool-row', 'mouseover', selectdna.highlightPool); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('pool-row', 'mouseout', selectdna.highlightPool); |
3449 |
28 Jul 15 |
olle |
45 |
|
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('btnLoadFromFile', selectdna.selectFile); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('btnAutoSelect', selectdna.autoSelect); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('btnManualSelect', selectdna.manualSelect); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('plate', 'base-selected', selectdna.manuallySelected); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('btnStratagene', selectdna.setToStratagene); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('btnExternal', selectdna.setToExternal); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('btnToggleQc', selectdna.toggleQc); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('btnComment', selectdna.commentSelected); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('btnCutSelected', selectdna.cutSelected); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('btnCopySelected', selectdna.copySelected); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('btnPasteToSelected', selectdna.pasteToSelected); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('btnSwitch', selectdna.switchSelected); |
3449 |
28 Jul 15 |
olle |
58 |
|
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('iconSpecialSelect', 'click', selectdna.toggleSpecialSelect); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('plate', 'mouseup', selectdna.contextEvent); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('plate', 'contextmenu', selectdna.contextEvent); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('mnuComment', 'click', selectdna.commentSelected); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('mnuToggleQc', 'click', selectdna.toggleQc); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('mnuCutSelected', 'click', selectdna.cutSelected); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('mnuCopySelected', 'click', selectdna.copySelected); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('mnuPasteToSelected', 'click', selectdna.pasteToSelected); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('mnuSwitch', 'click', selectdna.switchSelected); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('mnuCaseSummary', 'click', selectdna.showCaseSummary); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('mnuFlagLowQualityScore', 'click', selectdna.flagSelected); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('mnuFlagNotEnoughRemainingQuantity', 'click', selectdna.flagSelected); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('mnuFlagOther', 'click', selectdna.flagSelected); |
3449 |
28 Jul 15 |
olle |
72 |
|
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('flaggedDna', 'click', selectdna.showFlaggedDna); |
3449 |
28 Jul 15 |
olle |
74 |
|
3449 |
28 Jul 15 |
olle |
// Barcode wells |
3449 |
28 Jul 15 |
olle |
var wells = document.getElementsByClassName('barcode-well'); |
3449 |
28 Jul 15 |
olle |
for (var wellNo = 0; wellNo < wells.length; wellNo++) |
3449 |
28 Jul 15 |
olle |
78 |
{ |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler(wells[wellNo], 'click', selectdna.selectBarcode); |
3449 |
28 Jul 15 |
olle |
80 |
} |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('select-barcode', 'click', selectdna.barcodeSelected); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('wizard', 'click', selectdna.hideBarcodeSelection); |
3449 |
28 Jul 15 |
olle |
83 |
|
3449 |
28 Jul 15 |
olle |
// Navigation |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
3449 |
28 Jul 15 |
olle |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
3449 |
28 Jul 15 |
olle |
89 |
|
3449 |
28 Jul 15 |
olle |
// Final registration |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler('wizard', 'wizard-submit', selectdna.submit); |
3449 |
28 Jul 15 |
olle |
92 |
|
3449 |
28 Jul 15 |
olle |
var isNeoPrep = Data.int('page-data', 'is-neoprep'); |
3449 |
28 Jul 15 |
olle |
94 |
/* |
3449 |
28 Jul 15 |
olle |
TOTAL_VOLUME = isNeoPrep ? 45 : 50; // µl |
3449 |
28 Jul 15 |
olle |
96 |
*/ |
3449 |
28 Jul 15 |
olle |
TOTAL_VOLUME = isNeoPrep ? 45 : 10; // µl |
3449 |
28 Jul 15 |
olle |
MINIMAL_DNA_VOLUME = 1.0; // µl |
4200 |
01 Nov 16 |
olle |
99 |
|
4200 |
01 Nov 16 |
olle |
// Load configuration |
4200 |
01 Nov 16 |
olle |
selectdna.loadConfiguration(); |
4200 |
01 Nov 16 |
olle |
102 |
} |
4200 |
01 Nov 16 |
olle |
103 |
|
4200 |
01 Nov 16 |
olle |
selectdna.loadConfiguration = function() |
4200 |
01 Nov 16 |
olle |
105 |
{ |
4200 |
01 Nov 16 |
olle |
var url = '../Session.servlet?ID='+App.getSessionId(); |
4200 |
01 Nov 16 |
olle |
url += '&cmd=GetConfiguration'; |
4200 |
01 Nov 16 |
olle |
var request = Ajax.getXmlHttpRequest(); |
4200 |
01 Nov 16 |
olle |
request.open("GET", url, true); |
4200 |
01 Nov 16 |
olle |
Ajax.setReadyStateHandler(request, selectdna.onConfiguration, selectdna.onConfiguration); |
4200 |
01 Nov 16 |
olle |
request.send(null); |
4200 |
01 Nov 16 |
olle |
112 |
} |
4200 |
01 Nov 16 |
olle |
113 |
|
4200 |
01 Nov 16 |
olle |
selectdna.onConfiguration = function(request) |
4200 |
01 Nov 16 |
olle |
115 |
{ |
4200 |
01 Nov 16 |
olle |
if (debug) |
4200 |
01 Nov 16 |
olle |
117 |
{ |
4200 |
01 Nov 16 |
olle |
App.debug(Strings.encodeTags(request.responseText)); |
4200 |
01 Nov 16 |
olle |
119 |
} |
4200 |
01 Nov 16 |
olle |
120 |
|
4200 |
01 Nov 16 |
olle |
var response; |
4200 |
01 Nov 16 |
olle |
var error = false; |
4200 |
01 Nov 16 |
olle |
try |
4200 |
01 Nov 16 |
olle |
124 |
{ |
4200 |
01 Nov 16 |
olle |
response = JSON.parse(request.responseText); |
4200 |
01 Nov 16 |
olle |
if (response.status != 'ok') |
4200 |
01 Nov 16 |
olle |
127 |
{ |
4200 |
01 Nov 16 |
olle |
error = response.message || response.stacktrace || 'Unexpected error'; |
4200 |
01 Nov 16 |
olle |
129 |
} |
4200 |
01 Nov 16 |
olle |
130 |
} |
4200 |
01 Nov 16 |
olle |
catch (ex) |
4200 |
01 Nov 16 |
olle |
132 |
{ |
4200 |
01 Nov 16 |
olle |
error = ex; |
4200 |
01 Nov 16 |
olle |
134 |
} |
4200 |
01 Nov 16 |
olle |
if (error) App.debug(error); |
4200 |
01 Nov 16 |
olle |
136 |
|
4200 |
01 Nov 16 |
olle |
// Get configuration result |
4200 |
01 Nov 16 |
olle |
var conf = response.configuration; |
4200 |
01 Nov 16 |
olle |
// Check for start plate prefix |
4200 |
01 Nov 16 |
olle |
startPlatePrefix = conf.startPlateItemPrefix; |
4200 |
01 Nov 16 |
olle |
141 |
|
4200 |
01 Nov 16 |
olle |
// Continue with initializing info |
3449 |
28 Jul 15 |
olle |
var url = '../Dna.servlet?ID='+App.getSessionId(); |
3449 |
28 Jul 15 |
olle |
url += '&cmd=GetStratagene'; |
3449 |
28 Jul 15 |
olle |
Wizard.asyncJsonRequest(url, selectdna.stratageneLoaded); |
3449 |
28 Jul 15 |
olle |
146 |
|
3449 |
28 Jul 15 |
olle |
var url = '../Dna.servlet?ID='+App.getSessionId(); |
3449 |
28 Jul 15 |
olle |
url += '&cmd=GetNextAutoGeneratedPlateName'; |
3449 |
28 Jul 15 |
olle |
url += '&bioPlateType=' + (isNeoPrep ? 'NEOPREP' : 'DNA'); |
4200 |
01 Nov 16 |
olle |
url += '&bioPlatePrefix=' + startPlatePrefix; |
3449 |
28 Jul 15 |
olle |
Wizard.showLoadingAnimation('Loading next '+(isNeoPrep ? 'NeoPrep' : 'DNA') + ' plate'); |
3449 |
28 Jul 15 |
olle |
Wizard.asyncJsonRequest(url, selectdna.nextPlateNameLoaded); |
3449 |
28 Jul 15 |
olle |
153 |
|
3449 |
28 Jul 15 |
olle |
var url = '../LibPrep.servlet?ID='+App.getSessionId(); |
3449 |
28 Jul 15 |
olle |
url += '&cmd=GetAllBarcodeInfo'; |
3449 |
28 Jul 15 |
olle |
Wizard.asyncJsonRequest(url, selectdna.barcodesLoaded); |
3449 |
28 Jul 15 |
olle |
157 |
} |
3449 |
28 Jul 15 |
olle |
158 |
|
3449 |
28 Jul 15 |
olle |
selectdna.barcodesLoaded = function(response) |
3449 |
28 Jul 15 |
olle |
160 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
var isNeoPrep = Data.int('page-data', 'is-neoprep'); |
3449 |
28 Jul 15 |
olle |
163 |
|
3449 |
28 Jul 15 |
olle |
var barcodes = response.barcodes; |
3449 |
28 Jul 15 |
olle |
var selectBarcodeHtml = ''; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < barcodes.length; i++) |
3449 |
28 Jul 15 |
olle |
167 |
{ |
3449 |
28 Jul 15 |
olle |
if (i % 8 == 0 && i > 0) |
3449 |
28 Jul 15 |
olle |
169 |
{ |
3449 |
28 Jul 15 |
olle |
selectBarcodeHtml += '<div class="menuseparator"></div>'; |
3449 |
28 Jul 15 |
olle |
171 |
} |
3449 |
28 Jul 15 |
olle |
var barcode = barcodes[i]; |
3449 |
28 Jul 15 |
olle |
barcodesByName[barcode.name] = barcode; |
3449 |
28 Jul 15 |
olle |
selectBarcodeHtml += '<div class="menuitem interactable enabled" id="bc-'+barcode.id+'" data-barcode-name="'+Strings.encodeTags(barcode.name)+'">'; |
3449 |
28 Jul 15 |
olle |
selectBarcodeHtml += Strings.encodeTags(barcode.name)+'</div>'; |
3449 |
28 Jul 15 |
olle |
176 |
} |
3449 |
28 Jul 15 |
olle |
Doc.element('select-barcode-all').innerHTML = selectBarcodeHtml; |
3449 |
28 Jul 15 |
olle |
178 |
|
3449 |
28 Jul 15 |
olle |
selectdna.quantityOnChange(); |
3449 |
28 Jul 15 |
olle |
selectdna.warningLevelOnChange(); |
3449 |
28 Jul 15 |
olle |
181 |
|
3449 |
28 Jul 15 |
olle |
// Init plate, pool schema and barcode variants |
3449 |
28 Jul 15 |
olle |
graphics = new jsGraphics(Doc.element('canvas')); |
3449 |
28 Jul 15 |
olle |
pen = new jsPen(new jsColor('#2288AA'), 2); |
3449 |
28 Jul 15 |
olle |
var columns = isNeoPrep ? 2 : 12; |
3449 |
28 Jul 15 |
olle |
var rows = 8; |
3449 |
28 Jul 15 |
olle |
var schema = PoolSchema.initList(frm.pool_schema, null, isNeoPrep ? 'neoprep' : 'manual'); |
3449 |
28 Jul 15 |
olle |
Plate.init(rows, columns, schema, WellPainter); |
3449 |
28 Jul 15 |
olle |
Events.sendChangeEvent(frm.pool_schema); |
3449 |
28 Jul 15 |
olle |
// Set default for showing info for plate well |
3449 |
28 Jul 15 |
olle |
selectdna.setDefaultInfo('location'); |
3449 |
28 Jul 15 |
olle |
selectdna.setDefaultInfo('quantity'); |
3449 |
28 Jul 15 |
olle |
selectdna.setDefaultInfo('quality-score'); |
3449 |
28 Jul 15 |
olle |
selectdna.setDefaultInfo('qubitconc'); |
3449 |
28 Jul 15 |
olle |
selectdna.setDefaultInfo('volumes'); |
3449 |
28 Jul 15 |
olle |
selectdna.setDefaultInfo('qiacube-date'); |
3449 |
28 Jul 15 |
olle |
197 |
// |
3449 |
28 Jul 15 |
olle |
Doc.show('step-1'); |
3449 |
28 Jul 15 |
olle |
Doc.show('gocancel'); |
3449 |
28 Jul 15 |
olle |
Doc.show('goregister'); |
3449 |
28 Jul 15 |
olle |
Wizard.setNoConfirmOnFirstStep(false); |
3449 |
28 Jul 15 |
olle |
Wizard.keepSessionAlive(); |
3449 |
28 Jul 15 |
olle |
203 |
} |
3449 |
28 Jul 15 |
olle |
204 |
|
3449 |
28 Jul 15 |
olle |
selectdna.stratageneLoaded = function(response) |
3449 |
28 Jul 15 |
olle |
206 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
var stratagene = response.stratagene; |
3449 |
28 Jul 15 |
olle |
209 |
|
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < stratagene.length; i++) |
3449 |
28 Jul 15 |
olle |
211 |
{ |
3449 |
28 Jul 15 |
olle |
var s = stratagene[i]; |
3449 |
28 Jul 15 |
olle |
var name = s.name; |
3449 |
28 Jul 15 |
olle |
if (s.bioWell) |
3449 |
28 Jul 15 |
olle |
215 |
{ |
3449 |
28 Jul 15 |
olle |
name += ' -- ' + s.bioWell.bioPlate.name + ' ('+s.bioWell.location + ')'; |
3449 |
28 Jul 15 |
olle |
217 |
} |
3449 |
28 Jul 15 |
olle |
frm.stratagene[frm.stratagene.length] = new Option(name, s.name); |
3449 |
28 Jul 15 |
olle |
219 |
} |
3449 |
28 Jul 15 |
olle |
220 |
} |
3449 |
28 Jul 15 |
olle |
221 |
|
3449 |
28 Jul 15 |
olle |
selectdna.nextPlateNameLoaded = function(response) |
3449 |
28 Jul 15 |
olle |
223 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
Plate.name = response.name; |
3449 |
28 Jul 15 |
olle |
Doc.element('plateName').innerHTML = Strings.encodeTags(Plate.name); |
3449 |
28 Jul 15 |
olle |
227 |
} |
3449 |
28 Jul 15 |
olle |
228 |
|
3449 |
28 Jul 15 |
olle |
selectdna.quantityOnChange = function(event) |
3449 |
28 Jul 15 |
olle |
230 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
quantitiesAreValid = false; |
3449 |
28 Jul 15 |
olle |
233 |
|
3449 |
28 Jul 15 |
olle |
var qRegular = parseFloat(frm.quantity_regular.value); |
3449 |
28 Jul 15 |
olle |
if (!(qRegular > 0)) |
3449 |
28 Jul 15 |
olle |
236 |
{ |
3449 |
28 Jul 15 |
olle |
Wizard.setInputStatus('quantities', 'invalid', 'Amount must be ≥ 0.'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
239 |
} |
3449 |
28 Jul 15 |
olle |
var qQc = parseFloat(frm.quantity_qc.value); |
3449 |
28 Jul 15 |
olle |
if (!(qQc > qRegular)) |
3449 |
28 Jul 15 |
olle |
242 |
{ |
3449 |
28 Jul 15 |
olle |
Wizard.setInputStatus('quantities', 'invalid', 'Amount QC must be > ' + qRegular + '.'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
245 |
} |
3449 |
28 Jul 15 |
olle |
246 |
|
3449 |
28 Jul 15 |
olle |
quantitiesAreValid = true; |
3449 |
28 Jul 15 |
olle |
QUANTITY_REGULAR = qRegular; |
3449 |
28 Jul 15 |
olle |
QUANTITY_QC = qQc; |
3449 |
28 Jul 15 |
olle |
250 |
|
3449 |
28 Jul 15 |
olle |
Wizard.setInputStatus('quantities', 'valid'); |
3449 |
28 Jul 15 |
olle |
if (event) Plate.paint(Plate.getWells()); |
3449 |
28 Jul 15 |
olle |
253 |
} |
3449 |
28 Jul 15 |
olle |
254 |
|
3449 |
28 Jul 15 |
olle |
selectdna.warningLevelOnChange = function(event) |
3449 |
28 Jul 15 |
olle |
256 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
258 |
|
3449 |
28 Jul 15 |
olle |
var wQuantity = parseFloat(frm.warning_quantity.value); |
3449 |
28 Jul 15 |
olle |
if (!(wQuantity > 0)) |
3449 |
28 Jul 15 |
olle |
261 |
{ |
3449 |
28 Jul 15 |
olle |
Wizard.setInputStatus('warnings', 'invalid', 'Remaining quantity must be ≥ 0.'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
264 |
} |
3449 |
28 Jul 15 |
olle |
var wQualityScore = parseFloat(frm.warning_quality_score.value); |
3449 |
28 Jul 15 |
olle |
266 |
/* |
3449 |
28 Jul 15 |
olle |
if (!(wQualityScore > 0)) |
3449 |
28 Jul 15 |
olle |
268 |
{ |
3449 |
28 Jul 15 |
olle |
Wizard.setInputStatus('warnings', 'invalid', 'RQS/RIN must be ≥ 0.'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
271 |
} |
3449 |
28 Jul 15 |
olle |
272 |
*/ |
3449 |
28 Jul 15 |
olle |
273 |
|
3449 |
28 Jul 15 |
olle |
LOW_QUANTITY_WARNING_LIMIT = wQuantity; |
3449 |
28 Jul 15 |
olle |
QUALITY_SCORE_WARNING_LIMIT = wQualityScore; |
3449 |
28 Jul 15 |
olle |
276 |
|
3449 |
28 Jul 15 |
olle |
Wizard.setInputStatus('warnings', 'valid'); |
3449 |
28 Jul 15 |
olle |
if (event) Plate.paint(Plate.getWells()); |
3449 |
28 Jul 15 |
olle |
279 |
} |
3449 |
28 Jul 15 |
olle |
280 |
|
3449 |
28 Jul 15 |
olle |
selectdna.poolSchemaOnChange = function() |
3449 |
28 Jul 15 |
olle |
282 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
var schema = PoolSchema.getById(frm.pool_schema.value); |
3449 |
28 Jul 15 |
olle |
Plate.setPoolSchema(schema); |
3449 |
28 Jul 15 |
olle |
286 |
|
3449 |
28 Jul 15 |
olle |
var isNeoPrep = Data.int('page-data', 'is-neoprep'); |
3449 |
28 Jul 15 |
olle |
if (isNeoPrep) |
3449 |
28 Jul 15 |
olle |
289 |
{ |
3449 |
28 Jul 15 |
olle |
PoolSchema.buildPoolTableRow(schema, Plate.columns, true, '<td class="barcode-fill barcode-left"></td>', '<th></th><td class="barcode-fill barcode-right"></td>'); |
3449 |
28 Jul 15 |
olle |
PoolSchema.initVariantList(frm.barcode_variant, schema); |
3449 |
28 Jul 15 |
olle |
Events.sendChangeEvent(frm.barcode_variant); |
3449 |
28 Jul 15 |
olle |
293 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
295 |
{ |
3449 |
28 Jul 15 |
olle |
PoolSchema.buildPoolTableRow(schema, Plate.columns, true); |
3449 |
28 Jul 15 |
olle |
Plate.paint(Plate.getWells()); |
3449 |
28 Jul 15 |
olle |
298 |
} |
3449 |
28 Jul 15 |
olle |
299 |
} |
3449 |
28 Jul 15 |
olle |
300 |
|
3449 |
28 Jul 15 |
olle |
selectdna.barcodeVariantOnChange = function() |
3449 |
28 Jul 15 |
olle |
302 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
var schema = PoolSchema.getById(frm.pool_schema.value); |
3449 |
28 Jul 15 |
olle |
var barcodeVariant = PoolSchema.getBarcodeVariantByName(schema, frm.barcode_variant.value); |
3449 |
28 Jul 15 |
olle |
306 |
|
3449 |
28 Jul 15 |
olle |
selectdna.assignSchemaDefinedBarcodeVariant(schema, barcodeVariant); |
3449 |
28 Jul 15 |
olle |
WellPainter.barcodeVariant = barcodeVariant; |
3449 |
28 Jul 15 |
olle |
Plate.paint(Plate.getWells()); |
3449 |
28 Jul 15 |
olle |
310 |
} |
3449 |
28 Jul 15 |
olle |
311 |
|
3449 |
28 Jul 15 |
olle |
selectdna.assignSchemaDefinedBarcodeVariant = function(schema, barcodeVariant) |
3449 |
28 Jul 15 |
olle |
313 |
{ |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getWells(); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
316 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
318 |
|
3449 |
28 Jul 15 |
olle |
var indexSet = barcodeVariant ? barcodeVariant.indexSets[well.column] : null; |
3449 |
28 Jul 15 |
olle |
var barcode = null; |
3449 |
28 Jul 15 |
olle |
if (indexSet) |
3449 |
28 Jul 15 |
olle |
322 |
{ |
3449 |
28 Jul 15 |
olle |
var barcodeName = indexSet.barcodes[well.row]; |
3449 |
28 Jul 15 |
olle |
barcode = barcodesByName[barcodeName]; |
3449 |
28 Jul 15 |
olle |
325 |
} |
3449 |
28 Jul 15 |
olle |
well.barcode = barcode; |
3449 |
28 Jul 15 |
olle |
well.defaultBarcode = barcode; |
3449 |
28 Jul 15 |
olle |
well.duplicate = false; |
3449 |
28 Jul 15 |
olle |
329 |
} |
3449 |
28 Jul 15 |
olle |
330 |
} |
3449 |
28 Jul 15 |
olle |
331 |
|
3449 |
28 Jul 15 |
olle |
var currentWell; |
3449 |
28 Jul 15 |
olle |
var lastSelectedBarcode; |
3449 |
28 Jul 15 |
olle |
selectdna.selectBarcode = function(event) |
3449 |
28 Jul 15 |
olle |
335 |
{ |
3449 |
28 Jul 15 |
olle |
var row = Data.int(event.currentTarget, 'row'); |
3449 |
28 Jul 15 |
olle |
var column = Data.int(event.currentTarget, 'col'); |
3449 |
28 Jul 15 |
olle |
338 |
|
3449 |
28 Jul 15 |
olle |
// Locate the barcode selection div so that the current |
3449 |
28 Jul 15 |
olle |
// barcode is positioned next to the current mouse position |
3449 |
28 Jul 15 |
olle |
// Initially set it to the right of the mouse so that the |
3449 |
28 Jul 15 |
olle |
// center is vertically aligned |
3449 |
28 Jul 15 |
olle |
currentWell = Plate.getWell(row, column); |
3449 |
28 Jul 15 |
olle |
var scroll = 0; |
3449 |
28 Jul 15 |
olle |
345 |
|
3449 |
28 Jul 15 |
olle |
// Reset 'current' selection |
3449 |
28 Jul 15 |
olle |
var menu = Doc.element('select-barcode'); |
3449 |
28 Jul 15 |
olle |
var selectAll = Doc.element('select-barcode-all'); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < selectAll.childNodes.length; i++) |
3449 |
28 Jul 15 |
olle |
350 |
{ |
3449 |
28 Jul 15 |
olle |
Doc.removeClass(selectAll.childNodes[i], 'current'); |
3449 |
28 Jul 15 |
olle |
352 |
} |
3449 |
28 Jul 15 |
olle |
menu.style.display = 'block'; |
3449 |
28 Jul 15 |
olle |
354 |
|
3449 |
28 Jul 15 |
olle |
var x = event.clientX+1; |
3449 |
28 Jul 15 |
olle |
var halfHeight = Math.floor(selectAll.offsetHeight/2) |
3449 |
28 Jul 15 |
olle |
var y = event.clientY-halfHeight; |
3449 |
28 Jul 15 |
olle |
var scroll = 0; |
3449 |
28 Jul 15 |
olle |
var barcodeDiv; |
3449 |
28 Jul 15 |
olle |
360 |
|
3449 |
28 Jul 15 |
olle |
var useBarcode = currentWell.barcode || lastSelectedBarcode; |
3449 |
28 Jul 15 |
olle |
if (useBarcode) |
3449 |
28 Jul 15 |
olle |
363 |
{ |
3449 |
28 Jul 15 |
olle |
var barcodeDiv = Doc.element('bc-'+useBarcode.id); |
3449 |
28 Jul 15 |
olle |
if (!currentWell.barcode && barcodeDiv.nextSibling) barcodeDiv = barcodeDiv.nextSibling; |
3449 |
28 Jul 15 |
olle |
// Try to scroll the current barcode so that it's baseline is at the center of the div |
3449 |
28 Jul 15 |
olle |
scroll = barcodeDiv.offsetTop + barcodeDiv.offsetHeight - halfHeight; |
3449 |
28 Jul 15 |
olle |
if (scroll < 0) |
3449 |
28 Jul 15 |
olle |
369 |
{ |
3449 |
28 Jul 15 |
olle |
// We get a negative scroll for the first few elements, shift the |
3449 |
28 Jul 15 |
olle |
// entire selection div down instead |
3449 |
28 Jul 15 |
olle |
y -= scroll; |
3449 |
28 Jul 15 |
olle |
scroll = 0; |
3449 |
28 Jul 15 |
olle |
374 |
} |
3449 |
28 Jul 15 |
olle |
else if (scroll > selectAll.scrollHeight - selectAll.offsetHeight) |
3449 |
28 Jul 15 |
olle |
376 |
{ |
3449 |
28 Jul 15 |
olle |
// We get a too large scroll value for the last few elements, shift |
3449 |
28 Jul 15 |
olle |
// the entire selection div up instead |
3449 |
28 Jul 15 |
olle |
y -= scroll - (selectAll.scrollHeight - selectAll.offsetHeight); |
3449 |
28 Jul 15 |
olle |
scroll = selectAll.scrollHeight - selectAll.offsetHeight; |
3449 |
28 Jul 15 |
olle |
381 |
} |
3449 |
28 Jul 15 |
olle |
if (currentWell.barcode) |
3449 |
28 Jul 15 |
olle |
383 |
{ |
3449 |
28 Jul 15 |
olle |
Doc.addClass(barcodeDiv, 'current'); |
3449 |
28 Jul 15 |
olle |
385 |
} |
3449 |
28 Jul 15 |
olle |
386 |
} |
3449 |
28 Jul 15 |
olle |
387 |
|
3449 |
28 Jul 15 |
olle |
// Default barcode |
3449 |
28 Jul 15 |
olle |
if (currentWell.defaultBarcode && currentWell.defaultBarcode != currentWell.barcode) |
3449 |
28 Jul 15 |
olle |
390 |
{ |
3449 |
28 Jul 15 |
olle |
var selectDefault = Doc.element('select-barcode-default'); |
3449 |
28 Jul 15 |
olle |
Data.set(selectDefault, 'barcode-name', currentWell.defaultBarcode.name); |
3449 |
28 Jul 15 |
olle |
selectDefault.innerHTML = 'Default: ' + Strings.encodeTags(currentWell.defaultBarcode.name); |
3449 |
28 Jul 15 |
olle |
Doc.show('select-barcode-default'); |
3449 |
28 Jul 15 |
olle |
Doc.show('select-barcode-default-separator'); |
3449 |
28 Jul 15 |
olle |
396 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
398 |
{ |
3449 |
28 Jul 15 |
olle |
Doc.hide('select-barcode-default'); |
3449 |
28 Jul 15 |
olle |
Doc.hide('select-barcode-default-separator'); |
3449 |
28 Jul 15 |
olle |
401 |
} |
3449 |
28 Jul 15 |
olle |
402 |
|
3449 |
28 Jul 15 |
olle |
// Position the selection div |
3449 |
28 Jul 15 |
olle |
selectAll.scrollTop = scroll; |
3449 |
28 Jul 15 |
olle |
menu.style.left = (x)+'px'; |
3449 |
28 Jul 15 |
olle |
menu.style.top = (y)+'px'; |
3449 |
28 Jul 15 |
olle |
event.stopPropagation(); |
3449 |
28 Jul 15 |
olle |
408 |
} |
3449 |
28 Jul 15 |
olle |
409 |
|
3449 |
28 Jul 15 |
olle |
selectdna.barcodeSelected = function(event) |
3449 |
28 Jul 15 |
olle |
411 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
var schema = PoolSchema.getById(frm.pool_schema.value); |
3449 |
28 Jul 15 |
olle |
var target = event.target; |
3449 |
28 Jul 15 |
olle |
if (currentWell) |
3449 |
28 Jul 15 |
olle |
416 |
{ |
3449 |
28 Jul 15 |
olle |
lastSelectedBarcode = barcodesByName[Data.get(target, 'barcode-name')]; |
3449 |
28 Jul 15 |
olle |
currentWell.barcode = lastSelectedBarcode; |
3449 |
28 Jul 15 |
olle |
var poolNum = schema.getPoolNumForColumn(currentWell.column); |
3449 |
28 Jul 15 |
olle |
selectdna.checkDuplicateBarcode(poolNum); |
3449 |
28 Jul 15 |
olle |
Plate.paint(Plate.getWells()); |
3449 |
28 Jul 15 |
olle |
422 |
} |
3449 |
28 Jul 15 |
olle |
selectdna.hideBarcodeSelection(); |
3449 |
28 Jul 15 |
olle |
424 |
} |
3449 |
28 Jul 15 |
olle |
425 |
|
3449 |
28 Jul 15 |
olle |
selectdna.checkDuplicateBarcode = function(poolNum) |
3449 |
28 Jul 15 |
olle |
427 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
var schema = PoolSchema.getById(frm.pool_schema.value); |
3449 |
28 Jul 15 |
olle |
430 |
|
3449 |
28 Jul 15 |
olle |
var wells = schema.getWellsInPool(Plate, poolNum); |
3449 |
28 Jul 15 |
olle |
var wellByBarcodeName = []; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
434 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
if (well.barcode) |
3449 |
28 Jul 15 |
olle |
437 |
{ |
3449 |
28 Jul 15 |
olle |
if (wellByBarcodeName[well.barcode.name]) |
3449 |
28 Jul 15 |
olle |
439 |
{ |
3449 |
28 Jul 15 |
olle |
well.duplicate = true; |
3449 |
28 Jul 15 |
olle |
wellByBarcodeName[well.barcode.name].duplicate = true; |
3449 |
28 Jul 15 |
olle |
442 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
444 |
{ |
3449 |
28 Jul 15 |
olle |
wellByBarcodeName[well.barcode.name] = well; |
3449 |
28 Jul 15 |
olle |
well.duplicate = false; |
3449 |
28 Jul 15 |
olle |
447 |
} |
3449 |
28 Jul 15 |
olle |
448 |
} |
3449 |
28 Jul 15 |
olle |
449 |
} |
3449 |
28 Jul 15 |
olle |
450 |
} |
3449 |
28 Jul 15 |
olle |
451 |
|
3449 |
28 Jul 15 |
olle |
452 |
|
3449 |
28 Jul 15 |
olle |
selectdna.hideBarcodeSelection = function() |
3449 |
28 Jul 15 |
olle |
454 |
{ |
3449 |
28 Jul 15 |
olle |
Doc.hide('select-barcode'); |
3449 |
28 Jul 15 |
olle |
456 |
} |
3449 |
28 Jul 15 |
olle |
457 |
|
3449 |
28 Jul 15 |
olle |
458 |
|
3449 |
28 Jul 15 |
olle |
459 |
/** |
3449 |
28 Jul 15 |
olle |
Sets default display of info data for plate wells, |
3449 |
28 Jul 15 |
olle |
based on check box values. Assumes the id of the |
3449 |
28 Jul 15 |
olle |
check box in question as input. |
3449 |
28 Jul 15 |
olle |
463 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.setDefaultInfo = function(chkbox) |
3449 |
28 Jul 15 |
olle |
465 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
var show = frm[chkbox].checked; |
3449 |
28 Jul 15 |
olle |
Doc.addOrRemoveClass('plate', 'hide-'+chkbox, !show); |
3449 |
28 Jul 15 |
olle |
469 |
} |
3449 |
28 Jul 15 |
olle |
470 |
|
3449 |
28 Jul 15 |
olle |
selectdna.toggleInfo = function(event) |
3449 |
28 Jul 15 |
olle |
472 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
var show = event.currentTarget.checked; |
3449 |
28 Jul 15 |
olle |
Doc.addOrRemoveClass('plate', 'hide-'+event.currentTarget.id, !show); |
3449 |
28 Jul 15 |
olle |
476 |
} |
3449 |
28 Jul 15 |
olle |
477 |
|
3449 |
28 Jul 15 |
olle |
478 |
/** |
3449 |
28 Jul 15 |
olle |
Open a popup dialog for selecting a data files. |
3449 |
28 Jul 15 |
olle |
480 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.selectFile = function() |
3449 |
28 Jul 15 |
olle |
482 |
{ |
3449 |
28 Jul 15 |
olle |
Dialogs.openPopup('select_file.jsp?ID='+App.getSessionId(), 'SelectFile', 600, 400); |
3449 |
28 Jul 15 |
olle |
484 |
} |
3449 |
28 Jul 15 |
olle |
485 |
|
3449 |
28 Jul 15 |
olle |
486 |
/** |
3449 |
28 Jul 15 |
olle |
Parse a tab-separated data file. The columns must be in the following order: |
3449 |
28 Jul 15 |
olle |
0: DNA name |
3449 |
28 Jul 15 |
olle |
1: Row letter (A-H) |
3449 |
28 Jul 15 |
olle |
2: Column number (1-12) |
3449 |
28 Jul 15 |
olle |
3: QC flag (can be empty) |
3449 |
28 Jul 15 |
olle |
492 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.parseDnaFile = function(data) |
3449 |
28 Jul 15 |
olle |
494 |
{ |
3449 |
28 Jul 15 |
olle |
var lines = data.split(/[\n\r]+/); |
3449 |
28 Jul 15 |
olle |
496 |
|
3449 |
28 Jul 15 |
olle |
// Load information about all DNA items in a batch (will improve performance) |
3449 |
28 Jul 15 |
olle |
var names = []; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < lines.length; i++) |
3449 |
28 Jul 15 |
olle |
500 |
{ |
3449 |
28 Jul 15 |
olle |
var line = lines[i]; |
3449 |
28 Jul 15 |
olle |
if (line) |
3449 |
28 Jul 15 |
olle |
503 |
{ |
3449 |
28 Jul 15 |
olle |
var cols = lines[i].split(/\t/); |
3449 |
28 Jul 15 |
olle |
if (cols.length < 3) throw 'On line '+(i+1)+': Too few columns (' + cols.length + ')'; |
3449 |
28 Jul 15 |
olle |
names[names.length] = cols[0]; |
3449 |
28 Jul 15 |
olle |
507 |
} |
3449 |
28 Jul 15 |
olle |
508 |
} |
3449 |
28 Jul 15 |
olle |
Dna.loadInfoByNames(names); |
3449 |
28 Jul 15 |
olle |
510 |
|
3449 |
28 Jul 15 |
olle |
// Place DNA on the plate |
3449 |
28 Jul 15 |
olle |
var duplicates = []; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < lines.length; i++) |
3449 |
28 Jul 15 |
olle |
514 |
{ |
3449 |
28 Jul 15 |
olle |
var line = lines[i]; |
3449 |
28 Jul 15 |
olle |
if (line) |
3449 |
28 Jul 15 |
olle |
517 |
{ |
3449 |
28 Jul 15 |
olle |
var cols = lines[i].split(/\t/); |
3449 |
28 Jul 15 |
olle |
519 |
|
3449 |
28 Jul 15 |
olle |
var dna = Dna.createByName(cols[0]); |
3449 |
28 Jul 15 |
olle |
var row = Meludi.alphaToWell(cols[1].toUpperCase()); |
3449 |
28 Jul 15 |
olle |
var col = parseInt(cols[2], 10)-1; |
3449 |
28 Jul 15 |
olle |
523 |
|
3449 |
28 Jul 15 |
olle |
var well = Plate.getWell(row, col); |
3449 |
28 Jul 15 |
olle |
if (!well) throw 'On line '+(i+1)+': Invalid plate coordinate ['+cols[1]+','+cols[2]+']'; |
3449 |
28 Jul 15 |
olle |
526 |
|
3449 |
28 Jul 15 |
olle |
dna.qc = cols.length >= 4 && cols[3]; |
3449 |
28 Jul 15 |
olle |
Dna.unflag(dna); |
3449 |
28 Jul 15 |
olle |
529 |
|
3449 |
28 Jul 15 |
olle |
// Check for duplicate DNA on same position (which is an error) |
3449 |
28 Jul 15 |
olle |
var pos = 'c'+col+'r'+row; |
3449 |
28 Jul 15 |
olle |
if (duplicates[pos]) |
3449 |
28 Jul 15 |
olle |
533 |
{ |
3449 |
28 Jul 15 |
olle |
well.addDuplicate(dna); |
3449 |
28 Jul 15 |
olle |
535 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
537 |
{ |
3449 |
28 Jul 15 |
olle |
duplicates[pos] = dna.name; |
3449 |
28 Jul 15 |
olle |
well.setExtract(dna); |
3449 |
28 Jul 15 |
olle |
540 |
} |
3449 |
28 Jul 15 |
olle |
541 |
} |
3449 |
28 Jul 15 |
olle |
542 |
} |
3449 |
28 Jul 15 |
olle |
543 |
|
3449 |
28 Jul 15 |
olle |
selectdna.updateNumFlaggedDna(); |
3449 |
28 Jul 15 |
olle |
545 |
|
3449 |
28 Jul 15 |
olle |
// Check for replicates on the whole plate and repaint it |
3449 |
28 Jul 15 |
olle |
Plate.checkReplicates(null, true); |
3449 |
28 Jul 15 |
olle |
Plate.paint(Plate.getWells()); |
3449 |
28 Jul 15 |
olle |
549 |
} |
3449 |
28 Jul 15 |
olle |
550 |
|
3449 |
28 Jul 15 |
olle |
var currentSelected; |
3449 |
28 Jul 15 |
olle |
var names = []; |
3449 |
28 Jul 15 |
olle |
553 |
|
3449 |
28 Jul 15 |
olle |
554 |
/** |
3449 |
28 Jul 15 |
olle |
Open a popup dialog for manual selection of DNA. |
3449 |
28 Jul 15 |
olle |
556 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.manualSelect = function(event) |
3449 |
28 Jul 15 |
olle |
558 |
{ |
3449 |
28 Jul 15 |
olle |
currentSelected = Plate.getSelected(); |
3449 |
28 Jul 15 |
olle |
if (currentSelected.length == 0) |
3449 |
28 Jul 15 |
olle |
561 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'Please select one or more wells were DNA should be placed.'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
564 |
} |
3449 |
28 Jul 15 |
olle |
565 |
|
3449 |
28 Jul 15 |
olle |
if (subtypeDna == null) subtypeDna = Meludi.getSubtypeInfo('DNA'); |
3449 |
28 Jul 15 |
olle |
567 |
/* |
3449 |
28 Jul 15 |
olle |
if (subtypeDnaNormalized == null) subtypeDnaNormalized = Meludi.getSubtypeInfo('DNA_NORMALIZED_ALIQUOT'); |
3449 |
28 Jul 15 |
olle |
569 |
*/ |
3449 |
28 Jul 15 |
olle |
570 |
|
3449 |
28 Jul 15 |
olle |
var url = '&resetTemporary=1'; |
3449 |
28 Jul 15 |
olle |
572 |
/* |
3449 |
28 Jul 15 |
olle |
url += '&tmpfilter:INT:itemSubtype='+subtypeDna.id+'|'+subtypeDnaNormalized.id; |
3449 |
28 Jul 15 |
olle |
574 |
*/ |
3449 |
28 Jul 15 |
olle |
url += '&tmpfilter:INT:itemSubtype='+subtypeDna.id; |
3449 |
28 Jul 15 |
olle |
url += '&tmpfilter:DATE:creationEvent.eventDate='+encodeURIComponent('<>'); |
3449 |
28 Jul 15 |
olle |
url += '&tmpfilter:FLOAT:remainingQuantity='+encodeURIComponent('>=1'); |
3449 |
28 Jul 15 |
olle |
url += '&'+encodeURIComponent('tmpfilter:STRING:&childCreationEvents(event.bioMaterial.name)')+'='+encodeURIComponent('<>%.m'); |
3449 |
28 Jul 15 |
olle |
579 |
|
3449 |
28 Jul 15 |
olle |
Dialogs.selectItem('EXTRACT', 'plate', 1, url); |
3449 |
28 Jul 15 |
olle |
581 |
} |
3449 |
28 Jul 15 |
olle |
582 |
|
3449 |
28 Jul 15 |
olle |
583 |
/** |
3449 |
28 Jul 15 |
olle |
Callback method for manual selection. |
3449 |
28 Jul 15 |
olle |
585 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.manuallySelected = function(event) |
3449 |
28 Jul 15 |
olle |
587 |
{ |
3449 |
28 Jul 15 |
olle |
names[names.length] = event.detail.name; |
3449 |
28 Jul 15 |
olle |
589 |
|
3449 |
28 Jul 15 |
olle |
if (event.detail.remaining == 0 && names.length > 0) |
3449 |
28 Jul 15 |
olle |
591 |
{ |
3449 |
28 Jul 15 |
olle |
Dna.loadInfoByNames(names); |
3449 |
28 Jul 15 |
olle |
593 |
|
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < names.length && i < currentSelected.length; i++) |
3449 |
28 Jul 15 |
olle |
595 |
{ |
3449 |
28 Jul 15 |
olle |
var well = currentSelected[i]; |
3449 |
28 Jul 15 |
olle |
var name = names[i]; |
3449 |
28 Jul 15 |
olle |
598 |
|
3449 |
28 Jul 15 |
olle |
// Create a new DNA object |
3449 |
28 Jul 15 |
olle |
var dna = Dna.createByName(name); |
3449 |
28 Jul 15 |
olle |
Dna.unflag(dna); |
3449 |
28 Jul 15 |
olle |
well.setExtract(dna); |
3449 |
28 Jul 15 |
olle |
well.selected = false; |
3449 |
28 Jul 15 |
olle |
604 |
} |
3449 |
28 Jul 15 |
olle |
605 |
|
3449 |
28 Jul 15 |
olle |
Plate.checkReplicates(); |
3449 |
28 Jul 15 |
olle |
Plate.paint(currentSelected); |
3449 |
28 Jul 15 |
olle |
selectdna.updateNumFlaggedDna(); |
3449 |
28 Jul 15 |
olle |
names = []; |
3449 |
28 Jul 15 |
olle |
610 |
} |
3449 |
28 Jul 15 |
olle |
611 |
} |
3449 |
28 Jul 15 |
olle |
612 |
|
3449 |
28 Jul 15 |
olle |
613 |
|
3449 |
28 Jul 15 |
olle |
614 |
/** |
3449 |
28 Jul 15 |
olle |
Let the wizard automatically select among unprocessed DNA items. |
3449 |
28 Jul 15 |
olle |
616 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.autoSelect = function(event) |
3449 |
28 Jul 15 |
olle |
618 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getWells(); |
3449 |
28 Jul 15 |
olle |
var selected = []; |
3449 |
28 Jul 15 |
olle |
var ignore = []; |
3449 |
28 Jul 15 |
olle |
var notEmpty = 0; |
3449 |
28 Jul 15 |
olle |
624 |
|
3449 |
28 Jul 15 |
olle |
// Count selected and non-empty wells and keep track of DNA that is already present |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
627 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
if (well.selected) |
3449 |
28 Jul 15 |
olle |
630 |
{ |
3449 |
28 Jul 15 |
olle |
selected[selected.length] = well; |
3449 |
28 Jul 15 |
olle |
if (well.extract && !well.hasError()) notEmpty++; |
3449 |
28 Jul 15 |
olle |
633 |
} |
3449 |
28 Jul 15 |
olle |
if (well.extract && well.extract.id) |
3449 |
28 Jul 15 |
olle |
635 |
{ |
3449 |
28 Jul 15 |
olle |
ignore[ignore.length] = well.extract.id; |
3449 |
28 Jul 15 |
olle |
637 |
} |
3449 |
28 Jul 15 |
olle |
638 |
} |
3449 |
28 Jul 15 |
olle |
// Ignore DNA already flagged |
3449 |
28 Jul 15 |
olle |
var flagged = Dna.getFlagged(); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < flagged.length; i++) |
3449 |
28 Jul 15 |
olle |
642 |
{ |
3449 |
28 Jul 15 |
olle |
var dna = flagged[i]; |
3449 |
28 Jul 15 |
olle |
if (dna.id) ignore[ignore.length] = dna.id; |
3449 |
28 Jul 15 |
olle |
645 |
} |
3449 |
28 Jul 15 |
olle |
646 |
|
3449 |
28 Jul 15 |
olle |
if (selected.length == 0) |
3449 |
28 Jul 15 |
olle |
648 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'Please select one or more wells were DNA should be placed.'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
651 |
} |
3449 |
28 Jul 15 |
olle |
652 |
|
3449 |
28 Jul 15 |
olle |
if (notEmpty > 0) |
3449 |
28 Jul 15 |
olle |
654 |
{ |
3449 |
28 Jul 15 |
olle |
if (!confirm('Replace DNA in ' + notEmpty + ' wells?')) |
3449 |
28 Jul 15 |
olle |
656 |
{ |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
658 |
} |
3449 |
28 Jul 15 |
olle |
659 |
} |
3449 |
28 Jul 15 |
olle |
660 |
|
3449 |
28 Jul 15 |
olle |
var url = 'auto_select_dna.jsp?ID='+App.getSessionId(); |
3449 |
28 Jul 15 |
olle |
url += '&numToSelect='+selected.length; |
3449 |
28 Jul 15 |
olle |
url += '&quantity='+encodeURIComponent(frm.quantity_regular.value); |
3449 |
28 Jul 15 |
olle |
url += '&ignore='+ignore.join(','); |
3449 |
28 Jul 15 |
olle |
Dialogs.openPopup(url, 'AutoSelectDNA', 750, 500); |
3449 |
28 Jul 15 |
olle |
666 |
} |
3449 |
28 Jul 15 |
olle |
667 |
|
3449 |
28 Jul 15 |
olle |
668 |
/** |
3449 |
28 Jul 15 |
olle |
Callback function for auto-select. |
3449 |
28 Jul 15 |
olle |
670 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.dnaSelected = function(response) |
3449 |
28 Jul 15 |
olle |
672 |
{ |
3449 |
28 Jul 15 |
olle |
// Cache DNA information |
3449 |
28 Jul 15 |
olle |
Dna.cacheInfo(response.dna); |
3449 |
28 Jul 15 |
olle |
Dna.cacheInfo(response.flagged); |
3449 |
28 Jul 15 |
olle |
676 |
|
3449 |
28 Jul 15 |
olle |
selectdna.updateNumFlaggedDna(); |
3449 |
28 Jul 15 |
olle |
var selected = Plate.getSelected(); |
3449 |
28 Jul 15 |
olle |
679 |
|
3449 |
28 Jul 15 |
olle |
680 |
/* |
3449 |
28 Jul 15 |
olle |
// Get selected DNA names |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < response.dna.length; i++) |
3449 |
28 Jul 15 |
olle |
683 |
{ |
3449 |
28 Jul 15 |
olle |
if (i < selected.length) |
3449 |
28 Jul 15 |
olle |
685 |
{ |
3449 |
28 Jul 15 |
olle |
names[i] = response.dna[i].name; |
3449 |
28 Jul 15 |
olle |
687 |
} |
3449 |
28 Jul 15 |
olle |
688 |
} |
3449 |
28 Jul 15 |
olle |
if (names.length > 0) |
3449 |
28 Jul 15 |
olle |
690 |
{ |
3449 |
28 Jul 15 |
olle |
Dna.loadInfoByNames(names); |
3449 |
28 Jul 15 |
olle |
692 |
|
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < names.length && i < selected.length; i++) |
3449 |
28 Jul 15 |
olle |
694 |
{ |
3449 |
28 Jul 15 |
olle |
var well = selected[i]; |
3449 |
28 Jul 15 |
olle |
var name = names[i]; |
3449 |
28 Jul 15 |
olle |
697 |
|
3449 |
28 Jul 15 |
olle |
// Create a new DNA object |
3449 |
28 Jul 15 |
olle |
var dna = Dna.createByName(name); |
3449 |
28 Jul 15 |
olle |
Dna.unflag(dna); |
3449 |
28 Jul 15 |
olle |
well.setExtract(dna); |
3449 |
28 Jul 15 |
olle |
well.selected = false; |
3449 |
28 Jul 15 |
olle |
703 |
} |
3449 |
28 Jul 15 |
olle |
704 |
|
3449 |
28 Jul 15 |
olle |
Plate.checkReplicates(); |
3449 |
28 Jul 15 |
olle |
Plate.paint(selected); |
3449 |
28 Jul 15 |
olle |
selectdna.updateNumFlaggedDna(); |
3449 |
28 Jul 15 |
olle |
names = []; |
3449 |
28 Jul 15 |
olle |
709 |
} |
3449 |
28 Jul 15 |
olle |
710 |
*/ |
3449 |
28 Jul 15 |
olle |
711 |
|
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < response.dna.length; i++) |
3449 |
28 Jul 15 |
olle |
713 |
{ |
3449 |
28 Jul 15 |
olle |
if (i < selected.length) |
3449 |
28 Jul 15 |
olle |
715 |
{ |
3449 |
28 Jul 15 |
olle |
var well = selected[i]; |
3449 |
28 Jul 15 |
olle |
// Create a new DNA object |
3449 |
28 Jul 15 |
olle |
var dna = Dna.createByName(response.dna[i].name); |
3449 |
28 Jul 15 |
olle |
well.setExtract(dna); |
3449 |
28 Jul 15 |
olle |
well.selected = false; |
3449 |
28 Jul 15 |
olle |
721 |
} |
3449 |
28 Jul 15 |
olle |
722 |
} |
3449 |
28 Jul 15 |
olle |
723 |
|
3449 |
28 Jul 15 |
olle |
// Check for replicates on the whole plate and repaint it |
3449 |
28 Jul 15 |
olle |
Plate.checkReplicates(null, true); |
3449 |
28 Jul 15 |
olle |
Plate.paint(Plate.getWells()); |
3449 |
28 Jul 15 |
olle |
727 |
} |
3449 |
28 Jul 15 |
olle |
728 |
|
3449 |
28 Jul 15 |
olle |
// Update the 'Flagged DNA' information |
3449 |
28 Jul 15 |
olle |
selectdna.updateNumFlaggedDna = function() |
3449 |
28 Jul 15 |
olle |
731 |
{ |
3449 |
28 Jul 15 |
olle |
var numFlagged = Dna.getFlagged().length; |
3449 |
28 Jul 15 |
olle |
if (numFlagged > 0) |
3449 |
28 Jul 15 |
olle |
734 |
{ |
3449 |
28 Jul 15 |
olle |
Doc.element('flaggedDna').innerHTML = numFlagged + ' flagged DNA items.'; |
3449 |
28 Jul 15 |
olle |
Doc.show('flaggedDna'); |
3449 |
28 Jul 15 |
olle |
737 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
739 |
{ |
3449 |
28 Jul 15 |
olle |
Doc.hide('flaggedDna'); |
3449 |
28 Jul 15 |
olle |
741 |
} |
3449 |
28 Jul 15 |
olle |
742 |
} |
3449 |
28 Jul 15 |
olle |
743 |
|
3449 |
28 Jul 15 |
olle |
744 |
/** |
3449 |
28 Jul 15 |
olle |
Add 'Stratagene' to the selected wells. |
3449 |
28 Jul 15 |
olle |
746 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.setToStratagene = function(event) |
3449 |
28 Jul 15 |
olle |
748 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
selectdna.setToSpecial(event, frm.stratagene.value, true); |
3449 |
28 Jul 15 |
olle |
751 |
} |
3449 |
28 Jul 15 |
olle |
752 |
|
3449 |
28 Jul 15 |
olle |
753 |
|
3449 |
28 Jul 15 |
olle |
754 |
/** |
3449 |
28 Jul 15 |
olle |
Add 'External DNA' to the selected wells. |
3449 |
28 Jul 15 |
olle |
756 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.setToExternal = function(event) |
3449 |
28 Jul 15 |
olle |
758 |
{ |
3449 |
28 Jul 15 |
olle |
selectdna.setToSpecial(event, EXTERNAL_DNA_NAME, false); |
3449 |
28 Jul 15 |
olle |
760 |
} |
3449 |
28 Jul 15 |
olle |
761 |
|
3449 |
28 Jul 15 |
olle |
762 |
/** |
3449 |
28 Jul 15 |
olle |
Add special DNA to the selected wells. |
3449 |
28 Jul 15 |
olle |
764 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.setToSpecial = function(event, specialName, qc) |
3449 |
28 Jul 15 |
olle |
766 |
{ |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getSelected(); |
3449 |
28 Jul 15 |
olle |
768 |
|
3449 |
28 Jul 15 |
olle |
if (wells.length == 0) |
3449 |
28 Jul 15 |
olle |
770 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'No wells have been selected'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
773 |
} |
3449 |
28 Jul 15 |
olle |
774 |
|
3449 |
28 Jul 15 |
olle |
// Count non-empty wells |
3449 |
28 Jul 15 |
olle |
var count = 0; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
778 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
if (well.extract && !well.hasError()) count++; |
3449 |
28 Jul 15 |
olle |
781 |
} |
3449 |
28 Jul 15 |
olle |
782 |
|
3449 |
28 Jul 15 |
olle |
if (count > 0) |
3449 |
28 Jul 15 |
olle |
784 |
{ |
3449 |
28 Jul 15 |
olle |
if (!confirm('Replace DNA in ' + count + ' wells with '+specialName+'?')) |
3449 |
28 Jul 15 |
olle |
786 |
{ |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
788 |
} |
3449 |
28 Jul 15 |
olle |
789 |
} |
3449 |
28 Jul 15 |
olle |
790 |
|
3449 |
28 Jul 15 |
olle |
var info = Dna.infoByName(specialName); |
3449 |
28 Jul 15 |
olle |
if (!info.id) |
3449 |
28 Jul 15 |
olle |
793 |
{ |
3449 |
28 Jul 15 |
olle |
alert('Could not find any DNA with name=\''+specialName+'\'. Please check that it exists on the server.'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
796 |
} |
3449 |
28 Jul 15 |
olle |
797 |
|
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
799 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
var dna = Dna.createByInfo(info); |
3449 |
28 Jul 15 |
olle |
dna.qc = qc; |
3449 |
28 Jul 15 |
olle |
well.setExtract(dna); |
3449 |
28 Jul 15 |
olle |
well.selected = false; |
3449 |
28 Jul 15 |
olle |
805 |
} |
3449 |
28 Jul 15 |
olle |
806 |
|
3449 |
28 Jul 15 |
olle |
Plate.paint(wells); |
3449 |
28 Jul 15 |
olle |
808 |
|
3449 |
28 Jul 15 |
olle |
// Check for replicated DNA if some have been replaced with Stratagene |
3449 |
28 Jul 15 |
olle |
if (count > 0) Plate.checkReplicates(); |
3449 |
28 Jul 15 |
olle |
811 |
} |
3449 |
28 Jul 15 |
olle |
812 |
|
3449 |
28 Jul 15 |
olle |
813 |
/** |
3449 |
28 Jul 15 |
olle |
Toggle the QC flag for the selected wells. The first non-empty |
3449 |
28 Jul 15 |
olle |
well is toggled and the rest of the wells will use the same new QC |
3449 |
28 Jul 15 |
olle |
value. |
3449 |
28 Jul 15 |
olle |
817 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.toggleQc = function(event) |
3449 |
28 Jul 15 |
olle |
819 |
{ |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getSelected(); |
3449 |
28 Jul 15 |
olle |
821 |
|
3449 |
28 Jul 15 |
olle |
if (wells.length == 0) |
3449 |
28 Jul 15 |
olle |
823 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'No wells have been selected'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
826 |
} |
3449 |
28 Jul 15 |
olle |
827 |
|
3449 |
28 Jul 15 |
olle |
var gotQc = false; |
3449 |
28 Jul 15 |
olle |
var newQc; |
3449 |
28 Jul 15 |
olle |
var count = 0; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
832 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
if (well.extract) |
3449 |
28 Jul 15 |
olle |
835 |
{ |
3449 |
28 Jul 15 |
olle |
// Toggle QC flag for the first well with DNA, then use the same flag for the rest |
3449 |
28 Jul 15 |
olle |
if (!gotQc) |
3449 |
28 Jul 15 |
olle |
838 |
{ |
3449 |
28 Jul 15 |
olle |
gotQc = true; |
3449 |
28 Jul 15 |
olle |
newQc = !well.extract.qc; |
3449 |
28 Jul 15 |
olle |
841 |
} |
3449 |
28 Jul 15 |
olle |
well.extract.qc = newQc; |
3449 |
28 Jul 15 |
olle |
count++; |
3449 |
28 Jul 15 |
olle |
844 |
} |
3449 |
28 Jul 15 |
olle |
845 |
} |
3449 |
28 Jul 15 |
olle |
846 |
|
3449 |
28 Jul 15 |
olle |
if (count == 0) |
3449 |
28 Jul 15 |
olle |
848 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'None of the selected wells contain any DNA'); |
3449 |
28 Jul 15 |
olle |
850 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
852 |
{ |
3449 |
28 Jul 15 |
olle |
Plate.paint(wells); |
3449 |
28 Jul 15 |
olle |
854 |
} |
3449 |
28 Jul 15 |
olle |
855 |
} |
3449 |
28 Jul 15 |
olle |
856 |
|
3449 |
28 Jul 15 |
olle |
// Set a comment on the selected wells |
3449 |
28 Jul 15 |
olle |
selectdna.commentSelected = function(event) |
3449 |
28 Jul 15 |
olle |
859 |
{ |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getSelected(); |
3449 |
28 Jul 15 |
olle |
861 |
|
3449 |
28 Jul 15 |
olle |
if (wells.length == 0) |
3449 |
28 Jul 15 |
olle |
863 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'No wells have been selected'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
866 |
} |
3449 |
28 Jul 15 |
olle |
867 |
|
3449 |
28 Jul 15 |
olle |
var count = 0; |
3449 |
28 Jul 15 |
olle |
var comment = ''; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
871 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
if (well.extract) |
3449 |
28 Jul 15 |
olle |
874 |
{ |
3449 |
28 Jul 15 |
olle |
count++; |
3449 |
28 Jul 15 |
olle |
if (well.extract.comment) comment = well.extract.comment; |
3449 |
28 Jul 15 |
olle |
877 |
} |
3449 |
28 Jul 15 |
olle |
878 |
} |
3449 |
28 Jul 15 |
olle |
879 |
|
3449 |
28 Jul 15 |
olle |
if (count == 0) |
3449 |
28 Jul 15 |
olle |
881 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'None of the selected wells contain any DNA'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
884 |
} |
3449 |
28 Jul 15 |
olle |
885 |
|
3449 |
28 Jul 15 |
olle |
comment = prompt('Comment', comment || ''); |
3449 |
28 Jul 15 |
olle |
if (comment == null) return; |
3449 |
28 Jul 15 |
olle |
888 |
|
3449 |
28 Jul 15 |
olle |
if (comment == '') comment = null; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
891 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
if (well.extract) well.extract.comment = comment; |
3449 |
28 Jul 15 |
olle |
894 |
} |
3449 |
28 Jul 15 |
olle |
Plate.paint(wells); |
3449 |
28 Jul 15 |
olle |
896 |
} |
3449 |
28 Jul 15 |
olle |
897 |
|
3449 |
28 Jul 15 |
olle |
898 |
/** |
3449 |
28 Jul 15 |
olle |
Empty the selected wells from DNA. They can later be pasted again. |
3449 |
28 Jul 15 |
olle |
900 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.cutSelected = function(event) |
3449 |
28 Jul 15 |
olle |
902 |
{ |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getSelected(); |
3449 |
28 Jul 15 |
olle |
904 |
|
3449 |
28 Jul 15 |
olle |
if (wells.length == 0) |
3449 |
28 Jul 15 |
olle |
906 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'No wells have been selected'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
909 |
} |
3449 |
28 Jul 15 |
olle |
910 |
|
3449 |
28 Jul 15 |
olle |
var count = 0; |
3449 |
28 Jul 15 |
olle |
var valid = 0; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
914 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
if (well.extract) |
3449 |
28 Jul 15 |
olle |
917 |
{ |
3449 |
28 Jul 15 |
olle |
count++; |
3449 |
28 Jul 15 |
olle |
if (!well.hasError()) valid++; |
3449 |
28 Jul 15 |
olle |
920 |
} |
3449 |
28 Jul 15 |
olle |
921 |
} |
3449 |
28 Jul 15 |
olle |
922 |
|
3449 |
28 Jul 15 |
olle |
if (count == 0) |
3449 |
28 Jul 15 |
olle |
924 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'None of the selected wells contain any DNA'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
927 |
} |
3449 |
28 Jul 15 |
olle |
928 |
|
3449 |
28 Jul 15 |
olle |
// Ask for confirmation before deleting from valid wells |
3449 |
28 Jul 15 |
olle |
if (valid > 0) |
3449 |
28 Jul 15 |
olle |
931 |
{ |
3449 |
28 Jul 15 |
olle |
if (!confirm('Clear DNA from ' + count + ' of ' + wells.length + ' selected wells?')) |
3449 |
28 Jul 15 |
olle |
933 |
{ |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
935 |
} |
3449 |
28 Jul 15 |
olle |
936 |
} |
3449 |
28 Jul 15 |
olle |
937 |
|
3449 |
28 Jul 15 |
olle |
selectdna.copySelected(); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
940 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
well.setExtract(null); |
3449 |
28 Jul 15 |
olle |
well.selected = false; |
3449 |
28 Jul 15 |
olle |
944 |
} |
3449 |
28 Jul 15 |
olle |
Plate.paint(wells); |
3449 |
28 Jul 15 |
olle |
Plate.checkReplicates(); |
3449 |
28 Jul 15 |
olle |
947 |
} |
3449 |
28 Jul 15 |
olle |
948 |
|
3449 |
28 Jul 15 |
olle |
var copy; |
3449 |
28 Jul 15 |
olle |
950 |
/** |
3449 |
28 Jul 15 |
olle |
Copy information about the selected wells. |
3449 |
28 Jul 15 |
olle |
952 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.copySelected = function(event) |
3449 |
28 Jul 15 |
olle |
954 |
{ |
3449 |
28 Jul 15 |
olle |
// Clear existing wells in the copy |
3449 |
28 Jul 15 |
olle |
var repaint = []; |
3449 |
28 Jul 15 |
olle |
if (copy && copy.length > 0) |
3449 |
28 Jul 15 |
olle |
958 |
{ |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < copy.length; i++) |
3449 |
28 Jul 15 |
olle |
960 |
{ |
3449 |
28 Jul 15 |
olle |
var cp = copy[i]; |
3449 |
28 Jul 15 |
olle |
cp.well.doneWithCopy(); |
3449 |
28 Jul 15 |
olle |
repaint[repaint.length] = cp.well; |
3449 |
28 Jul 15 |
olle |
964 |
} |
3449 |
28 Jul 15 |
olle |
965 |
} |
3449 |
28 Jul 15 |
olle |
Plate.paint(repaint); |
3449 |
28 Jul 15 |
olle |
967 |
|
3449 |
28 Jul 15 |
olle |
// Place selected wells in the copy |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getSelected(); |
3449 |
28 Jul 15 |
olle |
copy = []; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
972 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
copy[copy.length] = well.makeCopy(); |
3449 |
28 Jul 15 |
olle |
well.selected = false; |
3449 |
28 Jul 15 |
olle |
976 |
} |
3449 |
28 Jul 15 |
olle |
Plate.paint(wells); |
3449 |
28 Jul 15 |
olle |
978 |
} |
3449 |
28 Jul 15 |
olle |
979 |
|
3449 |
28 Jul 15 |
olle |
980 |
/** |
3449 |
28 Jul 15 |
olle |
Paste information into the selected wells. |
3449 |
28 Jul 15 |
olle |
982 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.pasteToSelected = function(event) |
3449 |
28 Jul 15 |
olle |
984 |
{ |
3449 |
28 Jul 15 |
olle |
if (!copy || copy.length == 0) |
3449 |
28 Jul 15 |
olle |
986 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'Nothing to paste. Please cut or copy wells first.'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
989 |
} |
3449 |
28 Jul 15 |
olle |
990 |
|
3449 |
28 Jul 15 |
olle |
var wells = Plate.getSelected(); |
3449 |
28 Jul 15 |
olle |
// Count non-empty and valid wells |
3449 |
28 Jul 15 |
olle |
var count = 0; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
995 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
if (well.extract && !well.hasError()) count++; |
3449 |
28 Jul 15 |
olle |
998 |
} |
3449 |
28 Jul 15 |
olle |
999 |
|
3449 |
28 Jul 15 |
olle |
if (count > 0) |
3449 |
28 Jul 15 |
olle |
1001 |
{ |
3449 |
28 Jul 15 |
olle |
if (!confirm('Replace DNA in ' + count + ' wells with copy?')) |
3449 |
28 Jul 15 |
olle |
1003 |
{ |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
1005 |
} |
3449 |
28 Jul 15 |
olle |
1006 |
} |
3449 |
28 Jul 15 |
olle |
1007 |
|
3449 |
28 Jul 15 |
olle |
var wi = 0; |
3449 |
28 Jul 15 |
olle |
var ci = 0; |
3449 |
28 Jul 15 |
olle |
var copyEmpty; |
3449 |
28 Jul 15 |
olle |
var askIfEmpty = true; |
3449 |
28 Jul 15 |
olle |
var repaint = []; |
3449 |
28 Jul 15 |
olle |
1013 |
|
3449 |
28 Jul 15 |
olle |
while (wi < wells.length && ci < copy.length) |
3449 |
28 Jul 15 |
olle |
1015 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[wi]; |
3449 |
28 Jul 15 |
olle |
var cp = copy[ci]; |
3449 |
28 Jul 15 |
olle |
var dna = null; |
3449 |
28 Jul 15 |
olle |
cp.well.doneWithCopy(); |
3449 |
28 Jul 15 |
olle |
repaint[repaint.length] = cp.well; |
3449 |
28 Jul 15 |
olle |
if (cp.name) |
3449 |
28 Jul 15 |
olle |
1022 |
{ |
3449 |
28 Jul 15 |
olle |
dna = Dna.createByName(cp.name); |
3449 |
28 Jul 15 |
olle |
dna.comment = cp.comment; |
3449 |
28 Jul 15 |
olle |
1025 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1027 |
{ |
3449 |
28 Jul 15 |
olle |
// The copy is from an empty well |
3449 |
28 Jul 15 |
olle |
if (askIfEmpty) |
3449 |
28 Jul 15 |
olle |
1030 |
{ |
3449 |
28 Jul 15 |
olle |
askIfEmpty = false; |
3449 |
28 Jul 15 |
olle |
copyEmpty = confirm('Do you want to copy empty wells? If not, only non-empty well are copied.'); |
3449 |
28 Jul 15 |
olle |
1033 |
} |
3449 |
28 Jul 15 |
olle |
1034 |
} |
3449 |
28 Jul 15 |
olle |
if (dna != null || copyEmpty) |
3449 |
28 Jul 15 |
olle |
1036 |
{ |
3449 |
28 Jul 15 |
olle |
well.setExtract(dna); |
3449 |
28 Jul 15 |
olle |
well.selected = false; |
3449 |
28 Jul 15 |
olle |
repaint[repaint.length] = well; |
3449 |
28 Jul 15 |
olle |
wi++; |
3449 |
28 Jul 15 |
olle |
1041 |
} |
3449 |
28 Jul 15 |
olle |
ci++; |
3449 |
28 Jul 15 |
olle |
1043 |
} |
3449 |
28 Jul 15 |
olle |
Plate.paint(repaint); |
3449 |
28 Jul 15 |
olle |
copy.splice(0, ci); |
3449 |
28 Jul 15 |
olle |
Plate.checkReplicates(); |
3449 |
28 Jul 15 |
olle |
1047 |
} |
3449 |
28 Jul 15 |
olle |
1048 |
|
3449 |
28 Jul 15 |
olle |
1049 |
/* |
3449 |
28 Jul 15 |
olle |
If exactly two wells have been selected, switch the DNA in them. |
3449 |
28 Jul 15 |
olle |
1051 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.switchSelected = function(event) |
3449 |
28 Jul 15 |
olle |
1053 |
{ |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getSelected(); |
3449 |
28 Jul 15 |
olle |
1055 |
|
3449 |
28 Jul 15 |
olle |
if (wells.length != 2) |
3449 |
28 Jul 15 |
olle |
1057 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'Exactly 2 wells must be selected.'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
1060 |
} |
3449 |
28 Jul 15 |
olle |
1061 |
|
3449 |
28 Jul 15 |
olle |
var dna0 = wells[0].extract; |
3449 |
28 Jul 15 |
olle |
var dna1 = wells[1].extract; |
3449 |
28 Jul 15 |
olle |
1064 |
|
3449 |
28 Jul 15 |
olle |
wells[0].setExtract(dna1); |
3449 |
28 Jul 15 |
olle |
wells[1].setExtract(dna0); |
3449 |
28 Jul 15 |
olle |
Plate.paint(wells); |
3449 |
28 Jul 15 |
olle |
1068 |
} |
3449 |
28 Jul 15 |
olle |
1069 |
|
3449 |
28 Jul 15 |
olle |
// Toggle the 'special select' menu on and off |
3449 |
28 Jul 15 |
olle |
selectdna.toggleSpecialSelect = function(event) |
3449 |
28 Jul 15 |
olle |
1072 |
{ |
3449 |
28 Jul 15 |
olle |
var pos = Doc.getElementPosition('iconSpecialSelect'); |
3449 |
28 Jul 15 |
olle |
Menu.toggleTopMenu('menuSpecialSelect', pos.left+pos.width/4, pos.top+pos.height); |
3449 |
28 Jul 15 |
olle |
event.stopPropagation(); |
3449 |
28 Jul 15 |
olle |
1076 |
} |
3449 |
28 Jul 15 |
olle |
1077 |
|
3449 |
28 Jul 15 |
olle |
var contextDNA = null; |
3449 |
28 Jul 15 |
olle |
var contextX; |
3449 |
28 Jul 15 |
olle |
var contextY; |
3449 |
28 Jul 15 |
olle |
1081 |
/** |
3449 |
28 Jul 15 |
olle |
Reacts to 'mouseup' and 'contextmenu' events for the bioplate. |
3449 |
28 Jul 15 |
olle |
This should bring up the cut/copy/paste context menu depending on which |
3449 |
28 Jul 15 |
olle |
mouse button that was clicked. |
3449 |
28 Jul 15 |
olle |
1085 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.contextEvent = function(event) |
3449 |
28 Jul 15 |
olle |
1087 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
// Context menu on 'right' mouse button |
3449 |
28 Jul 15 |
olle |
// Can't just check the button since two events are sent ('mouseup' and 'contextmenu') |
3449 |
28 Jul 15 |
olle |
var showContext = event.type == 'contextmenu' && event.button == 2; |
3449 |
28 Jul 15 |
olle |
1092 |
|
3449 |
28 Jul 15 |
olle |
if (showContext) |
3449 |
28 Jul 15 |
olle |
1094 |
{ |
3449 |
28 Jul 15 |
olle |
event.preventDefault(); // Prevents the default right-click menu from appearing |
3449 |
28 Jul 15 |
olle |
1096 |
|
3449 |
28 Jul 15 |
olle |
// Get the well that is right-clicked and the DNA that is in it |
3449 |
28 Jul 15 |
olle |
contextDNA = null; |
3449 |
28 Jul 15 |
olle |
var well = event.target; |
3449 |
28 Jul 15 |
olle |
while (well && (!well.id || well.id.indexOf('well') != 0)) |
3449 |
28 Jul 15 |
olle |
1101 |
{ |
3449 |
28 Jul 15 |
olle |
well = well.parentNode; |
3449 |
28 Jul 15 |
olle |
1103 |
} |
3449 |
28 Jul 15 |
olle |
if (well) |
3449 |
28 Jul 15 |
olle |
1105 |
{ |
3449 |
28 Jul 15 |
olle |
var c = well.id.split(/\./); |
3449 |
28 Jul 15 |
olle |
contextDNA = Plate.getWell(parseInt(c[1]), parseInt(c[2])).extract; |
3449 |
28 Jul 15 |
olle |
1108 |
} |
3449 |
28 Jul 15 |
olle |
// Update the context meny |
3449 |
28 Jul 15 |
olle |
var caseSummaryMenu = Doc.element('mnuCaseSummary'); |
3449 |
28 Jul 15 |
olle |
if (contextDNA) |
3449 |
28 Jul 15 |
olle |
1112 |
{ |
3449 |
28 Jul 15 |
olle |
caseSummaryMenu.title = 'Show case summary for ' + Strings.encodeTags(contextDNA.name); |
3449 |
28 Jul 15 |
olle |
Doc.show('sepCaseSummary'); |
3449 |
28 Jul 15 |
olle |
Doc.show('mnuCaseSummary'); |
3449 |
28 Jul 15 |
olle |
1116 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1118 |
{ |
3449 |
28 Jul 15 |
olle |
Doc.hide('sepCaseSummary'); |
3449 |
28 Jul 15 |
olle |
Doc.hide('mnuCaseSummary'); |
3449 |
28 Jul 15 |
olle |
1121 |
} |
3449 |
28 Jul 15 |
olle |
1122 |
|
3449 |
28 Jul 15 |
olle |
var menu = Doc.element('menuContext'); |
3449 |
28 Jul 15 |
olle |
// 1 pixel offset to avoid losing well focus outline |
3449 |
28 Jul 15 |
olle |
contextX = event.clientX+1; |
3449 |
28 Jul 15 |
olle |
contextY = event.clientY+1; |
3449 |
28 Jul 15 |
olle |
// Need short delay since 'mouseup' are also sent as 'click' events |
3449 |
28 Jul 15 |
olle |
// to the 'document' object which BASE already have a Menu.hideAll() |
3449 |
28 Jul 15 |
olle |
// call which would hide the menu immediately |
3449 |
28 Jul 15 |
olle |
setTimeout(selectdna.showContextMenu, 100); |
3449 |
28 Jul 15 |
olle |
1131 |
} |
3449 |
28 Jul 15 |
olle |
1132 |
} |
3449 |
28 Jul 15 |
olle |
1133 |
|
3449 |
28 Jul 15 |
olle |
selectdna.showContextMenu = function() |
3449 |
28 Jul 15 |
olle |
1135 |
{ |
3449 |
28 Jul 15 |
olle |
Menu.showTopMenu('menuContext', contextX, contextY); |
3449 |
28 Jul 15 |
olle |
1137 |
} |
3449 |
28 Jul 15 |
olle |
1138 |
|
3449 |
28 Jul 15 |
olle |
selectdna.showCaseSummary = function() |
3449 |
28 Jul 15 |
olle |
1140 |
{ |
3449 |
28 Jul 15 |
olle |
if (!contextDNA) return; |
3449 |
28 Jul 15 |
olle |
var caseName = contextDNA.name; |
3449 |
28 Jul 15 |
olle |
// Remove suffix starting with dot "." |
3449 |
28 Jul 15 |
olle |
var firstDotIndex = caseName.indexOf("."); |
3449 |
28 Jul 15 |
olle |
if (firstDotIndex >= 0) |
3449 |
28 Jul 15 |
olle |
1146 |
{ |
3449 |
28 Jul 15 |
olle |
caseName = caseName.substring(0, firstDotIndex); |
3449 |
28 Jul 15 |
olle |
1148 |
} |
3449 |
28 Jul 15 |
olle |
var url = '../reports/case_summary.jsp?ID='+App.getSessionId(); |
3449 |
28 Jul 15 |
olle |
url += '&caseName='+encodeURIComponent(caseName); |
3449 |
28 Jul 15 |
olle |
url += '&pageType=popup'; |
3449 |
28 Jul 15 |
olle |
Dialogs.openPopup(url, 'CaseSummary'+caseName, 1000, 700); |
3449 |
28 Jul 15 |
olle |
1153 |
} |
3449 |
28 Jul 15 |
olle |
1154 |
|
3449 |
28 Jul 15 |
olle |
selectdna.showFlaggedDna = function() |
3449 |
28 Jul 15 |
olle |
1156 |
{ |
3449 |
28 Jul 15 |
olle |
currentSelected = Plate.getSelected(); |
3449 |
28 Jul 15 |
olle |
currentIndex = 0; |
3449 |
28 Jul 15 |
olle |
1159 |
|
3449 |
28 Jul 15 |
olle |
var flagged = Dna.getFlagged(); |
3449 |
28 Jul 15 |
olle |
var url = 'show_flagged_dna.jsp?ID='+App.getSessionId(); |
3449 |
28 Jul 15 |
olle |
url += '&numFlagged='+flagged.length; |
3449 |
28 Jul 15 |
olle |
url += '&numSelected='+currentSelected.length; |
3449 |
28 Jul 15 |
olle |
Dialogs.openPopup(url, 'FlaggedDna', 800, 500); |
3449 |
28 Jul 15 |
olle |
1165 |
} |
3449 |
28 Jul 15 |
olle |
1166 |
|
3449 |
28 Jul 15 |
olle |
1167 |
|
3449 |
28 Jul 15 |
olle |
//Flag the selected DNA |
3449 |
28 Jul 15 |
olle |
selectdna.flagSelected = function(event) |
3449 |
28 Jul 15 |
olle |
1170 |
{ |
3449 |
28 Jul 15 |
olle |
var flag = Data.get(event.currentTarget, 'flag'); |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getSelected(); |
3449 |
28 Jul 15 |
olle |
1173 |
|
3449 |
28 Jul 15 |
olle |
if (wells.length == 0) |
3449 |
28 Jul 15 |
olle |
1175 |
{ |
3449 |
28 Jul 15 |
olle |
Forms.showNotification(event.currentTarget, 'No wells have been selected.'); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
1178 |
} |
3449 |
28 Jul 15 |
olle |
1179 |
|
3449 |
28 Jul 15 |
olle |
var comment = null; |
3449 |
28 Jul 15 |
olle |
if (flag == 'ManualFlag') |
3449 |
28 Jul 15 |
olle |
1182 |
{ |
3449 |
28 Jul 15 |
olle |
// Check if a comment has been set on any of the DNA |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
1185 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
if (well.extract && well.extract.info) |
3449 |
28 Jul 15 |
olle |
1188 |
{ |
3449 |
28 Jul 15 |
olle |
if (well.extract.info.comment) comment = well.extract.info.comment; |
3449 |
28 Jul 15 |
olle |
1190 |
} |
3449 |
28 Jul 15 |
olle |
1191 |
} |
3449 |
28 Jul 15 |
olle |
comment = prompt('Comment', comment || ''); |
3449 |
28 Jul 15 |
olle |
if (!comment) return; |
3449 |
28 Jul 15 |
olle |
1194 |
} |
3449 |
28 Jul 15 |
olle |
1195 |
|
3449 |
28 Jul 15 |
olle |
var count = 0; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
1198 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
var dna = well.extract; |
3449 |
28 Jul 15 |
olle |
if (dna && !dna.stratagene && !dna.external) |
3449 |
28 Jul 15 |
olle |
1202 |
{ |
3449 |
28 Jul 15 |
olle |
Dna.flag(dna, flag); |
3449 |
28 Jul 15 |
olle |
dna.info.comment = comment; |
3449 |
28 Jul 15 |
olle |
well.setExtract(null); |
3449 |
28 Jul 15 |
olle |
count++; |
3449 |
28 Jul 15 |
olle |
1207 |
} |
3449 |
28 Jul 15 |
olle |
well.selected = false; |
3449 |
28 Jul 15 |
olle |
1209 |
} |
3449 |
28 Jul 15 |
olle |
1210 |
|
3449 |
28 Jul 15 |
olle |
selectdna.updateNumFlaggedDna(); |
3449 |
28 Jul 15 |
olle |
Plate.paint(wells); |
3449 |
28 Jul 15 |
olle |
1213 |
} |
3449 |
28 Jul 15 |
olle |
1214 |
|
3449 |
28 Jul 15 |
olle |
1215 |
|
3449 |
28 Jul 15 |
olle |
selectdna.validateStep1 = function(event) |
3449 |
28 Jul 15 |
olle |
1217 |
{ |
3449 |
28 Jul 15 |
olle |
if (!quantitiesAreValid) |
3449 |
28 Jul 15 |
olle |
1219 |
{ |
3449 |
28 Jul 15 |
olle |
event.preventDefault(); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
1222 |
} |
3449 |
28 Jul 15 |
olle |
1223 |
|
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
var numErrors = 0; |
3449 |
28 Jul 15 |
olle |
var numWarnings = 0; |
3449 |
28 Jul 15 |
olle |
var numDna = 0; |
3449 |
28 Jul 15 |
olle |
var numStratagene = 0; |
3449 |
28 Jul 15 |
olle |
var numExternal = 0; |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getWells(); |
3449 |
28 Jul 15 |
olle |
var schema = PoolSchema.getById(frm.pool_schema.value); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
1233 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
var dna = well.extract; |
3449 |
28 Jul 15 |
olle |
if (well.hasWarning()) |
3449 |
28 Jul 15 |
olle |
1237 |
{ |
3449 |
28 Jul 15 |
olle |
numWarnings++; |
3449 |
28 Jul 15 |
olle |
1239 |
} |
3449 |
28 Jul 15 |
olle |
if (well.hasError()) |
3449 |
28 Jul 15 |
olle |
1241 |
{ |
3449 |
28 Jul 15 |
olle |
numErrors++; |
3449 |
28 Jul 15 |
olle |
1243 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1245 |
{ |
3449 |
28 Jul 15 |
olle |
if (dna && dna.id) |
3449 |
28 Jul 15 |
olle |
1247 |
{ |
3449 |
28 Jul 15 |
olle |
numDna++; |
3449 |
28 Jul 15 |
olle |
if (dna.stratagene) numStratagene++; |
3449 |
28 Jul 15 |
olle |
if (dna.external) numExternal++; |
3449 |
28 Jul 15 |
olle |
1251 |
} |
3449 |
28 Jul 15 |
olle |
1252 |
} |
3449 |
28 Jul 15 |
olle |
1253 |
} |
3449 |
28 Jul 15 |
olle |
1254 |
|
3449 |
28 Jul 15 |
olle |
if (numErrors > 0) |
3449 |
28 Jul 15 |
olle |
1256 |
{ |
3449 |
28 Jul 15 |
olle |
event.preventDefault(); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
1259 |
} |
3449 |
28 Jul 15 |
olle |
1260 |
|
3449 |
28 Jul 15 |
olle |
if (numDna == 0) |
3449 |
28 Jul 15 |
olle |
1262 |
{ |
3449 |
28 Jul 15 |
olle |
alert('There is no DNA in any wells'); |
3449 |
28 Jul 15 |
olle |
event.preventDefault(); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
1266 |
} |
3449 |
28 Jul 15 |
olle |
1267 |
|
3449 |
28 Jul 15 |
olle |
if (numWarnings > 0) |
3449 |
28 Jul 15 |
olle |
1269 |
{ |
3449 |
28 Jul 15 |
olle |
if (!confirm('There are ' + numWarnings + ' wells with a warning. Continue anyway?')) |
3449 |
28 Jul 15 |
olle |
1271 |
{ |
3449 |
28 Jul 15 |
olle |
event.preventDefault(); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
1274 |
} |
3449 |
28 Jul 15 |
olle |
1275 |
} |
3449 |
28 Jul 15 |
olle |
1276 |
|
3449 |
28 Jul 15 |
olle |
if (schema) |
3449 |
28 Jul 15 |
olle |
1278 |
{ |
3449 |
28 Jul 15 |
olle |
var numPrimary = schema.numPools * schema.numWellsPerPool; |
3449 |
28 Jul 15 |
olle |
if (numDna < numPrimary) |
3449 |
28 Jul 15 |
olle |
1281 |
{ |
3449 |
28 Jul 15 |
olle |
if (!confirm((numPrimary-numDna)+ ' primary wells are missing DNA. Continue anyway?')) |
3449 |
28 Jul 15 |
olle |
1283 |
{ |
3449 |
28 Jul 15 |
olle |
event.preventDefault(); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
1286 |
} |
3449 |
28 Jul 15 |
olle |
1287 |
} |
3449 |
28 Jul 15 |
olle |
1288 |
} |
3449 |
28 Jul 15 |
olle |
1289 |
|
3449 |
28 Jul 15 |
olle |
if (numDna == numStratagene+numExternal) |
3449 |
28 Jul 15 |
olle |
1291 |
{ |
3449 |
28 Jul 15 |
olle |
if (!confirm('There are only wells with Stratagene or external DNA on this plate. Continue anyway?')) |
3449 |
28 Jul 15 |
olle |
1293 |
{ |
3449 |
28 Jul 15 |
olle |
event.preventDefault(); |
3449 |
28 Jul 15 |
olle |
return; |
3449 |
28 Jul 15 |
olle |
1296 |
} |
3449 |
28 Jul 15 |
olle |
1297 |
} |
3449 |
28 Jul 15 |
olle |
1298 |
|
3449 |
28 Jul 15 |
olle |
1299 |
} |
3449 |
28 Jul 15 |
olle |
1300 |
|
3449 |
28 Jul 15 |
olle |
selectdna.submit = function() |
3449 |
28 Jul 15 |
olle |
1302 |
{ |
3449 |
28 Jul 15 |
olle |
var frm = document.forms['meludi']; |
3449 |
28 Jul 15 |
olle |
var isNeoPrep = Data.int('page-data', 'is-neoprep'); |
3449 |
28 Jul 15 |
olle |
1305 |
|
3449 |
28 Jul 15 |
olle |
var submitInfo = {}; |
3449 |
28 Jul 15 |
olle |
var plateInfo = {}; |
3449 |
28 Jul 15 |
olle |
var flaggedDnaInfo = []; |
3449 |
28 Jul 15 |
olle |
1309 |
|
3449 |
28 Jul 15 |
olle |
submitInfo.bioplate = plateInfo; |
3449 |
28 Jul 15 |
olle |
submitInfo.flagged = flaggedDnaInfo; |
3449 |
28 Jul 15 |
olle |
var schema = PoolSchema.getById(frm.pool_schema.value); |
3449 |
28 Jul 15 |
olle |
1313 |
|
3449 |
28 Jul 15 |
olle |
plateInfo.name = Plate.name; |
3449 |
28 Jul 15 |
olle |
plateInfo.comments = frm.comments.value; |
3449 |
28 Jul 15 |
olle |
1316 |
/* |
3449 |
28 Jul 15 |
olle |
plateInfo.plateType = isNeoPrep ? 'NEOPREP' : 'MDNA'; |
3449 |
28 Jul 15 |
olle |
1318 |
*/ |
3449 |
28 Jul 15 |
olle |
plateInfo.plateType = isNeoPrep ? 'NEOPREP' : 'DNA'; |
3449 |
28 Jul 15 |
olle |
plateInfo.poolSchema = schema ? schema.id : null; |
3449 |
28 Jul 15 |
olle |
if (isNeoPrep) |
3449 |
28 Jul 15 |
olle |
1322 |
{ |
3449 |
28 Jul 15 |
olle |
plateInfo.barcodeVariant = frm.barcode_variant.value; |
3449 |
28 Jul 15 |
olle |
1324 |
} |
3449 |
28 Jul 15 |
olle |
plateInfo.wells = []; |
3449 |
28 Jul 15 |
olle |
1326 |
|
3449 |
28 Jul 15 |
olle |
var wells = Plate.getWells(); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < wells.length; i++) |
3449 |
28 Jul 15 |
olle |
1329 |
{ |
3449 |
28 Jul 15 |
olle |
var well = wells[i]; |
3449 |
28 Jul 15 |
olle |
var dna = well.extract; |
3449 |
28 Jul 15 |
olle |
if (dna && dna.id) |
3449 |
28 Jul 15 |
olle |
1333 |
{ |
3449 |
28 Jul 15 |
olle |
var tmp = {}; |
3449 |
28 Jul 15 |
olle |
tmp.row = well.row; |
3449 |
28 Jul 15 |
olle |
tmp.column = well.column; |
3449 |
28 Jul 15 |
olle |
tmp.dna = {}; |
3449 |
28 Jul 15 |
olle |
tmp.dna.id = dna.id; |
3449 |
28 Jul 15 |
olle |
tmp.dna.usedQuantity = dna.usedQuantity; |
3449 |
28 Jul 15 |
olle |
tmp.dna.dilutionConc = dna.dilutionConc; |
3449 |
28 Jul 15 |
olle |
tmp.dna.qc = dna.qc; |
3449 |
28 Jul 15 |
olle |
tmp.dna.comment = dna.comment; |
3449 |
28 Jul 15 |
olle |
if (well.barcode) |
3449 |
28 Jul 15 |
olle |
1344 |
{ |
3449 |
28 Jul 15 |
olle |
tmp.dna.barcode = well.barcode; |
3449 |
28 Jul 15 |
olle |
1346 |
} |
3449 |
28 Jul 15 |
olle |
plateInfo.wells[plateInfo.wells.length] = tmp; |
3449 |
28 Jul 15 |
olle |
1348 |
} |
3449 |
28 Jul 15 |
olle |
1349 |
} |
3449 |
28 Jul 15 |
olle |
1350 |
|
3449 |
28 Jul 15 |
olle |
var flagged = Dna.getFlagged(); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < flagged.length; i++) |
3449 |
28 Jul 15 |
olle |
1353 |
{ |
3449 |
28 Jul 15 |
olle |
var dna = flagged[i]; |
3449 |
28 Jul 15 |
olle |
var tmp = {}; |
3449 |
28 Jul 15 |
olle |
tmp.id = dna.id; |
3449 |
28 Jul 15 |
olle |
tmp.flag = dna.flag; |
3449 |
28 Jul 15 |
olle |
tmp.comment = dna.comment; |
3449 |
28 Jul 15 |
olle |
flaggedDnaInfo[flaggedDnaInfo.length] = tmp; |
3449 |
28 Jul 15 |
olle |
1360 |
} |
3449 |
28 Jul 15 |
olle |
1361 |
|
3449 |
28 Jul 15 |
olle |
var url = '../Dna.servlet?ID='+App.getSessionId(); |
3449 |
28 Jul 15 |
olle |
url += '&cmd=CreateDnaOrLibPlate'; |
3449 |
28 Jul 15 |
olle |
Wizard.showLoadingAnimation('Performing registration...'); |
3449 |
28 Jul 15 |
olle |
Wizard.asyncJsonRequest(url, selectdna.submissionResults, 'POST', JSON.stringify(submitInfo)); |
3449 |
28 Jul 15 |
olle |
1366 |
} |
3449 |
28 Jul 15 |
olle |
1367 |
|
3449 |
28 Jul 15 |
olle |
selectdna.submissionResults = function(response) |
3449 |
28 Jul 15 |
olle |
1369 |
{ |
3449 |
28 Jul 15 |
olle |
Wizard.showFinalMessage(response.messages); |
3449 |
28 Jul 15 |
olle |
Doc.show('gorestart'); |
3449 |
28 Jul 15 |
olle |
1372 |
} |
3449 |
28 Jul 15 |
olle |
1373 |
|
3449 |
28 Jul 15 |
olle |
selectdna.initElements = function(element, autoInit) |
3449 |
28 Jul 15 |
olle |
1375 |
{ |
3449 |
28 Jul 15 |
olle |
if (autoInit == 'plate-col') |
3449 |
28 Jul 15 |
olle |
1377 |
{ |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler(element, 'click', selectdna.toggleColumn); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler(element, 'mouseover', selectdna.highlightColumn); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler(element, 'mouseout', selectdna.highlightColumn); |
3449 |
28 Jul 15 |
olle |
1381 |
} |
3449 |
28 Jul 15 |
olle |
else if (autoInit == 'plate-row') |
3449 |
28 Jul 15 |
olle |
1383 |
{ |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler(element, 'click', selectdna.toggleRow); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler(element, 'mouseover', selectdna.highlightRow); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler(element, 'mouseout', selectdna.highlightRow); |
3449 |
28 Jul 15 |
olle |
1387 |
} |
3449 |
28 Jul 15 |
olle |
else if (autoInit == 'plate-well') |
3449 |
28 Jul 15 |
olle |
1389 |
{ |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler(element, 'click', selectdna.toggleWell); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler(element, 'mouseover', selectdna.highlightReplicated); |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler(element, 'mouseout', selectdna.highlightReplicated); |
3449 |
28 Jul 15 |
olle |
1393 |
} |
3449 |
28 Jul 15 |
olle |
else if (autoInit == 'special-select') |
3449 |
28 Jul 15 |
olle |
1395 |
{ |
3449 |
28 Jul 15 |
olle |
Events.addEventHandler(element, 'click', selectdna.specialToggle) |
3449 |
28 Jul 15 |
olle |
1397 |
} |
3449 |
28 Jul 15 |
olle |
1398 |
} |
3449 |
28 Jul 15 |
olle |
1399 |
|
3449 |
28 Jul 15 |
olle |
// Toggle the selected status of a single well |
3449 |
28 Jul 15 |
olle |
selectdna.toggleWell = function(event) |
3449 |
28 Jul 15 |
olle |
1402 |
{ |
3449 |
28 Jul 15 |
olle |
var row = Data.int(event.currentTarget, 'row'); |
3449 |
28 Jul 15 |
olle |
var column = Data.int(event.currentTarget, 'col'); |
3449 |
28 Jul 15 |
olle |
var well = Plate.getWell(row, column); |
3449 |
28 Jul 15 |
olle |
Plate.toggleSelected([well]); |
3449 |
28 Jul 15 |
olle |
1407 |
} |
3449 |
28 Jul 15 |
olle |
1408 |
|
3449 |
28 Jul 15 |
olle |
// Toggle the selected status of a complete row |
3449 |
28 Jul 15 |
olle |
selectdna.toggleRow = function(event) |
3449 |
28 Jul 15 |
olle |
1411 |
{ |
3449 |
28 Jul 15 |
olle |
var row = Data.int(event.currentTarget, 'row'); |
3449 |
28 Jul 15 |
olle |
Plate.toggleSelected(Plate.getRow(row)); |
3449 |
28 Jul 15 |
olle |
1414 |
} |
3449 |
28 Jul 15 |
olle |
1415 |
|
3449 |
28 Jul 15 |
olle |
// Toggle the selected status of a complete column |
3449 |
28 Jul 15 |
olle |
selectdna.toggleColumn = function(event) |
3449 |
28 Jul 15 |
olle |
1418 |
{ |
3449 |
28 Jul 15 |
olle |
var column = Data.int(event.currentTarget, 'col'); |
3449 |
28 Jul 15 |
olle |
Plate.toggleSelected(Plate.getColumn(column)); |
3449 |
28 Jul 15 |
olle |
1421 |
} |
3449 |
28 Jul 15 |
olle |
1422 |
|
3449 |
28 Jul 15 |
olle |
// Toggle the selected status of a pool |
3449 |
28 Jul 15 |
olle |
selectdna.togglePool = function(event) |
3449 |
28 Jul 15 |
olle |
1425 |
{ |
3449 |
28 Jul 15 |
olle |
var pool = Data.int(event.target, 'pool-num'); |
3449 |
28 Jul 15 |
olle |
if (!isNaN(pool)) Plate.toggleSelected(Plate.getPool(pool)); |
3449 |
28 Jul 15 |
olle |
1428 |
} |
3449 |
28 Jul 15 |
olle |
1429 |
|
3449 |
28 Jul 15 |
olle |
// Highlight enable/disable all wells in a column |
3449 |
28 Jul 15 |
olle |
selectdna.highlightColumn = function(event) |
3449 |
28 Jul 15 |
olle |
1432 |
{ |
3449 |
28 Jul 15 |
olle |
var column = Data.int(event.currentTarget, 'col'); |
3449 |
28 Jul 15 |
olle |
var on = event.type == 'mouseover'; |
3449 |
28 Jul 15 |
olle |
1435 |
|
3449 |
28 Jul 15 |
olle |
Doc.addOrRemoveClass(event.currentTarget, 'highlight-column', on); |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getColumn(column); |
3449 |
28 Jul 15 |
olle |
Plate.setHighlight(wells, 'highlight-column', on); |
3449 |
28 Jul 15 |
olle |
1439 |
} |
3449 |
28 Jul 15 |
olle |
1440 |
|
3449 |
28 Jul 15 |
olle |
// Highlight enable/disable all wells in a row |
3449 |
28 Jul 15 |
olle |
selectdna.highlightRow = function(event) |
3449 |
28 Jul 15 |
olle |
1443 |
{ |
3449 |
28 Jul 15 |
olle |
var row = Data.int(event.currentTarget, 'row'); |
3449 |
28 Jul 15 |
olle |
var on = event.type == 'mouseover'; |
3449 |
28 Jul 15 |
olle |
1446 |
|
3449 |
28 Jul 15 |
olle |
Doc.addOrRemoveClass(event.currentTarget, 'highlight-row', on); |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getRow(row); |
3449 |
28 Jul 15 |
olle |
Plate.setHighlight(wells, 'highlight-row', on); |
3449 |
28 Jul 15 |
olle |
1450 |
} |
3449 |
28 Jul 15 |
olle |
1451 |
|
3449 |
28 Jul 15 |
olle |
// Highligt enable/disable all wells in a pool |
3449 |
28 Jul 15 |
olle |
selectdna.highlightPool = function(event) |
3449 |
28 Jul 15 |
olle |
1454 |
{ |
3449 |
28 Jul 15 |
olle |
var pool = Data.int(event.target, 'pool-num'); |
3449 |
28 Jul 15 |
olle |
var on = event.type == 'mouseover'; |
3449 |
28 Jul 15 |
olle |
if (!isNaN(pool)) |
3449 |
28 Jul 15 |
olle |
1458 |
{ |
3449 |
28 Jul 15 |
olle |
Doc.addOrRemoveClass(event.target, 'highlight-pool', on); |
3449 |
28 Jul 15 |
olle |
var wells = Plate.getPool(pool); |
3449 |
28 Jul 15 |
olle |
Plate.setHighlight(wells, 'highlight-pool', on); |
3449 |
28 Jul 15 |
olle |
1462 |
} |
3449 |
28 Jul 15 |
olle |
1463 |
} |
3449 |
28 Jul 15 |
olle |
1464 |
|
3449 |
28 Jul 15 |
olle |
1465 |
/** |
3449 |
28 Jul 15 |
olle |
Highlight all replicated wells with the same DNA as the given well. |
3449 |
28 Jul 15 |
olle |
1467 |
*/ |
3449 |
28 Jul 15 |
olle |
selectdna.highlightReplicated = function(event) |
3449 |
28 Jul 15 |
olle |
1469 |
{ |
3449 |
28 Jul 15 |
olle |
var column = Data.int(event.currentTarget, 'col'); |
3449 |
28 Jul 15 |
olle |
var row = Data.int(event.currentTarget, 'row'); |
3449 |
28 Jul 15 |
olle |
var on = event.type == 'mouseover'; |
3449 |
28 Jul 15 |
olle |
1473 |
|
3449 |
28 Jul 15 |
olle |
var well = Plate.getWell(row, column); |
3449 |
28 Jul 15 |
olle |
if (well.extract && well.replicate) |
3449 |
28 Jul 15 |
olle |
1476 |
{ |
3449 |
28 Jul 15 |
olle |
// Get center coordinates for the current well |
3449 |
28 Jul 15 |
olle |
var pos = Doc.getElementPosition(well.tag); |
3449 |
28 Jul 15 |
olle |
var jsPos = new jsPoint(pos.left+pos.width/2, pos.top+pos.height/2); |
3449 |
28 Jul 15 |
olle |
1480 |
|
3449 |
28 Jul 15 |
olle |
var replicated = Plate.getWellsByName(well.extract.name); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < replicated.length; i++) |
3449 |
28 Jul 15 |
olle |
1483 |
{ |
3449 |
28 Jul 15 |
olle |
var rep = replicated[i]; |
3449 |
28 Jul 15 |
olle |
if (rep != well) |
3449 |
28 Jul 15 |
olle |
1486 |
{ |
3449 |
28 Jul 15 |
olle |
Doc.addOrRemoveClass(rep.tag, 'highlight-replicated', on); |
3449 |
28 Jul 15 |
olle |
if (rep.line) |
3449 |
28 Jul 15 |
olle |
1489 |
{ |
3449 |
28 Jul 15 |
olle |
// Clear any recent lines |
3449 |
28 Jul 15 |
olle |
graphics.clearDrawing(rep.line); |
3449 |
28 Jul 15 |
olle |
rep.line = null; |
3449 |
28 Jul 15 |
olle |
1493 |
} |
3449 |
28 Jul 15 |
olle |
if (on) |
3449 |
28 Jul 15 |
olle |
1495 |
{ |
3449 |
28 Jul 15 |
olle |
// We draw a line between the current and replicated well |
3449 |
28 Jul 15 |
olle |
var rPos = Doc.getElementPosition(rep.tag); |
3449 |
28 Jul 15 |
olle |
rep.line = graphics.drawLine(pen, jsPos, new jsPoint(rPos.left+rPos.width/2, rPos.top+rPos.height/2)); |
3449 |
28 Jul 15 |
olle |
1499 |
} |
3449 |
28 Jul 15 |
olle |
1500 |
} |
3449 |
28 Jul 15 |
olle |
1501 |
} |
3449 |
28 Jul 15 |
olle |
1502 |
} |
3449 |
28 Jul 15 |
olle |
1503 |
} |
3449 |
28 Jul 15 |
olle |
1504 |
|
3449 |
28 Jul 15 |
olle |
// Some special toogle operations |
3449 |
28 Jul 15 |
olle |
selectdna.specialToggle = function(event) |
3449 |
28 Jul 15 |
olle |
1507 |
{ |
3449 |
28 Jul 15 |
olle |
var what = Data.get(event.currentTarget, 'special'); |
3449 |
28 Jul 15 |
olle |
var wells = []; |
3449 |
28 Jul 15 |
olle |
if (what == 'all' || what == 'empty' || what == 'none') |
3449 |
28 Jul 15 |
olle |
1511 |
{ |
3449 |
28 Jul 15 |
olle |
// All wells or all empty (will be filtered later) |
3449 |
28 Jul 15 |
olle |
wells = Plate.getWells(); |
3449 |
28 Jul 15 |
olle |
1514 |
} |
3449 |
28 Jul 15 |
olle |
else if (what == 'pools' || what == 'empty-pools') |
3449 |
28 Jul 15 |
olle |
1516 |
{ |
3449 |
28 Jul 15 |
olle |
// All primary pools or all empty in the primary pools (will be filtered later) |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < Plate.poolSchema.numPools; i++) |
3449 |
28 Jul 15 |
olle |
1519 |
{ |
3449 |
28 Jul 15 |
olle |
wells = wells.concat(Plate.getPool(i)); |
3449 |
28 Jul 15 |
olle |
1521 |
} |
3449 |
28 Jul 15 |
olle |
1522 |
} |
3449 |
28 Jul 15 |
olle |
else if (what == 'stratagene') |
3449 |
28 Jul 15 |
olle |
1524 |
{ |
3449 |
28 Jul 15 |
olle |
// All wells with 'Stratagene' |
3449 |
28 Jul 15 |
olle |
var tmp = Plate.getWells(); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < tmp.length; i++) |
3449 |
28 Jul 15 |
olle |
1528 |
{ |
3449 |
28 Jul 15 |
olle |
var well = tmp[i]; |
3449 |
28 Jul 15 |
olle |
if (well.extract && well.extract.stratagene) wells[wells.length] = well; |
3449 |
28 Jul 15 |
olle |
1531 |
} |
3449 |
28 Jul 15 |
olle |
1532 |
} |
3449 |
28 Jul 15 |
olle |
else if (what == 'external') |
3449 |
28 Jul 15 |
olle |
1534 |
{ |
3449 |
28 Jul 15 |
olle |
// All wells with 'External DNA' |
3449 |
28 Jul 15 |
olle |
var tmp = Plate.getWells(); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < tmp.length; i++) |
3449 |
28 Jul 15 |
olle |
1538 |
{ |
3449 |
28 Jul 15 |
olle |
var well = tmp[i]; |
3449 |
28 Jul 15 |
olle |
if (well.extract && well.extract.external) wells[wells.length] = well; |
3449 |
28 Jul 15 |
olle |
1541 |
} |
3449 |
28 Jul 15 |
olle |
1542 |
} |
3449 |
28 Jul 15 |
olle |
else if (what == 'replicates') |
3449 |
28 Jul 15 |
olle |
1544 |
{ |
3449 |
28 Jul 15 |
olle |
// All wells with replicated DNA |
3449 |
28 Jul 15 |
olle |
var tmp = Plate.getWells(); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < tmp.length; i++) |
3449 |
28 Jul 15 |
olle |
1548 |
{ |
3449 |
28 Jul 15 |
olle |
var well = tmp[i]; |
3449 |
28 Jul 15 |
olle |
if (well.extract && well.replicate) wells[wells.length] = well; |
3449 |
28 Jul 15 |
olle |
1551 |
} |
3449 |
28 Jul 15 |
olle |
1552 |
} |
3449 |
28 Jul 15 |
olle |
else if (what == 'error') |
3449 |
28 Jul 15 |
olle |
1554 |
{ |
3449 |
28 Jul 15 |
olle |
// All wells with an error |
3449 |
28 Jul 15 |
olle |
var tmp = Plate.getWells(); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < tmp.length; i++) |
3449 |
28 Jul 15 |
olle |
1558 |
{ |
3449 |
28 Jul 15 |
olle |
var well = tmp[i]; |
3449 |
28 Jul 15 |
olle |
if (well.hasError()) wells[wells.length] = well; |
3449 |
28 Jul 15 |
olle |
1561 |
} |
3449 |
28 Jul 15 |
olle |
1562 |
} |
3449 |
28 Jul 15 |
olle |
else if (what == 'warning') |
3449 |
28 Jul 15 |
olle |
1564 |
{ |
3449 |
28 Jul 15 |
olle |
// All wells with a warning |
3449 |
28 Jul 15 |
olle |
var tmp = Plate.getWells(); |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < tmp.length; i++) |
3449 |
28 Jul 15 |
olle |
1568 |
{ |
3449 |
28 Jul 15 |
olle |
var well = tmp[i]; |
3449 |
28 Jul 15 |
olle |
if (well.warning) wells[wells.length] = well; |
3449 |
28 Jul 15 |
olle |
1571 |
} |
3449 |
28 Jul 15 |
olle |
1572 |
} |
3449 |
28 Jul 15 |
olle |
1573 |
|
3449 |
28 Jul 15 |
olle |
// Extra filter for empty wells only |
3449 |
28 Jul 15 |
olle |
if (what.indexOf('empty') != -1) |
3449 |
28 Jul 15 |
olle |
1576 |
{ |
3449 |
28 Jul 15 |
olle |
var tmp = wells; |
3449 |
28 Jul 15 |
olle |
wells = []; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < tmp.length; i++) |
3449 |
28 Jul 15 |
olle |
1580 |
{ |
3449 |
28 Jul 15 |
olle |
if (!tmp[i].extract) wells[wells.length] = tmp[i]; |
3449 |
28 Jul 15 |
olle |
1582 |
} |
3449 |
28 Jul 15 |
olle |
1583 |
} |
3449 |
28 Jul 15 |
olle |
1584 |
|
3449 |
28 Jul 15 |
olle |
if (what == 'none') |
3449 |
28 Jul 15 |
olle |
1586 |
{ |
3449 |
28 Jul 15 |
olle |
Plate.setSelected(wells, false); |
3449 |
28 Jul 15 |
olle |
1588 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1590 |
{ |
3449 |
28 Jul 15 |
olle |
Plate.toggleSelected(wells); |
3449 |
28 Jul 15 |
olle |
1592 |
} |
3449 |
28 Jul 15 |
olle |
1593 |
} |
3449 |
28 Jul 15 |
olle |
1594 |
|
3449 |
28 Jul 15 |
olle |
1595 |
|
3449 |
28 Jul 15 |
olle |
return selectdna; |
3449 |
28 Jul 15 |
olle |
1597 |
}(); |
3449 |
28 Jul 15 |
olle |
1598 |
|
3520 |
01 Oct 15 |
olle |
Doc.onLoad(SelectDnaRefCode.initPage); |
3520 |
01 Oct 15 |
olle |
Doc.addElementInitializer(SelectDnaRefCode.initElements); |
3449 |
28 Jul 15 |
olle |
1601 |
|
3449 |
28 Jul 15 |
olle |
1602 |
|
3449 |
28 Jul 15 |
olle |
var Dna = function() |
3449 |
28 Jul 15 |
olle |
1604 |
{ |
3449 |
28 Jul 15 |
olle |
var dna = {}; |
3449 |
28 Jul 15 |
olle |
var flagged = []; |
3449 |
28 Jul 15 |
olle |
var info = []; |
3449 |
28 Jul 15 |
olle |
1608 |
|
3449 |
28 Jul 15 |
olle |
1609 |
/** |
3449 |
28 Jul 15 |
olle |
Create a new DNA object by name. More information |
3449 |
28 Jul 15 |
olle |
about the DNA is automatically loaded from the database. |
3449 |
28 Jul 15 |
olle |
1612 |
*/ |
3449 |
28 Jul 15 |
olle |
dna.createByName = function(name) |
3449 |
28 Jul 15 |
olle |
1614 |
{ |
3449 |
28 Jul 15 |
olle |
var tmp = {}; |
3449 |
28 Jul 15 |
olle |
tmp.name = name; |
3449 |
28 Jul 15 |
olle |
tmp.stratagene = Meludi.isStratagene(name) |
3449 |
28 Jul 15 |
olle |
tmp.external = Meludi.isExternal(name); |
3449 |
28 Jul 15 |
olle |
tmp.info = dna.infoByName(name); |
3449 |
28 Jul 15 |
olle |
//alert("select_dna.js::dna.createByName(name): name = " + name + " info = " + JSON.stringify(tmp.info)); |
3449 |
28 Jul 15 |
olle |
tmp.id = tmp.info.id; |
3449 |
28 Jul 15 |
olle |
return tmp; |
3449 |
28 Jul 15 |
olle |
1623 |
} |
3449 |
28 Jul 15 |
olle |
1624 |
|
3449 |
28 Jul 15 |
olle |
1625 |
/** |
3449 |
28 Jul 15 |
olle |
Create a new DNA object by info object. |
3449 |
28 Jul 15 |
olle |
1627 |
*/ |
3449 |
28 Jul 15 |
olle |
dna.createByInfo = function(info) |
3449 |
28 Jul 15 |
olle |
1629 |
{ |
3449 |
28 Jul 15 |
olle |
var tmp = {}; |
3449 |
28 Jul 15 |
olle |
tmp.name = info.name; |
3449 |
28 Jul 15 |
olle |
tmp.stratagene = Meludi.isStratagene(tmp.name); |
3449 |
28 Jul 15 |
olle |
tmp.external = Meludi.isExternal(tmp.name); |
3449 |
28 Jul 15 |
olle |
tmp.id = info.id; |
3449 |
28 Jul 15 |
olle |
tmp.info = info; |
3449 |
28 Jul 15 |
olle |
return tmp; |
3449 |
28 Jul 15 |
olle |
1637 |
} |
3449 |
28 Jul 15 |
olle |
1638 |
|
3449 |
28 Jul 15 |
olle |
1639 |
/** |
3449 |
28 Jul 15 |
olle |
Get information about a DNA item with a given name. |
3449 |
28 Jul 15 |
olle |
1641 |
*/ |
3449 |
28 Jul 15 |
olle |
dna.infoByName = function(name) |
3449 |
28 Jul 15 |
olle |
1643 |
{ |
3449 |
28 Jul 15 |
olle |
var key = 'N'+name; |
3449 |
28 Jul 15 |
olle |
if (!info[key]) |
3449 |
28 Jul 15 |
olle |
1646 |
{ |
3449 |
28 Jul 15 |
olle |
dna.loadInfoByNames([name]); |
3449 |
28 Jul 15 |
olle |
if (!info[key]) info[key] = {}; |
3449 |
28 Jul 15 |
olle |
1649 |
} |
3449 |
28 Jul 15 |
olle |
return info[key]; |
3449 |
28 Jul 15 |
olle |
1651 |
} |
3449 |
28 Jul 15 |
olle |
1652 |
|
3449 |
28 Jul 15 |
olle |
1653 |
/** |
3449 |
28 Jul 15 |
olle |
Load and cache DNA information for all DNA items with a name in the |
3449 |
28 Jul 15 |
olle |
given list. |
3449 |
28 Jul 15 |
olle |
1656 |
*/ |
3449 |
28 Jul 15 |
olle |
dna.loadInfoByNames = function(names) |
3449 |
28 Jul 15 |
olle |
1658 |
{ |
3449 |
28 Jul 15 |
olle |
var newNames = []; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < names.length; i++) |
3449 |
28 Jul 15 |
olle |
1661 |
{ |
3449 |
28 Jul 15 |
olle |
if (!info['N'+names[i]]) newNames[newNames.length] = names[i]; |
3449 |
28 Jul 15 |
olle |
1663 |
} |
3449 |
28 Jul 15 |
olle |
1664 |
|
3449 |
28 Jul 15 |
olle |
var submitInfo = {}; |
3449 |
28 Jul 15 |
olle |
submitInfo.names = newNames; |
3449 |
28 Jul 15 |
olle |
1667 |
|
3449 |
28 Jul 15 |
olle |
if (newNames.length > 0) |
3449 |
28 Jul 15 |
olle |
1669 |
{ |
3449 |
28 Jul 15 |
olle |
var url = '../Dna.servlet?ID='+App.getSessionId(); |
3449 |
28 Jul 15 |
olle |
url += '&cmd=GetDnaInfoFromNames'; |
3449 |
28 Jul 15 |
olle |
var response = Wizard.syncJsonRequest(url, 'POST', JSON.stringify(submitInfo)); |
3449 |
28 Jul 15 |
olle |
dna.cacheInfo(response.dna); |
3449 |
28 Jul 15 |
olle |
1674 |
} |
3449 |
28 Jul 15 |
olle |
1675 |
} |
3449 |
28 Jul 15 |
olle |
1676 |
|
3449 |
28 Jul 15 |
olle |
dna.cacheInfo = function(dnaList) |
3449 |
28 Jul 15 |
olle |
1678 |
{ |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < dnaList.length; i++) |
3449 |
28 Jul 15 |
olle |
1680 |
{ |
3449 |
28 Jul 15 |
olle |
var r = dnaList[i]; |
3449 |
28 Jul 15 |
olle |
info['N'+r.name] = r; |
3449 |
28 Jul 15 |
olle |
info['I'+r.id] = r; |
3449 |
28 Jul 15 |
olle |
if (r.flag) flagged[flagged.length] = r; |
3449 |
28 Jul 15 |
olle |
1685 |
} |
3449 |
28 Jul 15 |
olle |
1686 |
} |
3449 |
28 Jul 15 |
olle |
1687 |
|
3449 |
28 Jul 15 |
olle |
dna.unflag = function(r) |
3449 |
28 Jul 15 |
olle |
1689 |
{ |
3449 |
28 Jul 15 |
olle |
if (!r.info || !r.info.flag) return false; |
3449 |
28 Jul 15 |
olle |
1691 |
|
3449 |
28 Jul 15 |
olle |
r.info.flag = null; |
3449 |
28 Jul 15 |
olle |
for (var i = 0; i < flagged.length; i++) |
3449 |
28 Jul 15 |
olle |
1694 |
{ |
3449 |
28 Jul 15 |
olle |
if (r.id == flagged[i].id) |
3449 |
28 Jul 15 |
olle |
1696 |
{ |
3449 |
28 Jul 15 |
olle |
flagged.splice(i, 1); |
3449 |
28 Jul 15 |
olle |
break; |
3449 |
28 Jul 15 |
olle |
1699 |
} |
3449 |
28 Jul 15 |
olle |
1700 |
} |
3449 |
28 Jul 15 |
olle |
return true; |
3449 |
28 Jul 15 |
olle |
1702 |
} |
3449 |
28 Jul 15 |
olle |
1703 |
|
3449 |
28 Jul 15 |
olle |
dna.flag = function(r, flag) |
3449 |
28 Jul 15 |
olle |
1705 |
{ |
3449 |
28 Jul 15 |
olle |
if (!r.info || r.info.flag) return false; |
3449 |
28 Jul 15 |
olle |
r.info.flag = flag; |
3449 |
28 Jul 15 |
olle |
flagged[flagged.length] = r.info; |
3449 |
28 Jul 15 |
olle |
1709 |
} |
3449 |
28 Jul 15 |
olle |
1710 |
|
3449 |
28 Jul 15 |
olle |
dna.getFlagged = function() |
3449 |
28 Jul 15 |
olle |
1712 |
{ |
3449 |
28 Jul 15 |
olle |
return flagged; |
3449 |
28 Jul 15 |
olle |
1714 |
} |
3449 |
28 Jul 15 |
olle |
1715 |
|
3449 |
28 Jul 15 |
olle |
return dna; |
3449 |
28 Jul 15 |
olle |
1717 |
}(); |
3449 |
28 Jul 15 |
olle |
1718 |
|
3449 |
28 Jul 15 |
olle |
1719 |
|
3449 |
28 Jul 15 |
olle |
1720 |
|
3449 |
28 Jul 15 |
olle |
var WellPainter = function() |
3449 |
28 Jul 15 |
olle |
1722 |
{ |
3449 |
28 Jul 15 |
olle |
var painter = {}; |
3449 |
28 Jul 15 |
olle |
1724 |
|
3449 |
28 Jul 15 |
olle |
// Add class indicators for replicates and QC assigned wells |
3449 |
28 Jul 15 |
olle |
painter.getClassNameForWell = function(well) |
3449 |
28 Jul 15 |
olle |
1727 |
{ |
3449 |
28 Jul 15 |
olle |
var cls = ''; |
3449 |
28 Jul 15 |
olle |
if (well.extract) |
3449 |
28 Jul 15 |
olle |
1730 |
{ |
3449 |
28 Jul 15 |
olle |
if (well.replicate) cls += ' replicate'; |
3449 |
28 Jul 15 |
olle |
if (well.extract.qc) cls += ' qc'; |
3449 |
28 Jul 15 |
olle |
1733 |
} |
3449 |
28 Jul 15 |
olle |
if (well.column == Plate.columns-1) cls += ' last-child'; |
3449 |
28 Jul 15 |
olle |
1735 |
|
3449 |
28 Jul 15 |
olle |
return cls; |
3449 |
28 Jul 15 |
olle |
1737 |
} |
3449 |
28 Jul 15 |
olle |
1738 |
|
3449 |
28 Jul 15 |
olle |
painter.getWellText = function(well) |
3449 |
28 Jul 15 |
olle |
1740 |
{ |
3449 |
28 Jul 15 |
olle |
var text = ''; |
3449 |
28 Jul 15 |
olle |
if (well.duplicates) |
3449 |
28 Jul 15 |
olle |
1743 |
{ |
3449 |
28 Jul 15 |
olle |
well.setError('Duplicate DNA in this location'); |
3449 |
28 Jul 15 |
olle |
text += '<div class="name">'+Strings.encodeTags(well.duplicates.join(', '))+'</div>'; |
3449 |
28 Jul 15 |
olle |
1746 |
} |
3449 |
28 Jul 15 |
olle |
else if (well.extract) |
3449 |
28 Jul 15 |
olle |
1748 |
{ |
3449 |
28 Jul 15 |
olle |
// The well contains DNA |
3449 |
28 Jul 15 |
olle |
var dna = well.extract; |
3449 |
28 Jul 15 |
olle |
var info = dna.info; |
3449 |
28 Jul 15 |
olle |
text += '<div class="name">'+Strings.encodeTags(dna.name)+'</div>'; |
3449 |
28 Jul 15 |
olle |
//alert("select_dna.js::getWellText(): info = " + JSON.stringify(info)); |
3449 |
28 Jul 15 |
olle |
1754 |
|
3449 |
28 Jul 15 |
olle |
var warningMsg = []; |
3449 |
28 Jul 15 |
olle |
if (info.bioWell) |
3449 |
28 Jul 15 |
olle |
1757 |
{ |
3449 |
28 Jul 15 |
olle |
var dnaWell = info.bioWell; |
3449 |
28 Jul 15 |
olle |
text += '<div class="location">'+Strings.encodeTags(dnaWell.bioPlate.name+'['+dnaWell.location)+']</div>'; |
3449 |
28 Jul 15 |
olle |
1760 |
} |
3449 |
28 Jul 15 |
olle |
else if (info.preNormalized) |
3449 |
28 Jul 15 |
olle |
1762 |
{ |
3449 |
28 Jul 15 |
olle |
text += '<div class="location">PreNormalized</div>'; |
3449 |
28 Jul 15 |
olle |
1764 |
} |
3449 |
28 Jul 15 |
olle |
else if (!dna.stratagene && !dna.external) |
3449 |
28 Jul 15 |
olle |
1766 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'No location'; |
3449 |
28 Jul 15 |
olle |
1768 |
} |
3449 |
28 Jul 15 |
olle |
1769 |
|
3449 |
28 Jul 15 |
olle |
if (info && info.id && !dna.stratagene && !dna.external) |
3449 |
28 Jul 15 |
olle |
1771 |
{ |
3449 |
28 Jul 15 |
olle |
var USED_VOL_PER_ALIQUOT = 10.0; // µl |
3449 |
28 Jul 15 |
olle |
var VOL_ALIQUOT = 10.0; // µl |
3449 |
28 Jul 15 |
olle |
var removedVolume = 2 * USED_VOL_PER_ALIQUOT; // µl |
3449 |
28 Jul 15 |
olle |
var deltaCt = info.deltaCt; |
3449 |
28 Jul 15 |
olle |
var dilutionFactor = painter.fetchDilutionFactor(deltaCt); |
3449 |
28 Jul 15 |
olle |
var origConc = info.QubitConc; // ng/µl |
3449 |
28 Jul 15 |
olle |
//var usedQuantityPerAliquout = Math.ceil(VOL_ALIQUOT*origConc/dilutionFactor/1000); // µg |
3449 |
28 Jul 15 |
olle |
//var usedQuantityPerAliquout = VOL_ALIQUOT*origConc/dilutionFactor/1000; // µg |
3449 |
28 Jul 15 |
olle |
var usedQuantityPerAliquout = VOL_ALIQUOT*origConc/dilutionFactor; // ng |
3449 |
28 Jul 15 |
olle |
alert("select_dna.js::painter.getWellText(): name = " + dna.name + " removedVolume = " + removedVolume + " deltaCt = " + deltaCt + " dilutionFactor = " + dilutionFactor + " origConc = " + origConc + " usedQuantityPerAliquout = " + usedQuantityPerAliquout + " ng"); |
3449 |
28 Jul 15 |
olle |
1782 |
|
3449 |
28 Jul 15 |
olle |
1783 |
/* |
3449 |
28 Jul 15 |
olle |
dna.usedQuantity = dna.qc ? QUANTITY_QC : QUANTITY_REGULAR; // µg |
3449 |
28 Jul 15 |
olle |
dna.dilutionConc = 1000 * dna.usedQuantity / TOTAL_VOLUME; // ng/µl |
3449 |
28 Jul 15 |
olle |
1786 |
|
3449 |
28 Jul 15 |
olle |
var volDNA = Math.ceil(10000*dna.usedQuantity/info.QubitConc) / 10; // µl, rounded to 1 decimal |
3449 |
28 Jul 15 |
olle |
var water = TOTAL_VOLUME - volDNA; |
3449 |
28 Jul 15 |
olle |
1789 |
*/ |
3449 |
28 Jul 15 |
olle |
var volDNA = USED_VOL_PER_ALIQUOT; // µl |
3449 |
28 Jul 15 |
olle |
1791 |
|
3449 |
28 Jul 15 |
olle |
if (removedVolume < MINIMAL_DNA_VOLUME) |
3449 |
28 Jul 15 |
olle |
1793 |
{ |
3449 |
28 Jul 15 |
olle |
1794 |
/* |
3449 |
28 Jul 15 |
olle |
// Large mix since we do not want to take less than 1µl |
3449 |
28 Jul 15 |
olle |
volDNA = MINIMAL_DNA_VOLUME; |
3449 |
28 Jul 15 |
olle |
dna.usedQuantity = volDNA * info.QubitConc / 1000; // µg |
3449 |
28 Jul 15 |
olle |
var totalVolume = 1000 * dna.usedQuantity / dna.dilutionConc; // µl |
3449 |
28 Jul 15 |
olle |
water = totalVolume - volDNA; |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'Large mix'; |
3449 |
28 Jul 15 |
olle |
1801 |
*/ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'Vol < MINIMAL_DNA_VOLUME = ' + MINIMAL_DNA_VOLUME; |
3449 |
28 Jul 15 |
olle |
1803 |
} |
3449 |
28 Jul 15 |
olle |
1804 |
|
3449 |
28 Jul 15 |
olle |
if (info.remainingQuantity) |
3449 |
28 Jul 15 |
olle |
1806 |
{ |
3449 |
28 Jul 15 |
olle |
1807 |
/* |
3449 |
28 Jul 15 |
olle |
text += '<div class="quantity">'+Numbers.formatNumber(info.remainingQuantity, 2) + 'µg</div>'; |
3449 |
28 Jul 15 |
olle |
1809 |
*/ |
3449 |
28 Jul 15 |
olle |
var quantityLeft = 1000.0*info.remainingQuantity - 2*usedQuantityPerAliquout; // ng |
3449 |
28 Jul 15 |
olle |
alert("select_dna.js::painter.getWellText(): name = " + dna.name + " info.remainingQuantity = " + info.remainingQuantity + " µg usedQuantityPerAliquout = " + usedQuantityPerAliquout + " ng quantityLeft = " + quantityLeft + " ng"); |
3449 |
28 Jul 15 |
olle |
1812 |
/* |
3449 |
28 Jul 15 |
olle |
text += '<div class="quantity">'+Numbers.formatNumber(quantityLeft, 2) + 'µg '+Numbers.formatNumber(volDNA, 1)+'µl</div>'; |
3449 |
28 Jul 15 |
olle |
1814 |
*/ |
3449 |
28 Jul 15 |
olle |
text += '<div class="quantity">'+Numbers.formatNumber(usedQuantityPerAliquout, 2) + 'ng '+Numbers.formatNumber(volDNA, 1)+'µl</div>'; |
3449 |
28 Jul 15 |
olle |
// Must have at least 1.1µg or 1.22µg (if default values are used) |
3449 |
28 Jul 15 |
olle |
var remainLimit = dna.qc ? QUANTITY_QC : QUANTITY_REGULAR; |
3449 |
28 Jul 15 |
olle |
1818 |
/* |
3449 |
28 Jul 15 |
olle |
if (info.remainingQuantity < remainLimit) |
3449 |
28 Jul 15 |
olle |
1820 |
{ |
3449 |
28 Jul 15 |
olle |
well.setError('Not enough DNA'); |
3449 |
28 Jul 15 |
olle |
1822 |
} |
3449 |
28 Jul 15 |
olle |
// Warning if near the limit |
3449 |
28 Jul 15 |
olle |
if (info.remainingQuantity < LOW_QUANTITY_WARNING_LIMIT && !info.preNormalized) |
3449 |
28 Jul 15 |
olle |
1825 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'Low quantity'; |
3449 |
28 Jul 15 |
olle |
1827 |
} |
3449 |
28 Jul 15 |
olle |
1828 |
*/ |
3449 |
28 Jul 15 |
olle |
if (quantityLeft < 1000.0*remainLimit) |
3449 |
28 Jul 15 |
olle |
1830 |
{ |
3449 |
28 Jul 15 |
olle |
well.setError('Not enough DNA'); |
3449 |
28 Jul 15 |
olle |
1832 |
} |
3449 |
28 Jul 15 |
olle |
// Warning if near the limit |
3449 |
28 Jul 15 |
olle |
if (quantityLeft < 1000.0*LOW_QUANTITY_WARNING_LIMIT && !info.preNormalized) |
3449 |
28 Jul 15 |
olle |
1835 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'Low quantity'; |
3449 |
28 Jul 15 |
olle |
1837 |
} |
3449 |
28 Jul 15 |
olle |
1838 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1840 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'No quantity'; |
3449 |
28 Jul 15 |
olle |
1842 |
} |
3449 |
28 Jul 15 |
olle |
if (info.deltaCt) |
3449 |
28 Jul 15 |
olle |
1844 |
{ |
3449 |
28 Jul 15 |
olle |
text += '<div class="quality-score">ΔCt='+Numbers.formatNumber(info.deltaCt, 1) + '</div>'; |
3449 |
28 Jul 15 |
olle |
if (info.deltaCt > QUALITY_SCORE_WARNING_LIMIT) warningMsg[warningMsg.length] = 'High ΔCt value'; |
3449 |
28 Jul 15 |
olle |
1847 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1849 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'No ΔCt value'; |
3449 |
28 Jul 15 |
olle |
1851 |
} |
3449 |
28 Jul 15 |
olle |
1852 |
/* |
3449 |
28 Jul 15 |
olle |
if (info.QubitConc) |
3449 |
28 Jul 15 |
olle |
1854 |
{ |
3449 |
28 Jul 15 |
olle |
text += '<div class="qubitconc">'+Numbers.formatNumber(info.QubitConc, 2) + 'ng/µl</div>'; |
3449 |
28 Jul 15 |
olle |
text += '<div class="volumes"><span class="volume">'+Numbers.formatNumber(volDNA, 1)+'</span> + <span class="water">'+Numbers.formatNumber(water, 1)+'µl</span></div>'; |
3449 |
28 Jul 15 |
olle |
1857 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1859 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'No QubitConc value'; |
3449 |
28 Jul 15 |
olle |
1861 |
} |
3449 |
28 Jul 15 |
olle |
1862 |
*/ |
3449 |
28 Jul 15 |
olle |
if (info.QiacubeDate) |
3449 |
28 Jul 15 |
olle |
1864 |
{ |
3449 |
28 Jul 15 |
olle |
text += '<div class="qiacube-date">'+info.QiacubeDate+'</div>'; |
3449 |
28 Jul 15 |
olle |
1866 |
} |
3449 |
28 Jul 15 |
olle |
else if (info.DilutionDate) |
3449 |
28 Jul 15 |
olle |
1868 |
{ |
3449 |
28 Jul 15 |
olle |
text += '<div class="dilution-date">'+info.DilutionDate+'</div>'; |
3449 |
28 Jul 15 |
olle |
1870 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1872 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = info.preNormalized ? 'No DilutionDate value' : 'No QiacubeDate value'; |
3449 |
28 Jul 15 |
olle |
1874 |
} |
3449 |
28 Jul 15 |
olle |
if (info.AutoProcessing) |
3449 |
28 Jul 15 |
olle |
1876 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = info.AutoProcessing; |
3449 |
28 Jul 15 |
olle |
1878 |
} |
3449 |
28 Jul 15 |
olle |
1879 |
/* |
3449 |
28 Jul 15 |
olle |
dna.usedQuantity = dna.qc ? QUANTITY_QC : QUANTITY_REGULAR; // µg |
3449 |
28 Jul 15 |
olle |
dna.dilutionConc = 1000 * dna.usedQuantity / TOTAL_VOLUME; // ng/µl |
3449 |
28 Jul 15 |
olle |
1882 |
|
3449 |
28 Jul 15 |
olle |
var volDNA = Math.ceil(10000*dna.usedQuantity/info.QubitConc) / 10; // µl, rounded to 1 decimal |
3449 |
28 Jul 15 |
olle |
var water = TOTAL_VOLUME - volDNA; |
3449 |
28 Jul 15 |
olle |
1885 |
|
3449 |
28 Jul 15 |
olle |
if (volDNA < MINIMAL_DNA_VOLUME) |
3449 |
28 Jul 15 |
olle |
1887 |
{ |
3449 |
28 Jul 15 |
olle |
// Large mix since we do not want to take less than 1µl |
3449 |
28 Jul 15 |
olle |
volDNA = MINIMAL_DNA_VOLUME; |
3449 |
28 Jul 15 |
olle |
dna.usedQuantity = volDNA * info.QubitConc / 1000; // µg |
3449 |
28 Jul 15 |
olle |
var totalVolume = 1000 * dna.usedQuantity / dna.dilutionConc; // µl |
3449 |
28 Jul 15 |
olle |
water = totalVolume - volDNA; |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'Large mix'; |
3449 |
28 Jul 15 |
olle |
1894 |
} |
3449 |
28 Jul 15 |
olle |
1895 |
|
3449 |
28 Jul 15 |
olle |
if (info.remainingQuantity) |
3449 |
28 Jul 15 |
olle |
1897 |
{ |
3449 |
28 Jul 15 |
olle |
//text += '<div class="quantity">'+Numbers.formatNumber(info.remainingQuantity, 2) + 'µg</div>'; |
3449 |
28 Jul 15 |
olle |
text += '<div class="quantity">'+Numbers.formatNumber(info.remainingQuantity, 2) + 'µg '+Numbers.formatNumber(volDNA, 1)+'µl</div>'; |
3449 |
28 Jul 15 |
olle |
// Must have at least 1.1µg or 1.22µg (if default values are used) |
3449 |
28 Jul 15 |
olle |
var remainLimit = dna.qc ? QUANTITY_QC : QUANTITY_REGULAR; |
3449 |
28 Jul 15 |
olle |
if (info.remainingQuantity < remainLimit) |
3449 |
28 Jul 15 |
olle |
1903 |
{ |
3449 |
28 Jul 15 |
olle |
well.setError('Not enough DNA'); |
3449 |
28 Jul 15 |
olle |
1905 |
} |
3449 |
28 Jul 15 |
olle |
// Warning if near the limit |
3449 |
28 Jul 15 |
olle |
if (info.remainingQuantity < LOW_QUANTITY_WARNING_LIMIT && !info.preNormalized) |
3449 |
28 Jul 15 |
olle |
1908 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'Low quantity'; |
3449 |
28 Jul 15 |
olle |
1910 |
} |
3449 |
28 Jul 15 |
olle |
1911 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1913 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'No quantity'; |
3449 |
28 Jul 15 |
olle |
1915 |
} |
3449 |
28 Jul 15 |
olle |
if (info.deltaCt) |
3449 |
28 Jul 15 |
olle |
1917 |
{ |
3449 |
28 Jul 15 |
olle |
text += '<div class="quality-score">ΔCt='+Numbers.formatNumber(info.deltaCt, 1) + '</div>'; |
3449 |
28 Jul 15 |
olle |
if (info.deltaCt > QUALITY_SCORE_WARNING_LIMIT) warningMsg[warningMsg.length] = 'High ΔCt value'; |
3449 |
28 Jul 15 |
olle |
1920 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1922 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'No ΔCt value'; |
3449 |
28 Jul 15 |
olle |
1924 |
} |
3449 |
28 Jul 15 |
olle |
if (info.QubitConc) |
3449 |
28 Jul 15 |
olle |
1926 |
{ |
3449 |
28 Jul 15 |
olle |
text += '<div class="qubitconc">'+Numbers.formatNumber(info.QubitConc, 2) + 'ng/µl</div>'; |
3449 |
28 Jul 15 |
olle |
text += '<div class="volumes"><span class="volume">'+Numbers.formatNumber(volDNA, 1)+'</span> + <span class="water">'+Numbers.formatNumber(water, 1)+'µl</span></div>'; |
3449 |
28 Jul 15 |
olle |
1929 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1931 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = 'No QubitConc value'; |
3449 |
28 Jul 15 |
olle |
1933 |
} |
3449 |
28 Jul 15 |
olle |
if (info.QiacubeDate) |
3449 |
28 Jul 15 |
olle |
1935 |
{ |
3449 |
28 Jul 15 |
olle |
text += '<div class="qiacube-date">'+info.QiacubeDate+'</div>'; |
3449 |
28 Jul 15 |
olle |
1937 |
} |
3449 |
28 Jul 15 |
olle |
else if (info.DilutionDate) |
3449 |
28 Jul 15 |
olle |
1939 |
{ |
3449 |
28 Jul 15 |
olle |
text += '<div class="dilution-date">'+info.DilutionDate+'</div>'; |
3449 |
28 Jul 15 |
olle |
1941 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1943 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = info.preNormalized ? 'No DilutionDate value' : 'No QiacubeDate value'; |
3449 |
28 Jul 15 |
olle |
1945 |
} |
3449 |
28 Jul 15 |
olle |
if (info.AutoProcessing) |
3449 |
28 Jul 15 |
olle |
1947 |
{ |
3449 |
28 Jul 15 |
olle |
warningMsg[warningMsg.length] = info.AutoProcessing; |
3449 |
28 Jul 15 |
olle |
1949 |
} |
3449 |
28 Jul 15 |
olle |
1950 |
*/ |
3449 |
28 Jul 15 |
olle |
1951 |
} |
3449 |
28 Jul 15 |
olle |
else if (!dna.id) |
3449 |
28 Jul 15 |
olle |
1953 |
{ |
3449 |
28 Jul 15 |
olle |
well.setError('DNA not found'); |
3449 |
28 Jul 15 |
olle |
1955 |
} |
3449 |
28 Jul 15 |
olle |
if (dna.comment) |
3449 |
28 Jul 15 |
olle |
1957 |
{ |
3449 |
28 Jul 15 |
olle |
text += '<div class="comment">'+Strings.encodeTags(dna.comment)+'</div>'; |
3449 |
28 Jul 15 |
olle |
1959 |
} |
3449 |
28 Jul 15 |
olle |
if (info && info.comment) |
3449 |
28 Jul 15 |
olle |
1961 |
{ |
3449 |
28 Jul 15 |
olle |
text += '<div class="comment">'+Strings.encodeTags(info.comment)+'</div>'; |
3449 |
28 Jul 15 |
olle |
1963 |
} |
3449 |
28 Jul 15 |
olle |
if (warningMsg.length > 0) |
3449 |
28 Jul 15 |
olle |
1965 |
{ |
3449 |
28 Jul 15 |
olle |
well.setWarning(warningMsg.join('; ')); |
3449 |
28 Jul 15 |
olle |
1967 |
} |
3449 |
28 Jul 15 |
olle |
1968 |
} |
3449 |
28 Jul 15 |
olle |
else if (well.copyText) |
3449 |
28 Jul 15 |
olle |
1970 |
{ |
3449 |
28 Jul 15 |
olle |
text = '<div class="copy-text">'+well.copyText+'</div>'; |
3449 |
28 Jul 15 |
olle |
1972 |
} |
3449 |
28 Jul 15 |
olle |
else |
3449 |
28 Jul 15 |
olle |
1974 |
{ |
3449 |
28 Jul 15 |
olle |
text = 'empty'; |
3449 |
28 Jul 15 |
olle |
1976 |
} |
3449 |
28 Jul 15 |
olle |
if (well.duplicate) |
3449 |
28 Jul 15 |
olle |
1978 |
{ |
3449 |
28 Jul 15 |
olle |
well.setError('Duplicate barcode'); |
3449 |
28 Jul 15 |
olle |
1980 |
} |
3449 |
28 Jul 15 |
olle |
1981 |
|
3449 |
28 Jul 15 |
olle |
var bc = Doc.element('barcode.'+well.row+'.'+well.column); |
3449 |
28 Jul 15 |
olle |
if (bc) |
3449 |
28 Jul 15 |
olle |
1984 |
{ |
3449 |
28 Jul 15 |
olle |
var cls = 'barcode-well' |
3449 |
28 Jul 15 |
olle |
cls += well.column == 0 ? ' barcode-left' : ' barcode-right'; |
3449 |
28 Jul 15 |
olle |
1987 |
|
3449 |
28 Jul 15 |
olle |
if (well.barcode) |
3449 |
28 Jul 15 |
olle |
1989 |
{ |
3449 |
28 Jul 15 |
olle |
bc.innerHTML = well.barcode.name; |
3449 |
28 Jul 15 |
olle |
var indexSet = painter.barcodeVariant ? painter.barcodeVariant.indexSets[well.column] : null; |
3449 |
28 Jul 15 |
olle |
if (indexSet) |
3449 |
28 Jul 15 |
olle |
1993 |
{ |
3449 |
28 Jul 15 |
olle |
cls += ' ' + indexSet.color; |
3449 |
28 Jul 15 |
olle |
1995 |
} |
3449 |
28 Jul 15 |
olle |
if (well.defaultBarcode && well.barcode != well.defaultBarcode) |
3449 |
28 Jul 15 |
olle |
1997 |
{ |
3449 |
28 Jul 15 |
olle |
cls += ' bg-modified'; |
3449 |
28 Jul 15 |
olle |
1999 |
} |
3449 |
28 Jul 15 |
olle |
if (well.duplicate) |
3449 |
28 Jul 15 |
olle |
2001 |
{ |
3449 |
28 Jul 15 |
olle |
cls += ' duplicate'; |
3449 |
28 Jul 15 |
olle |
2003 |
} |
3449 |
28 Jul 15 |
olle |
2004 |
} |
3449 |
28 Jul 15 |
olle |
bc.className = cls; |
3449 |
28 Jul 15 |
olle |
2006 |
} |
3449 |
28 Jul 15 |
olle |
return text; |
3449 |
28 Jul 15 |
olle |
2008 |
} |
3449 |
28 Jul 15 |
olle |
2009 |
|
3449 |
28 Jul 15 |
olle |
painter.fetchDilutionFactor = function(deltaCt) |
3449 |
28 Jul 15 |
olle |
2011 |
{ |
3449 |
28 Jul 15 |
olle |
var dilutionFactor = 1.0; |
3449 |
28 Jul 15 |
olle |
if (deltaCt > 0.5 && deltaCt <= 1.5) |
3449 |
28 Jul 15 |
olle |
2014 |
{ |
3449 |
28 Jul 15 |
olle |
dilutionFactor = 2.0; |
3449 |
28 Jul 15 |
olle |
2016 |
} |
3449 |
28 Jul 15 |
olle |
if (deltaCt > -0.5 && deltaCt <= 0.5) |
3449 |
28 Jul 15 |
olle |
2018 |
{ |
3449 |
28 Jul 15 |
olle |
dilutionFactor = 4.0; |
3449 |
28 Jul 15 |
olle |
2020 |
} |
3449 |
28 Jul 15 |
olle |
if (deltaCt > -1.5 && deltaCt <= -0.5) |
3449 |
28 Jul 15 |
olle |
2022 |
{ |
3449 |
28 Jul 15 |
olle |
dilutionFactor = 8.0; |
3449 |
28 Jul 15 |
olle |
2024 |
} |
3449 |
28 Jul 15 |
olle |
if (deltaCt <=- 1.5) |
3449 |
28 Jul 15 |
olle |
2026 |
{ |
3449 |
28 Jul 15 |
olle |
dilutionFactor = 16.0; |
3449 |
28 Jul 15 |
olle |
2028 |
} |
3449 |
28 Jul 15 |
olle |
return dilutionFactor; |
3449 |
28 Jul 15 |
olle |
2030 |
} |
3449 |
28 Jul 15 |
olle |
2031 |
|
3449 |
28 Jul 15 |
olle |
return painter; |
3449 |
28 Jul 15 |
olle |
2033 |
}(); |