@@ -154,7 +154,9 @@ public void addSite(VariantContext vc, Logger log)
154154 alleles .put (a , translated );
155155
156156 if (translated != null && !_alternates .contains (translated ))
157+ {
157158 _alternates .add (translated );
159+ }
158160 });
159161 _encounteredAlleles .put (getEncounteredKey (vc .getStart (), vc .getReference ()), alleles );
160162 }
@@ -176,13 +178,12 @@ protected String extractAlleleForPosition(VariantContext vc, Allele a, Logger lo
176178 }
177179 else if (offset == 0 && a .length () == 1 )
178180 {
179- return a .getBaseString ();
181+ return _ref . getBaseString (). equals ( a . getBaseString ()) ? null : a .getBaseString ();
180182 }
181183 else
182184 {
183- Allele ret = Allele .create (a .getBaseString ().substring (offset , offset + 1 ));
184-
185- return _ref .equals (ret , true ) ? null : ret .getBaseString ();
185+ String ret = a .getBaseString ().substring (offset , offset + 1 );
186+ return _ref .getBaseString ().equals (ret ) ? null : ret ;
186187 }
187188 }
188189 }
@@ -294,7 +295,7 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
294295 int idx = 0 ;
295296 try (CSVWriter writer = new CSVWriter (IOUtil .openFileForBufferedUtf8Writing (output ), '\t' , CSVWriter .NO_QUOTE_CHARACTER ))
296297 {
297- writer .writeNext (new String []{"ReadsetName" , "OutputFileId" , "ReadsetId" , "Contig" , "Start" , "End" , "Ref" , "AltAlleles" , "Depth " , "RefAF" , "AltAFs" , "NonRefCount" , "AltCounts" });
298+ writer .writeNext (new String []{"ReadsetName" , "OutputFileId" , "ReadsetId" , "Contig" , "Start" , "End" , "Ref" , "AltAlleles" , "GatkDepth" , "LoFreqDepth " , "RefAF" , "AltAFs" , "NonRefCount" , "AltCounts" });
298299
299300 for (Pair <String , Integer > site : whitelistSites )
300301 {
@@ -339,6 +340,7 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
339340 else
340341 {
341342 line .add (String .valueOf (depth ));
343+ line .add ("ND" );
342344 line .add ("1" );
343345 line .add (";0" .repeat (siteDef ._alternates .size ()).substring (1 ));
344346
@@ -351,7 +353,8 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
351353 }
352354 else
353355 {
354- Integer siteDepth = null ;
356+ Integer gatkDepth = null ;
357+ Integer lofreqDepth = null ;
355358 Double totalAltAf = 0.0 ;
356359 int totalAltDepth = 0 ;
357360 Map <String , Double > alleleToAf = new HashMap <>();
@@ -386,9 +389,12 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
386389 throw new PipelineJobException ("Expected AF annotation on line " + key + " in file: " + so .getFile ().getPath ());
387390 }
388391
389- siteDepth = vc .getAttributeAsInt ("GATK_DP" , 0 );
390- int aDepth = vc .getAttributeAsInt ("DP" , 0 );
391- if (siteDepth < minDepth )
392+ gatkDepth = vc .getAttributeAsInt ("GATK_DP" , 0 );
393+ lofreqDepth = vc .getAttributeAsInt ("DP" , 0 );
394+ List <Integer > depths = vc .getAttributeAsIntList ("DP4" , 0 );
395+ int alleleDepth = depths .get (2 ) + depths .get (3 );
396+
397+ if (gatkDepth < minDepth )
392398 {
393399 vc .getAlternateAlleles ().forEach (a -> {
394400 String translatedAllele = siteDef .getRenamedAllele (vc , a );
@@ -409,7 +415,7 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
409415 if (a != null )
410416 {
411417 totalAltAf += af ;
412- totalAltDepth += aDepth ;
418+ totalAltDepth += alleleDepth ;
413419
414420 double val = alleleToAf .getOrDefault (a , 0.0 );
415421 if (val == NO_DATA_VAL )
@@ -426,14 +432,15 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
426432 val1 = 0 ;
427433 }
428434
429- val1 = val1 + aDepth ;
435+ val1 = val1 + alleleDepth ;
430436 alleleToDp .put (a , val1 );
431437 }
432438 }
433439 }
434440
435441 List <String > toWrite = new ArrayList <>(line );
436- toWrite .add (String .valueOf (siteDepth ));
442+ toWrite .add (String .valueOf (gatkDepth ));
443+ toWrite .add (String .valueOf (lofreqDepth ));
437444 toWrite .add (String .valueOf (1 - totalAltAf ));
438445
439446 //Add AFs in order:
0 commit comments