Skip to content

Commit

Permalink
Merge branch 'backcompat_1_2_1', fixes #75
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuels committed Mar 19, 2012
2 parents 149e4b1 + ad94c59 commit 61d79a2
Show file tree
Hide file tree
Showing 88 changed files with 2,208 additions and 790 deletions.
7 changes: 2 additions & 5 deletions bin/prepare-refseqs.pl
Expand Up @@ -247,11 +247,8 @@ =head1 OPTIONS
'label' => $seqTrackName,
'key' => $seqTrackName,
'type' => "SequenceTrack",
'config' =>
{
'chunkSize' => $chunkSize,
'urlTemplate' => "$seqRel/{refseq}/",
}
'chunkSize' => $chunkSize,
'urlTemplate' => "$seqRel/{refseq}/",
};
return $trackList;
});
Expand Down
80 changes: 80 additions & 0 deletions compat_121.html
@@ -0,0 +1,80 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>JBrowse</title>
<link rel="stylesheet" type="text/css" href="jslib/dijit/themes/tundra/tundra.css"></link>
<link rel="stylesheet" type="text/css" href="jslib/dojo/resources/dojo.css"></link>
<link rel="stylesheet" type="text/css" href="genome.css"></link>

<script type="text/javascript" src="jslib/dojo/dojo.js" djConfig="isDebug: false"></script>
<script type="text/javascript" src="jslib/dojo/jbrowse_dojo.js" ></script>

<!-- js_source_files -->
<!-- the files between the "js_source_files" comments get replaced
when the JS gets minified (see the minification rule in the Makefile) -->
<script type="text/javascript" src="js/Browser.js"></script>
<script type="text/javascript" src="js/ConfigAdaptor/JB_json_v1.js"></script>
<script type="text/javascript" src="js/ConfigAdaptor/JB_json_v0.js"></script>
<script type="text/javascript" src="js/Util.js"></script>
<script type="text/javascript" src="js/ArrayRepr.js"></script>
<script type="text/javascript" src="js/NCList.js"></script>
<script type="text/javascript" src="js/NCList_v0.js"></script>
<script type="text/javascript" src="js/LazyPatricia.js"></script>
<script type="text/javascript" src="js/LazyArray.js"></script>
<script type="text/javascript" src="js/Track.js"></script>
<script type="text/javascript" src="js/SequenceTrack.js"></script>
<script type="text/javascript" src="js/Layout.js"></script>

<script type="text/javascript" src="js/Store.js"></script>
<script type="text/javascript" src="js/SeqFeatureStore.js"></script>
<script type="text/javascript" src="js/SeqFeatureStore/NCList.js"></script>
<script type="text/javascript" src="js/SeqFeatureStore/NCList_v0.js"></script>
<script type="text/javascript" src="js/TiledImageStore/Fixed.js"></script>
<script type="text/javascript" src="js/TiledImageStore/Fixed_v0.js"></script>
<script type="text/javascript" src="js/SequenceStore/StaticChunked.js"></script>

<script type="text/javascript" src="js/FeatureTrack.js"></script>
<script type="text/javascript" src="js/StaticTrack.js"></script>
<script type="text/javascript" src="js/GridTrack.js"></script>
<script type="text/javascript" src="js/ImageTrack.js"></script>
<script type="text/javascript" src="js/GenomeView.js"></script>
<script type="text/javascript" src="js/touchJBrowse.js"></script>

<script type="text/javascript">
window.onerror=function(msg){
document.body.setAttribute("JSError",msg);
}
</script>

<!-- js_source_files -->

<script type="text/javascript">
/* <![CDATA[ */
var queryParams = dojo.queryToObject( window.location.search.slice(1) );
var dataRoot = queryParams.data || 'data';
var b = new Browser({
include: { url: dataRoot+"/trackInfo.js", version: 0 },

containerID: "GenomeBrowser",
refSeqs: dataRoot+"/refSeqs.js",
nameUrl: dataRoot + "/names/root.json",
defaultTracks: "DNA,gene,mRNA,noncodingRNA",
queryParams: queryParams,
location: queryParams.loc,
forceTracks: queryParams.tracks,
show_nav: queryParams.nav,
show_tracklist: queryParams.tracklist,
show_overview: queryParams.overview
});
/* ]]> */
</script>
</head>

<body>
<div id="GenomeBrowser" style="height: 100%; width: 100%; padding: 0; border: 0;"></div>
</body>
</html>
17 changes: 13 additions & 4 deletions index.html
Expand Up @@ -17,6 +17,8 @@
<!-- the files between the "js_source_files" comments get replaced
when the JS gets minified (see the minification rule in the Makefile) -->
<script type="text/javascript" src="js/Browser.js"></script>
<script type="text/javascript" src="js/ConfigAdaptor/JB_json_v1.js"></script>
<script type="text/javascript" src="js/ConfigAdaptor/JB_json_v0.js"></script>
<script type="text/javascript" src="js/Util.js"></script>
<script type="text/javascript" src="js/ArrayRepr.js"></script>
<script type="text/javascript" src="js/NCList.js"></script>
Expand All @@ -25,6 +27,13 @@
<script type="text/javascript" src="js/Track.js"></script>
<script type="text/javascript" src="js/SequenceTrack.js"></script>
<script type="text/javascript" src="js/Layout.js"></script>

<script type="text/javascript" src="js/Store.js"></script>
<script type="text/javascript" src="js/SeqFeatureStore.js"></script>
<script type="text/javascript" src="js/SeqFeatureStore/NCList.js"></script>
<script type="text/javascript" src="js/TiledImageStore/Fixed.js"></script>
<script type="text/javascript" src="js/SequenceStore/StaticChunked.js"></script>

<script type="text/javascript" src="js/FeatureTrack.js"></script>
<script type="text/javascript" src="js/StaticTrack.js"></script>
<script type="text/javascript" src="js/GridTrack.js"></script>
Expand All @@ -46,15 +55,15 @@
var dataRoot = queryParams.data || 'data';
var b = new Browser({
containerID: "GenomeBrowser",
refSeqs: {url: dataRoot + "/seq/refSeqs.json"},
tracklists: [
{url: dataRoot + "/trackList.json"}
refSeqs: dataRoot + "/seq/refSeqs.json",
include: [
dataRoot + "/trackList.json",
],
nameUrl: dataRoot + "/names/root.json",
defaultTracks: "DNA,gene,mRNA,noncodingRNA",
queryParams: queryParams,
location: queryParams.loc,
tracks: queryParams.tracks,
forceTracks: queryParams.tracks,
show_nav: queryParams.nav,
show_tracklist: queryParams.tracklist,
show_overview: queryParams.overview
Expand Down
136 changes: 119 additions & 17 deletions js/ArrayRepr.js
@@ -1,26 +1,43 @@
/*
class for operating on indexed representations of objects
// MODEL

/**
@class
@constructor
@description
Class for operating on indexed array representations of objects.
For example, if we have a lot of objects with similar attrbutes, e.g.:
For example, if we have a lot of objects with similar attributes, e.g.:
<pre class="code">
[
{start: 1, end: 2, strand: -1},
{start: 5, end: 6, strand: 1},
...
]
</pre>
@description
we can represent them more compactly (e.g., in JSON) something like this:
<pre class="code">
class = ["start", "end", "strand"]
[
[1, 2, -1],
[5, 6, 1],
...
]
</pre>
If we want to represent a few different kinds of objects in our big list,
we can have multiple "class" arrays, and tag each object to identify
which "class" array describes it.
For example, if we have a lot of instances of a few types of objects,
like this:
<pre class="code">
[
{start: 1, end: 2, strand: 1, id: 1},
{start: 5, end: 6, strand: 1, id: 2},
Expand All @@ -29,8 +46,12 @@
{start: 30, end: 40, chunk: 2},
...
]
</pre>
We could use the first array position to indicate the "class" for the
object, like this:
<pre class="code">
classes = [["start", "end", "strand", "id"], ["start", "end", "chunk"]]
[
[0, 1, 2, 1, 1],
Expand All @@ -39,13 +60,18 @@
[1, 10, 20, 1],
[1, 30, 40, 1]
]
</pre>
Also, if we occasionally want to add an ad-hoc attribute, we could just
stick an optional dictionary onto the end:
<pre class="code">
classes = [["start", "end", "strand", "id"], ["start", "end", "chunk"]]
[
[0, 1, 2, 1, 1],
[0, 5, 6, 1, 2, {foo: 1}]
]
</pre>
Given that individual objects are being represented by arrays, generic
code needs some way to differentiate arrays that are meant to be objects
Expand All @@ -59,15 +85,15 @@
In the end, we get something like this:
<pre class="code">
classes=[
{'attributes': ['Start', 'End', 'Subfeatures'],
'proto': {'Chrom': 'chr1'},
'isArrayAttr': {Subfeatures: true}}
]
</pre>
That's what this class facilitates.
"""
*/
function ArrayRepr (classes) {
this.classes = classes;
Expand All @@ -84,6 +110,9 @@ function ArrayRepr (classes) {
}
}

/**
* @private
*/
ArrayRepr.prototype.attrIndices = function(attr) {
return this.classes.map(
function(x) {
Expand All @@ -107,12 +136,6 @@ ArrayRepr.prototype.get = function(obj, attr) {
}
};

ArrayRepr.prototype.fastGet = function(obj, attr) {
// can be used only if attr is guaranteed to be in
// the "classes" array for this object
return obj[self.fields[obj[0]][attr]];
};

ArrayRepr.prototype.set = function(obj, attr, val) {
if (attr in this.fields[obj[0]]) {
obj[this.fields[obj[0]][attr]] = val;
Expand All @@ -124,12 +147,6 @@ ArrayRepr.prototype.set = function(obj, attr, val) {
}
};

ArrayRepr.prototype.fastSet = function(obj, attr, val) {
// can be used only if attr is guaranteed to be in
// the "classes" array for this object
obj[this.fields[obj[0]][attr]] = val;
};

ArrayRepr.prototype.makeSetter = function(attr) {
var self = this;
return function(obj, val) { self.set(obj, attr, val); };
Expand Down Expand Up @@ -170,6 +187,91 @@ ArrayRepr.prototype.construct = function(self, obj, klass) {
return result;
};


/**
Returns fast pre-compiled getter and setter functions for use with
Arrays that use this representation.
When the returned <code>get</code> and <code>set</code> functions are
added as methods to an Array that contains data in this
representation, they provide fast access by name to the data.
@returns {Object} <code>{ get: function() {...}, set: function(val) {...} }</code>
@example
var accessors = attrs.accessors();
var feature = get_feature_from_someplace();
feature.get = accessors.get;
// print out the feature start and end
console.log( feature.get('start') + ',' + feature.get('end') );
*/
ArrayRepr.prototype.accessors = function () {
return this._accessors = this._accessors || this._makeAccessors();
};

/**
* @private
*/
ArrayRepr.prototype._makeAccessors = function() {
var that = this,
accessors = {
get: function(field) {
var f = this.get.field_accessors[field];
if( f )
return f.call(this);
else
return undefined;
},
set: function(field,val) {
var f = this.set.field_accessors[field];
if( f )
return f.call(this,val);
else
return undefined;
}
};
accessors.get.field_accessors = {};
accessors.set.field_accessors = {};

// make a data structure as: { attr_name: [offset,offset,offset], }
// that will be convenient for finding the location of the attr
// for a given class like: indexForAttr{attrname}[classnum]
var indices = {};
dojo.forEach( this.classes, function(cdef,classnum) {
dojo.forEach( cdef.attributes || [], function(attrname,offset) {
attrname = attrname.toLowerCase();
indices[attrname] = indices[attrname] || [];
indices[attrname][classnum] = offset + 1;
});
});

// use that to make precalculated get and set accessors for each field
for( var attrname in indices ) {
if( ! indices.hasOwnProperty(attrname) ) continue;

// get
accessors.get.field_accessors[ attrname ] = (function() {
var attr_indices = indices[attrname];
return !attr_indices ? function() { return undefined; } : function() {
return this[ attr_indices[ this[0] ] ];
};
})();

// set
accessors.set.field_accessors[ attrname ] = (function() {
var attr_indices = indices[attrname];
return !attr_indices ? function() { return undefined; } : function(v) {
return ( this[ attr_indices[ this[0] ] ] = v );
};
})();
}


return accessors;
};

/*
Copyright (c) 2007-2010 The Evolutionary Software Foundation
Expand Down

0 comments on commit 61d79a2

Please sign in to comment.