-
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
12 changed files
with
149 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
declare function describe(description: string, spec: () => void): void; | ||
declare function it(expectation: string, assertion: (done: () => void) => void): void; | ||
declare function afterEach(fn: () => void): void; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* @flow */ | ||
'use strict'; | ||
|
||
var chai = require('chai'); | ||
var expect = chai.expect; | ||
|
||
var Q = require('q'); | ||
|
||
var React = require('react/addons'), | ||
TwoBit = require('../src/TwoBit'), | ||
BigBed = require('../src/BigBed'), | ||
Root = require('../src/Root'), | ||
createTwoBitDataSource = require('../src/TwoBitDataSource'), | ||
createBigBedDataSource = require('../src/BigBedDataSource'); | ||
|
||
|
||
var WAIT_FOR_POLL_INTERVAL_MS = 100; | ||
function waitFor(predFn, timeoutMs) { | ||
var def = Q.defer(); | ||
|
||
var checkTimeoutId = null; | ||
|
||
var timeoutId = window.setTimeout(() => { | ||
if (checkTimeoutId) window.clearTimeout(checkTimeoutId); | ||
def.reject('Timed out'); | ||
}, timeoutMs); | ||
|
||
var check = function() { | ||
if (def.promise.isRejected()) return; | ||
if (predFn()) { | ||
def.resolve(null); // no arguments needed | ||
window.clearTimeout(timeoutId); | ||
} else { | ||
checkTimeoutId = window.setTimeout(check, WAIT_FOR_POLL_INTERVAL_MS); | ||
} | ||
}; | ||
checkTimeoutId = window.setTimeout(check, 0); | ||
|
||
return def.promise; | ||
} | ||
|
||
|
||
describe('Root component', function() { | ||
var genome = new TwoBit('/test/data/test.2bit'); | ||
var dataSource = createTwoBitDataSource(genome); | ||
|
||
// This file contains just the TP53 gene, shifted so that it starts at the | ||
// beginning of chr17 (to match test.2bit). See test/data/README.md. | ||
var ensembl = new BigBed('/test/data/tp53.shifted.bb'); | ||
var ensemblDataSource = createBigBedDataSource(ensembl); | ||
|
||
var testDiv = document.getElementById('testdiv'); | ||
|
||
afterEach(function() { | ||
testDiv.innerHTML = ''; // avoid pollution between tests. | ||
}); | ||
|
||
it('should render reference genome and genes', function(done) { | ||
this.timeout(5000); | ||
|
||
var div = document.createElement('div'); | ||
div.setAttribute('style', 'width: 800px; height: 200px;'); | ||
testDiv.appendChild(div); | ||
|
||
// TODO: changing to {start:1, stop:50} makes the test fail. | ||
React.render(<Root referenceSource={dataSource} | ||
geneSource={ensemblDataSource} | ||
initialRange={{contig:"chr17", start: 100, stop: 150}} />, div); | ||
|
||
var ready = (() => | ||
div.querySelectorAll('.basepair').length > 0 && | ||
div.querySelectorAll('.gene').length > 0 | ||
); | ||
|
||
waitFor(ready, 5000) | ||
.then(() => { | ||
var basepairs = div.querySelectorAll('.basepair'); | ||
expect(basepairs).to.have.length.at.least(10); | ||
var geneNames = div.querySelectorAll('.gene text'); | ||
expect(geneNames.length).to.equal(1); | ||
expect(geneNames[0].textContent).to.equal('TP53'); | ||
|
||
// Note: there are 11 exons, but two are split into coding/non-coding | ||
expect(div.querySelectorAll('.gene .exon').length).to.equal(13); | ||
done(); | ||
}) | ||
.done(); | ||
}); | ||
}); |
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,49 @@ | ||
This directory contains many small data files used in testing. | ||
|
||
This file documents how they were generated. | ||
|
||
|
||
#### test.2bit | ||
|
||
This is a small subset of the hg19 reference genome. It contains small swaths | ||
of chr1 and chr22 and a larger swath of chr17. It was generated from hg19.2bit | ||
using UCSC tools: | ||
|
||
curl -O http://www.biodalliance.org/datasets/hg19.2bit | ||
twoBitToFa -seqList=./test/data/seqList.txt hg19.2bit /tmp/extract.fa | ||
perl -i -pe 's/:.*//' /tmp/extract.fa | ||
faToTwoBit /tmp/extract.fa test/data/test.2bit | ||
|
||
|
||
#### itemRgb.bb, itemRgb.bed | ||
|
||
This file was generated from UCSC test data: | ||
|
||
cd kent/src/utils/bedToBigBed/tests | ||
make | ||
cp output/itemRgb.bb $PILEUP/test/data/ | ||
|
||
It is compressed, little endian, has autoSQL and two blocks. | ||
|
||
`itemRgb.bed` is copied unmodified from `bedToBigBed/tests/input`. | ||
|
||
|
||
#### ensembl.chr17.bb | ||
|
||
This file is derived from `ensGene.bb`. It contains just the genes on chr17. | ||
|
||
curl -O http://www.biodalliance.org/datasets/ensGene.bb | ||
bigBedToBed ensGene.bb ensGene.bed | ||
grep '^chr17\t' ensGene.bed > /tmp/ensGene17.bed | ||
bedToBigBed -type=bed12+2 /tmp/ensGene17.bed <(echo "chr17 78774742") test/data/ensembl.chr17.bb | ||
|
||
#### tp53.shifted.bb | ||
|
||
This is a subset of `ensembl.chr17.bb`, shifted to match the coordinates in | ||
`test.2bit`: | ||
|
||
curl -O http://www.biodalliance.org/datasets/ensGene.bb | ||
bigBedToBed ensGene.bb ensGene.bed | ||
grep '^chr17\t' ensGene.bed | grep TP53 | perl -pe 's/(75\d{4,})/$1-7512444/ge' > /tmp/tp53.shifted.bed | ||
bedToBigBed -type=bed12+2 /tmp/tp53.shifted.bed <(echo "chr17 78774742") test/data/tp53.shifted.bb | ||
|
File renamed without changes.
Binary file not shown.
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