Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protection against using the wrong sample alias which produces zero L… #1242

Merged
merged 6 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/main/java/picard/fingerprint/CheckFingerprint.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ protected int doWork() {
outputDetailMetricsFile = DETAIL_OUTPUT;
outputSummaryMetricsFile = SUMMARY_OUTPUT;
} else {
if (!OUTPUT.endsWith(".")) OUTPUT = OUTPUT + ".";
if (!OUTPUT.endsWith(".")) {
OUTPUT += ".";
}
outputDetailMetricsFile = new File(OUTPUT + FINGERPRINT_DETAIL_FILE_SUFFIX);
outputSummaryMetricsFile = new File(OUTPUT + FINGERPRINT_SUMMARY_FILE_SUFFIX);
}
Expand All @@ -245,8 +247,7 @@ protected int doWork() {
List<FingerprintResults> results;

String observedSampleAlias = null;
final boolean isBamOrSamFile = isBamOrSam(inputPath);
if (isBamOrSamFile) {
if (isBamOrSam(inputPath)) {
SequenceUtil.assertSequenceDictionariesEqual(SAMSequenceDictionaryExtractor.extractDictionary(inputPath), SAMSequenceDictionaryExtractor.extractDictionary(genotypesPath), true);
SequenceUtil.assertSequenceDictionariesEqual(SAMSequenceDictionaryExtractor.extractDictionary(inputPath), checker.getHeader().getSequenceDictionary(), true);

Expand Down Expand Up @@ -311,6 +312,7 @@ protected int doWork() {
final MetricsFile<FingerprintingSummaryMetrics, ?> summaryFile = getMetricsFile();
final MetricsFile<FingerprintingDetailMetrics, ?> detailsFile = getMetricsFile();

boolean allZeroLod = true;
for (final FingerprintResults fpr : results) {
final MatchResults mr = fpr.getMatchResults().first();

Expand Down Expand Up @@ -365,11 +367,20 @@ protected int doWork() {

summaryFile.addMetric(metrics);
log.info("Read Group: " + metrics.READ_GROUP + " / " + observedSampleAlias + " vs. " + metrics.SAMPLE + ": LOD = " + metrics.LOD_EXPECTED_SAMPLE);

allZeroLod &= metrics.LOD_EXPECTED_SAMPLE == 0;
}

summaryFile.write(outputSummaryMetricsFile);
detailsFile.write(outputDetailMetricsFile);

if (allZeroLod) {
log.error("No non-zero results found. This is likely an error. " +
"Probable cause: EXPECTED_SAMPLE (if provided) or the sample name from INPUT (if EXPECTED_SAMPLE isn't provided)" +
"isn't a sample in GENOTYPES file.");
return 1;
}

return 0;
}

Expand All @@ -389,10 +400,6 @@ protected String[] customCommandLineValidation() {
return super.customCommandLineValidation();
}

static boolean isBamOrSam(final File f) {
return isBamOrSam(f.toPath());
}

static boolean isBamOrSam(final Path p) {
return (p.toUri().getRawPath().endsWith(BamFileIoUtils.BAM_FILE_EXTENSION) || p.toUri().getRawPath().endsWith(IOUtil.SAM_FILE_EXTENSION));
}
Expand Down