hiddenGem

Take Home Exam

Jun 20th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.69 KB | None | 0 0
  1. % Take home exam from my 201 Class
  2. % removed any identifying features
  3. % similar to DNA Strands to Amino Acids Paste
  4.  
  5. %%
  6.  
  7. % opening file
  8. seq_file = fopen('nonnatural.txt'); % Opens the text file
  9. temp5_3 = fscanf(seq_file,'%s'); % scanning file and saving it as a variable
  10.  
  11. % starting replication
  12. A = {'A' 'T'
  13.      'C' 'G'
  14.      'G' 'C'
  15.      'T' 'A'}; % creates matrix to for comparison of replication
  16.  
  17. for i = 1:length(temp5_3) % makes the for loop until end of the template
  18.    
  19.     row_A = strcmp(temp5_3(i),A(:,1)); % compares the template in 5'-3' to the matrix and saves it to variable
  20.     synth5_3(i) = char(A(row_A,2)); %#ok<SAGROW> % chooses the corresponding DNA base and saves it to a synth variable as a character
  21.        
  22. end
  23.  
  24. % starts transcription
  25.  
  26. sense5_3 = synth5_3; % moves synth strand to sense strand in the same direction
  27.  
  28. B = {'A' 'U'
  29.      'C' 'G'
  30.      'G' 'C'
  31.      'T' 'A'};
  32.  
  33. for i = 1:length(temp5_3)
  34.    
  35.     row_B = strcmp(sense5_3(i),B(:,1)); % compares the sense strand to the matrix and saves as a variable
  36.     RNA5_3(i) = char(B(row_B,2)); % chooses the corresponding RNA base and saves it in the RNA variable
  37.    
  38. end
  39.  
  40. methionine_positions=strfind(RNA5_3,'AUG'); % finds all the start codons
  41.  
  42. C = {'UUU' 'F'
  43.      'UUC' 'F'
  44.      'UUA' 'L'
  45.      'UUG' 'L'
  46.      'CUU' 'L'
  47.      'CUC' 'L'
  48.      'CUA' 'L'
  49.      'CUG' 'L'
  50.      'AUU' 'I'
  51.      'AUC' 'I'
  52.      'AUA' 'I'
  53.      'AUG' 'M'
  54.      'GUU' 'V'
  55.      'GUC' 'V'
  56.      'GUA' 'V'
  57.      'GUG' 'V'
  58.      'UCU' 'S'
  59.      'UCC' 'S'
  60.      'UCA' 'S'
  61.      'UCG' 'S'
  62.      'CCU' 'P'
  63.      'CCC' 'P'
  64.      'CCA' 'P'
  65.      'CCG' 'P'
  66.      'ACU' 'T'
  67.      'ACC' 'T'
  68.      'ACA' 'T'
  69.      'ACG' 'T'
  70.      'GCU' 'A'
  71.      'GCC' 'A'
  72.      'GCA' 'A'
  73.      'GCG' 'A'
  74.      'UAU' 'Y'
  75.      'UAC' 'Y'
  76.      'UAA' '*'
  77.      'UAG' '*'
  78.      'CAU' 'H'
  79.      'CAC' 'H'
  80.      'CAA' 'Q'
  81.      'CAG' 'Q'
  82.      'AAU' 'N'
  83.      'AAC' 'N'
  84.      'AAA' 'K'
  85.      'AAG' 'K'
  86.      'GAU' 'D'
  87.      'GAC' 'D'
  88.      'GAA' 'E'
  89.      'GAG' 'E'
  90.      'UGU' 'C'
  91.      'UGC' 'C'
  92.      'UGA' 'X' % new amino acid
  93.      'UGG' 'W'
  94.      'CGU' 'R'
  95.      'CGC' 'R'
  96.      'CGA' 'R'
  97.      'CGG' 'R'
  98.      'AGU' 'S'
  99.      'AGC' 'S'
  100.      'AGA' 'R'
  101.      'AGG' 'R'
  102.      'GGU' 'G'
  103.      'GGC' 'G'
  104.      'GGA' 'G'
  105.      'GGG' 'G'}; % Matrix for identifying amino acids
  106.  
  107. AA_seq = NaN; % preallocating the vector to not a number
  108. ORF = RNA5_3(methionine_positions(2):end); % subsets the RNA starting with the first AUG
  109. AA_pos = 1; % the first Amino Acid position in the character vector
  110. ORF_pos = 1:3; % makes sure groups of 3 will be scanned
  111.  
  112. while ~strcmp(char(AA_seq(end)),'*'); % only wants the loop run until it hits a stop codon
  113.    
  114.     row_C = strcmp(ORF(ORF_pos),C(:,1)); % compares the 3 RNA bases to the matrix for its amino acid and saves it as a vector
  115.     AA_seq(AA_pos) = char(C(row_C,2)); % chooses the corresponding amino acid and saves it in the Amino Acid sequence vector
  116.      
  117.     AA_pos = AA_pos + 1; % moves to the next Amino acid index in the vector
  118.     ORF_pos = ORF_pos + 3; % moves to the next 3 bases to compare
  119. end
  120.  
  121. AA_seq = char(AA_seq); % changes to a character vector
  122.  
  123. AA_org = {'MRCVIGKVAHDDVRK*'}; % orginal amino acid sequence
  124. AA_new = {'MRCVIGKVAHDDVRKXLSSVLCACVDSKYGTK*'} % new amino acid sequence
  125. org_value = strlength(AA_org); % length of the orginal strand
  126. new_value = strlength(AA_new); % length of the new strand
  127.  
  128. if org_value > new_value % if the orginal strand is longer
  129.     fprintf('orginal strand is longer') % prints the text
  130. elseif new_value > org_value % if new strand is longer
  131.     fprintf('new strand is longer') % prints the text
  132. else % if strands are the same size
  133.     fprintf('strands are the same size') % prints the text
  134. end
  135.  
Add Comment
Please, Sign In to add comment