This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Fasta file manipulation

Hi All,

I want to extract the sequences that don't have * (special character/stop codon) in it from a fasta file that I have . Is there any one liner or easy way to do that t'h the command line (mac os) or if anyone could redirect me to the similar post on this forum, that would be very helpful.

Thanks!!

sequence

1 answer

linearize, grep, convert back to fasta:

awk '/^>/{printf("\n%s\t",$0);next;} {printf("%s",$0);} END {printf("\n");}' file.fa |\
awk -F '\t' '!($2 ~ /\*/)' |\
tr "\t" "\n"

Thanks for the fast response! It works perfectly :) and btw, what I will have to change in this command in order to print the sequences that has * in it.

Great, thanks again Pierre!!

Log in to answer this question.