Question: (Closed) Changing Fasta Header
0
gravatar for wanziyi89
3.7 years ago by
wanziyi8950
Singapore, Temasek Life Sciences Laboratory
wanziyi8950 wrote:

Dear Colleagues,

I would like to change my FASTA file header from this :

oreNil2_augustusGene_g25.t1 range=chrLG1:1047971-1161345 5'pad=0 3'pad=0 strand=+ repeatMasking=none

to this :

oreNil2_augustusGene_g25.t1

Basically removing all the lines after the space.

I know we can do this with sed or awk but my knowledge with this two commands are elementary at best. Any help here will be awesome!

regards,

Zi Yi

awk sed header fasta • 1.1k views
ADD COMMENTlink modified 3.7 years ago by kapil.joshi03680 • written 3.7 years ago by wanziyi8950

This perl script may help to solve your porblem:

open F,"<genome.fa";
open OUT,">new_genome.fa";
while(<F>){
     print OUT $_ unless ($_=~/^>/);
     print OUT "$1\n" if ($_=~/^(>.*)\s+range.*/);
}
close(F);close(OUT);
ADD REPLYlink modified 3.7 years ago • written 3.7 years ago by guoql.karen10

This was answered too many times on this forum. Here is one solution

sed '/>/ s/\s.*$//' foo.fa > out.fa
ADD REPLYlink modified 3.7 years ago • written 3.7 years ago by venu6.3k

Hello wanziyi89!

We believe that this post does not fit the main topic of this site.

Please read the multitude of identical posts here.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

ADD REPLYlink written 3.7 years ago by RamRS25k
1
gravatar for Brian Bushnell
3.7 years ago by
Walnut Creek, USA
Brian Bushnell17k wrote:

You can use the BBMap package for this:

reformat.sh in=sequences.fasta out=renamed.fasta trd

"trd" stands for "trim read description" and will truncate everything after the first whitespace.

ADD COMMENTlink written 3.7 years ago by Brian Bushnell17k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 718 users visited in the last hour