Adding sequences to alignment


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding sequences to alignment
# 1  
Old 06-23-2010
Adding sequences to alignment

I would like to add the following references at the very beggining of all my files:
Quote:
>REFERENCE1
TGACNTGACGATGGACCCCGGGGC
>REFERENCE2
GACAGTAGMGATCAGTAGCAGTAG
Thus, the resulting file should look like this:
Quote:
>REFERENCE1
TGACNTGACGATGGACCCCGGGGC
>REFERENCE2
GACAGTAGMGATCAGTAGCAGTAG
>GHXCZCC01AJ8CJ
TTGATGTGCCAGCTGCCGTTGGTGTGTATCAGCTGGATTTTCTGGGACGC
CCCGGGGC
>GHXCZCC01APUO5
TGATGTGCCAGCTGCCGTTGGTGTGTATCAGCTGGATTTCTGGGACGCCC
CGGGGCGA
>GHXCZCC01AQSRP
TTGATGTTGCCAGCTGCCGTTGGTGTGTATCAGCTGGATTTTCTGGGACG
CCCCGGGG
Any help will be very much appreciated

Last edited by Xterra; 06-23-2010 at 04:19 PM..
# 2  
Old 06-23-2010
Assuming your references are in "ref" file:
Code:
for f in *; do cat ref $f > $f.tmp; mv $f.tmp $f; done

# 3  
Old 06-23-2010
bartus11

Thanks but I have been using cat to add the references -located in file Reference.fas- with the following code
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.
# 4  
Old 06-23-2010
Code:
for i in *.fas
do
      printf ">REFERENCE1\nTGACNTGACGATGGAC\nCCCGGGGC\n>REFERENCE2\nGACAGTAGMGATCAGTAGCAGTAG\n" | cat - $i > Clipped$i.fas
done

Other way:
Code:
ref=">REFERENCE1
TGACNTGACGATGGAC
CCCGGGGC
>REFERENCE2
GACAGTAGMGATCAGTAGCAGTAG"
for i in *.fas
do
      echo "$ref" | cat - $i > Clipped$i.fas
done

# 5  
Old 06-23-2010
Thanks!

That worked pretty well!
# 6  
Old 06-23-2010
GNU sed:
Code:
sed -i '1i\
>REFERENCE1\
TGACNTGACGATGGACCCCGGGGC\
>REFERENCE2\
GACAGTAGMGATCAGTAGCAGTAG
' *.fas

# 7  
Old 06-23-2010
Scrutinizer

Very nice -as usual!
Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help with awk alignment

Dear All, I am in the beginning stage of learning shell scripting and preparing shell script on my own now. I would like to get help from fellow mates here. As I am trying to take O/P with space included from I/P table. Kindly guide me to align given I/P table as Expected O/P. ... (5 Replies)
Discussion started by: Raja007
5 Replies

2. Shell Programming and Scripting

Row alignment

*1 flash read test(*do_test1*) PASS *2 xxxxxxxxxxx flash write test(*do_test2) FAIL ------>xxxxx *1 flash read test(*do_test1*) PASS *2 xxxxxxxxxxx flash write test(*do_test2) FAIL ------>xxxxx I want pass and Fail to be aligned if each line uses printf or echo to print, is... (5 Replies)
Discussion started by: yanglei_fage
5 Replies

3. HP-UX

HP-UX text alignment

HI all, I tried to edit my files using HP-UX but my output tends to not align when I add another character in the files to edit my files i used the command is as follow chmod +w filename vi filename Help, :eek: (1 Reply)
Discussion started by: jasonhpwong
1 Replies

4. Shell Programming and Scripting

Formatting output alignment

Hi Gurus, I've the following output from my scripting as shown below. 0.48 GB 0.29 GB 0.19 GB 60% 0.48 GB 0.29 GB 0.19 GB 60% 228.90 GB 89.47 GB 139.42 GB 39% 228.76 GB 72.37 GB 156.39 GB 31% Is it possible to format this output into a proper... (16 Replies)
Discussion started by: superHonda123
16 Replies

5. Shell Programming and Scripting

alignment

Hi, I am having a file with with format. however, for longer xml, the xml code has been truncated like this. F1 |###################### |String1 |<XML><REQ><MSGTYPE>DBDIRECT</MSGTYPE><SYNC>0</SYNC><CLIENT>C11</CLIENT>NAME=MYNAME|JOB=MYJOB| | ... (3 Replies)
Discussion started by: shellwell
3 Replies

6. UNIX for Dummies Questions & Answers

VI paste out of alignment

We have a guy at work who is trying to copy and paste from one file to another using vi and highlighting the code to copy with a mouse. Source file: xyz 123 abc 999 zyx 321 cba 999 xyz 123 abc 999 But when he pastes it he gets (I put the underlines in to show... (4 Replies)
Discussion started by: dlam
4 Replies

7. Shell Programming and Scripting

alignment of variable

Dear Champs, i have a file let a.txt having value number text 00 123 012 145 456 ...etc i need number and text column vales should right align ??? how can i achive this ??? NOTE number is of max 3 char and text can take max 7 char...so if any records are less than above lengths... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

8. Shell Programming and Scripting

Alignment of terms to the left

Hi All, I have a set of data and i want to arrange it in a neater way. Is there any ways i can align each term to the left such that every field start on the same vertical point Actual Data 111111 bbb dddd zz 111111 bbbbbb dddd zz 111111 bbbbbbbbb dddd zz 111111 aa dddd zzz (2 Replies)
Discussion started by: Raynon
2 Replies

9. UNIX for Dummies Questions & Answers

Column Alignment

I copied a word file to my Unix directory, How do I line up my columns to the file I copied over? (3 Replies)
Discussion started by: nikncha
3 Replies
Login or Register to Ask a Question