[Biojava-dev] Biojava and biomanycores
mark.schreiber at novartis.com
mark.schreiber at novartis.com
Thu Oct 22 07:41:36 UTC 2009
Hi -
I think this is a historical hangover from the days when Java was not
actually very good at launching external processes. There are actually
two frameworks in biojava that attempted to overcome these shortcomings
although both are now deprecated by the existence the ProcessBuilder
(since JDK version 1.5).
Below is an example of calling the Linux/Unix command "ls". Typically for
Java much of the biolerplate is setting up the stream readers and handling
exceptions but you get the idea. You can do much more advanced things
such as launching long running jobs, monitoring them and cancelling them.
List<String> cmd = new ArrayList<String>();
cmd.add("/bin/ls");
ProcessBuilder builder = new ProcessBuilder(cmd);
try {
final Process process = builder.start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line);
}
return sb.toString();
} catch (Exception e) {
return e.getMessage();
}
Using this basic template you could theoretically launch any program, in
your case these would be presumably be compiled to use GPUs or have
command line options for these (the first item in the cmd list is the
program and all other items are command line arguments).
You can do this with much less work in Groovy which can be run as a stand
alone script or compiled to a class file and called from another Java
class.
Process proc = "ls -l ".execute()
proc.waitFor()
result = proc.in.text
If you want to get really "Groovy" you could even set up a Java program
that executes Groovy script on the fly, you could then have all your
scripts that lauch command line programs in text files that can be changed
during runtime (no compilation required).
Given that this is all quite easy now in java it would be good if someone
could add some of these to biojava.
Best regards,
- Mark
biojava-dev-bounces at lists.open-bio.org wrote on 10/22/2009 05:03:05 AM:
> Dear all,
>
> I'm one of the people who is trying to develop the biomanycores
> project (www.biomanycores.org) which aims to give access to efficient
> parallel algorithms developed for GPUs to bioinformaticians.
>
> To reach this goal we want to provide interfaces to those algorithms
> through Bio* frameworks. People will have to change only some lines in
> their Bio* code to use more efficient tools. In order to realize such
> interfaces, it is necessary to launch the command line tool and to
> retrieve results. I didn't see in the BioJava API a class enabling to
> do such a thing although a mechanism seems to exist in BioPython or
> BioPerl.
>
> I would like to know if I miss something in the API and, if it is not
> the case, what could be the best way to launch external programs to
> stay in the spirit of BioJava. For the moment, I use the trilead
> package to launch commands on distant computers and the Runtime class
> in the standard API to launch local commands. But may be it is
> completely irrelevant to add such functionalities to BioJava.
>
> Please let me know what do you think about it.
>
> Best regards
>
> Jean-Stephane
>
> Jean-Stephane Varre
> http://www.lifl.fr/~varre
> http://www.lifl.fr/SEQUOIA
> http://bioinfo.lifl.fr
>
>
> _______________________________________________
> biojava-dev mailing list
> biojava-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-dev
_________________________
CONFIDENTIALITY NOTICE
The information contained in this e-mail message is intended only for the
exclusive use of the individual or entity named above and may contain
information that is privileged, confidential or exempt from disclosure
under applicable law. If the reader of this message is not the intended
recipient, or the employee or agent responsible for delivery of the
message to the intended recipient, you are hereby notified that any
dissemination, distribution or copying of this communication is strictly
prohibited. If you have received this communication in error, please
notify the sender immediately by e-mail and delete the material from any
computer. Thank you.
More information about the biojava-dev
mailing list