# GO Database Perl Module

## Introduction

The go-db-perl module is an object/relational API for querying the GO db and receiving perl objects. Using the API you can write perl scripts to:

- Search on GO terms from the database
- Fetch and traverse subgraphs of the GO ontology
- Fetch gene products from the database; for example, find all gene products attached to transmembrane receptor and its children
- Fetch terms and graphs from the database by gene product
- Filter and constrain searches by GO evidence codes, species and other criteria
- ...and much more!

go-db-perl comes with a number of applications for loading and querying the GO Database, including a Tk graphical user interface, and a powerful command line interface "GOshell"

You should have a solid understanding of object oriented perl before using the the go-db-perl modules

## Installation

You should have a local copy of the GO mysql database. You will also need the go-perl modules

Please follow the installation instructions for go-perl

## Scripts

go-db-perl comes with scripts in the scripts directory to help with querying and loading databases.

### Command Line Options

The following command line options are available to all database scripts. If you are connecting to a local MySQL installation that is not password protected you should only need the -d option

- -dbname (-d) database-name
- -dbhost (-h) server-name
- -dbuser (-u) user-name
- -dbauth (-p) password
- -port port-number
- -dbms DBMS-type
- -dsn DBI-DSN

### Data access scripts

- GOshell.pl -- an interactive shell for easy object-oriented querying of the database. Contains online help

### Data loading scripts

- load-go-into-db.pl -- loads a go/obo or assoc file into a database
- go-prepare-release.pl -- handles the entire db release process, from generating an empty db through loading it to generating exported data
- go-manager.pl -- similar to above but allows interactive control over the parts of the release process

## GO::AppHandle

The core class in the API is the GO::AppHandle object - it mediates between your code and the database.

After downloading go-db-perl, consult the POD documentation, either using the perldoc command,

    perldoc GO/AppHandle.pm

or consult the Online Documentation

### Fetching Objects from the DB

The AppHandle takes requests, queries the database, and turns the results into perl objects. See the go-perl documentation for a description of the object model

## Database Loading

### How database loading works

First of all a file (any ontology format or a gene assoc file) is parsed using GO::Parser. The parser will generate an Obo-xml stream. This stream is transformed using an XSLT Transformation into a different kind of XML that is isomorphic to the GO Database Schema. This godb-xml can be loaded into the database using a generic loader.

### Database loading components

- go-prepare-release.pl -- this script is a wrapper for the components below
- GO::Parser -- the parser is created and used by the go-prepeare-release.pl script to make obo-xml
- oboxml_to_godb_prestore.xsl -- this is a 'program' written in the XSLT language specifying how to transform obo-xml into db-xml. It uses the xsltproc command.
- GO::Handlers::godb -- this module takes the db-xml stream and loads the database; this module is actually a wrapper for the generic DBIx::DBStag loader

See also xml documentation.

## Future Directions

We're currently looking at alternatives to the object/relational approach to querying the database via perl and other languages. On the one hand, the API allows us to reuse code and provide a simplified interface to some complex queries. On the other hand, it requires a lot of hard-to-maintain code. And whilst the API approach works well with queries that follow certain set patterns, it is not so good for arbitrary queries - for that you need to revert back to the full expressive power of a query language, such as SQL

### DBStag

We are developing a library called DBStag (see Stag project page for details), which transforms the results of multijoin SQL queries into nested XML. It also allows for SQL reuse in the form of Stag SQL templates. We have provided a number of these templates for GO in the stag-templates directory

We expect to stop development on GO::AppHandle by 2005 and switch to an approach such as DBStag which combines the expressive power of a language such as SQL with hierarchical XML query results

DBStag also allows for querying of the go-database using SQL templates - see GODB SQL documentation

Last modified: Thu Feb 10 15:30:54 PST 2005