Skip to content

Commit

Permalink
rm nested callbacks in GA4GHAlignment-test
Browse files Browse the repository at this point in the history
  • Loading branch information
akmorrow13 committed Sep 7, 2017
1 parent 074457c commit 74af57e
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions src/test/GA4GHAlignment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ import Bam from '../main/data/bam';

describe('GA4GHAlignment', function() {
var sampleAlignments = [];
var matchingBamAlignments = [];

before(function() {
return new RemoteFile('/test-data/alignments.ga4gh.1.10000-11000.json').getAllString().then(data => {
sampleAlignments = JSON.parse(data).alignments;
new RemoteFile('/test-data/alignments.ga4gh.chr17.1-250.json').getAllString().then(bamData => {
matchingBamAlignments = JSON.parse(bamData).alignments;
});
});
});

Expand All @@ -43,35 +39,41 @@ describe('GA4GHAlignment', function() {

it('should match SamRead', function() {
var bam = new Bam(new RemoteFile('/test-data/chr17.1-250.bam'));
return bam.readAll().then(({alignments: samReads}) => {
// This is a workaround. See https://github.com/ga4gh/server/issues/488
samReads.splice(-1, 1);
var json = new RemoteFile('/test-data/alignments.ga4gh.chr17.1-250.json');

expect(matchingBamAlignments.length).to.equal(samReads.length);
for (var i = 0; i < matchingBamAlignments.length; i++) {
var ga4gh = new GA4GHAlignment(matchingBamAlignments[i]),
bam = samReads[i];
expect(ga4gh.getSequence()).to.equal(bam.getSequence());
var interval = ga4gh.getInterval();
expect(interval.start()).to.equal(bam.pos);
json.getAllString().then(data => {
var matchingBamAlignments = JSON.parse(data).alignments;

// See https://github.com/ga4gh/server/issues/491
// expect(ga4gh.getStrand()).to.equal(bam.getStrand());
// For the if statement, see https://github.com/ga4gh/server/issues/492
var quality = ga4gh.getQualityScores();
if (quality.length) {
expect(quality).to.deep.equal(bam.getQualityScores());
}
expect(ga4gh.cigarOps).to.deep.equal(bam.cigarOps);
// After ga4gh#491, change this to a .deep.equal on getMateProperties()
var ga4ghMate = ga4gh.getMateProperties(),
bamMate = bam.getMateProperties();
expect(!!ga4ghMate).to.equal(!!bamMate);
if (ga4ghMate && bamMate) {
expect(ga4ghMate.ref).to.equal(bamMate.ref);
expect(ga4ghMate.pos).to.equal(bamMate.pos);
return bam.readAll().then(({alignments: samReads}) => {
// This is a workaround. See https://github.com/ga4gh/server/issues/488
samReads.splice(-1, 1);

expect(matchingBamAlignments.length).to.equal(samReads.length);
for (var i = 0; i < matchingBamAlignments.length; i++) {
var ga4gh = new GA4GHAlignment(matchingBamAlignments[i]),
bam = samReads[i];
expect(ga4gh.getSequence()).to.equal(bam.getSequence());
var interval = ga4gh.getInterval();
expect(interval.start()).to.equal(bam.pos);

// See https://github.com/ga4gh/server/issues/491
// expect(ga4gh.getStrand()).to.equal(bam.getStrand());
// For the if statement, see https://github.com/ga4gh/server/issues/492
var quality = ga4gh.getQualityScores();
if (quality.length) {
expect(quality).to.deep.equal(bam.getQualityScores());
}
expect(ga4gh.cigarOps).to.deep.equal(bam.cigarOps);
// After ga4gh#491, change this to a .deep.equal on getMateProperties()
var ga4ghMate = ga4gh.getMateProperties(),
bamMate = bam.getMateProperties();
expect(!!ga4ghMate).to.equal(!!bamMate);
if (ga4ghMate && bamMate) {
expect(ga4ghMate.ref).to.equal(bamMate.ref);
expect(ga4ghMate.pos).to.equal(bamMate.pos);
}
}
}
});
});
});
});

0 comments on commit 74af57e

Please sign in to comment.