Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement Burrows-Wheeler Transform (BWT) in matlab: 1. (20 points) Implement fu

ID: 3567806 • Letter: I

Question

Implement Burrows-Wheeler Transform (BWT) in matlab:

1. (20 points) Implement function bwt that generates the reversible transformation of a sequence:
   - Syntax: bwtSeq = bwt(seq)
   - Input: seq that is a single letter-code representation of a nucleotide sequence.
   - Output: bwtSeq that is BWT of seq.

Use file 'sample1.fa' provided in section Datasets to get the input sequence, and report the BWT of that sequence to file 'bwtSample1.fa'.

2. (20 points) Implement function reverseBwt that reverses the Burrows-Wheeler Transform:
   - Syntax: seq = reverseBwt(bwtSeq)
   - Input: bwtSeq that is the BWT of a sequence seq.
   - Output: seq that is the original nucleotide sequence such that BWT(seq) = bwtSeq.

Use file 'bwtHomoSapiens.fa' provided in section Datasets to get the input sequence, and report the reversed BWT of that sequence to file 'rBwtSample2.fa'.

NOTE: No files included but you can just put in in your code.

Explanation / Answer

path=pwd; [filename, pathname] = uigetfile('*.txt', 'Pick a file'); cd(pathname) file_open=fopen(filename,'r'); file_read=fread(file_open,'uint8'); fclose(file_open); cd(path) disp('precessing..BWT Transform'); a=file_read; b=zeros(1,2*length(a)); for sort_len=1:length(b) if(sort_len>length(a)) b(sort_len)=a(sort_len-length(a)); else b(sort_len)=a(sort_len); end end a=char(a); b=char(b); to_sort=zeros(length(a),length(a)); for row_sort=1:length(a) to_sort(row_sort,:)=b(row_sort:length(a)+row_sort-1); end char(to_sort); [lexi_sorted_data,ind]=sortrows(to_sort); char(lexi_sorted_data); encoded_data=lexi_sorted_data(:,length(a)); primary_index=find(ind==2); out_data=[encoded_data',primary_index]; file_bwt=fopen('bwt.cmp','w'); fwrite(file_bwt,out_data,'uint8'); fclose(file_bwt); disp('BWT Transform over'); disp('file written to bwt.cmp');

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote