I would need to add the sample name at the end of all the read headers in that fasta sample. For example I have
#Sample1
#>read1
#ATGC
#Sample2
#>read1
#ATGC
Desire output:
#Sample1
#>read1/Sample1
#ATGC
#Sample2
#> read1/Sample2
#ATGC
I can do it one by one using sed
sed 's/read1/read1\/Sample1/g' Sample1.fasta > Sample1_tagged.fasta
However I have hundreds of fasta samples. Any tips on how to do it all at once will be highly appreciated.
are these Sample1 and Sample2 file names? If you do not provide sufficient information, it would be xy problem and solutions posted here will be of no use. juan.galarza. If they are in different files:
or
input files (Sample1 and Sample2)
This would append string "SAMPLE" to each header of fasta and is different from OP intended output. OP wants to append sample names (sample 1, sample 2, sample 3 etc) to each sequence. From OP's post, it seems OP has several files name Sample1, Sample 2 etc and each file has a fasta sequence.
Thank you for your answers cpad0112 and Pierre Lindenbaum. Indeed, I have several files named Sample1.fa, Sample2.fa etc...each with sequences in fasta format. I would like to append the file name to the sequences IDs within those files. For example the seq IDs from file Sample1.fa would be
and IDs from file Sample2.fa would be
The awk solution does this, however it produces a single output. Ideally I would like to get the relabelled sequences printed to their corresponding file. I.e. all sequences from file Sample1.fa printed to Sample1_relabel.fa and sequences from Sample2.fa printed to Sample2_relabel.fa etc...
juan.galarza :
Please use the formatting bar (especially the
code
option) to present your post better. I've done it for you this time.Thank you!
I know this thread is old but I have been trying to find a oneliner to append a single word to the end of all fasta headers in a file and for some reason, none of the ones I've found actually work.... for example if I have a file with format
This
sed
line outputs:....kinda useless. something must be amiss but I have no earthly idea what it is...
If you simply want to append SAMPLE at end
You may want to separate the word by a
_
and then in that caseThese examples use
sed
on a unix/linux system. What OS are you using?