Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 44

...

Code Block
languagebash
titleSetup for samtools exercises
mkdir -p $SCRATCH/core_ngs/samtools
cd $SCRATCH/core_ngs/samtools
cp $CORENGS/yeastcatchup/for_stuffsamtools/*.bam* .

References

Handy links

...

Code Block
languagebash
module load biocontainers  # takes a while
module load samtools

cd $SCRATCH/core_ngs/samtools
samtools view yeast_chip_pe.sort.bam | head

With all the line wrapping, it looks pretty ugly. Still, you can pick out the CIGAR string in column 6. Let's select just that column with cut:

Code Block
languagebash
samtools view yeast_chip_pe.sort.bam | cut -f 6 | head -20

...

Code Block
languagebash
samtools view -F 0x4 yeast_chip_pe.sort.bam | cut -f 6 | head -20

...

Code Block
languagebash
samtools view -F 0x4 yeast_chip_pe.sort.bam | cut -f 6 | grep -P '[ID]' | head 

...

Code Block
languagebash
titleCount reads that mappedi with indels
samtools view -F 0x4 yeast_chip_pe.sort.bam | cut -f 6 | grep -P '[ID]' | wc -l 

...

Code Block
languagebash
titleCount all mapped reads
samtools view -c -F 0x4 yeast_chip_pe.sort.bam

There should be 547664 mapped alignments.

...

Code Block
languagebash
titleOne-liner for calculating BAM alignment rate
echo "`samtools view -F 0x4 -c yeast_chip_pe.sort.bam` `samtools view -F 0x4 yeast_chip_pe.sort.bam | cut -f 6 | grep -P '[ID]' | wc -l`" | awk '{ print 100 * $2/$1,"%" }'

...