Created
July 15, 2018 10:08
-
-
Save Phoenix-Effect/eedb3ff1a73c6d5ca5adbb7eb7835766 to your computer and use it in GitHub Desktop.
Checks if the bam index files in a directory are newer than their corresponding bam files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Directory of the directory you want to scan | |
DIR="ENTER DIRECTORY HERE" | |
TOTALBAMS=0 | |
OLDINDEX=0 | |
UNINDEXED=0 | |
for file in $DIR*.bam; do # Iterate over all bam files in given directory | |
((TOTALBAMS++)) #Count the bam | |
if [ -f "$file.bai" ]; then # If index exists then check if its newer than bam | |
if [ "$file" -nt "$file.bai" ]; then | |
((OLDINDEX++)) # If bam is newer then increment old index counter | |
fi | |
else | |
((UNINDEXED++)) # If index doesn't exist then increment unindexed | |
fi | |
done | |
printf "Total bams in directory: $TOTALBAMS\n" | |
printf "Old bams: $OLDINDEX\n" | |
printf "Unindexed bams: $UNINDEXED\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment