How do I connect my strings to my function?
Show older comments
I need to use the input nucleotide to make a string of amino acids. I am unsure how to use a for loop to do this, if someone could please help me. My code is below:
function [aminoAcidChain] = synthesise(nucleotide)
nucleotide = input('Please enter a nucelotide chain: ','s');
%Make sure code is all uppercase and 3 characters long
nucleotide = upper(nucleotide);
while ~all(ismember(nucleotide, 'AGUC'))
error('Character entered is invalid.');
end
%Divide the nucleotide chain into groups of 3 and discard leftover
%characters
if length (nucleotide)<3
aminoAcidChain= char([]);
end
codonChain = floor(length(nucleotide)/3);
aminoAcidChain = char(zeros(codonChain,3));
for i = 1:codonChain
start(i)= 3<(i-1)+1;
finish(i) = start+2;
CCodons = codonChain(start(i) : finish(i));
aminoAcidChain(i,:) = CCodons;
end
%convert codons to amino acids
UUC = {'F'};
UUU = {'F'};
UUA = {'L'};
UUG = {'L'};
CUU = {'L'};
CUC = {'L'};
CUG = {'L'};
AUU = {'I'};
AUC = {'I'};
AUA = {'I'};
AUG = {'M'};
GUU = {'V'};
GUC = {'V'};
GUA = {'V'};
GUG = {'V'};
UCU = {'S'};
UCC = {'S'};
UCA = {'S'};
UCG = {'S'};
CCU = {'P'};
CCC = {'P'};
CCA = {'P'};
CCG = {'P'};
ACU = {'T'};
ACC = {'T'};
ACA = {'T'};
ACG = {'T'};
GCU = {'A'};
GCC = {'A'};
GCA = {'A'};
GCG = {'A'};
UAU = {'Y'};
UAC = {'Y'};
CAU = {'H'};
CAC = {'H'};
CAA = {'Q'};
CAG = {'Q'};
AAU = {'N'};
AAC = {'N'};
AAA = {'K'};
AAG = {'K'};
GAU = {'D'};
GAC = {'D'};
GAA = {'E'};
GAG = {'E'};
UGU = {'C'};
UGC = {'C'};
UGG = {'W'};
CGU = {'R'};
CGC = {'R'};
CGA = {'R'};
CGC = {'R'};
AGU = {'S'};
AGC = {'S'};
AGA = {'R'};
AGG = {'R'};
GGU = {'G'};
GGC = {'G'};
GGA = {'G'};
GGG = {'G'};
UAA = {'STOP'};
UAG = {'STOP'};
UGA = {'STOP'};
fprintf('The resulting amino acid chain from the nucleotide is %s.',codonChain);
end
Accepted Answer
More Answers (0)
Categories
Find more on Sequence Alignment in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!