Skip to content

Commit

Permalink
Add grouping by name
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 12, 2017
1 parent 1428b4c commit 7b23670
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/JBrowse/Store/SeqFeature/BigBed.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ define( [
'dojo/_base/lang',
'dojo/_base/array',
'./BigWig',
'./BigWig/Window'
'./BigWig/Window',
'JBrowse/Model/SimpleFeature'
],
function(
declare,
lang,
array,
BigWig,
Window
Window,
SimpleFeature
) {
return declare(BigWig,

Expand All @@ -32,7 +34,28 @@ return declare(BigWig,
}

v.readWigData( chrName, min, max, dojo.hitch( this, function( features ) {
array.forEach( features || [], featureCallback );
var genes = {};
array.forEach( features || [], function(feature) {
var id = feature.get('id');
if(!genes[id]) {
genes[id] = new SimpleFeature({
id: feature.get('id'),
data: {
start: feature.get('start'),
end: feature.get('end'),
type: 'gene',
name: feature.get('name'),
id: feature.get('id'),
subfeatures: []
}
});
}
feature.data.name = null;
genes[id].data.subfeatures.push(feature);
});
Object.keys(genes).forEach(function(name) {
featureCallback(genes[name]);
});
endCallback();
}), errorCallback );
},
Expand Down

0 comments on commit 7b23670

Please sign in to comment.