This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract out fasta sequences using sequence headers.

I usually extract out fasta sequences using samtools:

i.e to extract the sequences for gene 000001

samtools faidx /path/to/transcriptome 000001

However, I was wondering whether there was a better method for extracting isoform sequences. I have tried the following command, but to no avail, to extract the sequences for gene isoforms 000001.1, 000001.2, 000001.3:

samtools faidx /path/to/transcriptome 000001.*

Does anyone have any tips on how to do this effectively?

gene

BBMap's filterbyname tool will work like this:

filterbyname.sh in=transcriptome.fa out=filtered.fa include names=000001. substring=name

1 answer

You can do this with Awk :

awk '/'000001.*'/{flag=1;print $0;next}/^>/{flag=0}flag' file.fasta >> outfile.fasta

Log in to answer this question.