Skip to content
Permalink
Browse files

Fixes tricky NPE in assembleContigs.

  • Loading branch information...
dbolotin committed Aug 28, 2019
1 parent bb88ab6 commit ebccfbad6c88654cd93df4e115ebfccfbccf24b2
@@ -0,0 +1 @@
Fixes `NPE` in very rare cases with incompatible V gene selection for `assembleContigs` in case of partially annotated gene libraries
@@ -136,10 +136,10 @@ public FullSeqAssembler(CloneFactory cloneFactory,
this.alignerParameters = alignerParameters;
GeneFeature[] assemblingFeatures = clone.getParentCloneSet().getAssemblingFeatures();
if (assemblingFeatures.length != 1)
throw new IllegalArgumentException();
throw new IllegalArgumentException("Supports only singular assemblingFeature.");

if (assemblingFeatures[0].isComposite())
throw new IllegalArgumentException();
throw new IllegalArgumentException("Supports only non-composite gene features as an assemblingFeature.");

this.assemblingFeature = assemblingFeatures[0];
this.genes = new VDJCGenes(baseVHit.getGene(), null, baseJHit.getGene(), null); // clone.getBestHitGenes();
@@ -1747,4 +1747,18 @@ else if (right == -1)
private boolean inSplitRegion(int p) {
return splitRegion != null && splitRegion.contains(p);
}

/**
* Check that the V/J gene can be used for full sequence assembly algorithm. Basically it checks that is has required reference points defined.
*
* @param hit hit to check
* @param assemblingFeature clonal assembling feature
* @return true if gene is compatible
*/
public static boolean checkGeneCompatibility(VDJCHit hit, GeneFeature assemblingFeature) {
GeneFeature vFeature = hit.getAlignedFeature();
VDJCGene gene = hit.getGene();
GeneFeature targetFeature = GeneFeature.intersection(assemblingFeature, vFeature);
return gene.getPartitioning().isAvailable(targetFeature);
}
}
@@ -146,12 +146,14 @@ public void run1() throws Exception {
.collect(Collectors.toMap(
Map.Entry::getKey,
e ->
Arrays.stream(e.getValue()).collect(
Collectors.toMap(
h -> h.getGene().getId(),
CoverageAccumulator::new
)
),
Arrays.stream(e.getValue())
.filter(h -> FullSeqAssembler.checkGeneCompatibility(h, cloneAssemblerParameters.getAssemblingFeatures()[0]))
.collect(
Collectors.toMap(
h -> h.getGene().getId(),
CoverageAccumulator::new
)
),
noMerge(),
() -> new EnumMap<>(GeneType.class)));

0 comments on commit ebccfba

Please sign in to comment.
You can’t perform that action at this time.