본문 바로가기
Tools

VCF reheader

by wycho 2021. 6. 17.

VCF header에 contig 정보가 빠져있으면 VCF 프로그램에서 처리되지 않는다. 따라서 항상 넣어주어야 한다.

 

아래 코드는 VCF의 contig를 생성해 주고, sample 정보를 제외한 header와 contig를 결합하고, 다시 sample 정보를 결합하여 이상이 없는 VCF를 만들어 준다.

#!/bin/bash

cat vfile.lst|while read line;do awk '!/^#/ { a[$1]++ } END {for (i in a) print i,a[i]}' ${line}|sort -V|awk '{print "##contig=<ID="$1",length="$2">"}' > ${line}.contig.tmp;done

cat vfile.lst|while read line;do bcftools view -h ${line} |tail -n1 > ${line}.sinfo.tmp;done

cat vfile.lst|while read line;do cat header.txt ${line}.contig.tmp ${line}.sinfo.tmp > ${line}.header.tmp;done

cat vfile.lst|while read line;do bcftools reheader -h ${line}.header.tmp ${line} -o ${line}.re;done

rm *.tmp

cat vfile.lst|while read line;do mv ${line}.re ${line};done

'Tools' 카테고리의 다른 글

Single Cell analysis tools  (0) 2021.08.13
Clustering - Fuzzy  (0) 2021.06.18
Clustering  (0) 2021.06.09
XGBR  (0) 2021.06.07
SHAP - impact  (0) 2021.06.06

댓글