This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Remove part of headers in FASTA file

I want to delete the part starting after "CDS" until "p". And the characters between CDS and p vary.
I have a header like this:

>Eindica.01T000001.1 CDS=1-201_p
ATGACTAGGGAACGTGGACGACCAGCAAGGGCTTGGAAGCCAAGGCAGGGATTAG
>Eindica.01T000002.1 CDS=1-3027_p
ATGACCTTCTATGGATACACACAACACTCCTTAA
>Eindica.01T000005.1 CDS=577-4218_p
CCAAGGCCAAAAAATACATTTCTAAGGCCAAAGCTTGGCTTGAATGAATCTTGA

and I want to keep the header like this:

>Eindica.01T000001.1 

ATGACTAGGGAACGTGGACGACCAGCAAGGGCTTGGAAGCCAAGGCAGGGATTAG

>Eindica.01T000002.1 

ATGACCTTCTATGGATACACACAACACTCCTTAA

>Eindica.01T000005.1 

CCAAGGCCAAAAAATACATTTCTAAGGCCAAAGCTTGGCTTGAATGAATCTTGA

Can someone help me with a solution? Would be great. Thank you.

fasta

1 answer

Use seqkit

seqkit replace -p " .+$" -r "" test.fasta

Where -p is the pattern (regex) and -r is the replacement pattern (in this case it's empty string)

https://bioinf.shenwei.me/seqkit/

Log in to answer this question.