MergeAllBamFilesWithBash.sh

From ZhangLabWiki
Jump to navigation Jump to search
find $BAM_DIR -name '*.bam' | {
   read firstbam
   samtools view -h "$firstbam"
   while read bam; do
       samtools view "$bam"
   done
} | samtools view -ubS - | samtools sort -o merged.bam -
samtools index merged.bam
ls -l merged.bam merged.bam.bai