Sunday, 12 April 2020

Encoding

Hi all,

Pls find the encoding program.

------------------------------------------------
//text=fileread(fullpathname);
text='HUP'
ASCII = double(text)
A=dec2bin(ASCII,8)

B= logical(A - 48)

 m=size(B,1)
 n=size(B,2)

p='A'
q='C'
r='G'
S= 'T'

k=1
 x=.4;
h=waitbar(x,'Process start');
for i=1:m
for j=1:2:n
if (B(i,j)==0 && B(i,j+1)==1)
sc(k)=p
elseif (B(i,j)==1 && B(i,j+1)==0)
sc(k)=q
elseif (B(i,j)==0 && B(i,j+1)==0)
sc(k)=r
else
sc(k)=S
end
k=k+1
end
end
p53nt = fastaread('p53nt.txt')
j=1
for i=1:4:length(sc)
k=strfind(p53nt.Sequence,sc(i:i+3))

code(j)=k(randi([1 length(k)]));
j=j+1;
end


fileID = fopen('Ciphertext.txt','w');
for (i=1:length(code))
fprintf(fileID,'%d ',code(i))
end

No comments:

Post a Comment