This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Introducing Known Mutations (From A Vcf) Into A Fasta File

Hi,

This could probably be coded easily enough but I don't want to reinvent the wheel.

Is anyone aware of software that will take a FASTA file and a corresponding VCF file and introduce the mutations from the VCF into the FASTA sequence?

Thanks in advance.

mutation vcf fasta next-gen sequencing

this would make a decent code golf challenge

Alternatively,maybe use FastG.

how do you manage the overlapping mutations and the heterozygous mutations ?

I don't - I was hoping someone else did :) I might pull something together myself but for initial simplicity I would ignore both cases you mention. Neither is important to the downstream testing in my application. I could envisage selecting overlapping mutations randomly. The heterozygous bit would be more complicated. As I said though - neither is important to my particular application.

3 answers

This is a duplicate question.

You want the following, from GATK:

java -Xmx2g -jar GenomeAnalysisTK.jar \
-R MY_REFERENCE.fa \
-T FastaAlternateReferenceMaker \
-o MY_REFERENCE_WITH_SNPS_FROM_VCF.fa \
--variant MY_VCF_IN_VCF_4.0_FORMAT.vcf

See also this question and this question.

Thanks David. I had actually searched for previous questions on the topic and retrieved nothing! Cheers.

I wrote a script that assumes no overlapping mutations, all biallelic, and tosses the heterozygous sites. Also depends on biopython but just for reading a fasta file so easy to get rid of.

https://github.com/aihardin/utils/blob/master/vcf2fasta.py

There is a very well written tool for it. Its called Personnel Genome Constructor.

http://alleleseq.gersteinlab.org/tools.html

Log in to answer this question.