Skip to content

Commit

Permalink
Variant json works when length is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
akmorrow13 committed Jun 21, 2019
1 parent a9165cd commit fb29859
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/json/GA4GHVariantJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ function create(json: string): VcfDataSource {
// fill variants with json
if (!_.isEmpty(parsedJson)) {
variants = _.values(parsedJson.variants).map(variant => new VariantContext(Variant.fromGA4GH(variant),variant.calls));
callSetNames = _.map(variants[0].calls, c => c.callSetName);
if (variants.length > 0) { // only call variants if non-empty
callSetNames = _.map(variants[0].calls, c => c.callSetName);
}
}

function rangeChanged(newRange: GenomeRange) {
Expand Down
14 changes: 13 additions & 1 deletion src/test/json/GA4GHVariantJson-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('GA4GHVariantJson', function() {
});

it('should filter variants from json', function(done) {

var source = GA4GHVariantJson.create(json);

var requestInterval = new ContigInterval('1', 10000, 10500);
Expand Down Expand Up @@ -62,4 +62,16 @@ describe('GA4GHVariantJson', function() {

});

it('should not fail when there are no variants', function(done) {

var source = GA4GHVariantJson.create("{\"variants\": []}");

var requestInterval = new ContigInterval('1', 10, 20);

var variants = source.getVariantsInRange(requestInterval);
expect(variants).to.have.length(0);
done();

});

});

0 comments on commit fb29859

Please sign in to comment.