Skip to content

Commit

Permalink
Allow the BAM index to be up to 5 seconds older than the BAM before w…
Browse files Browse the repository at this point in the history
…arning (#1634)

* HTSJDK itself when writing a BAM and indexing it will frequently leave an mtime on the index that is slightly older than the BAM itself, and this causes a lot of spurious warnings.   This is a simple way to reduce spurious warnings
  • Loading branch information
tfenne authored Nov 16, 2022
1 parent 067c553 commit 7346f5b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/htsjdk/samtools/BAMFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ public class BAMFileReader extends SamReader.ReaderImplementation {
throws IOException {
this(useAsynchronousIO ? new AsyncBlockCompressedInputStream(file, inflaterFactory) : new BlockCompressedInputStream(file, inflaterFactory),
indexFile!=null ? indexFile : SamFiles.findIndex(file), eagerDecode, useAsynchronousIO, file.getAbsolutePath(), validationStringency, samRecordFactory);
if (mIndexFile != null && mIndexFile.lastModified() < file.lastModified()) {

if (mIndexFile != null && mIndexFile.lastModified() < file.lastModified() - 5000) {
System.err.println("WARNING: BAM index file " + mIndexFile.getAbsolutePath() +
" is older than BAM " + file.getAbsolutePath());
}

// Provide better error message when there is an error reading.
mStream.setInputFileName(file.getAbsolutePath());
}
Expand Down

0 comments on commit 7346f5b

Please sign in to comment.