Skip to content

Commit

Permalink
Fix for incorrect return value in Genotype.getAnyAttribute()
Browse files Browse the repository at this point in the history
* The Genotype.getAnyAttribute() incorrectly handles converting int[] to
  List<Integer>.  Both getAD() and getPL() return an int[], and doing
  Arrays.asList(int[]) will return a List<int[]> instead of List<Integer>.

See: #274
  • Loading branch information
Dan Surdyk authored and Nils Homer committed Jul 23, 2015
1 parent 1cfa618 commit b2638e0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/java/htsjdk/variant/variantcontext/Genotype.java
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,19 @@ public Object getAnyAttribute(final String key) {
} else if (key.equals(VCFConstants.GENOTYPE_QUALITY_KEY)) {
return getGQ();
} else if (key.equals(VCFConstants.GENOTYPE_ALLELE_DEPTHS)) {
return Arrays.asList(getAD());
if (hasAD()) {
final List<Integer> intList = new ArrayList<Integer>(getAD().length);
for(int i : getAD()) intList.add(i);
return intList;
}
return Collections.EMPTY_LIST;
} else if (key.equals(VCFConstants.GENOTYPE_PL_KEY)) {
return Arrays.asList(getPL());
if (hasPL()) {
final List<Integer> intList = new ArrayList<Integer>(getPL().length);
for(int i : getPL()) intList.add(i);
return intList;
}
return Collections.EMPTY_LIST;
} else if (key.equals(VCFConstants.DEPTH_KEY)) {
return getDP();
} else {
Expand Down

0 comments on commit b2638e0

Please sign in to comment.