5424 |
13 May 19 |
nicklas |
var Protocol = function() |
5424 |
13 May 19 |
nicklas |
2 |
{ |
5424 |
13 May 19 |
nicklas |
var protocol = {}; |
5424 |
13 May 19 |
nicklas |
var debug = 0; |
5424 |
13 May 19 |
nicklas |
5 |
|
5424 |
13 May 19 |
nicklas |
// Page initialization |
5424 |
13 May 19 |
nicklas |
protocol.initPage = function() |
5424 |
13 May 19 |
nicklas |
8 |
{ |
5424 |
13 May 19 |
nicklas |
var pageId = Doc.getPageId(); |
5424 |
13 May 19 |
nicklas |
if (pageId == 'protocol') |
5424 |
13 May 19 |
nicklas |
11 |
{ |
5424 |
13 May 19 |
nicklas |
Buttons.addClickHandler('print-button', Wizard.goPrint); |
5424 |
13 May 19 |
nicklas |
13 |
|
5424 |
13 May 19 |
nicklas |
var mipsPlateId = Data.int('page-data', 'mips-plate'); |
5424 |
13 May 19 |
nicklas |
15 |
|
5424 |
13 May 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5424 |
13 May 19 |
nicklas |
url += '&cmd=GetLibraryInfoForPlate&bioplate='+mipsPlateId; |
5424 |
13 May 19 |
nicklas |
Wizard.showLoadingAnimation('Loading MIPs plate information...'); |
5424 |
13 May 19 |
nicklas |
Wizard.asyncJsonRequest(url, protocol.initializeProtocol); |
5424 |
13 May 19 |
nicklas |
20 |
} |
5424 |
13 May 19 |
nicklas |
else |
5424 |
13 May 19 |
nicklas |
22 |
{ |
5424 |
13 May 19 |
nicklas |
Events.addEventHandler('bioplate', 'change', protocol.bioplateOnChange); |
5424 |
13 May 19 |
nicklas |
Events.addEventHandler('listview', 'click', protocol.viewProtocol); |
5424 |
13 May 19 |
nicklas |
Events.addEventHandler('plateview', 'click', protocol.viewProtocol); |
5424 |
13 May 19 |
nicklas |
26 |
|
5424 |
13 May 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5424 |
13 May 19 |
nicklas |
url += '&cmd=GetUnprocessedPlates&plateType=MIPS'; |
5424 |
13 May 19 |
nicklas |
Wizard.showLoadingAnimation('Loading MIPs plates...'); |
5424 |
13 May 19 |
nicklas |
Wizard.asyncJsonRequest(url, protocol.initializeStep1); |
5424 |
13 May 19 |
nicklas |
31 |
} |
5424 |
13 May 19 |
nicklas |
32 |
} |
5424 |
13 May 19 |
nicklas |
33 |
|
5424 |
13 May 19 |
nicklas |
34 |
|
5424 |
13 May 19 |
nicklas |
protocol.initializeStep1 = function(response) |
5424 |
13 May 19 |
nicklas |
36 |
{ |
5424 |
13 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5424 |
13 May 19 |
nicklas |
38 |
|
5424 |
13 May 19 |
nicklas |
var bioplates = response.bioplates; |
5424 |
13 May 19 |
nicklas |
var plates = frm.bioplate; |
5424 |
13 May 19 |
nicklas |
if (bioplates.length > 0) |
5424 |
13 May 19 |
nicklas |
42 |
{ |
5424 |
13 May 19 |
nicklas |
for (var i=0; i < bioplates.length; i++) |
5424 |
13 May 19 |
nicklas |
44 |
{ |
5424 |
13 May 19 |
nicklas |
var bioplate = bioplates[i]; |
5424 |
13 May 19 |
nicklas |
var name = bioplate.name; |
5424 |
13 May 19 |
nicklas |
var option = new Option(name, bioplate.id); |
5424 |
13 May 19 |
nicklas |
option.bioplate = bioplate; |
5424 |
13 May 19 |
nicklas |
plates.options[plates.length] = option; |
5424 |
13 May 19 |
nicklas |
50 |
} |
5424 |
13 May 19 |
nicklas |
bioplateIsValid = true; |
5424 |
13 May 19 |
nicklas |
protocol.bioplateOnChange(); |
5424 |
13 May 19 |
nicklas |
53 |
} |
5424 |
13 May 19 |
nicklas |
else |
5424 |
13 May 19 |
nicklas |
55 |
{ |
5424 |
13 May 19 |
nicklas |
Wizard.setFatalError('No MIPs plates available for processing.'); |
5424 |
13 May 19 |
nicklas |
return; |
5424 |
13 May 19 |
nicklas |
58 |
} |
5424 |
13 May 19 |
nicklas |
59 |
|
5424 |
13 May 19 |
nicklas |
Doc.show('step-1'); |
5424 |
13 May 19 |
nicklas |
Doc.show('gonext'); |
5424 |
13 May 19 |
nicklas |
62 |
} |
5424 |
13 May 19 |
nicklas |
63 |
|
5424 |
13 May 19 |
nicklas |
64 |
|
5424 |
13 May 19 |
nicklas |
// Add pools to the pools list based on the bioplate selection |
5424 |
13 May 19 |
nicklas |
protocol.bioplateOnChange = function() |
5424 |
13 May 19 |
nicklas |
67 |
{ |
5424 |
13 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5424 |
13 May 19 |
nicklas |
var bioplate = frm.bioplate[frm.bioplate.selectedIndex].bioplate; |
5424 |
13 May 19 |
nicklas |
Doc.element('comments').innerHTML = Strings.encodeTags(bioplate.comments); |
5424 |
13 May 19 |
nicklas |
71 |
} |
5424 |
13 May 19 |
nicklas |
72 |
|
5424 |
13 May 19 |
nicklas |
protocol.viewProtocol = function(event) |
5424 |
13 May 19 |
nicklas |
74 |
{ |
5424 |
13 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5424 |
13 May 19 |
nicklas |
if (frm.bioplate && !frm.bioplate.disabled) |
5424 |
13 May 19 |
nicklas |
77 |
{ |
5424 |
13 May 19 |
nicklas |
frm.view.value = Data.get(event.currentTarget, 'protocol-type'); |
5424 |
13 May 19 |
nicklas |
frm.submit(); |
5424 |
13 May 19 |
nicklas |
80 |
} |
5424 |
13 May 19 |
nicklas |
81 |
} |
5424 |
13 May 19 |
nicklas |
82 |
|
5424 |
13 May 19 |
nicklas |
protocol.initializeProtocol = function(response) |
5424 |
13 May 19 |
nicklas |
84 |
{ |
5424 |
13 May 19 |
nicklas |
var plate = response.plate; |
5424 |
13 May 19 |
nicklas |
var list = response.libraries; |
5424 |
13 May 19 |
nicklas |
87 |
|
5451 |
27 May 19 |
nicklas |
protocol.preProcessPlate(plate, list); |
5424 |
13 May 19 |
nicklas |
var view = Data.get('page-data', 'view'); |
5424 |
13 May 19 |
nicklas |
if (view == 'list') |
5424 |
13 May 19 |
nicklas |
91 |
{ |
5424 |
13 May 19 |
nicklas |
protocol.viewAsList(list); |
5424 |
13 May 19 |
nicklas |
93 |
} |
5424 |
13 May 19 |
nicklas |
else |
5424 |
13 May 19 |
nicklas |
95 |
{ |
5424 |
13 May 19 |
nicklas |
protocol.viewAsPlate(plate, list) |
5424 |
13 May 19 |
nicklas |
97 |
} |
5424 |
13 May 19 |
nicklas |
98 |
} |
5424 |
13 May 19 |
nicklas |
99 |
|
5451 |
27 May 19 |
nicklas |
// We need to make column-wize checks on the data |
5604 |
13 Sep 19 |
nicklas |
// For example a single MIPS_Panel is expected per column otherwise we must show a warning |
5451 |
27 May 19 |
nicklas |
protocol.preProcessPlate = function(plate, list) |
5424 |
13 May 19 |
nicklas |
103 |
{ |
5451 |
27 May 19 |
nicklas |
Plate.init(plate.rows, plate.columns, WellPainter); |
5451 |
27 May 19 |
nicklas |
// Place all libraries on the plate and initialize some information |
5451 |
27 May 19 |
nicklas |
for (var i = 0; i < list.length; i++) |
5451 |
27 May 19 |
nicklas |
107 |
{ |
5451 |
27 May 19 |
nicklas |
var lib = list[i]; |
5451 |
27 May 19 |
nicklas |
var well = lib.bioWell; |
5451 |
27 May 19 |
nicklas |
var dna = lib.dna; |
5451 |
27 May 19 |
nicklas |
dna.remarks = []; |
5451 |
27 May 19 |
nicklas |
dna.warnings = []; |
5451 |
27 May 19 |
nicklas |
if (lib.comment) dna.remarks[dna.remarks.length] = lib.comment; |
5451 |
27 May 19 |
nicklas |
Plate.getWell(well.row, well.column).setExtract(lib); |
5451 |
27 May 19 |
nicklas |
115 |
} |
5424 |
13 May 19 |
nicklas |
116 |
|
5604 |
13 Sep 19 |
nicklas |
// Analyze columns on the MIPs plate with resepect to MIPS_Panel and PoolVolume |
5451 |
27 May 19 |
nicklas |
COLUMN_DATA = new Array(plate.columns); |
5451 |
27 May 19 |
nicklas |
for (var colNo = 0; colNo < plate.columns; colNo++) |
5451 |
27 May 19 |
nicklas |
120 |
{ |
5451 |
27 May 19 |
nicklas |
var col = {}; |
5451 |
27 May 19 |
nicklas |
COLUMN_DATA[colNo] = col; |
5451 |
27 May 19 |
nicklas |
col.numAliquots = 0; |
5604 |
13 Sep 19 |
nicklas |
col.panelCounter = new ItemCounter(); |
5451 |
27 May 19 |
nicklas |
col.poolVolumeCounter = new ItemCounter(); |
5451 |
27 May 19 |
nicklas |
for (var rowNo = 0; rowNo < Plate.rows; rowNo++) |
5451 |
27 May 19 |
nicklas |
127 |
{ |
5451 |
27 May 19 |
nicklas |
var well = Plate.getWell(rowNo, colNo); |
5451 |
27 May 19 |
nicklas |
if (well.extract) |
5451 |
27 May 19 |
nicklas |
130 |
{ |
5451 |
27 May 19 |
nicklas |
var aliquot = well.extract.dna; |
5451 |
27 May 19 |
nicklas |
col.numAliquots++; |
5604 |
13 Sep 19 |
nicklas |
col.panelCounter.count(aliquot.MIPS_Panel); |
5451 |
27 May 19 |
nicklas |
col.poolVolumeCounter.count(aliquot.MIPS_PoolVolume); |
5451 |
27 May 19 |
nicklas |
if (!col.plate && aliquot.bioWell) |
5451 |
27 May 19 |
nicklas |
136 |
{ |
5451 |
27 May 19 |
nicklas |
col.plate = aliquot.bioWell.bioPlate.name; |
5451 |
27 May 19 |
nicklas |
138 |
} |
5451 |
27 May 19 |
nicklas |
139 |
} |
5451 |
27 May 19 |
nicklas |
140 |
} |
5604 |
13 Sep 19 |
nicklas |
col.MIPS_Panel = col.panelCounter.maxKey; |
5604 |
13 Sep 19 |
nicklas |
col.isMissingMIPSPanel = col.panelCounter.numCounted != col.numAliquots; |
5604 |
13 Sep 19 |
nicklas |
col.hasMultipleMIPSPanels = col.panelCounter.numKeys() > 1; |
5451 |
27 May 19 |
nicklas |
col.MIPS_PoolVolume = col.poolVolumeCounter.maxKey; |
5451 |
27 May 19 |
nicklas |
col.hasMultiplePoolVolumes = col.poolVolumeCounter.numKeys() > 1; |
5451 |
27 May 19 |
nicklas |
146 |
} |
5424 |
13 May 19 |
nicklas |
147 |
|
5451 |
27 May 19 |
nicklas |
// Finally, check library data against column data and generate warnings |
5451 |
27 May 19 |
nicklas |
for (var i = 0; i < list.length; i++) |
5424 |
13 May 19 |
nicklas |
150 |
{ |
5451 |
27 May 19 |
nicklas |
var lib = list[i]; |
5451 |
27 May 19 |
nicklas |
var well = lib.bioWell; |
5451 |
27 May 19 |
nicklas |
var dna = lib.dna; |
5451 |
27 May 19 |
nicklas |
154 |
|
5451 |
27 May 19 |
nicklas |
if (dna.MIPS_PoolVolume != null) |
5451 |
27 May 19 |
nicklas |
156 |
{ |
5451 |
27 May 19 |
nicklas |
if (dna.MIPS_PoolVolume != COLUMN_DATA[well.column].MIPS_PoolVolume) |
5451 |
27 May 19 |
nicklas |
158 |
{ |
5461 |
03 Jun 19 |
nicklas |
dna.warnings[dna.warnings.length] = 'PoolVolume!'; |
5451 |
27 May 19 |
nicklas |
160 |
} |
5451 |
27 May 19 |
nicklas |
161 |
} |
5424 |
13 May 19 |
nicklas |
162 |
} |
5451 |
27 May 19 |
nicklas |
163 |
} |
5451 |
27 May 19 |
nicklas |
164 |
|
5451 |
27 May 19 |
nicklas |
protocol.viewAsPlate = function() |
5451 |
27 May 19 |
nicklas |
166 |
{ |
5451 |
27 May 19 |
nicklas |
protocol.buildPoolRow(); |
5451 |
27 May 19 |
nicklas |
protocol.buildPlateRow(); |
5451 |
27 May 19 |
nicklas |
Plate.paint(Plate.getWells()); |
5451 |
27 May 19 |
nicklas |
Doc.show('all-protocol'); |
5451 |
27 May 19 |
nicklas |
171 |
} |
5451 |
27 May 19 |
nicklas |
172 |
|
5451 |
27 May 19 |
nicklas |
protocol.buildPoolRow = function() |
5451 |
27 May 19 |
nicklas |
174 |
{ |
5451 |
27 May 19 |
nicklas |
var html = '<th></th>'; |
5604 |
13 Sep 19 |
nicklas |
var pools = []; // A 'pool' is a number of columns with the same MIPS_Panel |
5451 |
27 May 19 |
nicklas |
var currentPool = {}; |
5451 |
27 May 19 |
nicklas |
178 |
|
5451 |
27 May 19 |
nicklas |
var poolNum = -1; |
5451 |
27 May 19 |
nicklas |
for (var colNo = 0; colNo < COLUMN_DATA.length; colNo++) |
5424 |
13 May 19 |
nicklas |
181 |
{ |
5451 |
27 May 19 |
nicklas |
var col = COLUMN_DATA[colNo]; |
5604 |
13 Sep 19 |
nicklas |
if ((col.MIPS_Panel != currentPool.name) || (col.numAliquots == 0 && currentPool.numAliquots != 0)) |
5424 |
13 May 19 |
nicklas |
184 |
{ |
5604 |
13 Sep 19 |
nicklas |
// The column has a different MIPS_Panel than the previous one so we create a new pool |
5451 |
27 May 19 |
nicklas |
currentPool = {}; |
5604 |
13 Sep 19 |
nicklas |
currentPool.name = col.MIPS_Panel; |
5451 |
27 May 19 |
nicklas |
currentPool.startCol = colNo; |
5451 |
27 May 19 |
nicklas |
currentPool.columnSpan = 1; |
5604 |
13 Sep 19 |
nicklas |
currentPool.hasMultipleMIPSPanels = col.hasMultipleMIPSPanels; |
5451 |
27 May 19 |
nicklas |
currentPool.hasMultiplePoolVolumes = col.hasMultiplePoolVolumes; |
5604 |
13 Sep 19 |
nicklas |
currentPool.isMissingMIPSPanel = col.isMissingMIPSPanel; |
5451 |
27 May 19 |
nicklas |
currentPool.numAliquots = col.numAliquots; |
5451 |
27 May 19 |
nicklas |
pools[pools.length] = currentPool; |
5451 |
27 May 19 |
nicklas |
poolNum++; |
5424 |
13 May 19 |
nicklas |
196 |
} |
5451 |
27 May 19 |
nicklas |
else if (currentPool) |
5424 |
13 May 19 |
nicklas |
198 |
{ |
5604 |
13 Sep 19 |
nicklas |
// The column has the same MIPS_Panel as the previous one, we make the pool span across multiple columns |
5451 |
27 May 19 |
nicklas |
currentPool.columnSpan++; |
5451 |
27 May 19 |
nicklas |
currentPool.numAliquots += col.numAliquots; |
5604 |
13 Sep 19 |
nicklas |
if (col.isMissingMIPSPanel) currentPool.isMissingMIPSPanel = true; |
5604 |
13 Sep 19 |
nicklas |
if (col.hasMultipleMIPSPanels) currentPool.hasMultipleMIPSPanels = true; |
5451 |
27 May 19 |
nicklas |
if (col.hasMultiplePoolVolumes) currentPool.hasMultiplePoolVolumes = true; |
5424 |
13 May 19 |
nicklas |
205 |
} |
5451 |
27 May 19 |
nicklas |
206 |
} |
5451 |
27 May 19 |
nicklas |
207 |
|
5451 |
27 May 19 |
nicklas |
colNo = 0; |
5451 |
27 May 19 |
nicklas |
for (var poolNo = 0; poolNo < pools.length; poolNo++) |
5451 |
27 May 19 |
nicklas |
210 |
{ |
5451 |
27 May 19 |
nicklas |
var pool = pools[poolNo]; |
5451 |
27 May 19 |
nicklas |
var poolClass = 'pool link'; |
5451 |
27 May 19 |
nicklas |
var poolText = null; |
5451 |
27 May 19 |
nicklas |
214 |
|
5451 |
27 May 19 |
nicklas |
if (pool.columnSpan == 1) |
5424 |
13 May 19 |
nicklas |
216 |
{ |
5451 |
27 May 19 |
nicklas |
COLUMN_DATA[colNo].poolClass = 'pool-left pool-right'; |
5424 |
13 May 19 |
nicklas |
218 |
} |
5451 |
27 May 19 |
nicklas |
else |
5424 |
13 May 19 |
nicklas |
220 |
{ |
5451 |
27 May 19 |
nicklas |
COLUMN_DATA[colNo].poolClass = 'pool-left'; |
5451 |
27 May 19 |
nicklas |
for (var i = 1; i < pool.columnSpan-1; i++) |
5451 |
27 May 19 |
nicklas |
223 |
{ |
5451 |
27 May 19 |
nicklas |
COLUMN_DATA[colNo+i].poolClass = 'pool-middle'; |
5451 |
27 May 19 |
nicklas |
225 |
} |
5451 |
27 May 19 |
nicklas |
COLUMN_DATA[colNo+pool.columnSpan-1].poolClass = 'pool-right'; |
5424 |
13 May 19 |
nicklas |
227 |
} |
5451 |
27 May 19 |
nicklas |
228 |
|
5451 |
27 May 19 |
nicklas |
if (pool.numAliquots > 0) |
5424 |
13 May 19 |
nicklas |
230 |
{ |
5604 |
13 Sep 19 |
nicklas |
if (pool.hasMultiplePoolVolumes || pool.isMissingMIPSPanel) |
5451 |
27 May 19 |
nicklas |
232 |
{ |
5451 |
27 May 19 |
nicklas |
poolClass += ' pool-warning'; |
5604 |
13 Sep 19 |
nicklas |
if (pool.isMissingMIPSPanel) |
5451 |
27 May 19 |
nicklas |
235 |
{ |
5604 |
13 Sep 19 |
nicklas |
poolText = 'Some aliquots have no MIPS_Panel!'; |
5451 |
27 May 19 |
nicklas |
237 |
} |
5521 |
20 Jun 19 |
nicklas |
else if (pool.hasMultiplePoolVolumes) |
5451 |
27 May 19 |
nicklas |
239 |
{ |
5521 |
20 Jun 19 |
nicklas |
poolText = 'Some aliquots have a different pool volume!'; |
5451 |
27 May 19 |
nicklas |
241 |
} |
5451 |
27 May 19 |
nicklas |
242 |
} |
5521 |
20 Jun 19 |
nicklas |
if (pool.name) poolClass += ' ' + MipsColor.getColor(pool.name); |
5451 |
27 May 19 |
nicklas |
html += '<th id="pool.' + poolNo + '" colspan="'+pool.columnSpan+'"'; |
5451 |
27 May 19 |
nicklas |
html += ' class="'+poolClass+'"'; |
5451 |
27 May 19 |
nicklas |
html += ' data-start-col="'+pool.startCol+'"'; |
5451 |
27 May 19 |
nicklas |
html += ' data-end-col="'+(pool.startCol+pool.columnSpan-1)+'"'; |
5451 |
27 May 19 |
nicklas |
if (poolText) html += ' title="'+poolText+'"'; |
5604 |
13 Sep 19 |
nicklas |
html += '>'+Strings.encodeTags(pool.name || 'No MIPS_Panel')+'</th>'; |
5424 |
13 May 19 |
nicklas |
250 |
} |
5451 |
27 May 19 |
nicklas |
else |
5451 |
27 May 19 |
nicklas |
252 |
{ |
5451 |
27 May 19 |
nicklas |
poolClass = ''; |
5451 |
27 May 19 |
nicklas |
if (colNo > 0) poolClass += ' nopool-after-pool'; |
5451 |
27 May 19 |
nicklas |
if (colNo + pool.columnSpan < 12) poolClass += ' nopool-before-pool'; |
5451 |
27 May 19 |
nicklas |
html += '<th colspan="'+pool.columnSpan+'"'; |
5451 |
27 May 19 |
nicklas |
html += ' class="'+poolClass+'"'; |
5451 |
27 May 19 |
nicklas |
html += '></th>'; |
5451 |
27 May 19 |
nicklas |
259 |
} |
5451 |
27 May 19 |
nicklas |
colNo += pool.columnSpan; |
5424 |
13 May 19 |
nicklas |
261 |
} |
5424 |
13 May 19 |
nicklas |
262 |
|
5451 |
27 May 19 |
nicklas |
var row = Doc.element('pool-row'); |
5451 |
27 May 19 |
nicklas |
row.innerHTML = html; |
5451 |
27 May 19 |
nicklas |
Doc.show(row); |
5424 |
13 May 19 |
nicklas |
266 |
} |
5440 |
20 May 19 |
nicklas |
267 |
|
5451 |
27 May 19 |
nicklas |
protocol.buildPlateRow = function() |
5440 |
20 May 19 |
nicklas |
269 |
{ |
5440 |
20 May 19 |
nicklas |
var html = '<th></th>'; |
5451 |
27 May 19 |
nicklas |
var poolClass = 'group link'; |
5451 |
27 May 19 |
nicklas |
var totalSpan = 0; |
5451 |
27 May 19 |
nicklas |
var colNo = 0; |
5440 |
20 May 19 |
nicklas |
274 |
|
5440 |
20 May 19 |
nicklas |
var plates = []; |
5451 |
27 May 19 |
nicklas |
var currentPlate = {}; |
5451 |
27 May 19 |
nicklas |
for (var colNo = 0; colNo < COLUMN_DATA.length; colNo++) |
5440 |
20 May 19 |
nicklas |
278 |
{ |
5451 |
27 May 19 |
nicklas |
var col = COLUMN_DATA[colNo]; |
5451 |
27 May 19 |
nicklas |
if ((col.plate != currentPlate.name)) |
5440 |
20 May 19 |
nicklas |
281 |
{ |
5451 |
27 May 19 |
nicklas |
// The column has a different aliquot plate than the previous one so we create a new pool |
5451 |
27 May 19 |
nicklas |
currentPlate = {}; |
5451 |
27 May 19 |
nicklas |
currentPlate.name = col.plate; |
5451 |
27 May 19 |
nicklas |
currentPlate.startCol = colNo; |
5451 |
27 May 19 |
nicklas |
currentPlate.columnSpan = 1; |
5451 |
27 May 19 |
nicklas |
plates[plates.length] = currentPlate; |
5440 |
20 May 19 |
nicklas |
288 |
} |
5440 |
20 May 19 |
nicklas |
else if (currentPlate) |
5440 |
20 May 19 |
nicklas |
290 |
{ |
5451 |
27 May 19 |
nicklas |
// The column has the same aliquot plate as the previous one, we make the pool span across multiple columns |
5440 |
20 May 19 |
nicklas |
currentPlate.columnSpan++; |
5440 |
20 May 19 |
nicklas |
293 |
} |
5440 |
20 May 19 |
nicklas |
294 |
} |
5451 |
27 May 19 |
nicklas |
295 |
|
5440 |
20 May 19 |
nicklas |
for (var plateNo = 0; plateNo < plates.length; plateNo++) |
5440 |
20 May 19 |
nicklas |
297 |
{ |
5440 |
20 May 19 |
nicklas |
var plate = plates[plateNo]; |
5440 |
20 May 19 |
nicklas |
if (plate.columnSpan == 1) |
5440 |
20 May 19 |
nicklas |
300 |
{ |
5451 |
27 May 19 |
nicklas |
COLUMN_DATA[plate.startCol].groupClass = 'group-left group-right'; |
5440 |
20 May 19 |
nicklas |
302 |
} |
5440 |
20 May 19 |
nicklas |
else |
5440 |
20 May 19 |
nicklas |
304 |
{ |
5451 |
27 May 19 |
nicklas |
COLUMN_DATA[plate.startCol].groupClass = 'group-left'; |
5440 |
20 May 19 |
nicklas |
for (var i = 1; i < plate.columnSpan-1; i++) |
5440 |
20 May 19 |
nicklas |
307 |
{ |
5451 |
27 May 19 |
nicklas |
COLUMN_DATA[plate.startCol+i].groupClass = 'group-middle'; |
5440 |
20 May 19 |
nicklas |
309 |
} |
5451 |
27 May 19 |
nicklas |
COLUMN_DATA[plate.startCol+plate.columnSpan-1].groupClass = 'group-right'; |
5440 |
20 May 19 |
nicklas |
311 |
} |
5440 |
20 May 19 |
nicklas |
312 |
|
5451 |
27 May 19 |
nicklas |
if (plate.name) |
5451 |
27 May 19 |
nicklas |
314 |
{ |
5451 |
27 May 19 |
nicklas |
totalSpan += plate.columnSpan; |
5451 |
27 May 19 |
nicklas |
html += '<th id="group.' + plateNo + '" colspan="'+plate.columnSpan+'"'; |
5451 |
27 May 19 |
nicklas |
html += ' class="'+poolClass+'"'; |
5451 |
27 May 19 |
nicklas |
html += ' data-start-col="' + plate.startCol + '"'; |
5451 |
27 May 19 |
nicklas |
html += ' data-end-col="' + (plate.startCol+plate.columnSpan-1) + '"'; |
5451 |
27 May 19 |
nicklas |
html += '>'+Strings.encodeTags(plate.name)+'</th>'; |
5451 |
27 May 19 |
nicklas |
321 |
} |
5451 |
27 May 19 |
nicklas |
else |
5451 |
27 May 19 |
nicklas |
323 |
{ |
5451 |
27 May 19 |
nicklas |
totalSpan += plate.columnSpan; |
5451 |
27 May 19 |
nicklas |
html += '<th class="nopool-after-pool" colspan="'+plate.columnSpan+'"></th>'; |
5451 |
27 May 19 |
nicklas |
326 |
} |
5440 |
20 May 19 |
nicklas |
327 |
} |
5451 |
27 May 19 |
nicklas |
var row = document.getElementById('plate-row'); |
5440 |
20 May 19 |
nicklas |
row.innerHTML = html; |
5451 |
27 May 19 |
nicklas |
Doc.show(row); |
5440 |
20 May 19 |
nicklas |
331 |
} |
5451 |
27 May 19 |
nicklas |
332 |
|
5440 |
20 May 19 |
nicklas |
333 |
|
5424 |
13 May 19 |
nicklas |
protocol.viewAsList = function(list) |
5424 |
13 May 19 |
nicklas |
335 |
{ |
5424 |
13 May 19 |
nicklas |
var homeUrl = Data.get('page-data', 'home-url'); |
5424 |
13 May 19 |
nicklas |
var yellowImg = '<img src="'+homeUrl+'/images/yellow-label-small.png">'; |
5424 |
13 May 19 |
nicklas |
for (var i = 0; i < list.length; i++) |
5424 |
13 May 19 |
nicklas |
339 |
{ |
5424 |
13 May 19 |
nicklas |
var lib = list[i]; |
5424 |
13 May 19 |
nicklas |
var dna = lib.dna; |
5424 |
13 May 19 |
nicklas |
var idSuffix = lib.bioWell.column + '.' + lib.bioWell.row; |
5424 |
13 May 19 |
nicklas |
var tableRow = Doc.element('row.'+idSuffix); |
5424 |
13 May 19 |
nicklas |
344 |
|
5424 |
13 May 19 |
nicklas |
Doc.removeClass(tableRow, 'empty'); |
5424 |
13 May 19 |
nicklas |
Doc.element('dna.'+idSuffix).innerHTML = Strings.encodeTags(dna.name); |
5424 |
13 May 19 |
nicklas |
347 |
|
5424 |
13 May 19 |
nicklas |
Doc.element('box.'+idSuffix).innerHTML = Strings.encodeTags(protocol.getPlateCoordinate(dna, true)); |
5604 |
13 Sep 19 |
nicklas |
Doc.element('panel.'+idSuffix).innerHTML = Strings.encodeTags(dna.MIPS_Panel); |
5604 |
13 Sep 19 |
nicklas |
Doc.addClass('panel.'+idSuffix, MipsColor.getColor(dna.MIPS_Panel)); |
5451 |
27 May 19 |
nicklas |
351 |
|
5451 |
27 May 19 |
nicklas |
var form = ''; |
5451 |
27 May 19 |
nicklas |
if (dna.MIPS_NormalTumor != null) form += '<span>'+Strings.encodeTags(dna.MIPS_NormalTumor)+'</span>'; |
5451 |
27 May 19 |
nicklas |
if (dna.MIPS_Form != null) form += '<span>'+Strings.encodeTags(dna.MIPS_Form)+'</span>'; |
5451 |
27 May 19 |
nicklas |
Doc.element('form.'+idSuffix).innerHTML = form; |
5461 |
03 Jun 19 |
nicklas |
Doc.element('volume.'+idSuffix).innerHTML = Numbers.formatNumber(dna.MIPS_PoolVolume, 0, 'µl'); |
5451 |
27 May 19 |
nicklas |
var remarks = dna.remarks.join('; '); |
5451 |
27 May 19 |
nicklas |
if (dna.warnings.length > 0) |
5451 |
27 May 19 |
nicklas |
359 |
{ |
5451 |
27 May 19 |
nicklas |
remarks += '<span class="warning">'+dna.warnings.join('; ')+'</span>'; |
5451 |
27 May 19 |
nicklas |
361 |
} |
5451 |
27 May 19 |
nicklas |
Doc.element('remarks.'+idSuffix).innerHTML = remarks; |
5424 |
13 May 19 |
nicklas |
363 |
} |
5424 |
13 May 19 |
nicklas |
364 |
|
5424 |
13 May 19 |
nicklas |
Doc.show('all-protocol'); |
5424 |
13 May 19 |
nicklas |
366 |
} |
5424 |
13 May 19 |
nicklas |
367 |
|
5424 |
13 May 19 |
nicklas |
368 |
|
5424 |
13 May 19 |
nicklas |
protocol.getPlateCoordinate = function(dna, includePlateName) |
5424 |
13 May 19 |
nicklas |
370 |
{ |
5424 |
13 May 19 |
nicklas |
var c = ''; |
5424 |
13 May 19 |
nicklas |
if (dna.bioWell) |
5424 |
13 May 19 |
nicklas |
373 |
{ |
5451 |
27 May 19 |
nicklas |
if (includePlateName) c += dna.bioWell.bioPlate.name + ' '; |
5451 |
27 May 19 |
nicklas |
c += '[' + Reggie.wellToAlpha(dna.bioWell.row) + (dna.bioWell.column+1) + ']'; |
5424 |
13 May 19 |
nicklas |
376 |
} |
5424 |
13 May 19 |
nicklas |
else |
5424 |
13 May 19 |
nicklas |
378 |
{ |
5424 |
13 May 19 |
nicklas |
c = ' '; |
5424 |
13 May 19 |
nicklas |
380 |
} |
5424 |
13 May 19 |
nicklas |
return c; |
5424 |
13 May 19 |
nicklas |
382 |
} |
5424 |
13 May 19 |
nicklas |
383 |
|
5424 |
13 May 19 |
nicklas |
384 |
|
5424 |
13 May 19 |
nicklas |
return protocol; |
5424 |
13 May 19 |
nicklas |
386 |
}(); |
5424 |
13 May 19 |
nicklas |
387 |
|
5424 |
13 May 19 |
nicklas |
Doc.onLoad(Protocol.initPage); |
5424 |
13 May 19 |
nicklas |
389 |
|
5451 |
27 May 19 |
nicklas |
var COLUMN_DATA = []; |
5424 |
13 May 19 |
nicklas |
var WellPainter = function() |
5424 |
13 May 19 |
nicklas |
392 |
{ |
5424 |
13 May 19 |
nicklas |
var painter = {}; |
5424 |
13 May 19 |
nicklas |
394 |
|
5424 |
13 May 19 |
nicklas |
painter.getClassNameForWell = function(well) |
5424 |
13 May 19 |
nicklas |
396 |
{ |
5424 |
13 May 19 |
nicklas |
var cls = ''; |
5451 |
27 May 19 |
nicklas |
if (COLUMN_DATA[well.column]) |
5424 |
13 May 19 |
nicklas |
399 |
{ |
5451 |
27 May 19 |
nicklas |
cls += ' ' + (COLUMN_DATA[well.column].poolClass || ''); |
5451 |
27 May 19 |
nicklas |
cls += ' ' + (COLUMN_DATA[well.column].groupClass || ''); |
5424 |
13 May 19 |
nicklas |
402 |
} |
5604 |
13 Sep 19 |
nicklas |
if (well.extract) cls += ' ' + MipsColor.getColor(well.extract.dna.MIPS_Panel); |
5424 |
13 May 19 |
nicklas |
return cls; |
5424 |
13 May 19 |
nicklas |
405 |
} |
5424 |
13 May 19 |
nicklas |
406 |
|
5424 |
13 May 19 |
nicklas |
painter.getWellText = function(well) |
5424 |
13 May 19 |
nicklas |
408 |
{ |
5424 |
13 May 19 |
nicklas |
var text = ''; |
5424 |
13 May 19 |
nicklas |
var lib = well.extract; |
5424 |
13 May 19 |
nicklas |
if (lib) |
5424 |
13 May 19 |
nicklas |
412 |
{ |
5424 |
13 May 19 |
nicklas |
var dna = lib.dna; |
5483 |
11 Jun 19 |
nicklas |
414 |
|
5483 |
11 Jun 19 |
nicklas |
if (!dna.nameWithoutPrefix) dna.nameWithoutPrefix = dna.name.replace(/^[a-zA-Z]+_/, ''); |
5483 |
11 Jun 19 |
nicklas |
416 |
|
5483 |
11 Jun 19 |
nicklas |
text += '<div class="dna">'+Reggie.softLineBreaks(Strings.encodeTags(dna.nameWithoutPrefix))+'</div>'; |
5440 |
20 May 19 |
nicklas |
text += '<div class="box">'+Strings.encodeTags(Protocol.getPlateCoordinate(dna, false))+'</div>'; |
5424 |
13 May 19 |
nicklas |
419 |
|
5451 |
27 May 19 |
nicklas |
if (dna.MIPS_PoolVolume != null) |
5424 |
13 May 19 |
nicklas |
421 |
{ |
5461 |
03 Jun 19 |
nicklas |
text += '<div class="volume">'+Numbers.formatNumber(dna.MIPS_PoolVolume, 0, 'µl')+'</div>'; |
5451 |
27 May 19 |
nicklas |
423 |
} |
5451 |
27 May 19 |
nicklas |
424 |
|
5604 |
13 Sep 19 |
nicklas |
text += '<div class="mips-panel">'+Strings.encodeTags(dna.MIPS_Panel)+'</div>'; |
5451 |
27 May 19 |
nicklas |
426 |
|
5451 |
27 May 19 |
nicklas |
if (dna.MIPS_Form != null || dna.MIPS_NormalTumor != null) |
5451 |
27 May 19 |
nicklas |
428 |
{ |
5451 |
27 May 19 |
nicklas |
text += '<div class="mips-form">'; |
5451 |
27 May 19 |
nicklas |
if (dna.MIPS_NormalTumor != null) text += '<span>'+Strings.encodeTags(dna.MIPS_NormalTumor)+'</span>'; |
5451 |
27 May 19 |
nicklas |
if (dna.MIPS_Form != null) text += '<span>'+Strings.encodeTags(dna.MIPS_Form)+'</span>'; |
5424 |
13 May 19 |
nicklas |
text += '</div>'; |
5424 |
13 May 19 |
nicklas |
433 |
} |
5451 |
27 May 19 |
nicklas |
434 |
|
5451 |
27 May 19 |
nicklas |
if (dna.warnings.length > 0) |
5451 |
27 May 19 |
nicklas |
436 |
{ |
5451 |
27 May 19 |
nicklas |
well.setWarning(dna.warnings.join('; ')); |
5451 |
27 May 19 |
nicklas |
438 |
} |
5451 |
27 May 19 |
nicklas |
439 |
|
5424 |
13 May 19 |
nicklas |
text += '<div class="remarks">'+ dna.remarks.join('; ') + '</div>'; |
5424 |
13 May 19 |
nicklas |
441 |
} |
5424 |
13 May 19 |
nicklas |
return text; |
5424 |
13 May 19 |
nicklas |
443 |
} |
5424 |
13 May 19 |
nicklas |
444 |
|
5424 |
13 May 19 |
nicklas |
return painter; |
5424 |
13 May 19 |
nicklas |
446 |
}(); |
5424 |
13 May 19 |
nicklas |
447 |
|