Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some typos in the allele subsetting code #6265

Merged
merged 1 commit into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public static GenotypesContext subsetSomaticAlleles(final VCFHeader outputHeader
Set<String> keys = g.getExtendedAttributes().keySet();
for (final String key : keys) {
final VCFFormatHeaderLine headerLine = outputHeader.getFormatHeaderLine(key);
final int nonRefIndex = allelesToKeep.contains(Allele.NON_REF_ALLELE) ? allelesToKeep.indexOf(Allele.NON_REF_ALLELE) : -1;
gb.attribute(key, ReferenceConfidenceVariantContextMerger.generateAnnotationValueVector(headerLine.getCountType(),
GATKProtectedVariantContextUtils.attributeToList(g.getAnyAttribute(key)), relevantIndices));
}
Expand All @@ -155,7 +154,7 @@ public static GenotypesContext subsetSomaticAlleles(final VCFHeader outputHeader
*
* @param vc original variant context
* @param builder variant context builder with subset of original variant context's alleles
* @param keepOriginalChrCounts keep the orignal chromosome counts before subsetting
* @param keepOriginalChrCounts keep the original chromosome counts before subsetting
* @return variant context builder with updated INFO field attribute values
*/
public static void addInfoFieldAnnotations(final VariantContext vc, final VariantContextBuilder builder,
Expand All @@ -171,14 +170,14 @@ public static void addInfoFieldAnnotations(final VariantContext vc, final Varian
// don't have to subset, the original vc has the same number and hence, the same alleles
boolean keepOriginal = (vc.getAlleles().size() == alleles.size());

List<Integer> alleleIndecies = builder.getAlleles().stream().map(a -> vc.getAlleleIndex(a)).collect(Collectors.toList());
List<Integer> alleleIndices = builder.getAlleles().stream().map(vc::getAlleleIndex).collect(Collectors.toList());
if (keepOriginalChrCounts) {
if (vc.hasAttribute(VCFConstants.ALLELE_COUNT_KEY))
builder.attribute(GATKVCFConstants.ORIGINAL_AC_KEY, keepOriginal ?
vc.getAttribute(VCFConstants.ALLELE_COUNT_KEY) : alleleIndecies.stream().filter(i -> i > 0).map(j -> vc.getAttributeAsList(VCFConstants.ALLELE_COUNT_KEY).get(j - 1)).collect(Collectors.toList()).get(0));
vc.getAttribute(VCFConstants.ALLELE_COUNT_KEY) : alleleIndices.stream().filter(i -> i > 0).map(j -> vc.getAttributeAsList(VCFConstants.ALLELE_COUNT_KEY).get(j - 1)).collect(Collectors.toList()).get(0));
if (vc.hasAttribute(VCFConstants.ALLELE_FREQUENCY_KEY))
builder.attribute(GATKVCFConstants.ORIGINAL_AF_KEY, keepOriginal ?
vc.getAttribute(VCFConstants.ALLELE_FREQUENCY_KEY) : alleleIndecies.stream().filter(i -> i > 0).map(j -> vc.getAttributeAsList(VCFConstants.ALLELE_FREQUENCY_KEY).get(j - 1)).collect(Collectors.toList()).get(0));
vc.getAttribute(VCFConstants.ALLELE_FREQUENCY_KEY) : alleleIndices.stream().filter(i -> i > 0).map(j -> vc.getAttributeAsList(VCFConstants.ALLELE_FREQUENCY_KEY).get(j - 1)).collect(Collectors.toList()).get(0));
if (vc.hasAttribute(VCFConstants.ALLELE_NUMBER_KEY)) {
builder.attribute(GATKVCFConstants.ORIGINAL_AN_KEY, vc.getAttribute(VCFConstants.ALLELE_NUMBER_KEY));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public boolean equals(final Object o) {
*
* @throws IllegalArgumentException if {@code other} is {@code null}.
*
* @return {@code true} iff {@other} is not {@code null}, and contains exactly the same elements
* @return {@code true} iff {@code other} is not {@code null}, and contains exactly the same elements
* (as compared using {@link Object#equals} a this set with matching indices.
*/
public boolean equals(final IndexedSet<?> other) {
Expand Down Expand Up @@ -296,7 +296,7 @@ public E get(final int index) {
*/
public int indexOf(final Object o) {
Utils.nonNull(o, "the query object cannot be null");
return indexByElement.containsKey(o) ? indexByElement.get(o) : -1;
return indexByElement.getOrDefault(o, -1);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.List;

/**
* Represent a permutation of a ordered set or list of elements.
* Represent a permutation of an ordered set or list of elements.
*
* @author Valentin Ruano-Rubio &lt;[email protected]&gt;
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
//Note: Names in this interface are unusual because of name clash in a subclass.
// For example the name of AlleleList.alleleCount() cannot be simply size(), as would be usual,
// because {@link ReadLikelohoods} implements AlleleList and SampleList and then size() would be ambiguous.
// because {@link ReadLikelihoods} implements AlleleList and SampleList and then size() would be ambiguous.
public interface AlleleList<A extends Allele>{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.Collection;

/**
* Allele list implementation using and indexed-set.
* Allele list implementation using an indexed-set.
*
* @author Valentin Ruano-Rubio &lt;[email protected]&gt;
*/
Expand Down