From 4fe4ace232c6f01a9d1066ed4e0219d83b446bf3 Mon Sep 17 00:00:00 2001 From: skwalker Date: Wed, 26 Apr 2017 10:42:54 -0400 Subject: [PATCH] minor bug fix in depth of coverage for partitioning by library + test (#1574) minor bug fix in depth of coverage for partitioning by library --- .../tools/walkers/coverage/CoverageUtils.java | 9 ++++--- .../DepthOfCoverageIntegrationTest.java | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/coverage/CoverageUtils.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/coverage/CoverageUtils.java index f222380dc..62880ac19 100644 --- a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/coverage/CoverageUtils.java +++ b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/coverage/CoverageUtils.java @@ -206,12 +206,13 @@ public class CoverageUtils { for (PileupElement e : countPileup) { SAMReadGroupRecord readGroup = getReadGroup(e.getRead()); - String readGroupId = readGroup.getSample() + "_" + readGroup.getReadGroupId(); - int[] counts = countsByRGName.get(readGroupId); + // uniqueReadGroupID is unique across the library, read group ID, and the sample + String uniqueReadGroupId = readGroup.getSample() + "_" + readGroup.getReadGroupId() + "_" + readGroup.getLibrary() + "_" + readGroup.getPlatformUnit(); + int[] counts = countsByRGName.get(uniqueReadGroupId); if (counts == null) { counts = new int[6]; - countsByRGName.put(readGroupId, counts); - RGByName.put(readGroupId, readGroup); + countsByRGName.put(uniqueReadGroupId, counts); + RGByName.put(uniqueReadGroupId, readGroup); } updateCounts(counts, e); diff --git a/public/gatk-tools-public/src/test/java/org/broadinstitute/gatk/tools/walkers/coverage/DepthOfCoverageIntegrationTest.java b/public/gatk-tools-public/src/test/java/org/broadinstitute/gatk/tools/walkers/coverage/DepthOfCoverageIntegrationTest.java index 9515978cf..767339724 100644 --- a/public/gatk-tools-public/src/test/java/org/broadinstitute/gatk/tools/walkers/coverage/DepthOfCoverageIntegrationTest.java +++ b/public/gatk-tools-public/src/test/java/org/broadinstitute/gatk/tools/walkers/coverage/DepthOfCoverageIntegrationTest.java @@ -255,4 +255,30 @@ public class DepthOfCoverageIntegrationTest extends WalkerTest { final WalkerTestSpec spec = new WalkerTestSpec(cmd, 0, new ArrayList()); execute("testMissingSAMHeaderReadGroupSample", spec); } + + @Test + public void testPartitionByLibrary() { + final String[] intervals = {"1:2329607"}; + final String[] bams = { + // These 3 bams all have the same 2 read group IDs and the same sample name (HapMapVal_10plex) + privateTestDir + "partitionByLibraryExample1.bam", + privateTestDir + "partitionByLibraryExample2.bam", + privateTestDir + "partitionByLibraryExample3.bam"}; + + final String cmd = buildRootCmd(hg19Reference, new ArrayList<>(Arrays.asList(bams)), new ArrayList<>(Arrays.asList(intervals))) + " -mmq 20 -mbq 20 -pt library"; + final WalkerTestSpec spec = new WalkerTestSpec(cmd, 0, new ArrayList()); + + final File baseOutputFile = createTempFile("depthofcoveragepartitionbylibrary", ".tmp"); + spec.setOutputFileLocation(baseOutputFile); + + spec.addAuxFile("e0f0ab161225bf24fed20eb86777508e", baseOutputFile); + spec.addAuxFile("744e4d654536ef327288c9ee62adea15", createTempFileFromBase(baseOutputFile.getAbsolutePath()+".library_cumulative_coverage_counts")); + spec.addAuxFile("dc8b3aa0fee653f0e310cc8ada2bdb10", createTempFileFromBase(baseOutputFile.getAbsolutePath()+".library_cumulative_coverage_proportions")); + spec.addAuxFile("a1050deac4a01fd661149bb47253b590", createTempFileFromBase(baseOutputFile.getAbsolutePath()+".library_interval_statistics")); + spec.addAuxFile("e3f0f03233e0dc7d17811ed84101d8d8", createTempFileFromBase(baseOutputFile.getAbsolutePath()+".library_interval_summary")); + spec.addAuxFile("76a0fde72b9c42546ee5ca1f88d4fb09", createTempFileFromBase(baseOutputFile.getAbsolutePath()+".library_statistics")); + spec.addAuxFile("ed5c74dc512eae95987ed3b52f9a8743", createTempFileFromBase(baseOutputFile.getAbsolutePath()+".library_summary")); + + execute("testPartitionByLibrary", spec); + } }