-
Notifications
You must be signed in to change notification settings - Fork 109
/
demo_codontable.rb
119 lines (91 loc) · 2.84 KB
/
demo_codontable.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#
# = sample/demo_codontable.rb - demonstration of Bio::CodonTable
#
# Copyright:: Copyright (C) 2001, 2004
# Toshiaki Katayama <k@bioruby.org>
# License:: The Ruby License
#
#
# == Description
#
# Demonstration of Bio::CodonTable.
#
# == Usage
#
# Simply run this script.
#
# $ ruby demo_codontable.rb
#
# == Development information
#
# The code was moved from lib/bio/data/codontable.rb.
#
require 'bio'
#if __FILE__ == $0
begin
require 'pp'
alias p pp
rescue LoadError
end
puts "### Bio::CodonTable[1]"
p ct1 = Bio::CodonTable[1]
puts ">>> Bio::CodonTable#table"
p ct1.table
puts ">>> Bio::CodonTable#each"
ct1.each do |codon, aa|
puts "#{codon} -- #{aa}"
end
puts ">>> Bio::CodonTable#definition"
p ct1.definition
puts ">>> Bio::CodonTable#['atg']"
p ct1['atg']
puts ">>> Bio::CodonTable#revtrans('A')"
p ct1.revtrans('A')
puts ">>> Bio::CodonTable#start_codon?('atg')"
p ct1.start_codon?('atg')
puts ">>> Bio::CodonTable#start_codon?('aaa')"
p ct1.start_codon?('aaa')
puts ">>> Bio::CodonTable#stop_codon?('tag')"
p ct1.stop_codon?('tag')
puts ">>> Bio::CodonTable#stop_codon?('aaa')"
p ct1.stop_codon?('aaa')
puts ">>> ct1_copy = Bio::CodonTable.copy(1)"
p ct1_copy = Bio::CodonTable.copy(1)
puts ">>> ct1_copy['tga'] = 'U'"
p ct1_copy['tga'] = 'U'
puts " orig : #{ct1['tga']}"
puts " copy : #{ct1_copy['tga']}"
puts "### ct = Bio::CodonTable.new(hash, definition)"
hash = {
'ttt' => 'F', 'tct' => 'S', 'tat' => 'Y', 'tgt' => 'C',
'ttc' => 'F', 'tcc' => 'S', 'tac' => 'Y', 'tgc' => 'C',
'tta' => 'L', 'tca' => 'S', 'taa' => '*', 'tga' => 'U',
'ttg' => 'L', 'tcg' => 'S', 'tag' => '*', 'tgg' => 'W',
'ctt' => 'L', 'cct' => 'P', 'cat' => 'H', 'cgt' => 'R',
'ctc' => 'L', 'ccc' => 'P', 'cac' => 'H', 'cgc' => 'R',
'cta' => 'L', 'cca' => 'P', 'caa' => 'Q', 'cga' => 'R',
'ctg' => 'L', 'ccg' => 'P', 'cag' => 'Q', 'cgg' => 'R',
'att' => 'I', 'act' => 'T', 'aat' => 'N', 'agt' => 'S',
'atc' => 'I', 'acc' => 'T', 'aac' => 'N', 'agc' => 'S',
'ata' => 'I', 'aca' => 'T', 'aaa' => 'K', 'aga' => 'R',
'atg' => 'M', 'acg' => 'T', 'aag' => 'K', 'agg' => 'R',
'gtt' => 'V', 'gct' => 'A', 'gat' => 'D', 'ggt' => 'G',
'gtc' => 'V', 'gcc' => 'A', 'gac' => 'D', 'ggc' => 'G',
'gta' => 'V', 'gca' => 'A', 'gaa' => 'E', 'gga' => 'G',
'gtg' => 'V', 'gcg' => 'A', 'gag' => 'E', 'ggg' => 'G',
}
my_ct = Bio::CodonTable.new(hash, "my codon table")
puts ">>> ct.definition"
puts my_ct.definition
puts ">>> ct.definition=(str)"
my_ct.definition = "selenoproteins (Eukaryote)"
puts my_ct.definition
puts ">>> ct['tga']"
puts my_ct['tga']
puts ">>> ct.revtrans('U')"
puts my_ct.revtrans('U')
puts ">>> ct.stop_codon?('tga')"
puts my_ct.stop_codon?('tga')
puts ">>> ct.stop_codon?('tag')"
puts my_ct.stop_codon?('tag')
#end