Skip to content

Commit

Permalink
Fixes tricky NPE in assembleContigs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolotin committed Aug 28, 2019
1 parent bb88ab6 commit ebccfba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_CURRENT
@@ -0,0 +1 @@
Fixes `NPE` in very rare cases with incompatible V gene selection for `assembleContigs` in case of partially annotated gene libraries
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}
Expand Up @@ -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)));

Expand Down

0 comments on commit ebccfba

Please sign in to comment.