美文网首页
samtools notes

samtools notes

作者: 吴十三和小可爱的札记 | 来源:发表于2021-07-06 20:26 被阅读0次

    bam2sam

    -h: include header in SAM output
    -O: Specify output format (SAM, BAM, CRAM)
    -S: input format is auto-detected

    samtools view -h test.bam -O SAM -o test.sam 
    

    sam2bam

    samtools view -S -O BAM test.sam  -o test.bam
    

    sam2fastq

    -c: compression level
    -@: threads
    -t: copy RG, BC and QT tags to the FASTQ header line

    ~/miniconda3/bin/samtools fastq test.sam -c 6 -@ 10 -1 reads_1.fq.gz -2 reads_2.fq.gz
    

    bam2fastq

    ~/miniconda3/bin/samtools fastq test.bam -c 6 -@ 10 -1 reads_1.fq.gz -2 reads_2.fq.gz
    

    extract FLAG

    # from sam
    ~/miniconda3/bin/samtools view -S -O BAM -f 4 test.sam -o unmapped.bam
    ~/miniconda3/bin/samtools view -S -O SAM -f 4 test.sam -o unmapped.sam
    ~/miniconda3/bin/samtools fastq -c 6 -@ 10 -f 4  test.sam -1 reads_unmapped_1.fq.gz -2 reads_unmapped_2.fq.gz
    
    # from bam
    ~/miniconda3/bin/samtools view -S -O BAM -f 4 test.bam -o unmapped.bam
    ~/miniconda3/bin/samtools view -S -O SAM -f 4 test.bam -o unmapped.sam
    ~/miniconda3/bin/samtools fastq -c 6 -@ 10 -f 4  test.bam -1 reads_unmapped_1.fq.gz -2 reads_unmapped_2.fq.gz
    

    generate text files with alignment regions

    COLUMNS=200
    COLUMNS=$COLUMNS ~/miniconda3/bin/samtools tview -d T -p chr1:1000 sorted.bam hap1_chrom.fa 
    

    Reference

    https://en.wikipedia.org/wiki/Pileup_format
    https://www.samformat.info/sam-format-flag

    相关文章

      网友评论

          本文标题:samtools notes

          本文链接:https://www.haomeiwen.com/subject/lvtnultx.html