Module: CASCADE

Extended by:
Resource
Defined in:
lib/rbbt/sources/CASCADE.rb

Constant Summary collapse

URL =
'https://bitbucket.org/asmundf/cascade'

Class Method Summary collapse

Class Method Details

.process_interactions(file) ⇒ Object

self.search_paths = {} self.search_paths = :lib



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rbbt/sources/CASCADE.rb', line 15

def self.process_interactions(file)
  io = Open.open(file)
  tsv = TSV.open(io, :merge => true, :header_hash => '')

  new_fields = ["ENTITYB"] + (tsv.fields - ["ENTITYB"])
  tsv = tsv.reorder :key, new_fields

  tsv.key_field = "ENTITYA (Associated Gene Name)"
  tsv.rename_field "ENTITYB", "ENTITYB (Associated Gene Name)"

  tsv.process "PMID" do |values|
    values.collect{|v| v.scan(/\d+/) * ";;"}
  end

  tsv
end

.process_members(file) ⇒ Object



32
33
34
# File 'lib/rbbt/sources/CASCADE.rb', line 32

def self.process_members(file)
  TSV.open(file, :merge => true, :header_hash => '', :type => :flat, :sep2 => /[,.]\s*/)
end

.process_paradigm(interactions, members) ⇒ Object



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