Editing header of a fasta file
1
0
Entering edit mode
3.2 years ago
Melisa ▴ 10

Hello everybody, I've been using sed but for simple steps and now I can't do this: I have this header:

>ENSP00000451042.1 pep chromosome:GRCh38:14:22438547:22438554:1 gene:ENSG00000223997.1 transcript:ENST00000415118.1 gene_biotype:TR_D_gene transcript_biotype:TR_D_gene gene_symbol:TRDD1 description:T cell receptor delta diversity 1 [Source:HGNC Symbol;Acc:HGNC:12254]

and I would like to obtein this:

>gene_symbol:TRDD1

Does anybody can help me?

headers fasta • 676 views
ADD COMMENT
1
Entering edit mode
3.2 years ago

try (assuming that gene_symbol is always followed by description:

$ sed -re '/^>/ s/.*(gene_symbol:.*)\sdes.*$/>\1/'  input.fa
$ seqkit replace -ip '.*(gene_symbol:.*)\sdesc.*' -r \${1} input.fa
$ awk '/^>/ {print ">"$8};!/>/{print}' input.fa
$ awk  '{print ($0 ~ /^>/) ? ">"$8 :$0 }' input.fa
ADD COMMENT

Login before adding your answer.

Traffic: 1741 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6