6822 |
29 Aug 22 |
nicklas |
var StringTie = function() |
6822 |
29 Aug 22 |
nicklas |
2 |
{ |
6822 |
29 Aug 22 |
nicklas |
var stringtie = {}; |
6822 |
29 Aug 22 |
nicklas |
var debug = 0; |
6822 |
29 Aug 22 |
nicklas |
5 |
|
6822 |
29 Aug 22 |
nicklas |
var JOB_IMAGE = { 'DONE': 'ok.png', 'ERROR': 'error.png'}; |
6822 |
29 Aug 22 |
nicklas |
var rawBioAssays; |
6822 |
29 Aug 22 |
nicklas |
8 |
|
6822 |
29 Aug 22 |
nicklas |
// Page initialization |
6822 |
29 Aug 22 |
nicklas |
stringtie.initPage = function() |
6822 |
29 Aug 22 |
nicklas |
11 |
{ |
6822 |
29 Aug 22 |
nicklas |
12 |
|
6822 |
29 Aug 22 |
nicklas |
// Step 1 |
6822 |
29 Aug 22 |
nicklas |
14 |
|
6822 |
29 Aug 22 |
nicklas |
// Navigation |
6822 |
29 Aug 22 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
6822 |
29 Aug 22 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
6822 |
29 Aug 22 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
6822 |
29 Aug 22 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
6822 |
29 Aug 22 |
nicklas |
20 |
|
6822 |
29 Aug 22 |
nicklas |
// Final registration |
6822 |
29 Aug 22 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', stringtie.submit); |
6822 |
29 Aug 22 |
nicklas |
23 |
|
6822 |
29 Aug 22 |
nicklas |
Wizard.showLoadingAnimation('Loading bioassays...'); |
6822 |
29 Aug 22 |
nicklas |
var url = '../StringTie2023.servlet?ID='+App.getSessionId(); |
6822 |
29 Aug 22 |
nicklas |
url += '&cmd=GetUnconfirmed'; |
6822 |
29 Aug 22 |
nicklas |
Wizard.asyncJsonRequest(url, stringtie.initializeStep1); |
6822 |
29 Aug 22 |
nicklas |
28 |
} |
6822 |
29 Aug 22 |
nicklas |
29 |
|
6822 |
29 Aug 22 |
nicklas |
// --- Step 1 ----------------------------------- |
6822 |
29 Aug 22 |
nicklas |
stringtie.initializeStep1 = function(response) |
6822 |
29 Aug 22 |
nicklas |
32 |
{ |
6822 |
29 Aug 22 |
nicklas |
rawBioAssays = response.rawBioAssays; |
6822 |
29 Aug 22 |
nicklas |
if (rawBioAssays.length == 0) |
6822 |
29 Aug 22 |
nicklas |
35 |
{ |
6822 |
29 Aug 22 |
nicklas |
Wizard.setFatalError('No raw bioassays available for processing.'); |
6822 |
29 Aug 22 |
nicklas |
return; |
6822 |
29 Aug 22 |
nicklas |
38 |
} |
6822 |
29 Aug 22 |
nicklas |
39 |
|
6822 |
29 Aug 22 |
nicklas |
var html = '<table id="rawBioAssaysTable">'; |
6822 |
29 Aug 22 |
nicklas |
html += '<thead class="bg-filled-100">'; |
6822 |
29 Aug 22 |
nicklas |
// Header row |
6822 |
29 Aug 22 |
nicklas |
html += '<tr>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th></th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th class="dottedleft"></th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th class="dottedleft" colspan="3">StringTie</th>' |
6822 |
29 Aug 22 |
nicklas |
html += '<th class="dottedleft" colspan="3">Actions</th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th class="dottedleft">Comment</th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '</tr>'; |
6822 |
29 Aug 22 |
nicklas |
50 |
|
6822 |
29 Aug 22 |
nicklas |
html += '<tr>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th>Library</th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th class="dottedleft">Plate</th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th class="dottedleft">Job</th>' |
6822 |
29 Aug 22 |
nicklas |
html += '<th>gene.tsv</th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th>Files</th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th class="dottedleft"><span id="flagrna" data-prefix="flag" class="interactable link" title="Toggle selection – use CTRL, ALT or SHIFT to clear">Flag RNA</span></th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th><span id="rerun" data-prefix="rerun" class="interactable link" title="Toggle selection – use CTRL, ALT or SHIFT to clear">Re-run</span></th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th><span id="ssp" data-prefix="confirm" class="interactable link" title="Toggle selection – use CTRL, ALT or SHIFT to clear">Confirm</span></th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<th class="dottedleft"></th>'; |
6822 |
29 Aug 22 |
nicklas |
html += '</tr>'; |
6822 |
29 Aug 22 |
nicklas |
html += '</thead>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<tbody>'; |
6822 |
29 Aug 22 |
nicklas |
var numWithError = 0; |
6822 |
29 Aug 22 |
nicklas |
var yellowImg = '<img src="../images/yellow-label.png">'; |
6822 |
29 Aug 22 |
nicklas |
for (var rawNo = 0; rawNo < rawBioAssays.length; rawNo++) |
6822 |
29 Aug 22 |
nicklas |
67 |
{ |
6822 |
29 Aug 22 |
nicklas |
var raw = rawBioAssays[rawNo]; |
6822 |
29 Aug 22 |
nicklas |
69 |
|
6822 |
29 Aug 22 |
nicklas |
var lib = raw.lib; |
6822 |
29 Aug 22 |
nicklas |
lib.stratagene = Reggie.isStratagene(lib.name); |
6822 |
29 Aug 22 |
nicklas |
lib.external = Reggie.isExternal(lib.name); |
6822 |
29 Aug 22 |
nicklas |
var isYellow = lib.specimen && lib.specimen.YellowLabel != null; |
6822 |
29 Aug 22 |
nicklas |
var img = isYellow ? yellowImg : ''; |
6822 |
29 Aug 22 |
nicklas |
var libPlate = lib.bioWell ? lib.bioWell.bioPlate : null; |
6822 |
29 Aug 22 |
nicklas |
76 |
|
6822 |
29 Aug 22 |
nicklas |
var stringTieJob = raw.stringTieJob; |
6822 |
29 Aug 22 |
nicklas |
var isError = !raw.geneTsvFile || !raw.spots; |
6822 |
29 Aug 22 |
nicklas |
var flagChecked = false; |
6822 |
29 Aug 22 |
nicklas |
80 |
|
6822 |
29 Aug 22 |
nicklas |
html += '<tr class="highlight ' + (rawNo % 4 < 2 ? 'evenrow' : 'oddrow') + (isYellow ? ' yellow-specimen' : '') + '">'; |
6822 |
29 Aug 22 |
nicklas |
html += '<td class="prompt if-yellow">'+img+Strings.encodeTags(raw.name)+'</td>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<td class="dottedleft">'+(libPlate ? Strings.encodeTags(libPlate.name) : '-') +'</td>'; |
6822 |
29 Aug 22 |
nicklas |
84 |
|
6822 |
29 Aug 22 |
nicklas |
html += '<td class="dottedleft">'; |
6822 |
29 Aug 22 |
nicklas |
if (stringTieJob) |
6822 |
29 Aug 22 |
nicklas |
87 |
{ |
6822 |
29 Aug 22 |
nicklas |
isError |= stringTieJob.status == 'ERROR'; |
6822 |
29 Aug 22 |
nicklas |
var image = JOB_IMAGE[stringTieJob.status]; |
6822 |
29 Aug 22 |
nicklas |
if (!isError && !raw.geneTsvFile) image = 'warning.png'; |
6822 |
29 Aug 22 |
nicklas |
html += '<span class="link item-link" data-item-type="JOB" data-item-id="'+stringTieJob.id+'" title="'+Strings.encodeTags(stringTieJob.statusMessage)+'"><img src="../images/'+image+'"></span>'; |
6822 |
29 Aug 22 |
nicklas |
92 |
} |
6822 |
29 Aug 22 |
nicklas |
html += '</td>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<td>'; |
6822 |
29 Aug 22 |
nicklas |
html += raw.geneTsvFile ? raw.spots : '-'; |
6822 |
29 Aug 22 |
nicklas |
html += '</td>'; |
6822 |
29 Aug 22 |
nicklas |
97 |
|
6822 |
29 Aug 22 |
nicklas |
if (raw.DataFilesFolder && stringTieJob && stringTieJob.server) |
6822 |
29 Aug 22 |
nicklas |
99 |
{ |
6822 |
29 Aug 22 |
nicklas |
html += '<td>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<span class="link file-link" data-server="'+Strings.encodeTags(stringTieJob.server)+'" data-folder="'+Strings.encodeTags(raw.DataFilesFolder)+'" data-item-id="'+raw.id+'" title="View generated files"><img src="../images/remote_folder.png"></span>'; |
6822 |
29 Aug 22 |
nicklas |
html += '</td>'; |
6822 |
29 Aug 22 |
nicklas |
103 |
} |
6822 |
29 Aug 22 |
nicklas |
else |
6822 |
29 Aug 22 |
nicklas |
105 |
{ |
6822 |
29 Aug 22 |
nicklas |
html += '<td>-</td>'; |
6822 |
29 Aug 22 |
nicklas |
107 |
} |
6822 |
29 Aug 22 |
nicklas |
// Do not allow flagging external or stratagene |
6822 |
29 Aug 22 |
nicklas |
var confirmChecked = !isError ? ' checked' : ''; |
6822 |
29 Aug 22 |
nicklas |
var reRunChecked = isError ? ' checked' : ''; |
6822 |
29 Aug 22 |
nicklas |
var confirmDisabled = isError ? ' disabled' : ''; |
6822 |
29 Aug 22 |
nicklas |
if (isError) numWithError++; |
6822 |
29 Aug 22 |
nicklas |
113 |
|
6822 |
29 Aug 22 |
nicklas |
if (lib.stratagene || lib.external) |
6822 |
29 Aug 22 |
nicklas |
115 |
{ |
6822 |
29 Aug 22 |
nicklas |
html += '<td class="dottedleft">-</td>'; |
6822 |
29 Aug 22 |
nicklas |
117 |
} |
6822 |
29 Aug 22 |
nicklas |
else |
6822 |
29 Aug 22 |
nicklas |
119 |
{ |
6822 |
29 Aug 22 |
nicklas |
html += '<td class="dottedleft"><input type="checkbox" name="flag.'+raw.id+'"'+(flagChecked ? ' checked':'')+'></td>'; |
6822 |
29 Aug 22 |
nicklas |
121 |
} |
6822 |
29 Aug 22 |
nicklas |
122 |
|
6822 |
29 Aug 22 |
nicklas |
html += '<td><input type="checkbox" name="rerun.'+raw.id+'"'+reRunChecked+'></td>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<td><input type="checkbox" name="confirm.'+raw.id+'"'+confirmChecked+confirmDisabled+'></td>'; |
6822 |
29 Aug 22 |
nicklas |
html += '<td class="dottedleft comment"><input type="text" name="comment.'+raw.id+'"></td>'; |
6822 |
29 Aug 22 |
nicklas |
html += '</tr>'; |
6822 |
29 Aug 22 |
nicklas |
127 |
|
6822 |
29 Aug 22 |
nicklas |
128 |
} |
6822 |
29 Aug 22 |
nicklas |
html += '</tbody>'; |
6822 |
29 Aug 22 |
nicklas |
html += '</table>'; |
6822 |
29 Aug 22 |
nicklas |
Doc.element('rawBioAssays').innerHTML = html; |
6822 |
29 Aug 22 |
nicklas |
132 |
|
6822 |
29 Aug 22 |
nicklas |
Events.addEventHandler('flagrna', 'click', stringtie.toggleSelection); |
6822 |
29 Aug 22 |
nicklas |
Events.addEventHandler('rerun', 'click', stringtie.toggleSelection); |
6822 |
29 Aug 22 |
nicklas |
Events.addEventHandler('confirm', 'click', stringtie.toggleSelection); |
6822 |
29 Aug 22 |
nicklas |
136 |
|
6822 |
29 Aug 22 |
nicklas |
// Add click handler to items |
6822 |
29 Aug 22 |
nicklas |
var clickableItems = document.getElementsByClassName('item-link'); |
6822 |
29 Aug 22 |
nicklas |
for (var i = 0; i < clickableItems.length; i++) |
6822 |
29 Aug 22 |
nicklas |
140 |
{ |
6822 |
29 Aug 22 |
nicklas |
Events.addEventHandler(clickableItems[i], 'click', Items.itemOnClick); |
6822 |
29 Aug 22 |
nicklas |
142 |
} |
6822 |
29 Aug 22 |
nicklas |
143 |
|
6822 |
29 Aug 22 |
nicklas |
// Add click handler to file links |
6822 |
29 Aug 22 |
nicklas |
var clickableItems = document.getElementsByClassName('file-link'); |
6822 |
29 Aug 22 |
nicklas |
for (var i = 0; i < clickableItems.length; i++) |
6822 |
29 Aug 22 |
nicklas |
147 |
{ |
6822 |
29 Aug 22 |
nicklas |
Events.addEventHandler(clickableItems[i], 'click', stringtie.fileLinkOnClick); |
6822 |
29 Aug 22 |
nicklas |
149 |
} |
6822 |
29 Aug 22 |
nicklas |
150 |
|
6822 |
29 Aug 22 |
nicklas |
Doc.show('step-1'); |
6822 |
29 Aug 22 |
nicklas |
Doc.show('goregister'); |
6822 |
29 Aug 22 |
nicklas |
153 |
} |
6822 |
29 Aug 22 |
nicklas |
154 |
|
6822 |
29 Aug 22 |
nicklas |
stringtie.fileLinkOnClick = function(event) |
6822 |
29 Aug 22 |
nicklas |
156 |
{ |
6822 |
29 Aug 22 |
nicklas |
var folder = Data.get(event.currentTarget, 'folder'); |
6822 |
29 Aug 22 |
nicklas |
var server = Data.get(event.currentTarget, 'server'); |
6822 |
29 Aug 22 |
nicklas |
var itemId = Data.get(event.currentTarget, 'item-id'); |
6822 |
29 Aug 22 |
nicklas |
server = server.replace(/\s*\[.*\]/, ''); |
6822 |
29 Aug 22 |
nicklas |
var url = 'view_remote_files.jsp?ID=' + App.getSessionId(); |
6822 |
29 Aug 22 |
nicklas |
url += '&clusterId='+server; |
6822 |
29 Aug 22 |
nicklas |
url += '&path='+encodeURIComponent(folder); |
6822 |
29 Aug 22 |
nicklas |
url += '&itemType=RAWBIOASSAY&itemId='+itemId; |
6822 |
29 Aug 22 |
nicklas |
Dialogs.openPopup(url, 'ViewProjectFiles', 750, 500); |
6822 |
29 Aug 22 |
nicklas |
166 |
} |
6822 |
29 Aug 22 |
nicklas |
167 |
|
6822 |
29 Aug 22 |
nicklas |
stringtie.toggleSelection = function(event) |
6822 |
29 Aug 22 |
nicklas |
169 |
{ |
6822 |
29 Aug 22 |
nicklas |
var prefix = Data.get(event.currentTarget, 'prefix'); |
6822 |
29 Aug 22 |
nicklas |
var specialKey = event.altKey || event.ctrlKey || event.shiftKey; |
6822 |
29 Aug 22 |
nicklas |
172 |
|
6822 |
29 Aug 22 |
nicklas |
var frm = document.forms['reggie']; |
6822 |
29 Aug 22 |
nicklas |
for (var rawNo = 0; rawNo < rawBioAssays.length; rawNo++) |
6822 |
29 Aug 22 |
nicklas |
175 |
{ |
6822 |
29 Aug 22 |
nicklas |
var raw = rawBioAssays[rawNo]; |
6822 |
29 Aug 22 |
nicklas |
var chk = frm[prefix+'.'+raw.id]; |
6822 |
29 Aug 22 |
nicklas |
if (chk && !chk.disabled) |
6822 |
29 Aug 22 |
nicklas |
179 |
{ |
6822 |
29 Aug 22 |
nicklas |
chk.checked = specialKey ? false : !chk.checked; |
6822 |
29 Aug 22 |
nicklas |
181 |
} |
6822 |
29 Aug 22 |
nicklas |
182 |
} |
6822 |
29 Aug 22 |
nicklas |
183 |
} |
6822 |
29 Aug 22 |
nicklas |
184 |
|
6822 |
29 Aug 22 |
nicklas |
stringtie.submit = function() |
6822 |
29 Aug 22 |
nicklas |
186 |
{ |
6822 |
29 Aug 22 |
nicklas |
var frm = document.forms['reggie']; |
6822 |
29 Aug 22 |
nicklas |
var submitInfo = {}; |
6822 |
29 Aug 22 |
nicklas |
submitInfo.deleteItemsCreatedByFailedJobs = frm.deleteItemsCreatedByFailedJobs.checked; |
6822 |
29 Aug 22 |
nicklas |
190 |
|
6822 |
29 Aug 22 |
nicklas |
var all = []; |
6822 |
29 Aug 22 |
nicklas |
submitInfo.rawBioAssays = all; |
6822 |
29 Aug 22 |
nicklas |
for (var rawNo = 0; rawNo < rawBioAssays.length; rawNo++) |
6822 |
29 Aug 22 |
nicklas |
194 |
{ |
6822 |
29 Aug 22 |
nicklas |
var raw = rawBioAssays[rawNo]; |
6822 |
29 Aug 22 |
nicklas |
var tmp = {}; |
6822 |
29 Aug 22 |
nicklas |
tmp.id = raw.id; |
6822 |
29 Aug 22 |
nicklas |
198 |
|
6822 |
29 Aug 22 |
nicklas |
tmp.flag = frm['flag.'+raw.id] && frm['flag.'+raw.id].checked; |
6822 |
29 Aug 22 |
nicklas |
tmp.rerun = frm['rerun.'+raw.id].checked; |
6822 |
29 Aug 22 |
nicklas |
tmp.confirm = frm['confirm.'+raw.id].checked; |
6822 |
29 Aug 22 |
nicklas |
tmp.comment = frm['comment.'+raw.id].value; |
6822 |
29 Aug 22 |
nicklas |
203 |
|
6822 |
29 Aug 22 |
nicklas |
all[all.length] = tmp; |
6822 |
29 Aug 22 |
nicklas |
205 |
} |
6822 |
29 Aug 22 |
nicklas |
206 |
|
6822 |
29 Aug 22 |
nicklas |
var url = '../StringTie2023.servlet?ID='+App.getSessionId(); |
6822 |
29 Aug 22 |
nicklas |
url += '&cmd=RegisterStringTie2023'; |
6822 |
29 Aug 22 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
6822 |
29 Aug 22 |
nicklas |
Wizard.asyncJsonRequest(url, stringtie.submissionResults, 'POST', JSON.stringify(submitInfo)); |
6822 |
29 Aug 22 |
nicklas |
211 |
} |
6822 |
29 Aug 22 |
nicklas |
212 |
|
6822 |
29 Aug 22 |
nicklas |
stringtie.submissionResults = function(response) |
6822 |
29 Aug 22 |
nicklas |
214 |
{ |
6822 |
29 Aug 22 |
nicklas |
Wizard.showFinalMessage(response.messages); |
6822 |
29 Aug 22 |
nicklas |
Doc.show('gorestart'); |
6822 |
29 Aug 22 |
nicklas |
217 |
} |
6822 |
29 Aug 22 |
nicklas |
218 |
|
6822 |
29 Aug 22 |
nicklas |
219 |
|
6822 |
29 Aug 22 |
nicklas |
return stringtie; |
6822 |
29 Aug 22 |
nicklas |
221 |
}(); |
6822 |
29 Aug 22 |
nicklas |
222 |
|
6822 |
29 Aug 22 |
nicklas |
Doc.onLoad(StringTie.initPage); |
6822 |
29 Aug 22 |
nicklas |
224 |
|