Question: change headers from fasta files
0
gravatar for ulises.rodriguez
11 weeks ago by
ulises.rodriguez0 wrote:

I have multifasta files containing sequences like these:

>16S_ribosomal_RNA
attgcaggtcagcatactgcagtgaattcgttcc

>16S_ribosomal_RNA
attgcaggtcagcatactgcagtgaattcgttcc

>16S_ribosomal_RNA
attgcaggtcagcatactgcagtgaattcgttcc

these sequences are contained in fasta files named as following :

Bacteria_especie_strain.fasta

and I would like that headers has the same name that the multifasta file :

>16S_ribosomal_RNA_Bacteria_especie_strain.fasta 
attgcaggtcagcatactgcagtgaattcgttcc

> 16S_ribosomal_RNA_Bacteria_especie_strain.fasta 
attgcaggtcagcatactgcagtgaattcgttcc

>16S_ribosomal_RNA_Bacteria_especie_strain.fasta 
attgcaggtcagcatactgcagtgaattcgttcc
sequence • 227 views
ADD COMMENTlink modified 11 weeks ago by cpad01128.3k • written 11 weeks ago by ulises.rodriguez0
3
gravatar for cschu181
11 weeks ago by
cschu1811.3k
cschu1811.3k wrote:
awk -v fn="Bacteria_especie_strain.fasta"  '/^>/ { print $0"_"fn; next; } { print $0; }' Bacteria_especie_strain.fasta > Bacteria_especie_strain.fasta.modified_headers
ADD COMMENTlink written 11 weeks ago by cschu1811.3k
2
gravatar for h.mon
11 weeks ago by
h.mon18k
Brazil
h.mon18k wrote:

See answers from Question: Changing names of Fasta headers.

ADD COMMENTlink written 11 weeks ago by h.mon18k
1
gravatar for cpad0112
11 weeks ago by
cpad01128.3k
India
cpad01128.3k wrote:

Output from awk:

 $ awk   '/^>/ { print $0"_"FILENAME; next}1' Bacteria_especie_strain.fasta

>16S_ribosomal_RNA_Bacteria_especie_strain.fasta
attgcaggtcagcatactgcagtgaattcgttcc
>16S_ribosomal_RNA_Bacteria_especie_strain.fasta
attgcaggtcagcatactgcagtgaattcgttcc
>16S_ribosomal_RNA_Bacteria_especie_strain.fasta
attgcaggtcagcatactgcagtgaattcgttcc

output from sed and parallel:

$ parallel  'sed "/^>/ s/.*/&_{}/g"' {} ::: Bacteria_especie_strain.fasta 

>16S_ribosomal_RNA_Bacteria_especie_strain.fasta
attgcaggtcagcatactgcagtgaattcgttcc
>16S_ribosomal_RNA_Bacteria_especie_strain.fasta
attgcaggtcagcatactgcagtgaattcgttcc
>16S_ribosomal_RNA_Bacteria_especie_strain.fasta
attgcaggtcagcatactgcagtgaattcgttcc

input:

$ cat Bacteria_especie_strain.fasta 

>16S_ribosomal_RNA
attgcaggtcagcatactgcagtgaattcgttcc
>16S_ribosomal_RNA
attgcaggtcagcatactgcagtgaattcgttcc
>16S_ribosomal_RNA
attgcaggtcagcatactgcagtgaattcgttcc
ADD COMMENTlink modified 11 weeks ago • written 11 weeks ago by cpad01128.3k
Please log in to add an answer.

Help
Access

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