Samtools 使用

作者: 落寞的橙子 | 来源:发表于2020-03-10 21:08 被阅读0次

samtools常用命令详解
我的一个例子,用来分离并改chr名字,HPC递交系统,mouse_chr 分离并改成chr。注意echo的内的"要加上转置符号\

#!/bin/bash
#SBATCH --time=2:00:00
#SBATCH --cpus-per-task=2
#SBATCH --mem=2g
dir=/scratch/data
log_dir=${dir}/log
job_dir=${dir}/jobs
mouse_dir=${dir}/mouse
human_dir=${dir}/human
mkdir -p ${log_dir}
mkdir -p ${job_dir}

cd  ${dir}
thread=5
for i in $(ls $pwd *.sort.bam);do
job_file="${job_dir}/${i%.bam*}.job"

 echo "#!/bin/bash
#SBATCH --job-name=${i%.bam*}.change_name
#SBATCH --output=${log_dir}/${i%.bam*}.out
#SBATCH --time=20:00:00
#SBATCH --cpus-per-task=${thread}
#SBATCH --mem=20g
ml samtools
samtools view -h -@ ${thread} ${dir}/${i} | awk 'BEGIN{FS=OFS=\"\t\"} (/^@/ && !/@SQ/){print \$0} \$2~/^SN:mouse_chr[1-9]|^SN:mouse_chrX|^SN:mouse_chrY|^SN:mouse_chrM/{print \$0}  \$3~/^mouse_chr[1-9]|X|Y|M/{print \$0} ' | sed 's/mouse_chr/chr/g' | samtools view -bS - >${mouse_dir}/${i%.bam*}.mouse.bam
samtools view -h -@ ${thread} ${dir}/${i} | awk 'BEGIN{FS=OFS=\"\t\"} (/^@/ && !/@SQ/){print \$0} \$2~/^SN:human_chr[1-9]|^SN:human_chrX|^SN:human_chrY|^SN:human_chrM/{print \$0}  \$3~/^human_chr[1-9]|X|Y|M/{print \$0} ' | sed 's/human_chr/chr/g' | samtools view -bS - >${human_dir}/${i%.bam*}.human.bam
" > $job_file
sbatch $job_file
done
```

相关文章

网友评论

    本文标题:Samtools 使用

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