Skip to content

Instantly share code, notes, and snippets.

@SamBuckberry
Created May 15, 2014 06:17
Show Gist options
  • Save SamBuckberry/cac8ff90a6a39bc8c185 to your computer and use it in GitHub Desktop.
Save SamBuckberry/cac8ff90a6a39bc8c185 to your computer and use it in GitHub Desktop.
Create .bam file indexes for all bam files in a directory using samtools and parallel
## Write a bash script for looping through the bam files
#! /bin/bash
for i in *accepted_hits.bam
do
samtools index ${i}
done
## Save this files as indexBamFiles.sh
## To run in parallel (with 4 cores)
ls *.bam | parallel -j4 -k bash indexBamFiles.sh {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment