Question: Modifying fasta header
gravatar for empyrean999
6.2 years ago by
empyrean999170 wrote:

I have strange fasta headers like this for some good number of sequences,

>gi|61221638|sp|P0A366.1| >gi|61221640|sp|P0A368.1|CR1AA_BACTE RecName: Full= protein synthase>gi|40267|emb|CAA31886.1| unnamed protein product

I would like to replace the other (>gi) in the fasta header to blank or ;. Can anyone suggest how to do it. I have many such sequences in a big fasta file.

awk unix sed python perl • 2.4k views
ADD COMMENTlink modified 14 months ago by RamRS30k • written 6.2 years ago by empyrean999170
gravatar for Pierre Lindenbaum
6.2 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum131k wrote:

If the symbol before the second > is a space, just:

cut -d ' ' -f 1 in.fasta > out.fasta

But imho, if your fasta headers are broken, you'd better check your upstream workflow

ADD COMMENTlink modified 14 months ago by RamRS30k • written 6.2 years ago by Pierre Lindenbaum131k

The space thing worked. Thanks for the tip. I just substituted in vim using space . Unfortunately i cannot change the upstream flow as this itself is starting file which was given to me.

ADD REPLYlink written 6.2 years ago by empyrean999170

You should at least inform whoever gave it to you that what they gave you was not valid fasta. This kind of error is just a waste of everyone's time and should be fixed.

ADD REPLYlink written 6.2 years ago by Neilfws49k
Please log in to add an answer.


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