This is a test version of Biostars. For the public version, visit https://www.biostars.org.
COMMAND TO FIND EXACT DIGIT MATCHING

Hi everyone,

I have a dataset of fasta file which looks like this:

>13_seq2344_ATCGACGGAACTGA
>1342_seq2134_AGCTGTGGCAT
>130_SEQ2289_TCGAATCGAGGAAC

I want to remove the line which contains "13" only

so my output should look like:

>1342_seq2134_AGCTGTGGCAT
>130_SEQ2289_TCGAATCGAGGAAC

I am trying grep -w, grep -o, grep -E all these are not working for me.

Do suggest any command that works.

Thank you

linux

you also have to think about removing sequences as well. Try this: seqkit -w 0 grep -vrip "^13_" input.fa. Awk or sed remove only the matching the line, not the following sequences. It is difficult if sequences are in multlines.

1 answer

Hi!

awk '!/^13_/' file.fa >  new_file.fa

Should remove the line beginning with 13 only. The substring inbetween the slashes is what is searched for so you could play with this if you need to. The ! is a logical for NOT which means print these lines if they do NOT contain the pattern.

Hope this helps :)

EDIT - See below!

Should remove the line beginning with 13 only

No.

$ cat test.txt 

>13_seq2344_ATCGACGGAACTGA

>1342_seq2134_AGCTGTGGCAT

>130_SEQ2289_TCGAATCGAGGAAC

>113_test

$ awk '!/13_/' test.txt

>1342_seq2134_AGCTGTGGCAT

>130_SEQ2289_TCGAATCGAGGAAC


$ awk '!/^>13_/' test.txt    

>1342_seq2134_AGCTGTGGCAT

>130_SEQ2289_TCGAATCGAGGAAC

>113_test

Log in to answer this question.