Writing your first Biojava program using NetBeans in 3 easy steps
If you are using Java for your bioinformatics work, you should consider using Biojava as it saves lot of time in writing codes.
Prerequisites:
NetBeans 6.5.1
Biojava library
Biojava support library
Step 1 Create a new Java Application in NetBeans.
Step 2 Open the projects windows, right-click Libraries and select "Add JAR/Folder..." and add the two jar files you have downloaded previously in the prerequisites section.
Step 3 Open Main.java and start writing your biojava code. A sample code for reading a PDB file and accessing its contents is shown below(Don't forget to click "Fix Imports" after copying this code to automatically add the required import statements).
String filename = "path/to/pdbfile.pdb" ;
PDBFileReader pdbreader = new PDBFileReader();
// the following parameters are optional:
//the parser can read the secondary structure
// assignment from the PDB file header and add it to the amino acids
pdbreader.setParseSecStruc(true);
// align the SEQRES and ATOM records, default = true
// slows the parsing speed slightly down, so if speed matters turn it off.
pdbreader.setAlignSeqRes(true);
// parse the C-alpha atoms only, default = false
pdbreader.setParseCAOnly(false);
// download missing PDB files automatically from EBI ftp server, default = false
pdbreader.setAutoFetch(false);
try{
Structure struc = pdbreader.getStructure(filename);
System.out.println(struc);
GroupIterator gi = new GroupIterator(struc);
while (gi.hasNext()){
Group g = (Group) gi.next();
if ( g instanceof AminoAcid ){
AminoAcid aa = (AminoAcid)g;
Map sec = aa.getSecStruc();
Chain c = g.getParent();
System.out.println(c.getName() + " " + g + " " + sec);
}
}
} catch (Exception e) {
e.printStackTrace();
}
From the structure object, you could get the atoms and do calculations on it.
The best place to start learning about the features of Biojava is the Biojava CookBook
