Thanks for the answer! I painted my question poorly. I need to create a file for each sample. It is necessary to get information about specific SNPs for a sample from each file of a certain chromosome and write it in a separate VCF file. I hope that there are ready-made programs for this
How to convert a file to vcf format
Hello, I have a file for each chromosome that represents the following format:
CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Sample1 Sample2 Sample3
10 62010 10:62010 C T 999 PASS SING;AA=NN;AN=CC;AD=CC GT 0|0 0|0 0|0
10 110548 10:110548 T C 999 PASS SING;AA=T;AN=TT;AD=TT GT 0|0 0|0 0|0
10 110848 10:110848 T C 999 PASS SING;AA=T;AN=TT;AD=TT GT 1|1 1|1 1|1
How can I combine all the files and convert this format to standard vcf file?
Thank you so much for your help!
• 5,338 views
•
link
1 answer
assuming the delimiter is a tab:
run the following script for each file
awk -f script .awk input.txt | bcftools view -O z -o out.vcf.gz
with script.awk (add a '##contig' line for all your chromosomes)
BEGIN {
FS="\t";
}
/^CHROM/ {
printf("##fileformat=VCFv4.2\n");
printf("##FORMAT=<ID=GT,Number=1,Type=String,Description=\"Genotype\">\n");
printf("##INFO=<ID=AA,Number=1,Type=String,Description=\"TODO\">\n");
printf("##INFO=<ID=AN,Number=1,Type=String,Description=\"TODO\">\n");
printf("##INFO=<ID=AD,Number=1,Type=String,Description=\"TODO\">\n");
printf("##INFO=<ID=SING,Number=0,Type=Flag,Description=\"TODO\">\n");
printf("##INFO=<ID=SING,Number=0,Type=Flag,Description=\"TODO\">\n");
printf("##contig=<ID=10,length=135534747,assembly=human_g1k_v37>\n");
printf("#%s\n",$0);
next;
}
{
print;
}
index with 'bctools index' and then merge the vcf with bcftools merge
• 0 views
•
link
• 0 views
•
link
• 0 views
•
link
Log in to answer this question.