[BioRuby] rails blast server

Frank Schwach fs5 at sanger.ac.uk
Fri Sep 24 08:04:19 UTC 2010


Yes, Rails will give you some sugar for the AJAX stuff but, to be
honeest, it isn't that hard to code that "by hand" and if you need to
learn Rails first then it really won't be worth it for this project.
This is a bit off-topic for a BioRuby list but maybe it helps, so
here is what I use on one of my websites to check for the status of a
job. In this case, there is a cgi script that checks the job status
because this is a slightly more complex system, but you could just check
for the existence of the BLAST result file (but see below). You just
populate the job ID in the javascript function below in your template as
you generate the page. 
When my job is finished, I redirect to a different page which displays
the results but you could just as easily simply insert a link to
download the BLAST resutl file on the same page. I use Prototype.

<script  type="text/javascript"
src="../your/path/to/prototype.js"></script>

<script type="text/javascript">
function statusChecker(){
  new Ajax.Updater( 
  { success: 'jobStatus'}, 
  '../cgi-bin/some_job_status_checker.cgi',
    {
      parameters: 'jobid=1234567',
      method    : 'get',
      onComplete : onJobCompleteRedirect
    }
  );
} ;
/* the job_status_checker returns 'complete' if job is ready to download   */
function onJobCompleteRedirect(response){
  var status = response.responseText;
  if( status == 'completed') {
     window.location.href='../cgi-bin/result_page.cgi?jobid=1234567';
  }
} ;

/* this actually runs the StatusChecker every 5 secs */
new PeriodicalExecuter(statusChecker, 5) ;
</script>


Somewhere on the page I have this:
<span id="jobStatus">queued...</span> 

That's the bit that gets updated with whatever
some_job_status_checker.cgi returns. If it returns 'completed' the
results page is loaded.

One thing to bear in mind if you just check for the existence of files
to indicate job status: the BLAST result file exists before the job is
complete. For that reason you need a sysmte command that first runs
BLAST and then does something to indicate the job is finished, something
like "blastall ....; indicate_completeness.sh". 
That could be either to copy the BLAST result into the public download
folder, so your job status checker doesn't see it before it is complete
or to simply "touch" a file in that folder with a name like this:
"JOBID_complete". Then you take the existence of that file as proof that
the job is finished.
Hope this help. Good luck!

Frank




On Thu, 2010-09-23 at 23:36 +0530, Anurag Priyam wrote:
> > Dang I thought Rails would make AJAX stuff easier too? Or is that only if I need a database backend?
> > Sorry for the noob questions, I haven't done any web dev in a long time...
> 
> Yea Rails will help you with AJAX a bit. It will also help you with
> the upload process - paperclip plugin.
> 
> But yea, as Frank said, for something as simple as this you do not
> need something as heavy as Rails. You might just want to write a Ruby
> CGI script or perhaps a Sinatra app. To make life simple with AJAX you
> can just use jQuery library.
> 
> I have got some web development experience; feel free to contact me
> off the list :).
> 



-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE. 



More information about the BioRuby mailing list