Skip to content

Commit

Permalink
Validation of sequence dictionaries from multiple BAMs now throws war…
Browse files Browse the repository at this point in the history
…ning instead of exception in CNV workflows.
  • Loading branch information
samuelklee committed May 10, 2018
1 parent 0e8c5fd commit 1e7bf94
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ private void writeSamplesByCoveragePerContig(final File samplesByCoveragePerCont
logger.info(String.format("Aggregating read-count file %s (%d / %d)",
inputReadCountFile, sampleIndex + 1, numSamples));
final SimpleCountCollection readCounts = SimpleCountCollection.read(inputReadCountFile);
Utils.validateArg(CopyNumberArgumentValidationUtils.isSameDictionary(
readCounts.getMetadata().getSequenceDictionary(),
metadata.getSequenceDictionary()),
String.format("Sequence dictionary for read-count file %s does not match those " +
"in other read-count files.", inputReadCountFile));
if (!CopyNumberArgumentValidationUtils.isSameDictionary(
readCounts.getMetadata().getSequenceDictionary(), metadata.getSequenceDictionary())) {
logger.warn("Sequence dictionary for read-count file %s does not match that " +
"in other read-count files.", inputReadCountFile);
}
Utils.validateArg(readCounts.getIntervals().equals(intervals),
String.format("Intervals for read-count file %s do not match those in other " +
"read-count files.", inputReadCountFile));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,11 @@ private List<File> writeIntervalSubsetReadCountFiles() {
logger.info(String.format("Aggregating read-count file %s (%d / %d)",
inputReadCountFile, sampleIndex + 1, numSamples));
final SimpleCountCollection readCounts = SimpleCountCollection.read(inputReadCountFile);
Utils.validateArg(CopyNumberArgumentValidationUtils.isSameDictionary(
readCounts.getMetadata().getSequenceDictionary(),
specifiedIntervals.getMetadata().getSequenceDictionary()),
String.format("Sequence dictionary for read-count file %s does not match those in " +
"other read-count files.", inputReadCountFile));
if (!CopyNumberArgumentValidationUtils.isSameDictionary(
readCounts.getMetadata().getSequenceDictionary(), specifiedIntervals.getMetadata().getSequenceDictionary())) {
logger.warn("Sequence dictionary for read-count file %s does not match that " +
"in other read-count files.", inputReadCountFile);
}
Utils.validateArg(new HashSet<>(readCounts.getIntervals()).containsAll(intervalSubset),
String.format("Intervals for read-count file %s do not contain all specified intervals.",
inputReadCountFile));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,11 @@ private AllelicCountCollection genotypeHets(final SampleLocatableMetadata metada
"Run CollectAllelicCounts using the same interval list of sites for both samples.");
}
final SampleLocatableMetadata normalMetadata = normalAllelicCounts.getMetadata();
Utils.validateArg(CopyNumberArgumentValidationUtils.isSameDictionary(
if (!CopyNumberArgumentValidationUtils.isSameDictionary(
normalMetadata.getSequenceDictionary(),
metadata.getSequenceDictionary()),
"Sequence dictionaries in allelic-count files do not match.");
metadata.getSequenceDictionary())) {
logger.warn("Sequence dictionaries in allelic-count files do not match.");
}

//filter on total count in matched normal
logger.info(String.format("Filtering allelic counts in matched normal with total count less than %d...", minTotalAlleleCount));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ public static AnnotatedIntervalCollection validateAnnotatedIntervals(final File
logger.info("Reading and validating GC-content annotations for intervals...");
final AnnotatedIntervalCollection annotatedIntervals = new AnnotatedIntervalCollection(annotatedIntervalsFile);
final SAMSequenceDictionary sequenceDictionary = locatableCollection.getMetadata().getSequenceDictionary();
Utils.validateArg(annotatedIntervals.getMetadata().getSequenceDictionary().isSameDictionary(sequenceDictionary),
"Annotated-intervals file contains incorrect sequence dictionary.");
if (!CopyNumberArgumentValidationUtils.isSameDictionary(annotatedIntervals.getMetadata().getSequenceDictionary(), sequenceDictionary)) {
logger.warn("Sequence dictionary in annotated-intervals file does not match the master sequence dictionary.");
}
Utils.validateArg(annotatedIntervals.getIntervals().equals(locatableCollection.getIntervals()),
"Annotated intervals do not match provided intervals.");
return annotatedIntervals;
Expand All @@ -140,8 +141,9 @@ public static AnnotatedIntervalCollection validateAnnotatedIntervalsSubset(final
IOUtils.canReadFile(annotatedIntervalsFile);
final AnnotatedIntervalCollection annotatedIntervals = new AnnotatedIntervalCollection(annotatedIntervalsFile);
final SAMSequenceDictionary sequenceDictionary = locatableCollection.getMetadata().getSequenceDictionary();
Utils.validateArg(annotatedIntervals.getMetadata().getSequenceDictionary().isSameDictionary(sequenceDictionary),
"Annotated-intervals file contains incorrect sequence dictionary.");
if (!CopyNumberArgumentValidationUtils.isSameDictionary(annotatedIntervals.getMetadata().getSequenceDictionary(), sequenceDictionary)) {
logger.warn("Sequence dictionary in annotated-intervals file does not match the master sequence dictionary.");
}
final Set<SimpleInterval> intervalsSubset = new HashSet<>(locatableCollection.getIntervals());
Utils.validateArg(annotatedIntervals.getIntervals().containsAll(intervalsSubset),
"Annotated intervals do not contain all specified intervals.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,6 @@ public void testMissingSites() {
runCommandLine(argsBuilder);
}

@Test(expectedExceptions = IllegalArgumentException.class)
public void testSequenceDictionaryMismatch() {
final File outputDir = createTempDir("testDir");
final String outputPrefix = "test";
final ArgumentsBuilder argsBuilder = new ArgumentsBuilder()
.addArgument(CopyNumberStandardArgument.ALLELIC_COUNTS_FILE_LONG_NAME, TUMOR_ALLELIC_COUNTS_FILE.getAbsolutePath())
.addArgument(CopyNumberStandardArgument.NORMAL_ALLELIC_COUNTS_FILE_LONG_NAME, NORMAL_ALLELIC_COUNTS_FILE_WITH_SEQUENCE_DICTIONARY_MISMATCH.getAbsolutePath())
.addOutput(outputDir)
.addArgument(CopyNumberStandardArgument.OUTPUT_PREFIX_LONG_NAME, outputPrefix);
runCommandLine(argsBuilder);
}

@Test(expectedExceptions = UserException.class)
public void testOutputDirExists() {
final String outputPrefix = "test";
Expand Down

0 comments on commit 1e7bf94

Please sign in to comment.