I would like to add the following references at the very beggining of all my files:
Thus, the resulting file should look like this:
Any help will be very much appreciated
I would like to add the following references at the very beggining of all my files:
Thus, the resulting file should look like this:
Any help will be very much appreciated
Assuming your references are in "ref" file:
for f in *; do cat ref $f > $f.tmp; mv $f.tmp $f; done
Thanks but I have been using cat to add the references -located in file Reference.fas- with the following code
for i in *.fas
do
cat Reference.fas $i > Clipped$i.fas
done
It works ok but I was hoping there was another way to do it without the extra file (Reference.fas). Instead, I would like to include both sequences in my script, thus, I can just run the script without having to drop the Reference.fas file in the same folder.
Any ideas?
PS. Alternatively, I would not mind if I was able to create the Reference.fas file with both Reference sequences in it using the same script and then after adding the refrences to all files, the Reference.fas file will be just delete it using the same script.
for i in *.fas
do
printf ">REFERENCE1\nTGACNTGACGATGGAC\nCCCGGGGC\n>REFERENCE2\nGACAGTAGMGATCAGTAGCAGTAG\n" | cat - $i > Clipped$i.fas
done
Other way:
ref=">REFERENCE1
TGACNTGACGATGGAC
CCCGGGGC
>REFERENCE2
GACAGTAGMGATCAGTAGCAGTAG"
for i in *.fas
do
echo "$ref" | cat - $i > Clipped$i.fas
done
That worked pretty well!
GNU sed:
sed -i '1i\
>REFERENCE1\
TGACNTGACGATGGACCCCGGGGC\
>REFERENCE2\
GACAGTAGMGATCAGTAGCAGTAG
' *.fas
Very nice -as usual!
Thanks!