Skip to content

Commit

Permalink
Better error message for FingerprintChecker (#1982)
Browse files Browse the repository at this point in the history
  • Loading branch information
yfarjoun authored Dec 10, 2024
1 parent 63138fc commit 306401a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main/java/picard/fingerprint/FingerprintChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -526,15 +526,17 @@ public Map<FingerprintIdDetails, Fingerprint> fingerprintSamFile(final Path samF

public Map<FingerprintIdDetails, Fingerprint> fingerprintSamFile(final Path samFile, final Path indexPath, final boolean forceIndex,
final Function<HaplotypeBlock, HaplotypeProbabilities> blockToProbMapper) {

final SamReader in = getSamReader(samFile, indexPath, forceIndex);
checkDictionaryGoodForFingerprinting(in.getFileHeader().getSequenceDictionary());

if (!in.hasIndex()) {
log.warn(String.format("Operating without an index! We could be here for a while. (%s)", samFile.toUri().toString()));
} else {
log.info(String.format("Reading an indexed file (%s)", samFile.toUri().toString()));
}

checkDictionaryGoodForFingerprinting(in.getFileHeader().getSequenceDictionary());

// fingerprinting allows that headers differ, but SamLocusIterator doesn't allow the dictionary of the query
// interval list to differ from that of the samfile, leading to an exception thrown.
// At this point we already know that the dictionary of the haplotypes is a proper prefix of that of the sam file
Expand Down Expand Up @@ -712,12 +714,16 @@ public Map<FingerprintIdDetails, Fingerprint> fingerprintFiles(final Collection<
} else if (indexPath != null) {
log.info("Using explicit index provided for " + p);
}

// Perform fingerprinting on SAM or VCF file
if (CheckFingerprint.fileContainsReads(p)) {
oneFileFingerprints = fingerprintSamFile(p, indexPath, forceIndex, HaplotypeProbabilitiesFromSequence::new);
} else {
oneFileFingerprints = fingerprintVcf(p, indexPath, forceIndex);
try {
// Perform fingerprinting on SAM or VCF file
if (CheckFingerprint.fileContainsReads(p)) {
oneFileFingerprints = fingerprintSamFile(p, indexPath, forceIndex, HaplotypeProbabilitiesFromSequence::new);
} else {
oneFileFingerprints = fingerprintVcf(p, indexPath, forceIndex);
}
} catch (SequenceUtil.SequenceListsDifferException e){
log.error("file %s caused an exception".formatted(p));
throw e;
}

if (oneFileFingerprints.isEmpty()) {
Expand Down

0 comments on commit 306401a

Please sign in to comment.