Skip to content

Commit ec16872

Browse files
committed
Better handle indels in NextClade import
1 parent 6f6b9aa commit ec16872

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/analysis/NextCladeHandler.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.labkey.sequenceanalysis.run.analysis;
22

33
import htsjdk.samtools.util.IOUtil;
4+
import htsjdk.samtools.util.Interval;
45
import htsjdk.variant.variantcontext.VariantContext;
56
import org.apache.commons.io.FileUtils;
67
import 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

Comments
 (0)