[Biojava-l] Using Java to create BLAST searches

CEZARD Timothée cezard at nokad-technology.com
Thu Nov 2 08:41:02 UTC 2006


Hi everyone,

I've worked a bit on that point and want to share my view.

When you launch a blast via the Runtime exec command it creates (and
launches) a new thread outside the JVM. 
The Process object allows you to monitor and  wait for the end of this
thread.
I've observed that for obscure reason sometime the thread never finish.
In that case you have to clear the InputStream and the ErrorStream of the
process.

Last point I've worked on is how to notice the GUI of the end of the
process. For that I've used the SwingWorker object and it worked fine.
http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html


Hope this helps someone.


CEZARD Timothée Ms
bioinformatics Manager 
NOKAD SA
4 rue Pierre Fontaine 
91058 EVRY cedex
Tel : 01.60.87.89.90
Fax : 01.60.87.89.99
www.nokad-technology.com


-----Message d'origine-----
De : biojava-l-bounces at lists.open-bio.org
[mailto:biojava-l-bounces at lists.open-bio.org] De la part de Graham
Etherington
Envoyé : mercredi 1 novembre 2006 23:17
À : 'Ng, Peter'; mark.schreiber at novartis.com
Cc : biojava-l at lists.open-bio.org; biojava-l-bounces at lists.open-bio.org
Objet : Re: [Biojava-l] Using Java to create BLAST searches

Peter,
The method is explained quite well at:

http://java.sun.com/j2se/1.3/docs/api/java/lang/Process.html#waitFor()

Not sure about your threading question, but I'm presuming that the Process
produces and exit value. By convention, 0 indicates normal termination.

Hope this helps a little.
Graham


Dr. Graham Etherington
Post-doctoral Research Officer
Bioinformatics Discovery Group,
Institute for Molecular Bioscience,
University of Queensland,
St. Lucia Campus, Brisbane,
QLD 4072 Australia

-----Original Message-----
From: Ng, Peter [mailto:Peter.Ng at bccdc.ca] 
Sent: Thursday, 2 November 2006 7:53 AM
To: Graham Etherington; mark.schreiber at novartis.com
Cc: biojava-l at lists.open-bio.org; biojava-l-bounces at lists.open-bio.org
Subject: RE: [Biojava-l] Using Java to create BLAST searches

Graham,
thanks for the info!  I have two instances of Runtime.getRuntime().exec
going, should I be putting these into two threads?  also, when does java
see the process actually being finished?  how does java know when blastn
is done at the unix or window level?

thanks,
peter

-----Original Message-----
From: Graham Etherington [mailto:g.etherington at imb.uq.edu.au] 
Sent: November 1, 2006 1:22 PM
To: Ng, Peter; mark.schreiber at novartis.com
Cc: biojava-l at lists.open-bio.org; biojava-l-bounces at lists.open-bio.org
Subject: RE: [Biojava-l] Using Java to create BLAST searches


Peter,
If you are running a process, then you should be able to use the
Process.waitFor() command.
waitFor() causes the current thread to wait, if necessary, until the
process
represented by this Process object has terminated. I've used it in my
code
that I posted and have snippeted it below.

Runtime r = Runtime.getRuntime ();
Process runBlast = r.exec (new String[] {"sh","-c",cmd});
runBlast.waitFor ();

Hope this is of some help.
Cheers,
Graham


Dr. Graham Etherington
Post-doctoral Research Officer
Bioinformatics Discovery Group,
Institute for Molecular Bioscience,
University of Queensland,
St. Lucia Campus, Brisbane,
QLD 4072 Australia

-----Original Message-----
From: Ng, Peter [mailto:Peter.Ng at bccdc.ca] 
Sent: Thursday, 2 November 2006 5:41 AM
To: mark.schreiber at novartis.com; Graham Etherington
Cc: biojava-l at lists.open-bio.org; biojava-l-bounces at lists.open-bio.org
Subject: RE: [Biojava-l] Using Java to create BLAST searches

Hi Mark/Andy,

I have a similar question relating to command line blast searches.  I'm
using elements from both flatfile.txt and i.html to present on a html
page.  How do I ensure each of blast1 or blast2 is completed before I
start the next step?  I'm not sure how to maintain control once the
command line is being executed.  Is there a way to test the presence of
the output files?  Does synchronize work in this situation.  If so, how
would I put it in the code?  Any help would be appreciated!

thanks,
peter

blast1 = "CMD /c c:/blast/blastall -p blastn -d c:/blast/db/" +
getLibrary() + " -i c:/blast/files/noc.txt -e .0001 -m 8 -o
c:/blast/files/flatfile.txt -v 2 -b 2 -F F";
blast2 = "CMD /c c:/blast/blastall -p blastn -d c:/blast/db/" +
getLibrary() + " -i c:/blast/files/noc.txt -e .0001 -m 0 -o
c:/batchBLAST/" + i + ".html -T T -v 5 -b 5 -F F";			

Runtime.getRuntime().exec(blast1);
Runtime.getRuntime().exec(blast2);

-- 
Regards,

Peter Ng
Laboratory Information Management Coordinator
Laboratory Services
BC Centre for Disease Control
655 West 12th Avenue
Vancouver BC  V5Z 4R4
Tel: 604-660-2058     
Page: 604-205-4814    
Fax: 604-660-6073
Web: www.bccdc.org



-----Original Message-----
From: biojava-l-bounces at lists.open-bio.org
[mailto:biojava-l-bounces at lists.open-bio.org] On Behalf Of
mark.schreiber at novartis.com
Sent: November 1, 2006 1:54 AM
To: Graham Etherington
Cc: biojava-l at lists.open-bio.org; biojava-l-bounces at lists.open-bio.org
Subject: Re: [Biojava-l] Using Java to create BLAST searches


Hi -

It may not like the command line having spaces in the path. Try
installing 
blast somewhere else as a test. Eg put it in C:\blast and then try 

String cmd = "C:/blast/bin/blastall -p blastn -d ecoli.nt -i test.fas -o

blast.out";

You could possibly even trick it by putting a short cut in the C 
directory.

Also biojava has some nice tools for working with processes.

- Mark

Mark Schreiber
Research Investigator (Bioinformatics)

Novartis Institute for Tropical Diseases (NITD)
10 Biopolis Road
#05-01 Chromos
Singapore 138670
www.nitd.novartis.com
www.dengueinfo.org

phone +65 6722 2973
fax  +65 6722 2910





"Graham Etherington" <g.etherington at imb.uq.edu.au>
Sent by: biojava-l-bounces at lists.open-bio.org
11/01/2006 04:39 PM

 
        To:     <biojava-l at lists.open-bio.org>
        cc:     (bcc: Mark Schreiber/GP/Novartis)
        Subject:        [Biojava-l] Using Java to create BLAST searches


Hi,
I'm developing on Windows (using Apache Tomcat) using jsp's to create 
BLAST
searches on a local BLAST database. Even though I'm not using BioJava
(intend to use it to parse the results), I thought this formum would be 
the
best place to ask for help.
Even when I hard code a good BLAST search I keep getting the same error 
when
I run my search, namely: 
" java.io.IOException: CreateProcess: sh -c "C:/Program Files/Apache
Software Foundation/Tomcat 5.5/blast/bin/blastall -p blastn -d ecoli.nt
-i
test.fas -o blast.out" error=2 "

The pertinent bits of code I'm using are...

String cmd = "C:/Program Files/Apache Software Foundation/Tomcat
5.5/blast/bin/blastall -p blastn -d ecoli.nt -i test.fas -o blast.out";

............


Runtime r = Runtime.getRuntime ();
Process runBlast = r.exec (new String[] {"sh","-c",cmd});
 
runBlast.waitFor ();
out.println ("Waiting for result");

//Write the results
BufferedReader br = new BufferedReader (new FileReader (output));
String line = null;
String results = "";
while ( (line = br.readLine ()) != null )
results = results.concat ("/n" + line);

.............

I'm not sure why it give me an IOException. I've checked that the file 
input
file exists and that all the paths are correct.
Any ideas?

Many thanks,
Graham


_______________________________________________
Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/biojava-l



_______________________________________________
Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/biojava-l


_______________________________________________
Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/biojava-l





More information about the Biojava-l mailing list