Last active
July 17, 2017 17:15
-
-
Save bede/28071fe56dae5a3d3b7a to your computer and use it in GitHub Desktop.
Bioinformatics code golf: SAM to consensus FASTA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SAM to consensus FASTA code golf, inspired by http://lab.loman.net/2015/07/28/calling-haploid-consensus-sequence/ | |
# Starting with a SAM: | |
samtools view -bS seqs.sam | samtools sort - seqs # Generate and sort BAM | |
samtools index seqs.bam # Index BAM | |
# Starting with an indexed BAM: | |
samtools mpileup -ud 1000 -f seqs_ref.fasta seqs.bam | bcftools call -c | vcfutils.pl vcf2fq | seqtk seq -a - > seqs.consensus.fa # Generate pileup, call variants, convert to fq, convert to fa | |
# Who can do better? The bar is set low... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@nickloman suggests FreeBayes
http://lab.loman.net/2015/07/28/calling-haploid-consensus-sequence/