5845 |
26 Feb 20 |
nicklas |
var Align = function() |
5845 |
26 Feb 20 |
nicklas |
2 |
{ |
5845 |
26 Feb 20 |
nicklas |
var align = {}; |
5845 |
26 Feb 20 |
nicklas |
var debug = 0; |
5845 |
26 Feb 20 |
nicklas |
5 |
|
5845 |
26 Feb 20 |
nicklas |
var JOB_IMAGE = { 'DONE': 'ok.png', 'ERROR': 'error.png'}; |
5845 |
26 Feb 20 |
nicklas |
7 |
|
5845 |
26 Feb 20 |
nicklas |
var alignedSequences; |
5845 |
26 Feb 20 |
nicklas |
9 |
|
5845 |
26 Feb 20 |
nicklas |
// Page initialization |
5845 |
26 Feb 20 |
nicklas |
align.initPage = function() |
5845 |
26 Feb 20 |
nicklas |
12 |
{ |
5845 |
26 Feb 20 |
nicklas |
13 |
|
5845 |
26 Feb 20 |
nicklas |
// Step 1 |
5845 |
26 Feb 20 |
nicklas |
15 |
|
5845 |
26 Feb 20 |
nicklas |
// Navigation |
5845 |
26 Feb 20 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
5845 |
26 Feb 20 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
5845 |
26 Feb 20 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
5845 |
26 Feb 20 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
5845 |
26 Feb 20 |
nicklas |
21 |
|
5845 |
26 Feb 20 |
nicklas |
// Final registration |
5845 |
26 Feb 20 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', align.submit); |
5845 |
26 Feb 20 |
nicklas |
24 |
|
5845 |
26 Feb 20 |
nicklas |
Wizard.showLoadingAnimation('Loading bioassays...'); |
5845 |
26 Feb 20 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5845 |
26 Feb 20 |
nicklas |
url += '&cmd=GetUnconfirmedAlignedSequences'; |
5845 |
26 Feb 20 |
nicklas |
Wizard.asyncJsonRequest(url, align.initializeStep1); |
5845 |
26 Feb 20 |
nicklas |
29 |
} |
5845 |
26 Feb 20 |
nicklas |
30 |
|
5845 |
26 Feb 20 |
nicklas |
// --- Step 1 ----------------------------------- |
5845 |
26 Feb 20 |
nicklas |
align.initializeStep1 = function(response) |
5845 |
26 Feb 20 |
nicklas |
33 |
{ |
5845 |
26 Feb 20 |
nicklas |
alignedSequences = response.alignedSequences; |
5845 |
26 Feb 20 |
nicklas |
if (alignedSequences.length == 0) |
5845 |
26 Feb 20 |
nicklas |
36 |
{ |
5845 |
26 Feb 20 |
nicklas |
Wizard.setFatalError('No aligned sequences available for processing.'); |
5845 |
26 Feb 20 |
nicklas |
return; |
5845 |
26 Feb 20 |
nicklas |
39 |
} |
5845 |
26 Feb 20 |
nicklas |
40 |
|
5845 |
26 Feb 20 |
nicklas |
var html = '<table id="alignedSequencesTable">'; |
5845 |
26 Feb 20 |
nicklas |
html += '<thead class="bg-filled-100">'; |
5845 |
26 Feb 20 |
nicklas |
// Header row |
5845 |
26 Feb 20 |
nicklas |
html += '<tr>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th></th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft"></th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th></th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th></th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft" colspan="4">Reads</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft"></th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft"></th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft" colspan="3">Actions</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft">Comment</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '</tr>'; |
5845 |
26 Feb 20 |
nicklas |
55 |
|
5845 |
26 Feb 20 |
nicklas |
html += '<tr>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th>Plate</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft">Library</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th>MIPS_Panel</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th>Barcode</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft">PF_READS</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th>ALIGNED_PAIRS</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="icon-col"></th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th>Duplicates</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft">Job</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft">Files</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft">Flag RNA</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th>Re-align</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th>TODO</th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<th class="dottedleft"></th>'; |
5845 |
26 Feb 20 |
nicklas |
html += '</tr>'; |
5845 |
26 Feb 20 |
nicklas |
html += '</thead>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<tbody>'; |
5845 |
26 Feb 20 |
nicklas |
var numWithError = 0; |
5845 |
26 Feb 20 |
nicklas |
for (var alignedNo = 0; alignedNo < alignedSequences.length; alignedNo++) |
5845 |
26 Feb 20 |
nicklas |
76 |
{ |
5845 |
26 Feb 20 |
nicklas |
var aligned = alignedSequences[alignedNo]; |
5845 |
26 Feb 20 |
nicklas |
78 |
|
5845 |
26 Feb 20 |
nicklas |
var lib = aligned.lib; |
5845 |
26 Feb 20 |
nicklas |
lib.stratagene = Reggie.isStratagene(lib.name); |
5845 |
26 Feb 20 |
nicklas |
lib.external = Reggie.isExternal(lib.name); |
5845 |
26 Feb 20 |
nicklas |
var libPlate = lib.bioWell ? lib.bioWell.bioPlate : null; |
5845 |
26 Feb 20 |
nicklas |
83 |
|
5845 |
26 Feb 20 |
nicklas |
var merged = aligned.merged; |
5845 |
26 Feb 20 |
nicklas |
85 |
|
6716 |
29 Apr 22 |
nicklas |
var pfReads = Reggie.formatCount(merged.PF_READS, '-'); |
6716 |
29 Apr 22 |
nicklas |
var alignedReads = Reggie.formatCount(aligned.ALIGNED_PAIRS, '-'); |
5845 |
26 Feb 20 |
nicklas |
var alignedPercent = aligned.ALIGNED_PAIRS && merged.PF_READS ? ' (' + Math.round(100*aligned.ALIGNED_PAIRS/merged.PF_READS) + '%)' : ''; |
5845 |
26 Feb 20 |
nicklas |
var percentDuplicates = aligned.FRACTION_DUPLICATION == null ? '-' : Math.round(100*aligned.FRACTION_DUPLICATION)+'%'; |
5845 |
26 Feb 20 |
nicklas |
var job = aligned.job; |
5845 |
26 Feb 20 |
nicklas |
91 |
|
5845 |
26 Feb 20 |
nicklas |
var flag = null; |
5845 |
26 Feb 20 |
nicklas |
var isError = job.status == 'ERROR'; |
5845 |
26 Feb 20 |
nicklas |
94 |
|
5845 |
26 Feb 20 |
nicklas |
html += '<tr class="highlight ' + (alignedNo % 4 < 2 ? 'evenrow' : 'oddrow') + '">'; |
5845 |
26 Feb 20 |
nicklas |
html += '<td>'+(libPlate ? Strings.encodeTags(libPlate.name+' '+lib.bioWell.location) : '-')+'</td>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<td class="dottedleft">'+Strings.encodeTags(aligned.name)+'</td>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<td>'+Strings.encodeTags(lib.MIPSPanel)+'</td>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<td>'+Strings.encodeTags(lib.barcode.name)+'</td>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<td class="dottedleft">'+pfReads+'</td>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<td>'+alignedReads+alignedPercent+'</td>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<td class="icon-col">'; |
5845 |
26 Feb 20 |
nicklas |
html += '</td>'; |
5845 |
26 Feb 20 |
nicklas |
104 |
|
5845 |
26 Feb 20 |
nicklas |
html += '<td>'+percentDuplicates+'</td>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<td class="dottedleft">'; |
5845 |
26 Feb 20 |
nicklas |
html += '<span class="link item-link" data-item-type="JOB" data-item-id="'+job.id+'" title="'+Strings.encodeTags(job.statusMessage)+'"><img src="../images/'+JOB_IMAGE[job.status]+'"></span>'; |
5845 |
26 Feb 20 |
nicklas |
html += '</td>'; |
5845 |
26 Feb 20 |
nicklas |
if (aligned.DataFilesFolder && job.server) |
5845 |
26 Feb 20 |
nicklas |
110 |
{ |
5845 |
26 Feb 20 |
nicklas |
html += '<td class="dottedleft">'; |
5845 |
26 Feb 20 |
nicklas |
html += '<span class="link file-link" data-server="'+Strings.encodeTags(job.server)+'" data-folder="'+Strings.encodeTags(aligned.DataFilesFolder)+'" data-item-id="'+aligned.id+'" title="View generated files"><img src="../images/remote_folder.png"></span>'; |
5845 |
26 Feb 20 |
nicklas |
html += '</td>'; |
5845 |
26 Feb 20 |
nicklas |
114 |
} |
5845 |
26 Feb 20 |
nicklas |
else |
5845 |
26 Feb 20 |
nicklas |
116 |
{ |
5845 |
26 Feb 20 |
nicklas |
html += '<td class="dottedleft">-</td>'; |
5845 |
26 Feb 20 |
nicklas |
118 |
} |
5845 |
26 Feb 20 |
nicklas |
119 |
|
5845 |
26 Feb 20 |
nicklas |
var realignChecked = isError ? ' checked' : ''; |
5845 |
26 Feb 20 |
nicklas |
if (isError) numWithError++; |
5845 |
26 Feb 20 |
nicklas |
if (lib.stratagene || lib.external) |
5845 |
26 Feb 20 |
nicklas |
123 |
{ |
5845 |
26 Feb 20 |
nicklas |
html += '<td class="dottedleft">-</td>'; |
5845 |
26 Feb 20 |
nicklas |
125 |
} |
5845 |
26 Feb 20 |
nicklas |
else |
5845 |
26 Feb 20 |
nicklas |
127 |
{ |
5845 |
26 Feb 20 |
nicklas |
html += '<td class="dottedleft"><input type="checkbox" name="flag.'+aligned.id+'"'+(flag != null ? ' checked value="'+flag+'"':'')+'></td>'; |
5845 |
26 Feb 20 |
nicklas |
129 |
} |
5845 |
26 Feb 20 |
nicklas |
130 |
|
5845 |
26 Feb 20 |
nicklas |
html += '<td><input type="checkbox" name="realign.'+aligned.id+'"'+realignChecked+'></td>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<td><input type="checkbox" name="nextStepTODO.'+aligned.id+'"></td>'; |
5845 |
26 Feb 20 |
nicklas |
html += '<td class="dottedleft comment"><input type="text" name="comment.'+aligned.id+'"></td>'; |
5845 |
26 Feb 20 |
nicklas |
html += '</tr>'; |
5845 |
26 Feb 20 |
nicklas |
135 |
|
5845 |
26 Feb 20 |
nicklas |
136 |
} |
5845 |
26 Feb 20 |
nicklas |
html += '</tbody>'; |
5845 |
26 Feb 20 |
nicklas |
html += '</table>'; |
5845 |
26 Feb 20 |
nicklas |
Doc.element('alignedSequences').innerHTML = html; |
5845 |
26 Feb 20 |
nicklas |
if (numWithError > 0) Doc.show('delete-items', 'table'); |
5845 |
26 Feb 20 |
nicklas |
141 |
|
5845 |
26 Feb 20 |
nicklas |
// Add click handler to items |
5845 |
26 Feb 20 |
nicklas |
var clickableItems = document.getElementsByClassName('item-link'); |
5845 |
26 Feb 20 |
nicklas |
for (var i = 0; i < clickableItems.length; i++) |
5845 |
26 Feb 20 |
nicklas |
145 |
{ |
5845 |
26 Feb 20 |
nicklas |
Events.addEventHandler(clickableItems[i], 'click', Items.itemOnClick); |
5845 |
26 Feb 20 |
nicklas |
147 |
} |
5845 |
26 Feb 20 |
nicklas |
148 |
|
5845 |
26 Feb 20 |
nicklas |
// Add click handler to file links |
5845 |
26 Feb 20 |
nicklas |
var clickableItems = document.getElementsByClassName('file-link'); |
5845 |
26 Feb 20 |
nicklas |
for (var i = 0; i < clickableItems.length; i++) |
5845 |
26 Feb 20 |
nicklas |
152 |
{ |
5845 |
26 Feb 20 |
nicklas |
Events.addEventHandler(clickableItems[i], 'click', align.fileLinkOnClick); |
5845 |
26 Feb 20 |
nicklas |
154 |
} |
5845 |
26 Feb 20 |
nicklas |
155 |
|
5845 |
26 Feb 20 |
nicklas |
Doc.show('step-1'); |
5845 |
26 Feb 20 |
nicklas |
Doc.show('goregister'); |
5845 |
26 Feb 20 |
nicklas |
158 |
} |
5845 |
26 Feb 20 |
nicklas |
159 |
|
5845 |
26 Feb 20 |
nicklas |
align.fileLinkOnClick = function(event) |
5845 |
26 Feb 20 |
nicklas |
161 |
{ |
5845 |
26 Feb 20 |
nicklas |
var folder = Data.get(event.currentTarget, 'folder'); |
5845 |
26 Feb 20 |
nicklas |
var server = Data.get(event.currentTarget, 'server'); |
5845 |
26 Feb 20 |
nicklas |
var itemId = Data.get(event.currentTarget, 'item-id'); |
5845 |
26 Feb 20 |
nicklas |
server = server.replace(/\s*\[.*\]/, ''); |
5845 |
26 Feb 20 |
nicklas |
var url = '../analysis/view_remote_files.jsp?ID=' + App.getSessionId(); |
5845 |
26 Feb 20 |
nicklas |
url += '&clusterId='+server; |
5845 |
26 Feb 20 |
nicklas |
url += '&path='+encodeURIComponent(folder); |
5845 |
26 Feb 20 |
nicklas |
url += '&itemType=DERIVEDBIOASSAY&itemId='+itemId; |
5845 |
26 Feb 20 |
nicklas |
Dialogs.openPopup(url, 'ViewProjectFiles', 750, 500); |
5845 |
26 Feb 20 |
nicklas |
171 |
} |
5845 |
26 Feb 20 |
nicklas |
172 |
|
5845 |
26 Feb 20 |
nicklas |
align.submit = function() |
5845 |
26 Feb 20 |
nicklas |
174 |
{ |
5845 |
26 Feb 20 |
nicklas |
var frm = document.forms['reggie']; |
5845 |
26 Feb 20 |
nicklas |
var submitInfo = {}; |
5845 |
26 Feb 20 |
nicklas |
submitInfo.deleteItemsCreatedByFailedJobs = frm.deleteItemsCreatedByFailedJobs.checked; |
5845 |
26 Feb 20 |
nicklas |
178 |
|
5845 |
26 Feb 20 |
nicklas |
var all = []; |
5845 |
26 Feb 20 |
nicklas |
submitInfo.alignedSequences = all; |
5845 |
26 Feb 20 |
nicklas |
for (var alignedNo = 0; alignedNo < alignedSequences.length; alignedNo++) |
5845 |
26 Feb 20 |
nicklas |
182 |
{ |
5845 |
26 Feb 20 |
nicklas |
var aligned = alignedSequences[alignedNo]; |
5845 |
26 Feb 20 |
nicklas |
var tmp = {}; |
5845 |
26 Feb 20 |
nicklas |
tmp.id = aligned.id; |
5845 |
26 Feb 20 |
nicklas |
186 |
|
5845 |
26 Feb 20 |
nicklas |
tmp.flag = frm['flag.'+aligned.id] && frm['flag.'+aligned.id].checked ? frm['flag.'+aligned.id].value : null; |
5845 |
26 Feb 20 |
nicklas |
tmp.realign = frm['realign.'+aligned.id].checked; |
5845 |
26 Feb 20 |
nicklas |
tmp.nextStepTODO = frm['nextStepTODO.'+aligned.id].checked; |
5845 |
26 Feb 20 |
nicklas |
tmp.comment = frm['comment.'+aligned.id].value; |
5845 |
26 Feb 20 |
nicklas |
191 |
|
5845 |
26 Feb 20 |
nicklas |
all[all.length] = tmp; |
5845 |
26 Feb 20 |
nicklas |
193 |
} |
5845 |
26 Feb 20 |
nicklas |
194 |
|
5845 |
26 Feb 20 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5845 |
26 Feb 20 |
nicklas |
url += '&cmd=RegisterAlignment'; |
5845 |
26 Feb 20 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
5845 |
26 Feb 20 |
nicklas |
Wizard.asyncJsonRequest(url, align.submissionResults, 'POST', JSON.stringify(submitInfo)); |
5845 |
26 Feb 20 |
nicklas |
199 |
} |
5845 |
26 Feb 20 |
nicklas |
200 |
|
5845 |
26 Feb 20 |
nicklas |
align.submissionResults = function(response) |
5845 |
26 Feb 20 |
nicklas |
202 |
{ |
5845 |
26 Feb 20 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5845 |
26 Feb 20 |
nicklas |
Doc.show('gorestart'); |
5845 |
26 Feb 20 |
nicklas |
205 |
} |
5845 |
26 Feb 20 |
nicklas |
206 |
|
5845 |
26 Feb 20 |
nicklas |
207 |
|
5845 |
26 Feb 20 |
nicklas |
return align; |
5845 |
26 Feb 20 |
nicklas |
209 |
}(); |
5845 |
26 Feb 20 |
nicklas |
210 |
|
5845 |
26 Feb 20 |
nicklas |
Doc.onLoad(Align.initPage); |
5845 |
26 Feb 20 |
nicklas |
212 |
|