Search terms

Search gene products

Ontology root terms

molecular function

cellular component

biological process

Documentation

Tutorial

Resource URLs

Representations

Disclaimer

Tutorial

Please note that this tutorial is not yet complete.

To use the GO/wr web resource, all that is required is a programming language having libraries for dealing with HTTP and XML. (Every modern language has them; if it doesn't , it's not modern.) This is one of the advantages of a web service designed as a Resource-Oriented Architecture: It does not rely on the availability of special-purpose WS libraries for the programming language favoured by the potential user.

The programming language Python is used in this tutorial. This is just a matter of preference for this author; it should not be too difficult to translate the code into Java, Perl, Ruby or your language of choice.

The standard Python package urllib2 is all that is needed to fetch data from the GO/wr system. For most tasks, the fetched XML must be parsed by the client program. There are two main options: DOM (Document Object Model) and SAX (Simple API for XML). Both are supported by standard Python packages (xml.sax and xml.dom). In this case, we choose DOM and use the standard package xml.dom.minidom, which produces a tree-like data structure of nodes corresponding to XML elements, attributes and text. The nodes have methods that allow searching, traversal and access.

It would of course be possible to write a special-purpose package for accessing the GO/wr system which wrapped all details of HTTP and DOM. But it is instructive to see that standard, well-established, basic technologies are sometimes quite sufficient to perform useful tasks.

  1. Fetch XML document for the term 'G1 phase'

1. Fetch XML document for the term 'G phase'

import urllib, urllib2 urltemplate = 'http://www.avatar.se/GO/wr/term/%s.xml' url = urltemplate % urllib.quote_plus('G phase') xmldata = urllib2.urlopen(url).read() print xmldata

We build the URL from a template into which the term is inserted. Notice that we must URL-encode special characters in order to build a valid URL. The utility function 'quote_plus' from the standard Python package urllib does this for us. The 'plus' means that blank characters are converted to '+' , which is required in URLs.

The web resource is opened with the 'urlopen' function of urllib2. This returns a file-like instance that can be read from. We store the result in a variable. The result string is then printed just to check that it really is the requested XML.