Skip to content

Metabolomics Fiehn Lab

Sections
Personal tools
You are here: Home » Members » Martin Scholz » Development » Power User Gateway in Java » Hacking PubChem in Java: Learning to Speak PUG

Hacking PubChem in Java: Learning to Speak PUG

Document Actions
Submit complex queries to the Power User Gateway using Java.

how ?

  1. creating a request
  2. receiving an PCT-Waiting_reqid
  3. check the responseDocument for the requiered download URL
  4. refresh() the request until the response contains a download URL
  5. store(URL, File) the result in a local file.

Code

The simple way to use the this class:

int[] pctIDs = new int[]{1,2,3,4};
PowerUserGatewayRequest request = new PowerUserGatewayRequest(pctIDs);
request.submitInitalRequest();

while(!request.getStatus().isFinished()){
   System.out.println("waiting for " + request.getRequestID());    request.refresh();
}
// download it to your directory
PowerUserGatewayRequest.store(request.getResponseURL(), targetFile);


Update: Java 1.4 & Java5

added support for java 1.4 and java 5:
xpath(String, Document) method is now redirecting to xpathJDK1_4(String, Document) or xpathJDK5(String, Document).
Seperation was needed to support java5 without additional libraries.
In case you are running it on java1.4 you need to import org.apache.xpath.XPathAPI and modify the mehtod xpath(String, Document):

public static Node xpath(String pathString, final Document doc) throws Exception {
depending on your JDK use one of the methods.
  //Node node = xpathJDK1_4(pathString, doc);
  Node node = xpathJDK5(pathString, doc);
  return node;
}

See Also:
http://pubchem.ncbi.nlm.nih.gov/
http://depth-first.com/articles/2007/06/04/hacking-pubchem-power-user-gateway
http://depth-first.com/articles/2007/06/11/hacking-pubchem-learning-to-speak-pug
Author:
 Martin Scholz 
@version
$Revision: 1.18 $
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 United States License.
Created by zwluxx
Last modified 2007-08-02 02:47 PM
 

Powered by Plone

This site conforms to the following standards: