3590 |
11 Nov 15 |
olle |
var LibPrepDilutionProtocol = function() |
3590 |
11 Nov 15 |
olle |
2 |
{ |
3590 |
11 Nov 15 |
olle |
var lpdp = {}; |
3590 |
11 Nov 15 |
olle |
var debug = 0; |
3590 |
11 Nov 15 |
olle |
5 |
|
3590 |
11 Nov 15 |
olle |
lpdp.TITLE = 'MeLuDI'; |
3684 |
08 Jan 16 |
olle |
var MINIMAL_DNA_VOLUME = 1.0; //µl |
3590 |
11 Nov 15 |
olle |
var COLORS = ['blue', 'green', 'yellow', 'red']; |
3590 |
11 Nov 15 |
olle |
var nextColor = 0; |
4129 |
26 Sep 16 |
olle |
var projectName; |
3590 |
11 Nov 15 |
olle |
var meludiVersion; |
3590 |
11 Nov 15 |
olle |
12 |
|
3590 |
11 Nov 15 |
olle |
// Page initialization |
3590 |
11 Nov 15 |
olle |
lpdp.initPage = function() |
3590 |
11 Nov 15 |
olle |
15 |
{ |
3590 |
11 Nov 15 |
olle |
Buttons.addClickHandler('print-button', Wizard.goPrint); |
3590 |
11 Nov 15 |
olle |
var numItems = Data.get('page-data', 'numitems'); |
3590 |
11 Nov 15 |
olle |
var submitInfoJsonStr = Data.get('page-data', 'submitinfo'); |
4129 |
26 Sep 16 |
olle |
projectName = Data.get('page-data', 'projectname'); |
3590 |
11 Nov 15 |
olle |
meludiVersion = Data.get('page-data', 'meludiversion'); |
3590 |
11 Nov 15 |
olle |
lpdp.initializeProtocol(submitInfoJsonStr); |
3590 |
11 Nov 15 |
olle |
22 |
} |
3590 |
11 Nov 15 |
olle |
23 |
|
3590 |
11 Nov 15 |
olle |
lpdp.initializeProtocol = function(submitInfoJsonStr) |
3590 |
11 Nov 15 |
olle |
25 |
{ |
3590 |
11 Nov 15 |
olle |
var frm = document.forms['meludi']; |
3590 |
11 Nov 15 |
olle |
27 |
|
3590 |
11 Nov 15 |
olle |
var submitInfo = JSON.parse(submitInfoJsonStr); |
3590 |
11 Nov 15 |
olle |
var docMode = submitInfo.docMode; |
3590 |
11 Nov 15 |
olle |
var itemInfo = submitInfo.items; |
3590 |
11 Nov 15 |
olle |
var startPlateName = submitInfo.startPlateName; |
3590 |
11 Nov 15 |
olle |
var dilutionProtocolDate = submitInfo.dilutionProtocolDate; |
3590 |
11 Nov 15 |
olle |
33 |
|
3590 |
11 Nov 15 |
olle |
//var protocolVersionNo = submitInfo.protocolVersionNo; |
3590 |
11 Nov 15 |
olle |
var protocolVersionNo = '1.0'; |
3590 |
11 Nov 15 |
olle |
var protocolPreviewFlag = submitInfo.protocolPreviewFlag; |
3590 |
11 Nov 15 |
olle |
var numQiacubeItems = itemInfo.length; |
3590 |
11 Nov 15 |
olle |
38 |
|
3590 |
11 Nov 15 |
olle |
// Header data |
3590 |
11 Nov 15 |
olle |
var docModeText = 'Protocol'; |
3652 |
08 Dec 15 |
olle |
if (docMode == null || docMode == '') |
3652 |
08 Dec 15 |
olle |
42 |
{ |
3652 |
08 Dec 15 |
olle |
docMode = 'protocol'; |
3652 |
08 Dec 15 |
olle |
44 |
} |
3590 |
11 Nov 15 |
olle |
if (docMode && docMode == 'report') |
3590 |
11 Nov 15 |
olle |
46 |
{ |
3590 |
11 Nov 15 |
olle |
docModeText = 'Report'; |
3590 |
11 Nov 15 |
olle |
48 |
} |
3590 |
11 Nov 15 |
olle |
if (protocolVersionNo == null || protocolVersionNo == '') |
3590 |
11 Nov 15 |
olle |
50 |
{ |
3590 |
11 Nov 15 |
olle |
protocolVersionNo = '?'; |
3590 |
11 Nov 15 |
olle |
52 |
} |
3590 |
11 Nov 15 |
olle |
var protocolPreviewText = ''; |
3590 |
11 Nov 15 |
olle |
if (protocolPreviewFlag != null && protocolPreviewFlag == 'true') |
3590 |
11 Nov 15 |
olle |
55 |
{ |
3590 |
11 Nov 15 |
olle |
protocolPreviewText = ' <i>(preview)</i>'; |
3590 |
11 Nov 15 |
olle |
57 |
} |
3590 |
11 Nov 15 |
olle |
var headerText = 'Dilution ' + docModeText + ' for library preparation v' + protocolVersionNo + protocolPreviewText + ' <span class="meludi">' + LibPrepDilutionProtocol.TITLE + ' ' + meludiVersion + '</span>'; |
3652 |
08 Dec 15 |
olle |
var protocolDateNameText = 'Dilution ' + docMode + ' date'; |
3590 |
11 Nov 15 |
olle |
Doc.element('libraryPreparationDilutionProtocolHeader').innerHTML = headerText; |
3652 |
08 Dec 15 |
olle |
Doc.element('protocolDateName').innerHTML = protocolDateNameText; |
3590 |
11 Nov 15 |
olle |
62 |
|
3590 |
11 Nov 15 |
olle |
Doc.element('startplateid').innerHTML = Strings.encodeTags(startPlateName); |
3590 |
11 Nov 15 |
olle |
Doc.element('dilutionProtocolDate').innerHTML = Strings.encodeTags(dilutionProtocolDate); |
4129 |
26 Sep 16 |
olle |
Doc.element('projectnameid').innerHTML = Strings.encodeTags(projectName); |
3590 |
11 Nov 15 |
olle |
66 |
|
3590 |
11 Nov 15 |
olle |
// Item data |
3590 |
11 Nov 15 |
olle |
var accumItemNo = 0; |
3590 |
11 Nov 15 |
olle |
accumItemNo = tableRowsForItems(accumItemNo, itemInfo, 'Item', 'item'); |
3590 |
11 Nov 15 |
olle |
70 |
|
3590 |
11 Nov 15 |
olle |
Doc.show('all-protocol'); |
3590 |
11 Nov 15 |
olle |
72 |
} |
3590 |
11 Nov 15 |
olle |
73 |
|
3590 |
11 Nov 15 |
olle |
function tableRowsForItems( |
3590 |
11 Nov 15 |
olle |
accumItemNo, |
3590 |
11 Nov 15 |
olle |
itemJsonArr, |
3590 |
11 Nov 15 |
olle |
itemType, |
3590 |
11 Nov 15 |
olle |
itemTypeVarName) |
3590 |
11 Nov 15 |
olle |
79 |
{ |
3590 |
11 Nov 15 |
olle |
// Table item row |
3590 |
11 Nov 15 |
olle |
var html = ''; |
3590 |
11 Nov 15 |
olle |
if (itemJsonArr && itemJsonArr.length > 0) |
3590 |
11 Nov 15 |
olle |
83 |
{ |
3590 |
11 Nov 15 |
olle |
for (var i = 0; i < itemJsonArr.length; i++) |
3590 |
11 Nov 15 |
olle |
85 |
{ |
3590 |
11 Nov 15 |
olle |
var item = itemJsonArr[i]; |
3590 |
11 Nov 15 |
olle |
var dnaStorageBox = '-'; |
3590 |
11 Nov 15 |
olle |
var fpaPos = '-'; |
3590 |
11 Nov 15 |
olle |
var fpbPos = '-'; |
3590 |
11 Nov 15 |
olle |
var dnaConc = null; |
3590 |
11 Nov 15 |
olle |
var dnaDeltaCt = null; |
3590 |
11 Nov 15 |
olle |
var dilutionFactor = null; |
3590 |
11 Nov 15 |
olle |
var volAliquotSolution = null; |
3590 |
11 Nov 15 |
olle |
var volDnaInSolution = null; |
3590 |
11 Nov 15 |
olle |
var waterInSolution = null; |
3590 |
11 Nov 15 |
olle |
var solutionVolume = null; |
3590 |
11 Nov 15 |
olle |
var dnaComment = null; |
3590 |
11 Nov 15 |
olle |
var comment = null; |
3590 |
11 Nov 15 |
olle |
if (item) |
3590 |
11 Nov 15 |
olle |
100 |
{ |
3590 |
11 Nov 15 |
olle |
// DNA extract from specimen |
3590 |
11 Nov 15 |
olle |
var dna = item.info; |
3590 |
11 Nov 15 |
olle |
if (dna) |
3590 |
11 Nov 15 |
olle |
104 |
{ |
3667 |
15 Dec 15 |
olle |
if (dna.origBioWell) |
3590 |
11 Nov 15 |
olle |
106 |
{ |
3667 |
15 Dec 15 |
olle |
dnaStorageBox = Strings.encodeTags(dna.origBioWell.bioPlate.name + '[' + dna.origBioWell.location + ']'); |
3590 |
11 Nov 15 |
olle |
108 |
} |
3590 |
11 Nov 15 |
olle |
fpaPos = item.fpaPos; |
3590 |
11 Nov 15 |
olle |
fpbPos = item.fpbPos; |
3667 |
15 Dec 15 |
olle |
dnaConc = dna.origQubitConc; |
3667 |
15 Dec 15 |
olle |
dnaDeltaCt = dna.origDeltaCt; |
3679 |
18 Dec 15 |
olle |
dnaComment = dna.origDescription; |
3590 |
11 Nov 15 |
olle |
dilutionFactor = dna.dilutionFactor; |
3590 |
11 Nov 15 |
olle |
//volAliquotSolution = dna.volAliquotSolution; |
3590 |
11 Nov 15 |
olle |
volDnaInSolution = 2 * dna.volDnaInSolution; |
3590 |
11 Nov 15 |
olle |
waterInSolution = 2 * dna.waterInSolution; |
3590 |
11 Nov 15 |
olle |
solutionVolume = 2 * dna.volAliquotSolution; |
3590 |
11 Nov 15 |
olle |
119 |
} |
3590 |
11 Nov 15 |
olle |
120 |
|
3590 |
11 Nov 15 |
olle |
// Input DNA item storage location should be displayed in the DNA extract storage location column |
3667 |
15 Dec 15 |
olle |
if (lpdp.isDna(item) && item.origBioWell != null) |
3590 |
11 Nov 15 |
olle |
123 |
{ |
3667 |
15 Dec 15 |
olle |
dnaStorageBox = Strings.encodeTags(item.origBioWell.bioPlate.name + '[' + item.origBioWell.location + ']'); |
3590 |
11 Nov 15 |
olle |
125 |
} |
3590 |
11 Nov 15 |
olle |
comment = item.comment; |
3590 |
11 Nov 15 |
olle |
127 |
} |
3590 |
11 Nov 15 |
olle |
if (item.operatorDeliveryComment) |
3590 |
11 Nov 15 |
olle |
129 |
{ |
3590 |
11 Nov 15 |
olle |
comment = item.operatorDeliveryComment; |
3590 |
11 Nov 15 |
olle |
131 |
} |
3590 |
11 Nov 15 |
olle |
if (dnaComment) |
3590 |
11 Nov 15 |
olle |
133 |
{ |
3590 |
11 Nov 15 |
olle |
if (comment) |
3590 |
11 Nov 15 |
olle |
135 |
{ |
3590 |
11 Nov 15 |
olle |
comment += ' '; |
3590 |
11 Nov 15 |
olle |
137 |
} |
3590 |
11 Nov 15 |
olle |
else |
3590 |
11 Nov 15 |
olle |
139 |
{ |
3590 |
11 Nov 15 |
olle |
comment = ''; |
3590 |
11 Nov 15 |
olle |
141 |
} |
3590 |
11 Nov 15 |
olle |
comment += 'DNA: ' + dnaComment; |
3590 |
11 Nov 15 |
olle |
143 |
} |
3590 |
11 Nov 15 |
olle |
var waterVolumeStr = '-'; |
3590 |
11 Nov 15 |
olle |
if (waterInSolution > 0) |
3590 |
11 Nov 15 |
olle |
146 |
{ |
3590 |
11 Nov 15 |
olle |
waterVolumeStr = lpdp.encodeFloatTags(Numbers.formatNumber(waterInSolution, 2)); |
3590 |
11 Nov 15 |
olle |
148 |
} |
3590 |
11 Nov 15 |
olle |
// Insert item data in table columns |
3667 |
15 Dec 15 |
olle |
//Doc.element('extract.'+accumItemNo).innerHTML = Strings.encodeTags(item.info.name); |
3667 |
15 Dec 15 |
olle |
Doc.element('extract.'+accumItemNo).innerHTML = Strings.encodeTags(item.info.origName); |
3590 |
11 Nov 15 |
olle |
Doc.element('dnaStorageBox.'+accumItemNo).innerHTML = Strings.encodeTags(dnaStorageBox); |
3590 |
11 Nov 15 |
olle |
Doc.element('fpaPos.'+accumItemNo).innerHTML = Strings.encodeTags(fpaPos); |
3590 |
11 Nov 15 |
olle |
Doc.element('fpbPos.'+accumItemNo).innerHTML = Strings.encodeTags(fpbPos); |
3684 |
08 Jan 16 |
olle |
if (dna.volDnaInSolution < MINIMAL_DNA_VOLUME) |
3684 |
08 Jan 16 |
olle |
156 |
{ |
3684 |
08 Jan 16 |
olle |
Doc.element('dnaVolume.'+accumItemNo).innerHTML = '<span class="lowvolume">' + lpdp.encodeFloatTags(Numbers.formatNumber(volDnaInSolution, 2)) + '</span>'; |
3684 |
08 Jan 16 |
olle |
Doc.element('waterVolume.'+accumItemNo).innerHTML = '<span class="lowvolume">' + Strings.encodeTags(waterVolumeStr) + '</span>'; |
3684 |
08 Jan 16 |
olle |
Doc.element('solutionVolume.'+accumItemNo).innerHTML = '<span class="lowvolume">' + lpdp.encodeFloatTags(Numbers.formatNumber(solutionVolume, 2)) + '</span>'; |
3684 |
08 Jan 16 |
olle |
160 |
} |
3684 |
08 Jan 16 |
olle |
else |
3684 |
08 Jan 16 |
olle |
162 |
{ |
3684 |
08 Jan 16 |
olle |
Doc.element('dnaVolume.'+accumItemNo).innerHTML = lpdp.encodeFloatTags(Numbers.formatNumber(volDnaInSolution, 2)); |
3684 |
08 Jan 16 |
olle |
Doc.element('waterVolume.'+accumItemNo).innerHTML = Strings.encodeTags(waterVolumeStr); |
3684 |
08 Jan 16 |
olle |
Doc.element('solutionVolume.'+accumItemNo).innerHTML = lpdp.encodeFloatTags(Numbers.formatNumber(solutionVolume, 2)); |
3684 |
08 Jan 16 |
olle |
166 |
} |
3590 |
11 Nov 15 |
olle |
Doc.element('dilutionFactor.'+accumItemNo).innerHTML = lpdp.encodeFloatTags(Numbers.formatNumber(dilutionFactor, 4)); |
3590 |
11 Nov 15 |
olle |
Doc.element('deltaCt.'+accumItemNo).innerHTML = lpdp.encodeFloatTags(Numbers.formatNumber(dnaDeltaCt, 2)); |
3590 |
11 Nov 15 |
olle |
Doc.element('dnaConc.'+accumItemNo).innerHTML = lpdp.encodeFloatTags(Numbers.formatNumber(dnaConc, 2)); |
3590 |
11 Nov 15 |
olle |
Doc.element('remark.'+accumItemNo).innerHTML = Strings.encodeTags(comment); |
3590 |
11 Nov 15 |
olle |
171 |
|
3590 |
11 Nov 15 |
olle |
// Increment accumulated item number |
3590 |
11 Nov 15 |
olle |
accumItemNo++; |
3590 |
11 Nov 15 |
olle |
174 |
} |
3590 |
11 Nov 15 |
olle |
175 |
} |
3590 |
11 Nov 15 |
olle |
return accumItemNo; |
3590 |
11 Nov 15 |
olle |
177 |
} |
3590 |
11 Nov 15 |
olle |
178 |
|
3590 |
11 Nov 15 |
olle |
lpdp.isDna = function(item) |
3590 |
11 Nov 15 |
olle |
180 |
{ |
3590 |
11 Nov 15 |
olle |
var isDna = false; |
3590 |
11 Nov 15 |
olle |
if (item != null) |
3590 |
11 Nov 15 |
olle |
183 |
{ |
3590 |
11 Nov 15 |
olle |
var name = item.name; |
3590 |
11 Nov 15 |
olle |
if (name != null) |
3590 |
11 Nov 15 |
olle |
186 |
{ |
3590 |
11 Nov 15 |
olle |
// Check if item name ends with ".d" |
3590 |
11 Nov 15 |
olle |
if (name.indexOf('.d') == (name.length - 2)) |
3590 |
11 Nov 15 |
olle |
189 |
{ |
3590 |
11 Nov 15 |
olle |
isDna = true; |
3590 |
11 Nov 15 |
olle |
191 |
} |
3590 |
11 Nov 15 |
olle |
192 |
} |
3590 |
11 Nov 15 |
olle |
193 |
} |
3590 |
11 Nov 15 |
olle |
return isDna; |
3590 |
11 Nov 15 |
olle |
195 |
} |
3590 |
11 Nov 15 |
olle |
196 |
|
3590 |
11 Nov 15 |
olle |
lpdp.encodeFloatTags = function(value) |
3590 |
11 Nov 15 |
olle |
198 |
{ |
3590 |
11 Nov 15 |
olle |
var encodedValue = value; |
3590 |
11 Nov 15 |
olle |
if (!value) |
3590 |
11 Nov 15 |
olle |
201 |
{ |
3590 |
11 Nov 15 |
olle |
encodedValue = Strings.encodeTags(value); |
3590 |
11 Nov 15 |
olle |
203 |
} |
3590 |
11 Nov 15 |
olle |
return encodedValue; |
3590 |
11 Nov 15 |
olle |
205 |
} |
3590 |
11 Nov 15 |
olle |
206 |
|
3590 |
11 Nov 15 |
olle |
// A biowell as plate name |
3590 |
11 Nov 15 |
olle |
lpdp.asBioPlateName = function(well) |
3590 |
11 Nov 15 |
olle |
209 |
{ |
3590 |
11 Nov 15 |
olle |
if (!well) return ''; |
3590 |
11 Nov 15 |
olle |
var plate = well.bioPlate; |
3590 |
11 Nov 15 |
olle |
if (!plate) return ''; |
3590 |
11 Nov 15 |
olle |
var text = plate.name; |
3590 |
11 Nov 15 |
olle |
return text; |
3590 |
11 Nov 15 |
olle |
215 |
} |
3590 |
11 Nov 15 |
olle |
216 |
|
3590 |
11 Nov 15 |
olle |
// A biowell as the location |
3590 |
11 Nov 15 |
olle |
lpdp.asPureBioPlateLocation = function(well) |
3590 |
11 Nov 15 |
olle |
219 |
{ |
3590 |
11 Nov 15 |
olle |
if (!well) return ''; |
3590 |
11 Nov 15 |
olle |
var plate = well.bioPlate; |
3590 |
11 Nov 15 |
olle |
var text = well.location; |
3590 |
11 Nov 15 |
olle |
if (plate.storage) |
3590 |
11 Nov 15 |
olle |
224 |
{ |
3590 |
11 Nov 15 |
olle |
var storage = plate.storage; |
3590 |
11 Nov 15 |
olle |
var tmp = []; |
3590 |
11 Nov 15 |
olle |
if (storage.name) tmp[tmp.length] = storage.name; |
3590 |
11 Nov 15 |
olle |
if (storage.section) tmp[tmp.length] = 'section: ' +storage.section; |
3590 |
11 Nov 15 |
olle |
if (storage.tray) tmp[tmp.length] = 'tray: ' +storage.tray; |
3590 |
11 Nov 15 |
olle |
if (storage.position) tmp[tmp.length] = 'position: ' +storage.position; |
3590 |
11 Nov 15 |
olle |
text = text + ' ' + tmp.join('; '); |
3590 |
11 Nov 15 |
olle |
232 |
} |
3590 |
11 Nov 15 |
olle |
return text; |
3590 |
11 Nov 15 |
olle |
234 |
} |
3590 |
11 Nov 15 |
olle |
235 |
|
3590 |
11 Nov 15 |
olle |
return lpdp; |
3590 |
11 Nov 15 |
olle |
237 |
}(); |
3590 |
11 Nov 15 |
olle |
238 |
|
3590 |
11 Nov 15 |
olle |
Doc.onLoad(LibPrepDilutionProtocol.initPage); |
3590 |
11 Nov 15 |
olle |
240 |
|