How to get RESTful data from RCSB

Biojava includes a package that can be used to get information from RCSB’s RESTful service. As of 3.0.6, the package is only for “describeMol” descriptions of PDB entries: see 1 for an example. These description files typically contain accession numbers, molecular weights, EC numbers, and other information.

The most important class is RCSBDescriptionFactory. To use it: java RCSBDescription description = RCSBDescriptionFactory.get("1w0p"); This will automatically download and parse the describeMol file.

If you need an alternate stream (for example you don’t want to download the files each time), RCSBDescriptionFactory has another factory method: java RCSBDescriptionFactory.get(InputStream stream); // stream is an opened InputStream to the describeMol file

The RCSBDescription contains the PDB Id and a list of RCSBPolymers. We can use RCSBPolymer to obtain the molecular weight, EC number, taxonomy, and accession numbers of the first polymer as follows: ```java RCSBDescription description = RCSBDescriptionFactory.get(“1w0p”); RCSBPolymer polymer = description.getPolymers().get(0); System.out.println(polymer.getWeight()); // * System.out.println(polymer.getEnzClass()); RCSBMacromolecule molecule = polymer.getMolecule(); RCSBTaxonomy taxonomy = polymer.getTaxonomy(); System.out.println(taxonomy.getId() + “\t” + taxonomy.getName()); for (String accession : molecule.getAccessions()) {


} ```

RCSBPolymer and RCSBMacromolecule also contain other information from the describeMol file; see the Javadoc for a complete list.

Many of the numeric values in the describeMol file can be null. It is therefore crucial to check for null values when using these fields. For example, the molecular weight in the marked line above can be null, so the following code might throw a NullPointerException: java int weight = polymer.getWeight(); Instead, the following is preferred: ```java Integer weight = polymer.getWeight(); if (weight == null) {

   // do something

} else {

   // do something else

} ```