Remove unwanted characters from FASTA file
1
3
Entering edit mode
6.9 years ago
seta ★ 1.5k

Hi everybody,

I have some nucleotide sequence (fasta format) that contains many sequences with invalid characters, like  'e', 'q', 'i' and 'l',  there is also a item named "unavailable sequence" for some header. These characters were reported me as a error during working with MEME-chip. Could anybody please let me know how to find these characters and also the item "unavailable sequence" and remove them? Any suggestion and command warmly welcomed.

RNA-Seq alignment next-gen • 11k views
13
Entering edit mode
6.9 years ago

cleanup fasta:

sed -e '/^[^>]/s/[^ATGCatgc]/N/g' file.fa

0
Entering edit mode

Many thanks and so sorry for so basic question. However, I have no familiarity with the above command, is it possible please let me know which unwanted characters will be removed with the command, and how about the removing the header and its content that is actually noting and specify with "unavailable sequence"? Thanks

4
Entering edit mode

The sed command replaces all non ATCG/atcg characters with 'N' on non-header lines while ignoring header lines. Read sed commands so:

sed -CMD_LINE_OPTIONS '/<pattern_that_matches_line_to_process>/<operation>/<text_or_expression_to_be_replaced>/<new_text_or_expression>/<options>' INPUT_FILE

0
Entering edit mode

Thanks a lot for your clear clarification. As I mentioned there are some item as "sequence unavailable" under the related header, like " >AT1G01740|AT1G01740.1 Sequence unavailable", using the sed command it changes to ">AT1G01740|AT1G01740.1 NNNNNNcNNNNaNaNNaNNN", could you please share me how to remove these header with its contents, that actually is noting? Many thanks for your helpful commands