Advertisement
Tony041010

DNA轉錄

Jul 14th, 2021
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub Command1_Click()
  2.     '第一題,給定一DNA片段,請產生mRNA片段
  3.    For i = 1 To Len(Text1)
  4.         If Mid(Text1, i, 1) = "A" Then
  5.             Text2 = Text2 & "U"
  6.         ElseIf Mid(Text1, i, 1) = "T" Then
  7.             Text2 = Text2 & "A"
  8.         ElseIf Mid(Text1, i, 1) = "C" Then
  9.             Text2 = Text2 & "G"
  10.         ElseIf Mid(Text1, i, 1) = "G" Then
  11.             Text2 = Text2 & "C"
  12.         Else
  13.             MsgBox "X men"
  14.         End If
  15.     Next
  16.    
  17.     '第二題,從text2的mRNA片段,產生amino acid串列,3個為一組()包起來
  18.    For i = 1 To Len(Text2)
  19.         If i Mod 3 = 1 Then
  20.             Text3 = Text3 & "("
  21.         End If
  22.         If Mid(Text2, i, 1) = "A" Then
  23.             Text3 = Text3 & "U"
  24.         ElseIf Mid(Text2, i, 1) = "U" Then
  25.             Text3 = Text3 & "A"
  26.         ElseIf Mid(Text2, i, 1) = "C" Then
  27.             Text3 = Text3 & "G"
  28.         ElseIf Mid(Text2, i, 1) = "G" Then
  29.             Text3 = Text3 & "C"
  30.         Else
  31.             MsgBox "X men"
  32.         End If
  33.         If i Mod 3 = 0 Then
  34.             Text3 = Text3 & ")"
  35.         End If
  36.     Next
  37.    
  38.    
  39.     '第三題,給定一dna片段text1,請劃出雙股結構
  40.    For i = 1 To Command2.UBound
  41.         Unload Command2(i)
  42.     Next
  43.     For i = 1 To Len(Text1)
  44.         Load Command2(i)
  45.         Command2(i).Left = Command2(i - 1).Left + Command2(i - 1).Width
  46.         Command2(i).Caption = Mid(Text1, i, 1)
  47.         Command2(i).Visible = True
  48.     Next
  49.    
  50.     For i = 1 To Command3.UBound
  51.         Unload Command3(i)
  52.     Next
  53.    
  54.     For i = 1 To Len(Text1)
  55.         Load Command3(i)
  56.         Command3(i).Left = Command3(i - 1).Left + Command3(i - 1).Width
  57.         If Mid(Text1, i, 1) = "A" Then
  58.             Command3(i).Caption = "T"
  59.             Command2(i).BackColor = QBColor(11)
  60.             Command3(i).BackColor = QBColor(10)
  61.         ElseIf Mid(Text1, i, 1) = "T" Then
  62.             Command3(i).Caption = "A"
  63.             Command2(i).BackColor = QBColor(10)
  64.             Command3(i).BackColor = QBColor(11)
  65.         ElseIf Mid(Text1, i, 1) = "C" Then
  66.             Command3(i).Caption = "G"
  67.             Command2(i).BackColor = QBColor(14)
  68.             Command3(i).BackColor = QBColor(12)
  69.         ElseIf Mid(Text1, i, 1) = "G" Then
  70.             Command3(i).Caption = "C"
  71.             Command2(i).BackColor = QBColor(12)
  72.             Command3(i).BackColor = QBColor(14)
  73.         Else
  74.             MsgBox "X men"
  75.         End If
  76.         Command3(i).Visible = True
  77.    Next
  78.    Cls
  79.    For i = 1 To Len(Text1)
  80.     Line (Command2(i).Left + Command2(i).Width / 2, Command2(i).Top + Command2(i).Height)-(Command3(i).Left + Command3(i).Width / 2, Command3(i).Top + Command3(i).Height), vbRed
  81.    Next
  82.     '第四題,螺旋
  83.    T = 1
  84.     For j = 1 To 5
  85.         For i = T To T + 4
  86.             If i = 25 Then
  87.                 Exit For
  88.             End If
  89.             Command2(i).Top = Command2(i - 1).Top + Command2(i).Height
  90.             Command3(i).Top = Command3(i - 1).Top - Command3(i).Height
  91.         Next
  92.         If i = 25 Then
  93.             Exit For
  94.         End If
  95.         For h = T + 5 To T + 9
  96.             If h = 25 Then
  97.                 Exit For
  98.             End If
  99.             Command2(h).Top = Command2(h - 1).Top - Command2(h).Height
  100.             Command3(h).Top = Command3(h - 1).Top + Command3(h).Height
  101.         Next
  102.         If h > 25 Then
  103.             Exit For
  104.         End If
  105.        
  106.         T = T + 10
  107.     Next
  108.     Cls
  109.    For i = 1 To Len(Text1)
  110.     Line (Command2(i).Left + Command2(i).Width / 2, Command2(i).Top + Command2(i).Height)-(Command3(i).Left + Command3(i).Width / 2, Command3(i).Top + Command3(i).Height), vbRed
  111.    Next
  112. End Sub
  113.  
  114. Private Sub Form_Load()
  115.     Command3(0).Top = Command2(0).Top + Command2(0).Height * 5
  116. End Sub
  117.  
  118.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement