Fasta file from *.tab file
1
0
Entering edit mode
9.9 years ago
GP ▴ 10

Hi All,

I want to extract functional sequences from the tab separated file and convert it into the fasta file. I use mac and i know its possible with the awk command but I don't know how to use that so any help/indicator would be appreciated.

The tab file that I have is look like-

No  Seq ID  Functionality  Sequence
1    Seq_1        Yes          atcggtcggctggt

The output I want is-

>seq1
atcggtcggctggt

Thanks for any help!

sequence • 4.9k views
ADD COMMENT
2
Entering edit mode

If the proposed solution is not working, post the actual lines from your data file, and format as code.

You could also do a simple python script. Something like (untested):

with open('myfile.txt') as f:
    for line in f:
        fields = line.split('\t')
        print ">{}\n{}".format(fields[5],fields[6])
ADD REPLY
1
Entering edit mode
9.9 years ago
grep -v Functionality < file.tab |\
awk -F '\t' '{printf(">%s\n%s\n",$2,$7);}'
ADD COMMENT
0
Entering edit mode

Hi Pierre,

Thanks for the fast reply. The command you gave worked well, however, it extracting the wrong sequence (I changed the $4 to $7 because I want seq from that column but didn't work, it extracts the seqs from different column. I tried other $column number but still not working.

In .tab file, a few entries in columns before $7 is empty, may be thats causing the problem in extracting the sequences from the column I want? Any suggestion how to solve this (I also tried to upload picture of the data file here but don't know how it works)

Thanks!

ADD REPLY
0
Entering edit mode

added -F '\t' to specify the tabulation as the delimiter.

ADD REPLY
0
Entering edit mode

Updated command works well with all other columns but unfortunately not with the $6 and $7, don't know whats wrong? Is there anything more that can be changed or modification in the file that can help?

Again, thanks.

ADD REPLY

Login before adding your answer.

Traffic: 1960 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6