Hello everybody, I have multiple fasta files from multiple samples I am trying to add the sample names in each sequence within each fasta file.
My one file looks like :
>M03691:51:000000000-BD94Y:1:1101:14841:1381 1:N:0:1
ACTGGGTGTAAAGGGCGTGTAGGCGGAGAAGCAAGTCAGAAGTGAAATCCATGGGCTTAACCCATGAACTGCTTTTGAAACTGTTTCCCTTGAGTATCGGAGAGGCAGGCGGAATTCCTAGTGTAGCGGTGAAATGCGTAGATATTAGGAGGAACACCAGTGGCGAAGGCGGCCTGCTGGACGACAACTGACGCTGAGGCGCGAAAGCGTGGGGAGCAAACAGGATTAGATACCCCGGT
>M03691:51:000000000-BD94Y:1:1101:15960:1389 1:N:0:1
TACTGGGGTATCTAATCCTATTTGCTCCCCACGCTTTCGGGACTGAGCGTCAGTTATGCGCCAGATCGTCGCCTTCGCCACTGGTGTTCCTCCATATATCTACGCATTTCACCGCTACACATGGAATTCCACGATCCTCTCACACACTCTAGCTCTACGGTTTCCATGGCTTACCGAAGTTAAGCTTCGATCTTTCACCACAGACCCTTAGTGCCGCCTGCTCCCTCTTTACACCCAGT
>M03691:51:000000000-BD94Y:1:1101:15662:1415 1:N:0:1
ACTGGGTGTAAAGGGCTCGTAGGCGGTTCGTCGCGTCCGGTGTGAAAGTCCATCGCTTAACGGTGGATCTGCGCCGGGTACGGGCGGGCTGGAGTGCGGTAGGGGAGACTGGAATTCCCGGTGTAACGGTGGAATGTGTAGATATCGGGAAGAACACCAATGGCGAAGGCAGGTCTCTGGGCCGTTACTGACGCTGAGGAGCGAAAGCGTGGGGAGCGAACAGGATTAGATACCCCCGTA
Now For example I want to add Sample1 in front of every sequence in this file. Keeping everything else as it is.
In this case I found one old post in Biostart which is very similar.. C: Renaming Entries In A Fasta File ..But it completely rename the header. I want to keep everything only add the sample name after >.
And addition I want to do this for a batch of files. So I assume I need to run some loop?
I am trying with this code...and obviously not successful. When I am in the folder where I have all the fasta files. I try to do this.
for f in *.fasta ; do
bname=`basename $f`
pref=${bname%%.fasta}
awk '/^>/{print ">bname" ++i next; next}{print}' < $f > ${pref}_new.fasta;
done
Can anybody please help me with this? Thanks,
Mitra
Are you doing this for the purpose of adding read groups to the samples?
I need to add Sample names to all sequences as later I want to concatenate all fasta files together and feed it for OTU picking in qiime. Thanks.
Qiime has accessory programs to do this sort of thing. Are you not following their workflow?
Please let me know if QIIME has any direct way to do this? I could't find any ..... There only it said I need to pass the file as labelled if I work with demultiplexed files. But not said how I can do this. So this is above as I was trying.