Question: Rename several fasta-headers
gravatar for genomes_and_MGEs
11 months ago by
genomes_and_MGEs0 wrote:

Hey guys,

I have a multi-fasta file containing several extracted regions, such as


I would like to include strain name on fasta header, such as


Could you please help me out? Thanks!

assembly genome • 566 views
ADD COMMENTlink modified 11 months ago by Pierre Lindenbaum126k • written 11 months ago by genomes_and_MGEs0

See the following post

Renaming Entries In A Fasta File

and many others on its right panel,

like these ones: Rename fasta headers,

How to move the last 4 characters of all FASTA headers to the beginning?,

Renaming fasta file headers, etc.

There are many awk- or sed-scripts mentioned inside,

they may give you some hints.

ADD REPLYlink modified 11 months ago • written 11 months ago by natasha.sernova3.7k

Where are the strain names coming from? A separate file/NCBI search?

ADD REPLYlink written 11 months ago by genomax78k

From simple NCBI search! I don't have a separate file with the corresponding strain name for each accession... And the suggested links can't help me on this issue. Can you help me out? Thanks!

ADD REPLYlink written 11 months ago by genomes_and_MGEs0

The following will get you part way there.

Step 1: Look up names of the organisms in your blast result. (following work with the small snippet example above)

awk -F '>|_' '/^>/ {print $2"_"$3}' test | xargs -n 1 sh -c 'efetch -db nuccore -id "$0" -format docsum | xtract -pattern DocumentSummary -element Caption,Organism' > names.txt

names.txt now contains the names of the organisms.

Step 2: Use one of the solutions in Renaming fasta headers according to a matching name list to do the replacements. There is small issue though. names.txt does not contain the version number for the accession so the solutions may need to be changed to suit your needs.

ADD REPLYlink modified 11 months ago • written 11 months ago by genomax78k
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: 1059 users visited in the last hour