List<SAMSequenceRecord> x = findDisequalCommonContigs(getCommonContigsByName(dict1, dict2), dict1, dict2);
SAMSequenceRecord elt1 = x.get(0);
SAMSequenceRecord elt2 = x.get(1);
// todo -- replace with toString when SAMSequenceRecord has a nice toString routine
UserException ex = new UserException.IncompatibleSequenceDictionaries(String.format("Found contigs with the same name but different lengths:\n contig %s = %s / %d\n contig %s = %s / %d",
name1, elt1.getSequenceName(), elt1.getSequenceLength(),
name2, elt2.getSequenceName(), elt2.getSequenceLength()),
name1, dict1, name2, dict2);
if ( allowNonFatalIncompabilities(validationExclusion) )
logger.warn(ex.getMessage());
else
throw ex;
break;
}
case NON_CANONICAL_HUMAN_ORDER: {
UserException ex;
if ( nonCanonicalHumanContigOrder(dict1) )
ex = new UserException.LexicographicallySortedSequenceDictionary(name1, dict1);
else
ex = new UserException.LexicographicallySortedSequenceDictionary(name2, dict2);
if ( allowNonFatalIncompabilities(validationExclusion) )
logger.warn(ex.getMessage());
else
throw ex;
break;
}
case OUT_OF_ORDER: {
UserException ex = new UserException.IncompatibleSequenceDictionaries("Relative ordering of overlapping contigs differs, which is unsafe", name1, dict1, name2, dict2);
if ( allowNonFatalIncompabilities(validationExclusion) )
logger.warn(ex.getMessage());
else
throw ex;
break;
}
case DIFFERENT_INDICES: {
// This is currently only known to be problematic when the index mismatch is between a bam and the
// reference AND when the user's intervals actually include one or more of the contigs that are
// indexed differently from the reference. In this case, the engine will fail to correctly serve
// up the reads from those contigs, so throw an exception unless unsafe operations are enabled.
if ( isReadsToReferenceComparison && intervals != null ) {
final Set<String> misindexedContigs = findMisindexedContigsInIntervals(intervals, dict1, dict2);
if ( ! misindexedContigs.isEmpty() ) {
final String msg = String.format("The following contigs included in the intervals to process have " +
"different indices in the sequence dictionaries for the reads vs. " +
"the reference: %s. As a result, the GATK engine will not correctly " +
"process reads from these contigs. You should either fix the sequence " +
"dictionaries for your reads so that these contigs have the same indices " +
"as in the sequence dictionary for your reference, or exclude these contigs " +
"from your intervals. This error can be disabled via -U %s, " +
"however this is not recommended as the GATK engine will not behave correctly.",
misindexedContigs, ValidationExclusion.TYPE.ALLOW_SEQ_DICT_INCOMPATIBILITY);
final UserException ex = new UserException.IncompatibleSequenceDictionaries(msg, name1, dict1, name2, dict2);
if ( allowNonFatalIncompabilities(validationExclusion) )
logger.warn(ex.getMessage());
else
throw ex;
}
}
break;