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
|
# File 'lib/rbbt/sources/CASCADE.rb', line 36
def self.process_paradigm(interactions, members)
proteins = Set.new members.values.flatten.uniq
outputs = Set.new
associations = {}
interactions.through do |source, values|
values.zip_fields.each do |target,typea,ida,databasea,typeb,idb,databaseb,effect|
next if typea == 'gene'
if typeb == 'gene'
target.sub!('_g','')
type = '-t'
elsif typeb == 'output' or typea == 'output'
type = '-ap'
else
type = '-a'
end
proteins << source unless source.include? '_f' or source.include? '_c'
proteins << target unless target.include? '_f' or target.include? '_c'
outputs << source if typea == 'output'
outputs << target if typeb == 'output'
effect_symbol = '>'
effect_symbol = '|' if effect.include? 'inhibit'
associations[[source,target]] = [type, effect_symbol]
end
end
str = StringIO.new
proteins.each do |p|
next if outputs.include? p
str.puts ["protein", p] * "\t"
end
outputs.each do |o|
str.puts ["abstract", o] * "\t"
end
members.each do |e, targets|
e = e.dup
case
when e.include?('_c')
str.puts ["complex", e] * "\t"
type = 'component'
when e.include?('_f')
str.puts ["family", e] * "\t"
type = 'member'
else
next
end
targets.each do |target|
associations[[target,e]] = [type, '>']
end
end
associations.each do |p,i|
source, target = p
type, symbol = i
str.puts [source, target, [type,symbol]*""] * "\t"
end
str.rewind
str
end
|