source: extensions/net.sf.basedb.reggie/trunk/resources/analysis/align_confirm.jsp @ 2593

Last change on this file since 2593 was 2593, checked in by Nicklas Nordborg, 8 years ago

Resetting debug flags.

File size: 11.9 KB
Line 
1<%@ page
2  pageEncoding="UTF-8"
3  session="false"
4  import="net.sf.basedb.core.User"
5  import="net.sf.basedb.core.DbControl"
6  import="net.sf.basedb.core.SessionControl"
7  import="net.sf.basedb.core.Application"
8  import="net.sf.basedb.clients.web.Base" 
9  import="net.sf.basedb.clients.web.util.HTML" 
10  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
11%>
12<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
13<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
14<%
15final SessionControl sc = Base.getExistingSessionControl(request, true);
16final String ID = sc.getId();
17final float scale = Base.getScale(sc);
18final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie");
19DbControl dc = null;
20try
21{
22  dc = sc.newDbControl();
23  final User user = User.getById(dc, sc.getLoggedInUserId());
24%>
25<base:page type="default" >
26<base:head scripts="ajax.js" styles="path.css">
27  <link rel="stylesheet" type="text/css" href="../css/reggie.css">
28  <script language="JavaScript" src="../reggie.js" type="text/javascript" charset="UTF-8"></script>
29
30<script language="JavaScript">
31
32var debug = 0;
33var currentStep = 1;
34var alignedSequences;
35
36function init()
37{
38  var frm = document.forms['reggie'];
39  alignedSequences = getAlignedSequences();
40
41  // Load existing aligned sequences
42  if (alignedSequences != null && alignedSequences.length > 0)
43  {
44    gotoStep1();
45  }
46  else
47  {
48    var msg = 'No aligned sequences available for processing.';
49    setFatalError(msg);
50    return;
51  }
52
53}
54
55
56function goNextAuto()
57{
58  goNext(false);
59}
60
61function goNext(manual)
62{
63  setInnerHTML('gonext.message', '');
64  if (currentStep == 1)
65  {
66    if (step1IsValid()) gotoStep2();
67  }
68  setCurrentStep(currentStep);
69}
70
71function step1IsValid()
72{
73  return true;
74}
75
76
77
78function getAlignedSequences()
79{
80  var frm = document.forms['reggie'];
81 
82  var request = Ajax.getXmlHttpRequest();
83  try
84  {
85    showLoadingAnimation('Loading aligned sequences...');
86    var url = '../MaskAlign.servlet?ID=<%=ID%>&cmd=GetUnconfirmedAlignedSequences';   
87    request.open("GET", url, false); 
88    request.send(null);
89  }
90  finally
91  {
92    hideLoadingAnimation();
93  }
94 
95  if (debug) Main.debug(request.responseText);
96  var response = JSON.parse(request.responseText); 
97  if (response.status != 'ok')
98  {
99    setFatalError(response.message);
100    return false;
101  }
102  return response.alignedSequences;
103}
104
105
106function formatDate(value)
107{
108  if (!value) return '';
109  if (value.length == 8)
110  {
111    // YYYYMMDD
112    value = value.substr(0, 4) + '-' + value.substr(4, 2) + '-' + value.substr(6, 2);
113  }
114  else if (value.length == 13)
115  {
116    // YYYYMMDD HHMM
117    value = value.substr(0, 4) + '-' + value.substr(4, 2) + '-' + value.substr(6, 2) + ' ' + value.substr(9, 2) + ':' + value.substr(11, 2);
118  }
119  return value;
120}
121
122
123function gotoStep1()
124{
125  var frm = document.forms['reggie'];
126 
127  Main.show('gocancel');
128  Main.show('goregister');
129  Main.hide('gonext');
130   
131  var html = '<table id="alignedSequencesTable">';
132  html += '<thead style="background-color: #E8E8E8; border-bottom: 1px solid #A0A0A0;">';
133  // Header row
134  html += '<tr>';
135  html += '<th>Library</th>';
136  html += '<th class="dottedleft">Plate</th>';
137  html += '<th class="dottedleft" colspan="4">Reads</th>';
138  html += '<th class="dottedleft">Job</th>';
139  html += '<th class="dottedleft" colspan="4">Actions</th>';
140  html += '<th class="dottedleft">Comment</th>';
141  html += '</tr>';
142  html += '<tr>';
143  html += '<th></th>';
144  html += '<th class="dottedleft"></th>';
145  html += '<th class="dottedleft">PF_READS</th>';
146  html += '<th>PT_READS</th>';
147  html += '<th>PM_READS</th>';
148  html += '<th>ALIGNED_PAIRS</th>';
149  html += '<th class="dottedleft"></th>';
150  html += '<th class="dottedleft">Files</th>';
151  html += '<th>Flag RNA</th>';
152  html += '<th>Re-align</th>';
153  html += '<th>Cufflinks</th>';
154  html += '<th class="dottedleft"></th>';
155  html += '</tr>';
156  html += '</thead>';
157  html += '<tbody>';
158  for (var alignedNo = 0; alignedNo < alignedSequences.length; alignedNo++)
159  {
160    var aligned = alignedSequences[alignedNo];
161
162    var lib = aligned.lib;
163    lib.stratagene = lib.name.indexOf(GENERIC_STRATAGENE_NAME) == 0;
164    lib.external = lib.name.indexOf(EXTERNAL_RNA_NAME) == 0;
165    var libPlate = lib.bioWell.bioPlate;
166   
167    var masked = aligned.masked;
168    var merged = aligned.merged;
169    var pfReads = merged.PF_READS == null ? '-' : formatNumber(merged.PF_READS/1000000, null, 2)
170    var ptReads = merged.PT_READS == null ? '-' : formatNumber(merged.PT_READS/1000000, null, 2)
171    var maskedReads = masked.PM_READS == null ? '-' : formatNumber(masked.PM_READS/1000000, null, 2)
172    var alignedReads = aligned.ALIGNED_PAIRS == null ? '-' : formatNumber(aligned.ALIGNED_PAIRS/1000000, null, 2);
173    var job = aligned.job;
174   
175    html += '<tr class="highlight ' + (alignedNo % 4 < 2 ? 'evenrow' : 'oddrow') + '">';
176    html += '<td class="prompt">'+aligned.name+'</td>';
177    html += '<td class="dottedleft">'+libPlate.name+'</td>';
178    html += '<td class="dottedleft">'+pfReads+'</td>';
179    html += '<td>'+ptReads+' ('+Math.round(100*ptReads/pfReads)+'%)</td>';
180    html += '<td>'+maskedReads+'</td>';
181    html += '<td>'+alignedReads+' ('+Math.round(100*alignedReads/pfReads)+'%)</td>';
182
183    html += '<td class="dottedleft">';
184    html += '<span class="link item-link" data-item-type="JOB" data-item-id="'+job.id+'" title="'+Strings.encodeTags(job.statusMessage)+'">'+job.status+'</span>';
185    html += '</td>';
186    if (aligned.DataFilesFolder && job.server)
187    {
188      html += '<td class="dottedleft">';
189      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>';
190      html += '</td>';
191    }
192    else
193    {
194      html += '<td class="dottedleft">-</td>';
195    }
196    // Do not allow flagging external or stratagene
197    var cufflinksChecked = alignedReads > 0 ? 'checked' : '';
198    var realignChecked = job.status == 'ERROR' ? 'checked' : '';
199    if (lib.stratagene || lib.external)
200    {
201      html += '<td>-</td>';
202      cufflinksChecked = '';
203    }
204    else
205    {
206      html += '<td><input type="checkbox" name="flag.'+aligned.id+'"></td>';
207    }
208   
209    html += '<td><input type="checkbox" name="realign.'+aligned.id+'" '+realignChecked+'></td>';
210    html += '<td><input type="checkbox" name="cufflinks.'+aligned.id+'" '+cufflinksChecked+'></td>';
211    html += '<td class="dottedleft"><input type="text" name="comment.'+aligned.id+'" style="width: 20em;"></td>';
212    html += '</tr>';
213
214  }
215  html += '</tbody>';
216  html += '</table>';
217  setInnerHTML('alignedSequences', html);
218 
219  // Add click handler to items
220  var clickableItems = document.getElementsByClassName('item-link');
221  for (var i = 0; i < clickableItems.length; i++)
222  {
223    Events.addEventHandler(clickableItems[i], 'click', Items.itemOnClick);
224  }
225 
226  // Add click handler to file links
227  var clickableItems = document.getElementsByClassName('file-link');
228  for (var i = 0; i < clickableItems.length; i++)
229  {
230    Events.addEventHandler(clickableItems[i], 'click', fileLinkOnClick);
231  }
232
233}
234
235
236function goRegister()
237{
238  if (!step1IsValid()) return;
239
240  var frm = document.forms['reggie'];
241  Main.addClass(document.getElementById('step.1.section'), 'disabled');
242 
243  Main.hide('goregister');
244  Main.hide('gocancel');
245  Main.hide('gonext.message');
246 
247  var submitInfo = {};
248 
249  var all = [];
250  submitInfo.alignedSequences = all;
251  for (var alignedNo = 0; alignedNo < alignedSequences.length; alignedNo++)
252  {
253    var aligned = alignedSequences[alignedNo];
254    var tmp = {};
255    tmp.id = aligned.id;
256   
257    tmp.flag = frm['flag.'+aligned.id] && frm['flag.'+aligned.id].checked;
258    tmp.realign = frm['realign.'+aligned.id].checked;
259    tmp.cufflinks = frm['cufflinks.'+aligned.id].checked;
260    tmp.comment = frm['comment.'+aligned.id].value;
261   
262    all[all.length] = tmp;
263  }
264 
265  if (debug) Main.debug(JSON.stringify(submitInfo));
266 
267  var url = '../MaskAlign.servlet?ID=<%=ID%>&cmd=RegisterMaskingAndAlignment';
268  var request = Ajax.getXmlHttpRequest();
269  try
270  {
271    showLoadingAnimation('Performing registration...');
272    request.open("POST", url, false);
273    request.send(JSON.stringify(submitInfo));
274  }
275  finally
276  {
277    hideLoadingAnimation();
278  }
279 
280  if (debug) Main.debug(request.responseText);
281  var response = JSON.parse(request.responseText);
282 
283  if (response.messages && response.messages.length > 0)
284  {
285    var msg = '<ul>';
286    for (var i = 0; i < response.messages.length; i++)
287    {
288      var msgLine = response.messages[i];
289      if (msgLine.indexOf('[Warning]') >= 0)
290      {
291        msg += '<li class="warning">' + msgLine.replace('[Warning]', '');
292      }
293      else
294      {
295        msg += '<li>' + msgLine;
296      }
297    }
298    msg += '</ul>';
299    setInnerHTML('messages', msg);
300    Main.show('messages');
301  }
302 
303  if (response.status != 'ok')
304  {
305    Main.addClass(document.getElementById('messages'), 'failure');
306    setFatalError(response.message);
307    return false;
308  }
309
310  Main.show('gorestart');
311}
312
313function fileLinkOnClick(event)
314{
315  var folder = Data.get(event.currentTarget, 'folder');
316  var server = Data.get(event.currentTarget, 'server');
317  var itemId = Data.get(event.currentTarget, 'item-id');
318  server = server.replace(/\s*\[.*\]/, '');
319  var url = 'view_remote_files.jsp?ID=' + App.getSessionId();
320  url += '&clusterId='+server;
321  url += '&path='+encodeURIComponent(folder);
322  url += '&itemType=DERIVEDBIOASSAY&itemId='+itemId;
323  Dialogs.openPopup(url, 'ViewProjectFiles', 750, 500);
324}
325
326
327</script>
328<style>
329tr.highlight
330{
331  border-top: 1px dotted #A0A0A0;
332}
333
334.dottedleft
335{
336  border-left: 1px dotted #A0A0A0;
337}
338
339.oddrow
340{
341  background-color: #F0F0F0;
342}
343
344#alignedSequencesTable
345{
346  width: 100%;
347  border-collapse: collapse;
348}
349
350#alignedSequencesTable td
351{
352  text-align: center;
353  min-width: 4.5em;
354}
355
356#alignedSequencesTable tbody td
357{
358  padding-top: 1px;
359  padding-bottom: 1px;
360}
361
362#alignedSequencesTable .italic
363{
364  font-style: italic;
365}
366
367.file-link
368{
369  margin-left: 0.5em;
370}
371
372</style>
373</base:head>
374<base:body onload="init()">
375
376  <p:path><p:pathelement 
377    title="Reggie" href="<%="../index.jsp?ID="+ID%>" 
378    /><p:pathelement title="Confirm masking and alignment ended" 
379    /></p:path>
380
381  <div class="content">
382  <%
383  if (sc.getActiveProjectId() == 0)
384  {
385    %>
386    <div class="messagecontainer note" style="width: 950px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;">
387      No project has been selected. You may proceed with the registration but
388      created items will not be shared.
389    </div>
390    <%
391  }
392  %>
393 
394  <form name="reggie" onsubmit="return false;">
395 
396  <div id="step.1.section">
397  <table class="stepform" style="width: 95%;">
398  <tr>
399    <td rowspan="3" class="stepno">1</td>
400
401    <td class="stepfields">
402      <div id="alignedSequences"></div>
403    </td>
404  </tr>
405  </table>
406  </div>
407   
408  <div class="loading" id="loading" style="display: none;"><table><tr><td><img src="../images/loading.gif"></td><td id="loading.msg">Please wait...</td></tr></table></div>
409 
410  <div class="messagecontainer error" id="errorMessage" style="display: none; width: 950px; margin-left: 20px; margin-bottom: 0px;"></div>
411 
412  <div id="messages" class="success" style="display: none; width: 950px; margin-left: 20px; margin-top: 20px;"></div>
413 
414  <table style="margin-left: 20px; margin-top: 10px;" class="navigation">
415    <tr>
416      <td><base:button id="gocancel" title="Cancel" onclick="goRestart(false)" style="display: none;"/></td>
417      <td><base:button id="gonext" title="Next" image="<%=home+"/images/gonext.png"%>" onclick="goNext(true)"/></td>
418      <td><base:button id="goregister" title="Register" image="<%=home+"/images/import.png"%>" onclick="goRegister()" style="display: none;"/></td>
419      <td><base:button id="gorestart" title="Restart" image="<%=home+"/images/goback.png"%>" onclick="goRestart(true)" style="display: none;"/></td>
420      <td id="gonext.message" class="message"></td>
421    </tr>
422  </table>
423 
424  </form>
425  </div>
426 
427</base:body>
428</base:page>
429<%
430}
431finally
432{
433  if (dc != null) dc.close();
434}
435%>
Note: See TracBrowser for help on using the repository browser.