Skip to content

Commit

Permalink
Merge pull request #3853 from Mark-de-Haan/fix/3838
Browse files Browse the repository at this point in the history
Fix #3838 Tabix based annotator fails if chromosome is not present in the tabix resource
  • Loading branch information
fdlk committed Oct 7, 2015
2 parents 568230a + 92f9f7f commit a4c63bc
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,26 @@ public Iterable<Entity> findAll(Query q)
public synchronized List<Entity> query(String chrom, long posFrom, long posTo)
{
String queryString = String.format("%s:%s-%s", checkNotNull(chrom), checkNotNull(posFrom), checkNotNull(posTo));
Collection<String> lines = getLines(tabixReader.query(queryString));
return lines.stream().map(line -> line.split("\t")).map(vcfToEntitySupplier.get()::toEntity)
.filter(entity -> positionMatches(entity, posFrom, posTo)).collect(Collectors.toList());
try
{
Collection<String> lines = getLines(tabixReader.query(queryString));
return lines.stream().map(line -> line.split("\t")).map(vcfToEntitySupplier.get()::toEntity)
.filter(entity -> positionMatches(entity, posFrom, posTo)).collect(Collectors.toList());
}
catch (NullPointerException e)
{
LOG.warn("Unable to read from tabix resource for query: " + queryString
+ " (Position not present in resource file?)");
LOG.debug("", e);
}
catch (ArrayIndexOutOfBoundsException e)
{
LOG.warn("Unable to read from tabix resource for query: " + queryString
+ " (Chromosome not present in resource file?)");
LOG.debug("", e);
}

return Collections.emptyList();
}

/**
Expand Down

0 comments on commit a4c63bc

Please sign in to comment.