Advertisement
stupid_pro

prac2_ann

Dec 25th, 2023
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 24.45 KB | None | 0 0
  1. uses SysUtils;
  2.  
  3. {
  4.     nucleotid_coord - координаты нуклеотидов для печати
  5.     series - последовательности с именем, типом, координатами
  6. }
  7.  
  8. type
  9.     nucleotid_coord = record
  10.         str_coord: longint;
  11.         column_coord: longint;  
  12.         val: char;
  13.     end;
  14.    
  15.     series = record
  16.         name: array of char;
  17.         type_trip: (DNA, RNA, NoName);
  18.         items: array of nucleotid_coord;
  19.     end;
  20.    
  21. {
  22.     table_tripl - массив для расшифровки аминокислот
  23. }
  24.     table_tripl = array['A'..'Y', 1..6] of string;
  25.  
  26. {
  27.     file1, file2 - текстовые файлы для чтения
  28.     file_amin - файл с аминокислотами
  29.     file_nucl - файл с последовательностями ДНК, РНК
  30.  
  31.     mode - режим (1 или 4)
  32.     space - сколько можем максимально пропустить триплетов
  33.     iter - счетчик пропусков триплетов
  34.  
  35.     nucleatide - массив нуклеотидов с именем, типом (ДНК/РНК и тд) и координатами
  36.     aminoAcidArr - массив аминокислотных остатков
  37.     table_of_amin - таблица триплетов
  38.  
  39.     len_amin - длина последовательности из аминокислот
  40.     i, j - итераторы
  41.     str, colomn - координаты для старта и конца
  42.     multiplier - множитель (коэффицент) для выделения памяти с запасом
  43.     counter - счетчик для освобождения лишней памяти
  44.  
  45.     flag_start_name - флаг начала названия новой последовательности
  46.     flag_error - флаг ошибки
  47.     dop_flag - флаг для 4 режима (найдена нужная последовательность через <= space триплетов)
  48. }
  49. var
  50.     file_amin, file_nucl: file of char;
  51.     file1, file2: string;
  52.    
  53.     mode: integer;
  54.     space: longint;
  55.    
  56.     nucleatide: series;
  57.     aminoAcidArr: array of char;
  58.     table_of_amin: table_tripl;
  59.    
  60.     len_amin, coloumn, str, multiplier: longint;
  61.    
  62.     flag_start_name, flag_error, dop_flag: boolean;
  63.  
  64. {
  65.     таблица триплетов
  66. }
  67. procedure CreateTable(var table_of_amin: table_tripl);
  68. begin
  69.     table_of_amin['A'][1] := 'GCU';
  70.     table_of_amin['A'][2] := 'GCC';
  71.     table_of_amin['A'][3] := 'GCA';
  72.     table_of_amin['A'][4] := 'GCG';
  73.    
  74.     table_of_amin['R'][1] := 'CGU';
  75.     table_of_amin['R'][2] := 'CGC';
  76.     table_of_amin['R'][3] := 'CGA';
  77.     table_of_amin['R'][4] := 'CGG';
  78.     table_of_amin['R'][5] := 'AGA';
  79.     table_of_amin['R'][6] := 'AGG';
  80.    
  81.     table_of_amin['N'][1] := 'AAU';
  82.     table_of_amin['N'][2] := 'AAC';
  83.    
  84.     table_of_amin['D'][1] := 'GAU';
  85.     table_of_amin['D'][2] := 'GAC';
  86.    
  87.     table_of_amin['C'][1] := 'UGU';
  88.     table_of_amin['C'][2] := 'UGC';
  89.    
  90.     table_of_amin['Q'][1] := 'CAA';
  91.     table_of_amin['Q'][2] := 'CAG';
  92.    
  93.     table_of_amin['E'][1] := 'GAA';
  94.     table_of_amin['E'][2] := 'GAG';
  95.    
  96.     table_of_amin['G'][1] := 'GGU';
  97.     table_of_amin['G'][2] := 'GGC';
  98.     table_of_amin['G'][3] := 'GGA';
  99.     table_of_amin['G'][4] := 'GGG';
  100.    
  101.     table_of_amin['H'][1] := 'CAU';
  102.     table_of_amin['H'][2] := 'CAC';
  103.    
  104.     table_of_amin['I'][1] := 'AUU';
  105.     table_of_amin['I'][2] := 'AUC';
  106.     table_of_amin['I'][3] := 'AUA';
  107.    
  108.     table_of_amin['L'][1] := 'UUA';
  109.     table_of_amin['L'][2] := 'UUG';
  110.     table_of_amin['L'][3] := 'CUU';
  111.     table_of_amin['L'][4] := 'CUC';
  112.     table_of_amin['L'][5] := 'CUA';
  113.     table_of_amin['L'][6] := 'CUG';
  114.    
  115.     table_of_amin['K'][1] := 'AAA';
  116.     table_of_amin['K'][2] := 'AAG';
  117.    
  118.     table_of_amin['M'][1] := 'AUG';
  119.    
  120.     table_of_amin['F'][1] := 'UUU';
  121.     table_of_amin['F'][2] := 'UUC';
  122.    
  123.     table_of_amin['P'][1] := 'CCU';
  124.     table_of_amin['P'][2] := 'CCC';
  125.     table_of_amin['P'][3] := 'CCA';
  126.     table_of_amin['P'][4] := 'CCG';
  127.    
  128.     table_of_amin['S'][1] := 'UCU';
  129.     table_of_amin['S'][2] := 'UCC';
  130.     table_of_amin['S'][3] := 'UCA';
  131.     table_of_amin['S'][4] := 'UCG';
  132.     table_of_amin['S'][5] := 'AGU';
  133.     table_of_amin['S'][6] := 'AGC';
  134.    
  135.     table_of_amin['T'][1] := 'ACU';
  136.     table_of_amin['T'][2] := 'ACC';
  137.     table_of_amin['T'][3] := 'ACA';
  138.     table_of_amin['T'][4] := 'ACG';
  139.    
  140.     table_of_amin['W'][1] := 'UGG';
  141.    
  142.     table_of_amin['Y'][1] := 'UAU';
  143.     table_of_amin['Y'][2] := 'UAC';
  144.    
  145.     table_of_amin['V'][1] := 'GUU';
  146.     table_of_amin['V'][2] := 'GUC';
  147.     table_of_amin['V'][3] := 'GUA';
  148.     table_of_amin['V'][4] := 'GUG';
  149. end;
  150.  
  151. {
  152.     start_str, end_str - координаты начала и конца по строке
  153.     start_clmn, end_clmn - координаты начала и конца по столбцу
  154.     clmn_i - итератор по столбцам
  155.     str_i - итератор по строкам
  156.  
  157.     start_pos - начальная позиция
  158.     end_pos - финальная позиция
  159.  
  160.     процедура вывода координат в обратной проходке
  161. }
  162.  
  163. procedure Print_End_Start(var nucleatide: series;
  164.             start_pos: longint; end_pos: longint;
  165.             start_str: longint; end_str: longint;
  166.             start_clmn: longint; end_clmn: longint;
  167.             end_coord: longint);
  168. var
  169.     i, clmn_i, str_i: longint;
  170. begin
  171.     clmn_i := 1;
  172.     str_i := 0;
  173.     for i := 1 to Length(nucleatide.name) - 1 do
  174.         write(nucleatide.name[i]);
  175.     writeln;
  176.     writeln('[', start_pos - end_coord, ', ',  end_pos - end_coord, ']');
  177.     writeln('(', start_str, ', ', start_clmn, ')', ' - (', end_str, ', ', end_clmn, ')');
  178.     i := end_pos + 2;
  179.     while (i <= start_pos + 2) do
  180.     begin
  181.         while (clmn_i <= 10) and (i <= start_pos + 2) do
  182.         begin
  183.             write(nucleatide.items[i].val);
  184.             clmn_i += 1;
  185.             i += 1;
  186.         end;
  187.         clmn_i := 1;
  188.         str_i += 1;
  189.         write(' ');
  190.         i += 6;
  191.         if (str_i mod 6 = 0) then
  192.             writeln;
  193.     end;
  194.     writeln;
  195. end;
  196.  
  197. procedure Print_Start_End(var nucleatide: series;
  198.             start_pos: longint; end_pos: longint;
  199.             start_str: longint; end_str: longint;
  200.             start_clmn: longint; end_clmn: longint);
  201. var
  202.     i, clmn_i, str_i: longint;
  203. begin
  204.     clmn_i := 1;
  205.     str_i := 0;
  206.     for i := 1 to Length(nucleatide.name) - 1 do
  207.         write(nucleatide.name[i]);
  208.     writeln;
  209.     writeln('[', start_pos, ', ', end_pos, ']');
  210.     writeln('(', start_str, ', ', start_clmn, ')', ' - (', end_str, ', ', end_clmn, ')');
  211.     i := start_pos;
  212.     while (i <= end_pos) do
  213.     begin
  214.         while (clmn_i <= 10) and (i <= end_pos) do
  215.         begin
  216.             write(nucleatide.items[i].val);
  217.             clmn_i += 1;
  218.             i += 1;
  219.         end;
  220.         clmn_i := 1;
  221.         str_i += 1;
  222.         write(' ');
  223.         if (str_i mod 6 = 0) then
  224.             writeln;
  225.     end;
  226.     writeln;
  227. end;
  228.  
  229. procedure CreateDNA(var nucleatide: series;
  230.                     var triplet: string; i: longint);
  231. var
  232.     j: longint;
  233. begin
  234.     for j := i + 2 downto i do
  235.     begin
  236.         if (nucleatide.items[j].val = 't') or
  237.            (nucleatide.items[j].val = 'T') then
  238.         begin
  239.             triplet += 'A';
  240.             continue;
  241.         end;
  242.         if (nucleatide.items[j].val = 'a') or
  243.            (nucleatide.items[j].val = 'A') then
  244.         begin
  245.             triplet += 'U';
  246.             continue;
  247.         end;
  248.         if (nucleatide.items[j].val = 'g') or
  249.            (nucleatide.items[j].val = 'G') then
  250.         begin
  251.             triplet += 'C';
  252.             continue;
  253.         end;
  254.        if (nucleatide.items[j].val = 'c') or
  255.            (nucleatide.items[j].val = 'C') then
  256.         begin
  257.             triplet += 'G';
  258.             continue;
  259.         end;
  260.         if nucleatide.items[j].val in ['a'..'z'] then
  261.             triplet += (chr(ord(nucleatide.items[j].val) - (ord('a') - ord('A'))))
  262.         else
  263.             triplet += nucleatide.items[j].val;
  264.     end;
  265.    
  266. end;
  267.  
  268.  
  269. procedure CreateTrip(var nucleatide: series;
  270.                      var triplet: string; i: longint);
  271. var
  272.     j: longint;
  273. begin
  274.     for j := i to 2 + i do
  275.     begin
  276.         if (nucleatide.type_trip = DNA) then
  277.             if (nucleatide.items[j].val = 't') or
  278.                (nucleatide.items[j].val = 'T') then
  279.             begin
  280.                 triplet += 'U';
  281.                 continue;
  282.             end;
  283.         if nucleatide.items[j].val in ['a'..'z'] then
  284.             triplet += (chr(ord(nucleatide.items[j].val) - (ord('a') - ord('A'))))
  285.         else
  286.             triplet += nucleatide.items[j].val;
  287.     end;
  288. end;
  289.  
  290. {
  291.     count_error - счетчик сколько уже пропустили
  292. }
  293. procedure Find(var nucleatide: series;
  294.                var aminoAcids: array of char;  
  295.                Tabble: table_tripl; space: longint);
  296. var
  297.     i, k, count_occure, num_in_trip: longint;
  298.     triplet: string;
  299.     cur_amino_acid: char;
  300.     flag_right_triplet, flag_mini_start: boolean;
  301.     flag_find, flag_main_start: boolean;
  302.     start_pos, end_pos: longint;
  303.     start_clmn, start_str, end_clmn, end_str: longint;
  304.     count_error: longint;
  305. begin
  306.     count_error := 0;
  307.     triplet := ' ';
  308.     cur_amino_acid := ' ';
  309.     flag_right_triplet := false;
  310.     flag_mini_start := false;
  311.     flag_find := false;
  312.     start_pos := 1;
  313.     while not flag_find do
  314.     begin
  315.         for num_in_trip := 0 to 2 do
  316.         begin
  317.             count_occure := 0;
  318.             i := start_pos + num_in_trip;
  319.             flag_find := false;
  320.             flag_right_triplet := false;
  321.             end_pos := 1;
  322.             cur_amino_acid := ' ';
  323.             flag_main_start := true;
  324.  
  325.             i += 1;
  326.             while (i <= Length(nucleatide.items) - 2) do
  327.             begin
  328.                 count_error := 0;
  329.                 triplet := '';
  330.                 i -= 2;
  331.                 CreateTrip(nucleatide, triplet, i);
  332.                 i += 2;
  333.                 if flag_right_triplet or flag_main_start then
  334.                     cur_amino_acid := aminoAcids[count_occure];
  335.                 for k := 1 to Length(Tabble[cur_amino_acid]) do
  336.                 begin
  337.                     if (Tabble[cur_amino_acid][k] = triplet) then
  338.                     begin
  339.                         flag_right_triplet := true;
  340.                         flag_mini_start := true;
  341.                        
  342.                         if (count_occure = 0) then
  343.                         begin
  344.                             start_pos := i;
  345.                             start_str := nucleatide.items[i].str_coord;
  346.                             start_clmn := nucleatide.items[i].column_coord;
  347.                         end;
  348.                         count_occure += 1;
  349.                         break;
  350.                     end;
  351.                     if (Tabble[cur_amino_acid][k] <> triplet) then
  352.                         flag_right_triplet := false;
  353.                 end;
  354.                 if (i > 1) and not (flag_right_triplet) and flag_mini_start then
  355.                 begin
  356.                     if (flag_main_start) and (mode = 4) then
  357.                     begin
  358.                         count_error += 1;
  359.                         if (count_error > space) then
  360.                             break;
  361.                     end
  362.                     else if (mode = 1) then
  363.                         break;
  364.                 end;
  365.                 if (count_occure >= Length(aminoAcidArr)) and flag_right_triplet then
  366.                 begin
  367.                     flag_find := true;
  368.                     end_str := nucleatide.items[i + 2].str_coord;
  369.                     end_clmn := nucleatide.items[i + 2].column_coord;
  370.                     end_pos := i + 2;
  371.                     break;
  372.                 end;
  373.                 if (flag_mini_start) then
  374.                     i += 3
  375.                 else
  376.                     i += 1;
  377.                 if (count_error > space) and (mode = 4) then
  378.                 begin
  379.                     flag_main_start := false
  380.                 end
  381.                 else
  382.                 if (mode = 1) then
  383.                     flag_main_start := false
  384.             end;
  385.            
  386.             if (flag_find) then
  387.             begin
  388.                 if count_occure < Length(aminoAcidArr) then
  389.                 begin
  390.                     flag_find := false;
  391.                     continue;
  392.                 end;
  393.                 Print_Start_End(nucleatide, start_pos, end_pos,
  394.                      start_str, end_str, start_clmn, end_clmn);
  395.                 break;
  396.             end
  397.         end;
  398.        
  399.         if (num_in_trip = 2) and (not flag_find)
  400.             and ((mode = 4) or (mode = 1)) then
  401.         begin
  402.             start_pos += 3;
  403.             triplet := '';
  404.             i -= 6;
  405.             CreateTrip(nucleatide, triplet, i);
  406.             i += 6;
  407.         end;
  408.         if i > Length(nucleatide.items) then
  409.             exit;
  410.     end;
  411. end;
  412.  
  413. {
  414.     flag_mini_start - начало каждого триплета
  415.     flag_main_start - начало всей последовательности
  416. }
  417. procedure FindDNA(var nucleatide: series; var aminoAcids: array of char;
  418.                   Tabble: table_tripl);
  419. var
  420.     i, k, count_occure, num_in_trip: longint;
  421.     triplet: string;
  422.     cur_amino_acid: char;
  423.     flag_right_triplet, flag_mini_start: boolean;
  424.     flag_find, flag_main_start: boolean;
  425.     start_pos, end_pos: longint;
  426.     start_clmn, start_str, end_clmn, end_str: longint;
  427. begin
  428.     triplet := ' ';
  429.     cur_amino_acid := ' ';
  430.     flag_right_triplet := false;
  431.     flag_mini_start := false;
  432.     flag_find := false;
  433.     start_pos := Length(nucleatide.items);
  434.     i := start_pos - 2;
  435.     while not flag_find do
  436.     begin
  437.         if i < 1 then
  438.             break;
  439.         for num_in_trip := 0 to 2 do
  440.         begin
  441.             count_occure := 0;
  442.             i := start_pos + num_in_trip - 2;
  443.             flag_find := false;
  444.             flag_right_triplet := false;
  445.             end_pos := Length(nucleatide.items);
  446.             cur_amino_acid := ' ';
  447.             flag_main_start := true;  
  448.             flag_mini_start := false;
  449.            
  450.             if (num_in_trip = 2) then
  451.                 i -= 1;
  452.             i -= 1;
  453.             while (i >= 1) do
  454.             begin
  455.                 triplet := '';
  456.                 CreateDNA(nucleatide, triplet, i);
  457.                 if ((triplet = ('UAA')) or ((triplet = 'UGA')) or
  458.                         ((triplet = 'UAG'))) and (flag_mini_start) then
  459.                 begin
  460.                     if flag_right_triplet then
  461.                         flag_find := true;
  462.                     break;
  463.                 end;
  464.                 if flag_right_triplet or flag_main_start then
  465.                     cur_amino_acid := aminoAcids[count_occure];
  466.                
  467.                 for k := 1 to Length(Tabble[cur_amino_acid]) do                    
  468.                     if (Tabble[cur_amino_acid][k] = triplet) and (Length(triplet) <> 0) then
  469.                     begin
  470.                         flag_right_triplet := true;
  471.                         flag_mini_start := true;
  472.                         if (count_occure = 0) then
  473.                         begin
  474.                             start_pos := i;
  475.                             start_str := nucleatide.items[i].str_coord;
  476.                             start_clmn := nucleatide.items[i].column_coord;
  477.                         end;
  478.                         count_occure += 1;
  479.                         break;
  480.                     end
  481.                     else
  482.                         flag_right_triplet := false;
  483.                 if (i > 1) and not (flag_right_triplet) and flag_mini_start then
  484.                 begin
  485.                     if (i < 3) then
  486.                         flag_find := false;
  487.                     break;
  488.                 end;
  489.                 if (count_occure = Length(aminoAcidArr)) and flag_right_triplet then
  490.                 begin
  491.                     flag_find := true;
  492.                     end_str := nucleatide.items[i].str_coord;
  493.                     end_clmn := nucleatide.items[i].column_coord;
  494.                     end_pos := i - 2;
  495.                     break;
  496.                 end;
  497.                 if flag_mini_start then
  498.                     i -= 3
  499.                 else
  500.                     i -= 1;
  501.                 flag_main_start := false;
  502.             end;
  503.             if (flag_find) and (i >= 1)  then
  504.             begin
  505.                 if count_occure < Length(aminoAcidArr) then
  506.                 begin
  507.                     flag_find := false;
  508.                     continue;
  509.                 end;
  510.                 Print_End_Start(nucleatide, start_pos, end_pos,
  511.                     start_str, end_str, start_clmn, end_clmn,
  512.                     length(nucleatide.items));
  513.                 break;
  514.                
  515.             end;
  516.         end;
  517.         if (num_in_trip = 2) and not (flag_find)
  518.             and ((mode = 4) or (mode = 1)) then
  519.         begin
  520.             start_pos -= 3;
  521.             triplet := '';
  522.             CreateDNA(nucleatide, triplet, i);
  523.         end;
  524.         if i > Length(nucleatide.items) then
  525.             exit;
  526.        
  527.     end;
  528. end;
  529.  
  530. {
  531.     основное тело программы
  532.  
  533.     current_sym - текущий символ
  534.     i, j - итераторы
  535. }
  536. var
  537.     current_sym: char;
  538.     i, j: longint;
  539.     iter_param : longint;
  540.  
  541. begin
  542.     file1 := ParamStr(1);
  543.     file2 := ParamStr(2);
  544.     Val(ParamStr(3), mode);
  545.     space := 0;
  546.     if (mode = 4) then
  547.     begin
  548.         for iter_param := 1 to length(ParamStr(4)) do
  549.         begin
  550.             if not((ParamStr(4)[iter_param] >= '0') and
  551.                  (ParamStr(4)[iter_param] <= '9')) then
  552.             begin
  553.                 writeln('error parametr');
  554.                 halt;
  555.             end
  556.         end;
  557.         Val(ParamStr(4), space);
  558.  
  559.         if (space < 0) then
  560.         begin
  561.             writeln('error parametr');
  562.             halt;
  563.         end
  564.         else
  565.             writeln(space);
  566.     end
  567.     else
  568.     if (mode <> 1) then
  569.     begin
  570.         writeln('error mode');
  571.         exit;
  572.     end;
  573.  
  574.     if (space = 0) then mode := 1;
  575.    
  576.     Assign(file_amin, file1);
  577.     Assign(file_nucl, file2);
  578.    
  579.     Reset(file_amin);
  580.     Reset(file_nucl);
  581.    
  582.     len_amin := FileSize(file_amin);
  583.     SetLength(aminoAcidArr, len_amin);
  584.    
  585.     flag_start_name := false;
  586.     CreateTable(table_of_amin);
  587.    
  588.     {
  589.         запись последовательности аминокислот
  590.     }
  591.     i := 0;
  592.     while not Eof(file_amin) do
  593.     begin
  594.         if (i = 0) then
  595.             Read(file_amin, current_sym);
  596.        
  597.         if (current_sym = '>') then
  598.             while (current_sym <> #10) do
  599.                 if not Eof(file_amin) then
  600.                     Read(file_amin, current_sym);
  601.        
  602.         if (not Eof(file_amin)) and (i <> 0) then
  603.             Read(file_amin, current_sym);
  604.        
  605.         if (not ((current_sym in ['A'..'Z']) or
  606.                  (current_sym in ['0'..'9']) or
  607.                  (current_sym in [' ', '-', #9, #10, #11]))) then
  608.         begin
  609.             writeln('error in series of amin');
  610.             exit;
  611.         end;
  612.        
  613.         if (mode = 1) or (mode = 4) then
  614.         begin
  615.             if (current_sym in ['A'..'Z']) then
  616.             begin
  617.                 len_amin := i + 1;
  618.                 aminoAcidArr[i] := current_sym;
  619.                 i += 1;
  620.             end;
  621.         end;
  622.     end;
  623.    
  624.     SetLength(aminoAcidArr, len_amin);
  625.     i := 1;
  626.     j := 1;
  627.     coloumn := 1;
  628.     str := 1;
  629.    
  630.     {
  631.         запись последовательности нуклеотидов
  632.     }
  633.     multiplier := 1;
  634.     while not eof(file_nucl) do
  635.     begin
  636.         flag_error := false;
  637.         if not flag_start_name then
  638.             read(file_nucl, current_sym);
  639.        
  640.         {
  641.             начало новой последовательности
  642.         }
  643.         if(current_sym = '>') then
  644.         begin
  645.             j := 1;
  646.             SetLength(nucleatide.name, 100);
  647.            
  648.             if not Eof(file_nucl) then
  649.                 read(file_nucl, current_sym);
  650.            
  651.             while (current_sym <> #10) do
  652.             begin
  653.                 if (j > multiplier * 100 - 1) then
  654.                 begin
  655.                     multiplier += 1;
  656.                     SetLength(nucleatide.name, 100 * multiplier);
  657.                 end;
  658.                 nucleatide.name[j] := current_sym;
  659.                 j += 1;
  660.                 if not Eof(file_nucl) then
  661.                     read(file_nucl, current_sym)
  662.                 else
  663.                     break;
  664.             end;
  665.             str += 1;
  666.             if not Eof(file_nucl) then
  667.                 read(file_nucl, current_sym)
  668.             else
  669.             begin
  670.                 writeln('free series');
  671.                 break;
  672.             end;
  673.            
  674.             SetLength(nucleatide.items, 100);
  675.             j := 1;
  676.             nucleatide.type_trip := NoName;
  677.             multiplier := 1;
  678.            
  679.             if(current_sym = '>') then
  680.             begin
  681.                 writeln('free series');
  682.                 SetLength(nucleatide.name, 0);  
  683.                 SetLength(nucleatide.items, 0);
  684.                 nucleatide.type_trip := NoName;
  685.                 continue;
  686.             end;
  687.            
  688.             coloumn := 1;
  689.             while(current_sym <> '>') do  
  690.             begin
  691.                 if (current_sym = #10) then
  692.                 begin
  693.                     str += 1;
  694.                     coloumn := 1;
  695.                 end;
  696.                 if (j > multiplier * 100 - 1) then
  697.                 begin
  698.                     multiplier += 1;
  699.                     SetLength(nucleatide.items, 100 * multiplier);
  700.                 end;
  701.                 if not ((current_sym in [' ', '-', #10, #9, #11]) or
  702.                         (current_sym in ['0'..'9']) or
  703.                         (current_sym in ['A', 'a', 'C', 'c', 'G', 'g', 'U', 'u', 'T', 't'])) then
  704.                 begin
  705.                     writeln('error input series');
  706.                     writeln;
  707.                     flag_error := true;
  708.                 end;
  709.                 if (current_sym in ['A', 'a', 'C', 'c', 'G', 'g', 'U', 'u', 'T', 't']) then
  710.                 begin
  711.                     if ((current_sym = 'u') or (current_sym = 'U'))
  712.                         and (nucleatide.type_trip = NoName) then
  713.                         nucleatide.type_trip := RNA;
  714.                    
  715.                     if ((current_sym = 't') or (current_sym = 'T'))
  716.                         and (nucleatide.type_trip = NoName) then
  717.                         nucleatide.type_trip := DNA;
  718.                    
  719.                     if ((nucleatide.type_trip = DNA) and (current_sym = 'u'))
  720.                        or ((nucleatide.type_trip = RNA) and (current_sym = 't')) then
  721.                         writeln('error input of series');
  722.                    
  723.                     nucleatide.items[j].val := current_sym;
  724.                     nucleatide.items[j].str_coord := str;
  725.                     nucleatide.items[j].column_coord := coloumn;
  726.                     j += 1;
  727.                 end;
  728.                 if not Eof(file_nucl) then
  729.                 begin
  730.                     read(file_nucl, current_sym);
  731.                     coloumn += 1;
  732.                 end
  733.                 else
  734.                     break;
  735.             end;
  736.            
  737.             if (nucleatide.type_trip = NoName) then
  738.                 nucleatide.type_trip := DNA;
  739.            
  740.             if (nucleatide.type_trip = RNA) and (not flag_error) then
  741.             begin
  742.                 Find(nucleatide, aminoAcidArr, table_of_amin, space);
  743.                 writeln;
  744.             end
  745.             else if (nucleatide.type_trip = DNA) and (not flag_error) then
  746.             begin
  747.                 Find(nucleatide, aminoAcidArr, table_of_amin, space);
  748.                 FindDNA(nucleatide, aminoAcidArr, table_of_amin);
  749.                 writeln;
  750.             end;
  751.             flag_start_name := true;
  752.             SetLength(nucleatide.name, 0);  
  753.             SetLength(nucleatide.items, 0);
  754.             nucleatide.type_trip := NoName;
  755.         end;
  756.     end;
  757.     close(file_amin);
  758.     close(file_nucl);
  759. end.
  760.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement