i5K-KINBRE-script-share/BAM_and_SAM_files_tools — pull request #1 by ZSlie (2014-06-10 21:36:58+00:00)
Title: Create Summarize_BAM_Alignments.md

## Summarize BAM Alignments

Please take note, you should have a BEOCAT account or [samtools downloaded](http://sourceforge.net/projects/samtools/files/latest/download) for this exercise.

All of the scripts you will need to complete this lab as well as the sample dataset will be copied to your Beocat directory as you follow the instructions below. You should type or paste the text in the beige code block into your terminal as you follow along with the instructions below. If you are not used to commandline, practice with real data is one of the best ways to learn.

If you would like a quick primer on basic linux commands try these 10 minute lessons from Software Carpentry http://software-carpentry.org/v4/shell/index.html. To learn to start using Beocat and begin using the terminal go to https://github.com/i5K-KINBRE-script-share/FAQ/blob/master/UsingBeocat.md. Learn how to download files from Beocat at https://github.com/i5K-KINBRE-script-share/FAQ/blob/master/BeocatEditingTransferingFiles.md.

#### Part 1:
Concatenate BAM or SAM files using the samtools cat tool.
```
/homes/bioinfo/bioinfo_software/samtools/samtools cat -o /homes/rp3448/Project_Veeman/Project_Veeman/all_accepted_hits.bam [space separated list of the bam files you want to merge, USE THEIR FULL PATH]
```

Additional reading on samtools can be found [here](http://samtools.sourceforge.net/samtools.shtml).

#### Part 2:
Now, we use samtools flagstat to summarize alignments metrics.

```
/homes/bioinfo/bioinfo_software/samtools/samtools flagstat /homes/rp3448/Project_Veeman/Project_Veeman/all_accepted_hits.bam
```

Flagstat is a command for summary statistics; you can read more on how to interpret those statistics [here](http://picard.sourceforge.net/explain-flags.html).