bam2fq

samtools bam2fq

1
samtools.1.3.1 bam2fq input.bam |gzip -c > output.fq.gz


picard SamToFastq

1
java -jar picard-tools-2.5.0/picard.jar SamToFastq I=input.bam F=out.1.fq.gz F2=out.2.fq.gz


提取 unmapped reads

1
2
# 提取unmapped reads比对到另一个ref(比如线粒体)上
samtools.1.3.1 bam2fq -f 4 input.bam | bwa mem -t 30 -M -R '@RG\tID:Sample01\tLB:Sample01\tSM:Sample01\tPL:Illumina\tPU:Illumina\tSM:Sample01\t' mt.fa - | samtools.1.3.1 sort -O bam -T /dir/tmp -o mapMt.sort.bam


提取 unique reads

1
2
3
# unique reads (a single read mapping at one best position)
# -q INT Skip alignments with MAPQ smaller than INT [0]
samtools view -bq 1 file.bam > unique.bam