Fix bug in ReadThreadingAssembler in cycle failures causing NPE
This commit is contained in:
parent
e3e8631ff5
commit
ed0b1c5aba
|
|
@ -99,13 +99,18 @@ public class ReadThreadingAssembler extends LocalAssemblyEngine {
|
||||||
this.justReturnRawGraph = justReturnRawGraph;
|
this.justReturnRawGraph = justReturnRawGraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addResult(final List<AssemblyResult> results, final AssemblyResult maybeNullResult) {
|
||||||
|
if ( maybeNullResult != null )
|
||||||
|
results.add(maybeNullResult);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AssemblyResult> assemble(final List<GATKSAMRecord> reads, final Haplotype refHaplotype, final List<Haplotype> activeAlleleHaplotypes) {
|
public List<AssemblyResult> assemble(final List<GATKSAMRecord> reads, final Haplotype refHaplotype, final List<Haplotype> activeAlleleHaplotypes) {
|
||||||
final List<AssemblyResult> results = new LinkedList<>();
|
final List<AssemblyResult> results = new LinkedList<>();
|
||||||
|
|
||||||
// first, try using the requested kmer sizes
|
// first, try using the requested kmer sizes
|
||||||
for ( final int kmerSize : kmerSizes ) {
|
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
|
// 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;
|
int numIterations = 1;
|
||||||
while ( results.isEmpty() && numIterations <= MAX_KMER_ITERATIONS_TO_ATTEMPT ) {
|
while ( results.isEmpty() && numIterations <= MAX_KMER_ITERATIONS_TO_ATTEMPT ) {
|
||||||
// on the last attempt we will allow low complexity graphs
|
// 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;
|
kmerSize += KMER_SIZE_ITERATION_INCREASE;
|
||||||
numIterations++;
|
numIterations++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue