Last active
          October 16, 2022 12:22 
        
      - 
      
- 
        Save elowy01/21929ad87152254d592743da8f741eb7 to your computer and use it in GitHub Desktop. 
    Cheat sheet for SAMtools
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | #getting the insert size from a BAM file | |
| samtools view -F 0x4 accepted_hits.bam | awk '{if ($9 >0) {sum+=$9;sumsq+=$9*$9;N+=1}} END {print "mean = " sum/N " SD=" sqrt(sumsq/N - (sum/N)**2)}' | |
| #slicing a BAM file | |
| samtools view aln.sorted.bam chr2:20100000-20200000 | |
| # extract a subsequence from a FASTA file | |
| # 1) Index the Fasta file | |
| samtools faidx hs37d5.ch20.fa | |
| # 2) Fetch the sequence | |
| samtools faidx hs37d5.ch20.fa |20:10000000-11000000 | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment