Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable timeout and handle the dataoverflow error during stats estimation #730

Merged
merged 2 commits into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/JBrowse/Store/SeqFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ return declare( Store,

constructor: function( args ) {
this.globalStats = {};
this.storeTimeout = args.storeTimeout || 500;
},

_evalConf: function( confVal, confKey ) {
Expand Down
2 changes: 2 additions & 0 deletions src/JBrowse/Store/SeqFeature/BAM.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ var BAMStore = declare( [ SeqFeatureStore, DeferredStatsMixin, DeferredFeaturesM
}),
failure: lang.hitch( this, '_failAllDeferred' )
});

this.storeTimeout = args.storeTimeout || 3000;
},

/**
Expand Down
2 changes: 2 additions & 0 deletions src/JBrowse/Store/SeqFeature/BigWig.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ return declare([ SeqFeatureStore, DeferredFeaturesMixin, DeferredStatsMixin ],

this.name = args.name || ( this.data.url && new urlObj( this.data.url ).path.replace(/^.+\//,'') ) || 'anonymous';

this.storeTimeout = 3000;

this._load();
},

Expand Down
19 changes: 13 additions & 6 deletions src/JBrowse/Store/SeqFeature/GlobalStatsEstimationMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
define([
'dojo/_base/declare',
'dojo/_base/array',
'dojo/Deferred'
'dojo/Deferred',
'JBrowse/Errors'
],
function( declare, array, Deferred ) {
function( declare, array, Deferred, Errors ) {

return declare( null, {

Expand All @@ -22,6 +23,7 @@ return declare( null, {
var deferred = new Deferred();

refseq = refseq || this.refSeq;
var timeout = this.storeTimeout || 3000;

var startTime = new Date();

Expand All @@ -43,20 +45,25 @@ return declare( null, {
});
},
function( error ) {
console.error( error );
callback.call( thisB, length, null, error );
});
};

var maybeRecordStats = function( interval, stats, error ) {
if( error ) {
deferred.reject( error );
if( error.isInstanceOf(Errors.DataOverflow) ) {
console.log( 'Store statistics found chunkSizeLimit error, using empty: '+(this.source||this.name) );
deferred.resolve( { featureDensity: 0, error: 'global stats estimation found chunkSizeError' } );
}
else {
deferred.reject( error );
}
} else {
var refLen = refseq.end - refseq.start;
var refLen = refseq.end - refseq.start;
if( stats._statsSampleFeatures >= 300 || interval * 2 > refLen || error ) {
console.log( 'Store statistics: '+(this.source||this.name), stats );
deferred.resolve( stats );
} else if( ((new Date()) - startTime) < 500 ) {
} else if( ((new Date()) - startTime) < timeout ) {
statsFromInterval.call( this, interval * 2, maybeRecordStats );
} else {
console.log( 'Store statistics timed out: '+(this.source||this.name) );
Expand Down
2 changes: 2 additions & 0 deletions src/JBrowse/Store/SeqFeature/VCFTabix.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ return declare( [ SeqFeatureStore, DeferredStatsMixin, DeferredFeaturesMixin, Gl
},
lang.hitch( thisB, '_failAllDeferred' )
);

this.storeTimeout = args.storeTimeout || 3000;
},

/** fetch and parse the VCF header lines */
Expand Down