Skip to content

Commit

Permalink
replaced some iterators with indexed-for-lists in hopes of making an …
Browse files Browse the repository at this point in the history
…impact on the world
  • Loading branch information
jamesemery committed Jan 28, 2019
1 parent 9c0e2ae commit b3f376f
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,18 @@ public List<VariantContext> calculateRefConfidence(final Haplotype refHaplotype,
final String sampleName = readLikelihoods.getSample(0);

final int globalRefOffset = refSpan.getStart() - activeRegion.getExtendedSpan().getStart();
for ( final ReadPileup pileup : refPileups ) {
for (int i = 0, size = refPileups.size(); i < size; i++) {
ReadPileup pileup = refPileups.get(i);
final Locatable curPos = pileup.getLocation();
final int offset = curPos.getStart() - refSpan.getStart();

final VariantContext overlappingSite = GATKVariantContextUtils.getOverlappingVariantContext(curPos, variantCalls);
final List<VariantContext> currentPriors = getMatchingPriors(curPos, overlappingSite, VCpriors);
if ( overlappingSite != null && overlappingSite.getStart() == curPos.getStart() ) {
if (overlappingSite != null && overlappingSite.getStart() == curPos.getStart()) {
if (applyPriors) {
results.add(PosteriorProbabilitiesUtils.calculatePosteriorProbs(overlappingSite, currentPriors,
numRefSamplesForPrior, options));
}
else {
} else {
results.add(overlappingSite);
}
} else {
Expand Down Expand Up @@ -422,9 +422,15 @@ protected static boolean isAltAfterAssembly(final PileupElement element, final b
* @param priorList priors within the current ActiveRegion
* @return prior VCs representing the same variant position as call
*/
List<VariantContext> getMatchingPriors(final Locatable curPos, final VariantContext call, final List<VariantContext> priorList) {
private List<VariantContext> getMatchingPriors(final Locatable curPos, final VariantContext call, final List<VariantContext> priorList) {
final int position = call != null ? call.getStart() : curPos.getStart();
return priorList.stream().filter(vc -> position == vc.getStart()).collect(Collectors.toList());
List<VariantContext> list = new ArrayList<>(priorList.size());
for (int i = 0, size = priorList.size(); i < size; i++) {
if (position == priorList.get(i).getStart()) {
list.add(priorList.get(i));
}
}
return list;
}

/**
Expand Down

0 comments on commit b3f376f

Please sign in to comment.