[Gmod-ajax] Using multiple "data" directories with a single copy of JBrowse code

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Gmod-ajax] Using multiple "data" directories with a single copy of JBrowse code

Mitch Skinner
A lot of people have been asking about this lately, and it's something I
hadn't looked at in a while so it took me some time to remember all the
details.  Now that I do, I wanted to write a message that hopefully
helps all of the people asking about this.  This should also address the
issues some people were having with relative URLs.

First of all, if you only have a few JBrowse instances ("instance"
meaning "data set", e.g. a genome) , it's probably easiest to just have
a separate copy of JBrowse for each one.  And, right now, that's the
recommended approach: just make copies, and ignore the rest of this
email.  Now that this is becoming such a common request, I plan to
streamline things in a future version, but right now you have to do
things in a very specific way for it to work.

If you have a lot of different JBrowse instances, though, or if  you
want to create new ones on the fly, then read on:

Each instance needs to be in a directory named "data", and that
directory needs to be in a directory with a unique path.  So, for
example, if you have two genomes, genome1 and genome2, the directory
setup should look like this:

genome1/
    data/
genome2/
    data/

Suppose, for this example, you have the jbrowse programs in a separate
directory that's a sibling of the genome1 and genome2 directories, so
the whole thing looks like this:

genome1/
    data/
genome2/
    data/
jbrowse/
    bin/
       prepare-refseqs.pl
       flatfile-to-json.pl
       biodb-to-json.pl

When you set up, say, genome1, you need to run the JBrowse programs
*from that directory*.  This is so that the relative paths used to write
the files and the relative paths used in the URLs match up.  For
example, something like this (in this case my config file is
~/JBrowseConfig.js, and I'm only processing the reference sequence named
"4"; those parts of the command line will probably vary in your case):

$ pwd
/var/www/html/genome1
$ ../jbrowse/bin/prepare-refseqs.pl --conf ~/JBrowseConfig.js --refs 4
$ ../jbrowse/bin/biodb-to-json.pl --conf ~/JBrowseConfig.js
$ ../jbrowse/bin/generate-names.pl

Then you have to create an html file for each genome.  Something like this:

$ cd ../jbrowse/
$ cp index.html genome1.html

Now edit genome1.html.  Find the lines referring to refSeqs.js and
trackInfo.js:

<script type="text/javascript" src="data/refSeqs.js"></script>
<script type="text/javascript" src="data/trackInfo.js"></script>

and edit them to point to the genome1 directory, so that they look like
this:

<script type="text/javascript" src="../genome1/data/refSeqs.js"></script>
<script type="text/javascript" src="../genome1/data/trackInfo.js"></script>

These can be either absolute or relative URLs.

Now, find the "Browser" constructor in the same genome1.html file:

            var b = new Browser({
                                    containerID: "GenomeBrowser",
                                    refSeqs: refSeqs,
                                    trackData: trackInfo,
                                    defaultTracks:
"DNA,gene,mRNA,noncodingRNA",
                                    location: queryParams.loc,
                                    tracks: queryParams.tracks,
                                    bookmark: bookmarkCallback
                                });

and add the "dataRoot" parameter:

            var b = new Browser({
                                    containerID: "GenomeBrowser",
                                    refSeqs: refSeqs,
                                    trackData: trackInfo,
                                    defaultTracks:
"DNA,gene,mRNA,noncodingRNA",
                                    location: queryParams.loc,
                                    tracks: queryParams.tracks,
                                    bookmark: bookmarkCallback,
                                    dataRoot: "../genome1/"
                                });

The "dataRoot" parameter has to refer to a directory on the same server
that's serving the html page.  It can be either relative, with the ".."
parent directory paths in the URL, or it can start with a / and be
relative to the root on that server, like this:

                                    dataRoot: "/genome1/"

If you're generating the HTML with server-side code, you can do
something analogous.

So, to summarize, you need to do three main things:

1. run the jbrowse programs from the "data" directory's parent directory
2. make it so that the html page loads refSeqs.js and trackInfo.js from
the desired "data" directory
3. add the "dataRoot" parameter to the Browser constructor.

HTH,
Mitch

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax