Modifying fasta header
1
0
Entering edit mode
9.7 years ago
empyrean999 ▴ 180

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
HTSIDGRPINQGNFSATMSSGSNLQSGSFRTVGFTTPFNFSNGSSVFTLSAHVFNSGNEVYIDRIEFVPAEVTFEAEYDLERAQKAVNELFTSSNQIGLKTDVTDYHIDQVSNLVECLSDEFCLDEKQELSEKVKHAKRLSDERNLLQDPNFRGINRQLDRGWRGSTDITIQGGDDVFKENYVTLLGTFDECYPTYLYQKIDESKLKAYTRYQLRGYIEDSQDLEIYLIRYNAKHETVNVPGTGSLWPLSAQSPIGKCGEPNRCAPHLEWNPDLDCSCRDGEKCAHHSHHFSLDIDVGCTDLNEDLGVWVIFKIKTQDGHARLGNLEFLEEKPLVGEALARVKRAEKKWRDKREKLEWETNIVYKEAKESVDALFVNSQYDQLQADTNIAMIHAADKRVHSI

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 perl sed unix python • 3.3k views
ADD COMMENT
3
Entering edit mode
9.7 years ago

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY

Login before adding your answer.

Traffic: 3148 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