From 522830fb0187882cfca5b43576dd9e90dcb08adc Mon Sep 17 00:00:00 2001 From: depristo Date: Tue, 21 Sep 2010 20:33:34 +0000 Subject: [PATCH] Support for --assume-single-sample in UG, better malformated bam exceptions, and ignoring out of order contigs in seqdictutils. All for the CG bam file git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4323 348d0f76-0448-11de-a6fe-93d51630548a --- .../contexts/StratifiedAlignmentContext.java | 2 +- .../genotyper/UnifiedGenotyperEngine.java | 2 +- .../sting/utils/SequenceDictionaryUtils.java | 17 ++++++++++++----- .../sting/utils/exceptions/UserException.java | 4 ++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/contexts/StratifiedAlignmentContext.java b/java/src/org/broadinstitute/sting/gatk/contexts/StratifiedAlignmentContext.java index f42ab6a66..a75eea37b 100755 --- a/java/src/org/broadinstitute/sting/gatk/contexts/StratifiedAlignmentContext.java +++ b/java/src/org/broadinstitute/sting/gatk/contexts/StratifiedAlignmentContext.java @@ -113,7 +113,7 @@ public class StratifiedAlignmentContext { contexts.put(sampleName,new StratifiedAlignmentContext(loc,pileupBySample)); else { if(assumedSingleSample == null) { - throw new UserException.MalformedBam(pileupBySample.iterator().next().getRead(), "Missing read group for read"); + throw new UserException.ReadMissingReadGroup(pileupBySample.iterator().next().getRead()); } contexts.put(assumedSingleSample,new StratifiedAlignmentContext(loc,pileupBySample)); } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java index 06e2b6068..573e38460 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java @@ -187,7 +187,7 @@ public class UnifiedGenotyperEngine { // annotate the call, if possible if ( call != null && call.vc != null && annotationEngine != null ) { // first off, we want to use the *unfiltered* context for the annotations - stratifiedContexts = StratifiedAlignmentContext.splitContextBySample(rawContext.getBasePileup()); + stratifiedContexts = StratifiedAlignmentContext.splitContextBySample(rawContext.getBasePileup(), UAC.ASSUME_SINGLE_SAMPLE); Collection variantContexts = annotationEngine.annotateContext(tracker, refContext, stratifiedContexts, call.vc); call.vc = variantContexts.iterator().next(); //We know the collection will always have exactly 1 element. diff --git a/java/src/org/broadinstitute/sting/utils/SequenceDictionaryUtils.java b/java/src/org/broadinstitute/sting/utils/SequenceDictionaryUtils.java index fb3d6f6a2..6435a0ab0 100755 --- a/java/src/org/broadinstitute/sting/utils/SequenceDictionaryUtils.java +++ b/java/src/org/broadinstitute/sting/utils/SequenceDictionaryUtils.java @@ -79,7 +79,8 @@ public class SequenceDictionaryUtils { * @param dict2 the sequence dictionary dict2 */ public static void validateDictionaries(Logger logger, String name1, SAMSequenceDictionary dict1, String name2, SAMSequenceDictionary dict2) { - switch ( compareDictionaries(dict1, dict2) ) { + SequenceDictionaryCompatability type = compareDictionaries(dict1, dict2); + switch ( type ) { case IDENTICAL: return; case COMMON_SUBSET: @@ -104,7 +105,7 @@ public class SequenceDictionaryUtils { break; } - case NON_CANONICAL_HUMAN_ORDER: + case NON_CANONICAL_HUMAN_ORDER: { UserException ex = new UserException.IncompatibleSequenceDictionaries("Human genome sequence provided in non-canonical ordering. For safety's sake the GATK requires contigs in karyotypic order: 1, 2, ..., 10, 11, ..., 20, 21, 22, X, Y with M either leading or trailing these contigs", name1, dict1, name2, dict2); @@ -112,11 +113,17 @@ public class SequenceDictionaryUtils { logger.warn(ex.getMessage()); else throw ex; + } - case OUT_OF_ORDER: - throw new UserException.IncompatibleSequenceDictionaries("Order of contigs differences, which is unsafe", name1, dict1, name2, dict2); + case OUT_OF_ORDER: { + UserException ex = new UserException.IncompatibleSequenceDictionaries("Order of contigs differences, which is unsafe", name1, dict1, name2, dict2); + if ( allowNonFatalIncompabilities() ) + logger.warn(ex.getMessage()); + else + throw ex; + } break; default: - throw new ReviewedStingException("Unexpected SequenceDictionaryComparison type"); + throw new ReviewedStingException("Unexpected SequenceDictionaryComparison type: " + type); } } diff --git a/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java b/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java index b5cd705db..0803b4e2c 100755 --- a/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java +++ b/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java @@ -112,7 +112,7 @@ public class UserException extends ReviewedStingException { public static class MalformedBam extends UserException { public MalformedBam(SAMRecord read, String message) { - super(String.format("SAM/BAM file %s is malformed: %s", read.getFileSource(), message)); + super(String.format("SAM/BAM file %s is malformed: %s", read.getFileSource().getReader(), message)); } } @@ -133,7 +133,7 @@ public class UserException extends ReviewedStingException { public MissortedBAM(SAMFileHeader.SortOrder order, SAMRecord read, String message) { super(String.format("Missorted Input SAM/BAM file %s: file sorted in %s order but %s is required; %s", - read.getFileSource(), read.getHeader().getSortOrder(), order, message)); + read.getFileSource().getReader(), read.getHeader().getSortOrder(), order, message)); } public MissortedBAM(String message) {