[Biojava-l] BLAST from Java
Russell Smithies
russell.smithies@xtra.co.nz
Wed, 20 Feb 2002 11:55:33 +1300
Has anyone had any luck running Blast locally from Java using Runtime.exec()
and command array??
I always get an error from Blast and the only reliable way I've found so far
is to write a batch file then delete it as follows:
*****************************************************
File batFileName = new File("runme.bat");
PrintStream bfile = new PrintStream(new BufferedOutputStream(new
FileOutputStream(batFileName)));
//command string for BLAST
String cmds = "c:/bio/blast/blastall.exe -p blastn -d
c:/bio/blast/ecoli -e 1e-30 -m8 -i c:/bio/blast/test.txt";
//create batch file
bfile.print(cmds);
bfile.close();
//execute batch file
Process pro = Runtime.getRuntime().exec(batFileName.toString());
InputStream out = pro.getInputStream();
int i;
while((i = out.read())!= -1){
//do stuff with the output
System.out.print((char)i);
}
//stop process
pro.destroy();
//delete batch file
boolean sucess = batFileName.delete();
******************************************************
It works fine but there must be a tidier way.
Russell Smithies
University of Otago
Dunedin
New Zealand