-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethylation_sandbox.rb
68 lines (62 loc) · 1.21 KB
/
methylation_sandbox.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
class Gene
attr_reader :expression, :name
attr_accessor :locked
def initialize(args)
@expression = args[:expression]
@name = args[:name]
@locked = true
end
def express
unless locked
@expression
end
end
end
METHYLS = {
"a1" => false,
"a2" => false,
"b" => false,
"g" => false
}
GENES = {
"a1" => Gene.new({:name => "alpha1", :expression=>"alpha-globin"}),
"a2" => Gene.new({:name => "alpha2", :expression=>"alpha-globin"}),
"b" => Gene.new({:name => "beta", :expression=>"beta-globlin"}),
"g1" => "gamma1",
"g2" => "gamma2",
"d" => "delta",
"e" => "epsilon",
"t" => "theta",
"m" => "mu",
"z" => "zeta"
}
def get_input
input = gets.chomp
end
def switch_expression(input)
markers = input.split(",")
METHYLS.keys.each do |marker|
if markers.include?(marker)
METHYLS[marker] = !METHYLS[marker]
end
end
end
def express_genes
combined_expressions = []
GENES.each do |key, value|
if METHYLS[key]
combined_expressions << value.expression
end
end
p(combined_expressions)
end
#### Playing around... ####
loop do
input = get_input
if input.match(/q/i)
puts 'bye'
exit
end
switch_expression(input)
express_genes
end