Difference between revisions of "Using Existing Databases With JBrowse"

From GMOD
Jump to: navigation, search
(Preparing a Database That JBrowse Can Use)
(No difference)

Revision as of 14:27, 29 March 2013

This page explains the configuration necessary to allow JBrowse server-side scripts to use information from a database.

Giving JBrowse Access to a Database

JBrowse is capable of extracting sequence and feature information from databases managed by a Database Management System (DBMS) such as PostgreSQL, MySQL, or Oracle, as long as they have an adaptor for BioPerl's Bio::DB::* system. This is done by using prepare-refseqs.pl or biodb-to-json.pl with a configuration file containing information about the database.

For example, the config file header for a PostgreSQL database with the Chado schema will look something like this:

{
  "description": "D. melanogaster (release 5.37)",
  "db_adaptor": "Bio::DB::Das::Chado",
  "db_args": { "-dsn": "dbi:Pg:dbname=fruitfly;host=localhost;port=5432",
               "-user": "yourusername",
               "-pass": "yourpassword"
             },
  ...
}

In the database source name (dsn) argument, 'dbi:Pg' indicates that you are using PostgreSQL, and the dbname, host, and port were specified when the database was created with PostgreSQL's createdb command. The user and pass arguments were specified when the PostgreSQL user account was created with the createuser command. Collectively, these arguments identify the database and give the Bio::DB::Das::Chado object access to it. Other adaptors (Bio::DB::SeqFeature::Store, Bio:DB::GFF, etc.) will require similar information.

Assuming that you already have access to an existing database with an appropriate schema (Chado, in this example), this is all you will need in order to use JBrowse with that database.

This page describes how to create a JBrowse configuration file by using an example with inline comments.

Summary

biodb-to-json.pl takes a set of instructions in JSON syntax that first indicates the location of the feature data, and then specifies a list of JBrowse tracks that it will generate from the referenced feature data. The options for the feature tracks are virtually the same in the config file as they are in flatfile-to-json.pl. The difference is that, instead of formatting the feature tracks one at a time with flatfile-to-json.pl, the tracks are specified all at once in this config file. This greatly reduces the amount of typing needed to change a track, especially for tracks that use several options. It also makes it easier to format a large number of tracks, since the options used for those tracks are all recorded in a human-readable way.

Example

Here is a sample config file with each line explained. Note that, in order for this config file to work, it would be necessary to remove the grey comments (since JSON does not support them).

{
  This is the header. It contains information about the database.
description: a brief textual description of the data source. "description": "D. melanogaster (release 5.37)", db_adaptor: a perl module with methods for opening databases and extracting
information. This will normally be either Bio::DB::SeqFeature::Store,
Bio::DB::Das::Chado, or Bio::DB::GFF, but it can also be the name of any
other perl module that implements the Bio::SeqFeatureI interface.
"db_adaptor": "Bio::DB::SeqFeature::Store", db_args: arguments required to produce an instance of the db_adaptor. The
required arguments can be found by searching for the db_adaptor on the CPAN
website.
"db_args": { adaptor: With Bio::DB::SeqFeature::Store, a value of "memory"
for the adaptor indicates that the data is stored somewhere in
the file system. Alternatively, it might have been stored in a
database such as MySQL or BerkeleyDB.
"-adaptor": "memory", dir: given the "memory" argument for the adaptor, this is the
file system path to the location in memory where the data is
stored. Data will automatically be extracted from any *.gff
or *.gff3 files in this directory.
"-dir": "/Users/stephen/Downloads/dmel_r5.37" },
This is the body. It contains information about the feature tracks.
TRACK DEFAULTS: The default options for every track. "TRACK DEFAULTS": { class: same as 'cssClass' in flatfile-to-json.pl. "class": "feature" }, tracks: information about each individual track. "tracks": [ Information about the first track. { track: same as 'tracklabel' in flatfile-to-json.pl. "track": "gene", key: same meaning as in flatfile-to-json.pl. "key": "Gene Span", feature: an array of the feature types that will be used for the track.
Similar to 'type' in flatfile-to-json.pl.
"feature": ["gene"], autocomplete: same meaning as in flatfile-to-json.pl. "autocomplete": "all", "class": "feature2", urlTemplate: same meaning as in flatfile-to-json.pl. Note how
urlTemplate is being used with a variable called "feature_id" defined
in extraData. In this way, different features in the same track can
be linked to different pages on FlyBase.
"urlTemplate": "http://flybase.org/cgi-bin/fbidq.html?{feature_id}", extraData: same as in flatfile-to-json.pl. "extraData": {"feature_id": "sub {shift->attributes(\"load_id\");}"} }, Information about the second track. { "track": "mRNA", "feature": ["mRNA"], "autocomplete": "alias", subfeatures: similar to 'getSubs' in flatfile-to-json.pl. "subfeatures": true, "key": "mRNA", "class": "transcript", subfeature_classes: same as 'subfeatureClasses' in flatfile-to-json.pl. "subfeature_classes": { "CDS": "transcript-CDS", "five_prime_UTR": "transcript-five_prime_UTR", "three_prime_UTR": "transcript-three_prime_UTR" }, arrowheadClass: same meaning as in flatfile-to-json.pl. "arrowheadClass": "transcript-arrowhead", clientConfig: same meaning as in flatfile-to-json.pl. "clientConfig": { "histScale":5 }, "urlTemplate": "http://flybase.org/cgi-bin/fbidq.html?{feature_id}", "extraData": {"feature_id": "sub {shift->attributes(\"load_id\");}"} } ] }

Note how the config file is divided into two parts, a header section that contains information about the database, and a body section that contains information about the feature tracks.

External Links

See also