This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extractreference allele from fasta file

I am running vcftools to get ped file from a list of vcf files. I would like to know the reference allele for these snps and I already download the fa file from http://www.ensembl.org/info/data/ftp/index.html

However, is there some tool with which I could extract the allele information for each SNP?

Thanks and with best regards,
Xinhui

snp

1 answer

Index the reference and search each position with samtools faidx http://www.htslib.org/doc/samtools-1.1.html

Dear Pierre, Thanks. However, i had a huge list of SNP''s in my vcf file. do you mind to show me one command hoe to index the reference and search each positon and samtools faidx is a little diffcult for me. Thanks and with best regards, Xinhui

something like this:

samtools faix ref.fa

grep -v "#" in.vcf | wk '{printf("%s:%s-%s\n",$1,$2,$2);}' | while read P; do samtools faix ref.fa ${P} ; done

Dear Pierre,

Thanks and it worked very well. However, the output is on screen and I would like to output results to a txt file. Could you help me a little more with that? Sorry I am not familiar with linux.

With best regards,

Xinhui

(grep -v "#" in.vcf | wk '{printf("%s:%s-%s\n",$1,$2,$2);}' | while read P; do samtools faix ref.fa ${P} ; done) > out.txt

Log in to answer this question.