-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
124 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
var Events = require('backbone').Events, | ||
_ = require('underscore'); | ||
|
||
|
||
var ContigInterval = require('./ContigInterval'); | ||
|
||
|
||
function createBigBedDataSource(remoteSource: BigBed) { | ||
// (ContigInterval, name) tuples | ||
var features = []; | ||
|
||
function addFeature(contigInterval, name) { | ||
for (var i = 0; i < features.length; i++) { | ||
var f = features[i]; | ||
if (f[0].isEqual(contigInterval)) return; | ||
} | ||
features.push([contigInterval, name]); | ||
} | ||
|
||
function getFeaturesInRange(range) { | ||
if (!range) return []; | ||
var contigInterval = new ContigInterval(range.contig, range.start, range.stop); | ||
return features.filter(x => contigInterval.intersects(x[0])); | ||
} | ||
|
||
function fetch(range: GenomeRange) { | ||
return remoteSource.getFeaturesInRange(range.contig, range.start, range.stop) | ||
.then(features => { | ||
features.forEach(f => { | ||
var range = new ContigInterval(f.contig, f.start, f.end); | ||
var info = f.rest.split('\t'); | ||
var strand = info[2]; // either + or - | ||
var ensembleId = info[0]; // e.g. ENST00000359597 | ||
var name = info[10]; // e.g. TP53 | ||
|
||
addFeature(range, name || ensembleId); | ||
}); | ||
}); | ||
} | ||
|
||
var o = { | ||
rangeChanged: function(newRange: GenomeRange) { | ||
fetch(newRange) | ||
.then(() => o.trigger('newdata', newRange)) | ||
.done(); | ||
}, | ||
getFeaturesInRange | ||
}; | ||
_.extend(o, Events); // Make this an event emitter | ||
|
||
return o; | ||
} | ||
|
||
module.exports = createBigBedDataSource; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var React = require('react/addons'), | ||
_ = require('underscore'), | ||
d3 = require('d3'), | ||
types = require('./types'); | ||
|
||
var GeneTrack = React.createClass({ | ||
propTypes: { | ||
range: types.GenomeRange, | ||
genes: React.PropTypes.array.isRequired | ||
}, | ||
render: function(): any { | ||
return ( | ||
<div className="genes"> | ||
{JSON.stringify(this.props.genes)} | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = GeneTrack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters