3685 |
12 Jan 16 |
olle |
var Protocol = function() |
3685 |
12 Jan 16 |
olle |
2 |
{ |
3685 |
12 Jan 16 |
olle |
var protocol = {}; |
3685 |
12 Jan 16 |
olle |
var debug = 0; |
3685 |
12 Jan 16 |
olle |
var MINIMAL_DNA_VOLUME = 1.0; //µl |
3685 |
12 Jan 16 |
olle |
6 |
|
3685 |
12 Jan 16 |
olle |
// Page initialization |
3685 |
12 Jan 16 |
olle |
protocol.initPage = function() |
3685 |
12 Jan 16 |
olle |
9 |
{ |
3685 |
12 Jan 16 |
olle |
var pageId = Doc.getPageId(); |
3685 |
12 Jan 16 |
olle |
if (pageId == 'protocol') |
3685 |
12 Jan 16 |
olle |
12 |
{ |
3685 |
12 Jan 16 |
olle |
Buttons.addClickHandler('print-button', Wizard.goPrint); |
3685 |
12 Jan 16 |
olle |
14 |
|
3685 |
12 Jan 16 |
olle |
var submitInfoJsonStr = Data.get('page-data', 'submitinfo'); |
3685 |
12 Jan 16 |
olle |
protocol.initializeProtocol(submitInfoJsonStr); |
3685 |
12 Jan 16 |
olle |
17 |
} |
3685 |
12 Jan 16 |
olle |
18 |
} |
3685 |
12 Jan 16 |
olle |
19 |
|
3685 |
12 Jan 16 |
olle |
protocol.initializeProtocol = function(submitInfoJsonStr) |
3685 |
12 Jan 16 |
olle |
21 |
{ |
3685 |
12 Jan 16 |
olle |
var submitInfo = JSON.parse(submitInfoJsonStr); |
3685 |
12 Jan 16 |
olle |
var docMode = submitInfo.docMode; |
3685 |
12 Jan 16 |
olle |
var itemInfo = submitInfo.items; |
3685 |
12 Jan 16 |
olle |
var list = itemInfo; |
3685 |
12 Jan 16 |
olle |
26 |
|
3685 |
12 Jan 16 |
olle |
var schema = PoolSchema.getById(Data.get('page-data', 'schema')); |
3685 |
12 Jan 16 |
olle |
28 |
|
3685 |
12 Jan 16 |
olle |
var view = Data.get('page-data', 'view'); |
3685 |
12 Jan 16 |
olle |
if (view == 'list') |
3685 |
12 Jan 16 |
olle |
31 |
{ |
3685 |
12 Jan 16 |
olle |
protocol.viewAsList(list); |
3685 |
12 Jan 16 |
olle |
33 |
} |
3685 |
12 Jan 16 |
olle |
else |
3685 |
12 Jan 16 |
olle |
35 |
{ |
3685 |
12 Jan 16 |
olle |
protocol.viewAsPlate(list, schema) |
3685 |
12 Jan 16 |
olle |
37 |
} |
3685 |
12 Jan 16 |
olle |
38 |
|
3685 |
12 Jan 16 |
olle |
39 |
} |
3685 |
12 Jan 16 |
olle |
40 |
|
3685 |
12 Jan 16 |
olle |
protocol.viewAsPlate = function(list, schema) |
3685 |
12 Jan 16 |
olle |
42 |
{ |
3685 |
12 Jan 16 |
olle |
var rows = Data.get('page-data', 'rows'); |
3685 |
12 Jan 16 |
olle |
var columns = Data.get('page-data', 'columns'); |
3685 |
12 Jan 16 |
olle |
Plate.init(rows, columns, schema, WellPainter); |
3685 |
12 Jan 16 |
olle |
46 |
|
3685 |
12 Jan 16 |
olle |
for (var i = 0; i < list.length; i++) |
3685 |
12 Jan 16 |
olle |
48 |
{ |
3685 |
12 Jan 16 |
olle |
var lib = list[i]; |
3685 |
12 Jan 16 |
olle |
var well = lib.bioWell; |
3685 |
12 Jan 16 |
olle |
Plate.getWell(well.row, well.column).setExtract(lib); |
3685 |
12 Jan 16 |
olle |
// FPB aliquot |
3685 |
12 Jan 16 |
olle |
var libFpb = protocol.fetchFpbAliquot(lib); |
3685 |
12 Jan 16 |
olle |
var wellFpb = libFpb.bioWell; |
3685 |
12 Jan 16 |
olle |
Plate.getWell(wellFpb.row, wellFpb.column).setExtract(libFpb); |
3685 |
12 Jan 16 |
olle |
56 |
} |
3685 |
12 Jan 16 |
olle |
57 |
|
3685 |
12 Jan 16 |
olle |
Plate.paint(Plate.getWells()); |
3685 |
12 Jan 16 |
olle |
PoolSchema.buildPoolTableRow(schema, columns); |
3685 |
12 Jan 16 |
olle |
60 |
|
3685 |
12 Jan 16 |
olle |
Doc.show('all-protocol'); |
3685 |
12 Jan 16 |
olle |
62 |
} |
3685 |
12 Jan 16 |
olle |
63 |
|
3685 |
12 Jan 16 |
olle |
protocol.viewAsList = function(list) |
3685 |
12 Jan 16 |
olle |
65 |
{ |
3685 |
12 Jan 16 |
olle |
var lastPoolNum = -1; |
3685 |
12 Jan 16 |
olle |
for (var i = 0; i < list.length; i++) |
3685 |
12 Jan 16 |
olle |
68 |
{ |
3685 |
12 Jan 16 |
olle |
var lib = list[i]; |
3685 |
12 Jan 16 |
olle |
protocol.libListEntry(lib); |
3685 |
12 Jan 16 |
olle |
// FPB aliquot |
3685 |
12 Jan 16 |
olle |
var libFpb = protocol.fetchFpbAliquot(lib); |
3685 |
12 Jan 16 |
olle |
protocol.libListEntry(libFpb); |
3685 |
12 Jan 16 |
olle |
74 |
} |
3685 |
12 Jan 16 |
olle |
75 |
|
3685 |
12 Jan 16 |
olle |
Doc.show('all-protocol'); |
3685 |
12 Jan 16 |
olle |
77 |
} |
3685 |
12 Jan 16 |
olle |
78 |
|
3685 |
12 Jan 16 |
olle |
protocol.libListEntry = function(lib) |
3685 |
12 Jan 16 |
olle |
80 |
{ |
3685 |
12 Jan 16 |
olle |
var well = lib.bioWell; |
3685 |
12 Jan 16 |
olle |
82 |
|
3685 |
12 Jan 16 |
olle |
var idSuffix = well.column + '.' + well.row; |
3685 |
12 Jan 16 |
olle |
Doc.removeClass('row.'+idSuffix, 'empty'); |
3685 |
12 Jan 16 |
olle |
Doc.element('lib.'+idSuffix).innerHTML = Strings.encodeTags(lib.name); |
3685 |
12 Jan 16 |
olle |
// Index 1 & 2 primers |
3685 |
12 Jan 16 |
olle |
var well = lib.bioWell; |
3685 |
12 Jan 16 |
olle |
var row = well.row + 1; |
3685 |
12 Jan 16 |
olle |
var column = well.column + 1; |
3685 |
12 Jan 16 |
olle |
var index2 = 'A50' + row; |
3685 |
12 Jan 16 |
olle |
var index1 = 'A70' + column; |
3685 |
12 Jan 16 |
olle |
if (column > 9) |
3685 |
12 Jan 16 |
olle |
93 |
{ |
3685 |
12 Jan 16 |
olle |
index1 = 'A7' + column; |
3685 |
12 Jan 16 |
olle |
95 |
} |
3685 |
12 Jan 16 |
olle |
Doc.element('barcode.'+idSuffix).innerHTML = Strings.encodeTags(index2 + ', ' + index1); |
3685 |
12 Jan 16 |
olle |
// DNA extract |
3685 |
12 Jan 16 |
olle |
var dna = lib.info; |
3685 |
12 Jan 16 |
olle |
if (dna) |
3685 |
12 Jan 16 |
olle |
100 |
{ |
3685 |
12 Jan 16 |
olle |
var volDnaInSolution = Numbers.formatNumber(dna.volDnaInSolution, 2); |
3685 |
12 Jan 16 |
olle |
var waterInSolution = Numbers.formatNumber(dna.waterInSolution, 2); |
3685 |
12 Jan 16 |
olle |
if (dna.volDnaInSolution < MINIMAL_DNA_VOLUME) |
3685 |
12 Jan 16 |
olle |
104 |
{ |
3685 |
12 Jan 16 |
olle |
Doc.element('dilution.'+idSuffix).innerHTML = '<span class="lowvolume">' + volDnaInSolution + ' + ' + waterInSolution + 'µl</span>'; |
3685 |
12 Jan 16 |
olle |
106 |
} |
3685 |
12 Jan 16 |
olle |
else |
3685 |
12 Jan 16 |
olle |
108 |
{ |
3685 |
12 Jan 16 |
olle |
Doc.element('dilution.'+idSuffix).innerHTML = volDnaInSolution + ' + ' + waterInSolution + 'µl'; |
3685 |
12 Jan 16 |
olle |
110 |
} |
3685 |
12 Jan 16 |
olle |
111 |
} |
3685 |
12 Jan 16 |
olle |
112 |
|
3685 |
12 Jan 16 |
olle |
if (lib.remarks) |
3685 |
12 Jan 16 |
olle |
114 |
{ |
3685 |
12 Jan 16 |
olle |
Doc.element('remarks.'+idSuffix).innerHTML = lib.remarks.join('; '); |
3685 |
12 Jan 16 |
olle |
116 |
} |
3685 |
12 Jan 16 |
olle |
117 |
} |
3685 |
12 Jan 16 |
olle |
118 |
|
3685 |
12 Jan 16 |
olle |
protocol.fetchFpbAliquot = function(lib) |
3685 |
12 Jan 16 |
olle |
120 |
{ |
3685 |
12 Jan 16 |
olle |
// FPA aliquot |
3685 |
12 Jan 16 |
olle |
var well = lib.bioWell; |
3685 |
12 Jan 16 |
olle |
var fpaName = lib.name; |
3685 |
12 Jan 16 |
olle |
var fpaInfo = lib.info; |
3685 |
12 Jan 16 |
olle |
// FPB aliquot |
3685 |
12 Jan 16 |
olle |
var row = well.row; |
3685 |
12 Jan 16 |
olle |
var column = well.column; |
3685 |
12 Jan 16 |
olle |
if (column < 6) |
3685 |
12 Jan 16 |
olle |
129 |
{ |
3685 |
12 Jan 16 |
olle |
column += 6; |
3685 |
12 Jan 16 |
olle |
131 |
} |
3685 |
12 Jan 16 |
olle |
var wellFpb = {}; |
3685 |
12 Jan 16 |
olle |
wellFpb.row = row; |
3685 |
12 Jan 16 |
olle |
wellFpb.column = column; |
3685 |
12 Jan 16 |
olle |
var aliquotExtensionIndex = fpaName.indexOf('.fpa'); |
3685 |
12 Jan 16 |
olle |
var fpbName = fpaName.substring(0, aliquotExtensionIndex) + ".fpb"; |
3685 |
12 Jan 16 |
olle |
var libFpb = {}; |
3685 |
12 Jan 16 |
olle |
libFpb.bioWell = wellFpb; |
3685 |
12 Jan 16 |
olle |
libFpb.name = fpbName; |
3685 |
12 Jan 16 |
olle |
// Clone of FPA info is OK for library preparation plate protocol |
3685 |
12 Jan 16 |
olle |
libFpb.info = fpaInfo; |
3685 |
12 Jan 16 |
olle |
return libFpb; |
3685 |
12 Jan 16 |
olle |
143 |
} |
3685 |
12 Jan 16 |
olle |
144 |
|
3685 |
12 Jan 16 |
olle |
return protocol; |
3685 |
12 Jan 16 |
olle |
146 |
}(); |
3685 |
12 Jan 16 |
olle |
147 |
|
3685 |
12 Jan 16 |
olle |
Doc.onLoad(Protocol.initPage); |
3685 |
12 Jan 16 |
olle |
149 |
|
3685 |
12 Jan 16 |
olle |
150 |
|
3685 |
12 Jan 16 |
olle |
var WellPainter = function() |
3685 |
12 Jan 16 |
olle |
152 |
{ |
3685 |
12 Jan 16 |
olle |
var MINIMAL_DNA_VOLUME = 1.0; //µl |
3685 |
12 Jan 16 |
olle |
var painter = {}; |
3685 |
12 Jan 16 |
olle |
155 |
|
3685 |
12 Jan 16 |
olle |
painter.getClassNameForWell = function(well, schema) |
3685 |
12 Jan 16 |
olle |
157 |
{ |
3685 |
12 Jan 16 |
olle |
var cls = ''; |
3685 |
12 Jan 16 |
olle |
if (well.column < 6) |
3685 |
12 Jan 16 |
olle |
160 |
{ |
3685 |
12 Jan 16 |
olle |
cls = 'bg-green'; |
3685 |
12 Jan 16 |
olle |
162 |
} |
3685 |
12 Jan 16 |
olle |
else |
3685 |
12 Jan 16 |
olle |
164 |
{ |
3685 |
12 Jan 16 |
olle |
cls = 'bg-blue'; |
3685 |
12 Jan 16 |
olle |
166 |
} |
3685 |
12 Jan 16 |
olle |
return cls; |
3685 |
12 Jan 16 |
olle |
168 |
} |
3685 |
12 Jan 16 |
olle |
169 |
|
3685 |
12 Jan 16 |
olle |
painter.getWellText = function(well, schema) |
3685 |
12 Jan 16 |
olle |
171 |
{ |
3685 |
12 Jan 16 |
olle |
var text = ''; |
3685 |
12 Jan 16 |
olle |
var lib = well.extract; |
3685 |
12 Jan 16 |
olle |
if (lib) |
3685 |
12 Jan 16 |
olle |
175 |
{ |
3685 |
12 Jan 16 |
olle |
var name = lib.name; |
3685 |
12 Jan 16 |
olle |
var aliquotName = painter.fetchPlateViewAliquotName(name); |
3685 |
12 Jan 16 |
olle |
text += '<div class="lib">'+Strings.encodeTags(aliquotName)+'</div>'; |
3685 |
12 Jan 16 |
olle |
// DNA extract |
3685 |
12 Jan 16 |
olle |
var dna = lib.info; |
3685 |
12 Jan 16 |
olle |
if (dna) |
3685 |
12 Jan 16 |
olle |
182 |
{ |
3685 |
12 Jan 16 |
olle |
var volDnaInSolution = Numbers.formatNumber(dna.volDnaInSolution, 2); |
3685 |
12 Jan 16 |
olle |
var waterInSolution = Numbers.formatNumber(dna.waterInSolution, 2); |
3685 |
12 Jan 16 |
olle |
if (dna.volDnaInSolution < MINIMAL_DNA_VOLUME) |
3685 |
12 Jan 16 |
olle |
186 |
{ |
3685 |
12 Jan 16 |
olle |
text += '<div class="lib"><span class="lowvolume">'+volDnaInSolution+' + '+waterInSolution+'µl</span></div>'; |
3685 |
12 Jan 16 |
olle |
188 |
} |
3685 |
12 Jan 16 |
olle |
else |
3685 |
12 Jan 16 |
olle |
190 |
{ |
3685 |
12 Jan 16 |
olle |
text += '<div class="lib">'+volDnaInSolution+' + '+waterInSolution+'µl</div>'; |
3685 |
12 Jan 16 |
olle |
192 |
} |
3685 |
12 Jan 16 |
olle |
193 |
} |
3685 |
12 Jan 16 |
olle |
// Index 1 & 2 primers |
3685 |
12 Jan 16 |
olle |
var well = lib.bioWell; |
3685 |
12 Jan 16 |
olle |
var row = well.row + 1; |
3685 |
12 Jan 16 |
olle |
var column = well.column + 1; |
3685 |
12 Jan 16 |
olle |
var index2 = 'A50' + row; |
3685 |
12 Jan 16 |
olle |
var index1 = 'A70' + column; |
3685 |
12 Jan 16 |
olle |
if (column > 9) |
3685 |
12 Jan 16 |
olle |
201 |
{ |
3685 |
12 Jan 16 |
olle |
index1 = 'A7' + column; |
3685 |
12 Jan 16 |
olle |
203 |
} |
3685 |
12 Jan 16 |
olle |
text += '<div class="lib">'+index2+'</div>'; |
3685 |
12 Jan 16 |
olle |
text += '<div class="lib">'+index1+'</div>'; |
3685 |
12 Jan 16 |
olle |
206 |
} |
3685 |
12 Jan 16 |
olle |
return text; |
3685 |
12 Jan 16 |
olle |
208 |
} |
3685 |
12 Jan 16 |
olle |
209 |
|
3685 |
12 Jan 16 |
olle |
painter.fetchPlateViewAliquotName = function(name) |
3685 |
12 Jan 16 |
olle |
211 |
{ |
3685 |
12 Jan 16 |
olle |
// Concatenate parts before first dot and after last dot and convert to uppercase |
3685 |
12 Jan 16 |
olle |
var extIndex = name.indexOf('.fp'); |
3685 |
12 Jan 16 |
olle |
var origBaseName = name.substring(0, extIndex); |
3685 |
12 Jan 16 |
olle |
var origExtName = name.substring(extIndex); |
3685 |
12 Jan 16 |
olle |
var baseName = origBaseName.toUpperCase(); |
3685 |
12 Jan 16 |
olle |
var dotIndex = baseName.indexOf('.'); |
3685 |
12 Jan 16 |
olle |
baseName = baseName.substring(0, dotIndex); |
3685 |
12 Jan 16 |
olle |
var extName = 'FPA'; |
3685 |
12 Jan 16 |
olle |
if (origExtName == '.fpb') |
3685 |
12 Jan 16 |
olle |
221 |
{ |
3685 |
12 Jan 16 |
olle |
extName = 'FPB'; |
3685 |
12 Jan 16 |
olle |
223 |
} |
3685 |
12 Jan 16 |
olle |
var aliquotName = baseName + extName; |
3685 |
12 Jan 16 |
olle |
return aliquotName; |
3685 |
12 Jan 16 |
olle |
226 |
} |
3685 |
12 Jan 16 |
olle |
227 |
|
3685 |
12 Jan 16 |
olle |
return painter; |
3685 |
12 Jan 16 |
olle |
229 |
}(); |