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