Skip to content

Latest commit

 

History

History
116 lines (81 loc) · 5.06 KB

firststeps.md

File metadata and controls

116 lines (81 loc) · 5.06 KB

First Steps

First Steps

The simplest way to load a PDB file is by using the StructureIO class.

     public static void main(String[] args) throws Exception {
           Structure structure = StructureIO.getStructure("4HHB");
           // and let's print out how many atoms are in this structure
           System.out.println(StructureTools.getNrAtoms(structure));
    }   

BioJava automatically downloads the PDB file for hemoglobin 4HHB and copies it into a temporary location. Then the PDB file parser loads the data into a Structure object, that provides access to the content in the file. (If you call this a second time, BioJava will automatically re-use the local file.)

The crystal structure of human deoxyhaemoglobin PDB ID 4HHB (image source: RCSB)

This demonstrates two things:

  • BioJava can automatically download and install files locally (more on this in Chapter 4)
  • BioJava by default writes those files into a temporary location (The system temp directory "java.io.tempdir").

If you already have a local PDB installation, you can configure where BioJava should read the files from by setting the PDB_DIR system property

    -DPDB_DIR=/wherever/you/want/

Memory Consumption

Talking about startup properties, it is also good to mention the fact that many PDB entries are large molecules and the default 64k memory allowance for Java applications is not sufficient in many cases. BioJava contains several built-in caches which automatically adjust to the available memory. As such, the more memory you grant your Java applicaiton, the better it can utilize the caches and the better the performance will be. Change the maximum heap space of your Java VM with this startup parameter:

    -Xmx1G

A Quick 3D View

If you have the biojava-structure-gui module installed, you can quickly visualise a Structure via this:

    public static void main(String[] args) throws Exception {
        Structure struc = StructureIO.getStructure("4hhb");

        StructureAlignmentJmol jmolPanel = new StructureAlignmentJmol();

        jmolPanel.setStructure(struc);

        // send some commands to Jmol
        jmolPanel.evalString("select * ; color chain;");            
        jmolPanel.evalString("select *; spacefill off; wireframe off; cartoon on;  ");
        jmolPanel.evalString("select ligands; cartoon off; wireframe 0.3; spacefill 0.5; color cpk;");         
    }

This will result in the following view:

The StructureAlignmentJmol class provides a wrapper for the Jmol viewer and provides a bridge to BioJava, so Structure objects can be sent to Jmol for visualisation.

Asymmetric Unit and Biological Assembly

By default many people work with the asymmetric unit of a protein. However for many studies the correct representation to look at is the biological assembly of a protein. You can request it by calling

     public static void main(String[] args) throws Exception {
        Structure structure = StructureIO.getBiologicalAssembly("1GAV");
        // and let's print out how many atoms are in this structure
        System.out.println(StructureTools.getNrAtoms(structure));
    }

This topic is important, so we dedicated a whole chapter to it.

I Loaded a Structure Object, What Now?

BioJava provides a number of algorithms and visualisation tools that you can use to further analyse the structure, or look at it. Here a couple of suggestions for further reads:


Navigation: Home | Book 3: The Structure Modules | Chapter 2 : First Steps

Prev: Chapter 1 : Installation

Next: Chapter 3 : Structure Data Model