Skip to content

Commit

Permalink
added VCFTabix store. working and emitting features. still needs deep…
Browse files Browse the repository at this point in the history
…er parsing.
  • Loading branch information
rbuels committed Mar 7, 2013
1 parent 022f7e5 commit 4b97bf7
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 40 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
packages: [ 'dojo', 'dijit', 'dojox', 'jszlib',
{ name: 'lazyload', main: 'lazyload' },
'dgrid', 'xstyle', 'put-selector',
{ name: 'jDataView', location: 'jDataView/src', main: 'jdataview' },
'JBrowse'
]
},
Expand Down
1 change: 1 addition & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ echo -n "Formatting Volvox example data ...";
bin/add-track-json.pl docs/tutorial/data_files/volvox_sine.bw.conf sample_data/json/volvox/trackList.json
bin/add-track-json.pl docs/tutorial/data_files/volvox-sorted.bam.conf sample_data/json/volvox/trackList.json
bin/add-track-json.pl docs/tutorial/data_files/volvox-sorted.bam.coverage.conf sample_data/json/volvox/trackList.json
bin/add-track-json.pl docs/tutorial/data_files/volvox.vcf.gz.conf sample_data/json/volvox/trackList.json
bin/generate-names.pl -v --out sample_data/json/volvox;

# also recreate some symlinks used by tests and such
Expand Down
13 changes: 8 additions & 5 deletions src/JBrowse/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,11 +853,14 @@ Browser.prototype.getStore = function( storeName, callback ) {
}

require( [ storeClassName ], dojo.hitch( this, function( storeClass ) {
var storeArgs = dojo.mixin( conf,
{
browser: this,
refSeq: this.refSeq
});
var storeArgs = dojo.clone( conf );
dojo.mixin( storeArgs,
{
config: conf,
browser: this,
refSeq: this.refSeq
});

var store = new storeClass( storeArgs );
this._storeCache[ storeName ] = { refCount: 1, store: store };
callback( store );
Expand Down
23 changes: 20 additions & 3 deletions src/JBrowse/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
*/

define([
'dojo/_base/declare'
'dojo/_base/declare',
'JBrowse/Util'
],
function(
declare
declare,
Util
) {

return declare( null, {
Expand All @@ -19,10 +21,25 @@ return declare( null, {
this.config = this._mergeConfigs( dojo.clone( this._defaultConfig() ), this.config );

this.browser = args.browser;

this.compiledConfig = {};
},

_defaultConfig: function() {
return {};
return {
baseUrl: '/'
};
},

resolveUrl: function( url, args ) {
args = args || {};
return Util.resolveUrl(
this.getConf('baseUrl',[]),
Util.fillTemplate( url,
args
)
);

},

_mergeConfigs: function(a, b) {
Expand Down
11 changes: 8 additions & 3 deletions src/JBrowse/Model/TabixIndex.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
define([
'dojo/_base/declare',
'dojo/_base/array',
'dojo/_base/Deferred',
'jDataView',
'JBrowse/Util',
'JBrowse/Model/BGZip/VirtualOffset'
],
function(
declare,
array,
Deferred,
jDataView,
Util,
Expand Down Expand Up @@ -146,7 +148,7 @@ return declare( null, {
getRefSeqs: function( refSeqCallback, finishCallback, errorCallback ) {
var thisB = this;
thisB.load().then( function() {
array.forEach( this.refIDToName || [], function( name ) {
array.forEach( thisB._refIDToName || [], function( name ) {
refSeqCallback({ name: name });
});
finishCallback();
Expand All @@ -160,6 +162,9 @@ return declare( null, {
TAD_LIDX_SHIFT: 14,

blocksForRange: function( refName, beg, end ) {
if( beg < 0 )
beg = 0;

var tid = this.getRefId( refName );
var indexes = this._indices[tid];
if( ! indexes )
Expand All @@ -184,7 +189,7 @@ return declare( null, {
}

if( n_off == 0 )
return null;
return [];

var off = [];

Expand All @@ -196,7 +201,7 @@ return declare( null, {
off[n_off++] = new Chunk( chunks[j].minv, chunks[j].maxv, chunks[j].bin );

if( ! off.length )
return null;
return [];

off = off.sort( function(a,b) { return a.compareTo(b); } );

Expand Down
13 changes: 9 additions & 4 deletions src/JBrowse/Store.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
define( [ 'dojo/_base/declare'],
function( declare ) {
define( [
'dojo/_base/declare',
'JBrowse/Component'
],
function(
declare,
Component
) {

return declare( null,
return declare( Component,

/**
* @lends JBrowse.Store.prototype
Expand All @@ -14,7 +20,6 @@ return declare( null,
constructor: function( args ) {
this.refSeq = dojo.clone( args.refSeq );
this.changeCallback = args.changeCallback || function() {};
this.browser = args.browser;
},

notifyChanged: function( changeDescription ) {
Expand Down
32 changes: 17 additions & 15 deletions src/JBrowse/Store/SeqFeature/GlobalStatsEstimationMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@ return declare( null, {
_estimateGlobalStats: function( finishCallback ) {

var statsFromInterval = function( refSeq, length, callback ) {
var thisB = this;
var sampleCenter = refSeq.start*0.75 + refSeq.end*0.25;
var start = Math.max( 0, Math.round( sampleCenter - length/2 ) );
var end = Math.min( Math.round( sampleCenter + length/2 ), refSeq.end );
this.bam.fetch( refSeq.name, start, end, dojo.hitch( this, function( features, error) {
if ( error ) {
console.error( error );
callback.call( this, length, null, error );
}
else if( features ) {
features = array.filter( features, function(f) { return f.get('start') >= start && f.get('end') <= end; } );
callback.call( this, length,
{
featureDensity: features.length / length,
_statsSampleFeatures: features.length,
_statsSampleInterval: { ref: refSeq.name, start: start, end: end, length: length }
});
}
}));
var features = [];
this._getFeatures({ ref: refSeq.name, start: start, end: end},
function( f ) { features.push(f); },
function( error ) {
features = array.filter( features, function(f) { return f.get('start') >= start && f.get('end') <= end; } );
callback.call( thisB, length,
{
featureDensity: features.length / length,
_statsSampleFeatures: features.length,
_statsSampleInterval: { ref: refSeq.name, start: start, end: end, length: length }
});
},
function( error ) {
console.error( error );
callback.call( thisB, length, null, error );
});
};

var maybeRecordStats = function( interval, stats, error ) {
Expand Down

0 comments on commit 4b97bf7

Please sign in to comment.