Created
August 11, 2020 19:35
-
-
Save danielecook/2582c5285f06cb33827e8b6bdbc05897 to your computer and use it in GitHub Desktop.
Fix missing BAM indices
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
# This quick script will check for big differences in a bams index and creation date and perform indexing. | |
for i in *.bam; do | |
bam=${i} | |
bai=${i}.bai | |
bam_date=$(stat -c %Y ${bam}) | |
bai_date=$(stat -c %Y ${bai}) | |
diff=`expr ${bam_date} - ${bai_date}` | |
if [ ${diff} -gt 100000 ]; then | |
echo "${bam} ${diff}"; | |
sbatch --job-name=${bam} --partition=cpu --time=3:00:00 --cpus-per-task=32 --wrap "samtools index -@ 32 ${bam}" | |
fi; | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment