minor bug fix in depth of coverage for partitioning by library + test (#1574)

minor bug fix in depth of coverage for partitioning by library
This commit is contained in:
skwalker 2017-04-26 10:42:54 -04:00 committed by GitHub
parent 5110b13124
commit 4fe4ace232
2 changed files with 31 additions and 4 deletions

View File

@ -206,12 +206,13 @@ public class CoverageUtils {
for (PileupElement e : countPileup) { for (PileupElement e : countPileup) {
SAMReadGroupRecord readGroup = getReadGroup(e.getRead()); SAMReadGroupRecord readGroup = getReadGroup(e.getRead());
String readGroupId = readGroup.getSample() + "_" + readGroup.getReadGroupId(); // uniqueReadGroupID is unique across the library, read group ID, and the sample
int[] counts = countsByRGName.get(readGroupId); String uniqueReadGroupId = readGroup.getSample() + "_" + readGroup.getReadGroupId() + "_" + readGroup.getLibrary() + "_" + readGroup.getPlatformUnit();
int[] counts = countsByRGName.get(uniqueReadGroupId);
if (counts == null) { if (counts == null) {
counts = new int[6]; counts = new int[6];
countsByRGName.put(readGroupId, counts); countsByRGName.put(uniqueReadGroupId, counts);
RGByName.put(readGroupId, readGroup); RGByName.put(uniqueReadGroupId, readGroup);
} }
updateCounts(counts, e); updateCounts(counts, e);

View File

@ -255,4 +255,30 @@ public class DepthOfCoverageIntegrationTest extends WalkerTest {
final WalkerTestSpec spec = new WalkerTestSpec(cmd, 0, new ArrayList<String>()); final WalkerTestSpec spec = new WalkerTestSpec(cmd, 0, new ArrayList<String>());
execute("testMissingSAMHeaderReadGroupSample", spec); 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<String>());
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);
}
} }