11package org .labkey .sequenceanalysis .run .analysis ;
22
33import htsjdk .samtools .util .IOUtil ;
4+ import htsjdk .samtools .util .Interval ;
45import htsjdk .variant .variantcontext .VariantContext ;
56import org .apache .commons .io .FileUtils ;
67import org .apache .commons .lang3 .StringUtils ;
@@ -292,6 +293,23 @@ public static void processAndImportNextCladeAa(PipelineJob job, File jsonFile, i
292293
293294 if (vcList .isEmpty ())
294295 {
296+ //NOTE: if this is an indel, upstream variants could cause this:
297+ for (int ntPos : consensusMap .keySet ())
298+ {
299+ job .getLogger ().info ("No identical position match found, inspecting overlapping variants:" );
300+ for (VariantContext vc : consensusMap .get (ntPos ))
301+ {
302+ if (vc .overlaps (new Interval (vc .getContig (), positions .get (0 ), positions .get (positions .size () - 1 ))))
303+ {
304+ vcList .add (vc );
305+ }
306+ }
307+ }
308+ }
309+
310+ if (vcList .isEmpty ())
311+ {
312+ job .getLogger ().error ("Cannot find matching NT SNP: " + aa .toString ());
295313 throw new PipelineJobException ("Expected variant for AA position: " + aaName + " " + pos );
296314 }
297315
@@ -311,7 +329,7 @@ public static void processAndImportNextCladeAa(PipelineJob job, File jsonFile, i
311329 }
312330 else
313331 {
314- job .getLogger ().info ("Multiple NT SNPs found at AA pos: " + aaName + " " + pos + ", was: " + vcList .size ());
332+ job .getLogger ().warn ("Multiple NT SNPs found at AA pos: " + aaName + " " + pos + ", was: " + vcList .size ());
315333 depth = vcList .stream ().mapToInt (x -> x .getAttributeAsInt ("GATK_DP" , 0 )).summaryStatistics ().getAverage ();
316334
317335 alleleDepth = vcList .stream ().mapToDouble (x -> {
0 commit comments