From ed0b1c5abab1d0a8c3a26211940ead415720a189 Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Tue, 25 Jun 2013 10:53:33 -0400 Subject: [PATCH] Fix bug in ReadThreadingAssembler in cycle failures causing NPE --- .../readthreading/ReadThreadingAssembler.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/readthreading/ReadThreadingAssembler.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/readthreading/ReadThreadingAssembler.java index ee35efebd..d575f14a5 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/readthreading/ReadThreadingAssembler.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/readthreading/ReadThreadingAssembler.java @@ -99,13 +99,18 @@ public class ReadThreadingAssembler extends LocalAssemblyEngine { this.justReturnRawGraph = justReturnRawGraph; } + private void addResult(final List results, final AssemblyResult maybeNullResult) { + if ( maybeNullResult != null ) + results.add(maybeNullResult); + } + @Override public List assemble(final List reads, final Haplotype refHaplotype, final List activeAlleleHaplotypes) { final List results = new LinkedList<>(); // first, try using the requested kmer sizes for ( final int kmerSize : kmerSizes ) { - results.add(createGraph(reads, refHaplotype, kmerSize, activeAlleleHaplotypes, dontIncreaseKmerSizesForCycles)); + addResult(results, createGraph(reads, refHaplotype, kmerSize, activeAlleleHaplotypes, dontIncreaseKmerSizesForCycles)); } // if none of those worked, iterate over larger sizes if allowed to do so @@ -114,7 +119,7 @@ public class ReadThreadingAssembler extends LocalAssemblyEngine { int numIterations = 1; while ( results.isEmpty() && numIterations <= MAX_KMER_ITERATIONS_TO_ATTEMPT ) { // on the last attempt we will allow low complexity graphs - results.add(createGraph(reads, refHaplotype, kmerSize, activeAlleleHaplotypes, numIterations == MAX_KMER_ITERATIONS_TO_ATTEMPT)); + addResult(results, createGraph(reads, refHaplotype, kmerSize, activeAlleleHaplotypes, numIterations == MAX_KMER_ITERATIONS_TO_ATTEMPT)); kmerSize += KMER_SIZE_ITERATION_INCREASE; numIterations++; }