Approaches to Web Development for Bioinformatics

Previous  Contents  Next
References

BioJava

In this section:

This section discusses the BioJava open source project 59. The Java section discussed the Java programming in general with some bioinformatics examples and the section Web Programming with Java discussed web development with the Java 2 Enterprise Edition using an example from the BioJava API.

The BioJava really stands out as an open source bioinformatics project. The BioJava API's have capabilities for manipulating biological sequences, parsing common file formats, accessing to BioSQL and Ensembl databases, performing statistical analysis, and other tasks. The documentation of the BioJava API's on the project wiki includes a getting started section and is excellent.

Getting Started

Here is an example Java program that uses the BioJava libraries to translate DNA into an amino acid sequence.  The source code is also in file TranslateDNA.java.


import org.biojava.bio.seq.DNATools;
import org.biojava.bio.seq.RNATools;
import org.biojava.bio.symbol.SymbolList;
import org.biojava.bio.symbol.IllegalAlphabetException;
import org.biojava.bio.symbol.IllegalSymbolException;

/**
* Program to demonstrate translation of a DNA nucleotide sequence into an amino acid sequence
*/
public class TranslateDNA {

/**
* Entry point for the program, as driven by the command line
* @param argv No command line arguments expected
*/
public static void main(String[] argv) {

try {

// Create a DNA Sequence
SymbolList dna = DNATools.createDNA(
"atggcacaggcactgttggtacccccaggacctgaaagcttccgcctttttactaga");
System.out.println("Translated amino acid sequence: " + dna.seqString());

// transcribe DNA to RNA
SymbolList rna = RNATools.transcribe(dna);

// translate RNA to amino acid sequence
SymbolList aminoAcidSequence = RNATools.translate(rna);

// print the result
System.out.println("Translated amino acid sequence: " + aminoAcidSequence.seqString());

} catch(IllegalAlphabetException e) {
e.printStackTrace();
} catch(IllegalSymbolException e) {
e.printStackTrace();
} catch(IllegalArgumentException e) {
e.printStackTrace();
}
}
}

You will notice is that everything is object oriented. The Java language helps steer you in this direction but the BioJava team has done a nice job of designing a clean and powerful API. Firstly, the program imports the several BioJava classes. Class DNATools provides some useful capabilities for processing DNA sequences. The class RNATools is used to transcribe the given DNA sequence to RNA. Following that RNATools is used again to translate the RNA sequence into an amino acid sequence.

To compile the code enter the command line (for Windows; similar for UNIX, repacing '\' with '/' and ';' with ':'):


>javac -classpath lib\biojava-1.5-beta2.jar -d classes src\TranslateDNA.java

which assumes that the source file is in directory 'src' and places the compiled class file in the directory 'classes'.  The compiled class is also in TranslateDNA.class.  To run the program enter this at a command prompt:


>java -classpath lib\biojava-1.5-beta2.jar;classes TranslateDNA
Translated amino acid sequence:
atggcacaggcactgttggtacccccaggacctgaaagcttccgcctttttactaga
Translated amino acid sequence: MAQALLVPPGPESFRLFTR


Previous  Contents  Next
References

Contributed Comments and NotesAdd a comment.

There are no user comments.

Google

Please send ideas and opinions by email at alexamies@gmail.com.

© 2006-2007 Alex Amies