Class: Sylfy::Feature
- Inherits:
-
Object
- Object
- Sylfy::Feature
- Defined in:
- lib/sylfy/feature.rb
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#listnumber ⇒ Object
readonly
Returns the value of attribute listnumber.
-
#member ⇒ Object
readonly
Returns the value of attribute member.
Class Method Summary collapse
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
15 16 17 |
# File 'lib/sylfy/feature.rb', line 15 def length @length end |
#listnumber ⇒ Object (readonly)
Returns the value of attribute listnumber.
15 16 17 |
# File 'lib/sylfy/feature.rb', line 15 def listnumber @listnumber end |
#member ⇒ Object (readonly)
Returns the value of attribute member.
15 16 17 |
# File 'lib/sylfy/feature.rb', line 15 def member @member end |
Class Method Details
.fromKEGG(species = 'ref') ⇒ Object
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 |
# File 'lib/sylfy/feature.rb', line 53 def self.fromKEGG(species = 'ref') listnumber = {} member = {} complist = Service::KEGGREST.link("compound/pathway") if species == 'ref' pathwaylist = Service::KEGGREST.list("pathway") genelist = Service::KEGGREST.link("ko/pathway") genelist.delete_if{|k, v| k !~ /^path:map/ } complist.delete_if{|k, v| k !~ /^path:map/ } else pathwaylist = Service::KEGGREST.list("pathway/#{species}") genelist = Service::KEGGREST.link("#{species}/pathway") tmp = {} complist.each_pair do |k, v| tmp["path:#{species}#{k[-6..-1]}"] = v if !tmp.has_key?("path:#{species}#{k[-6..-1]}") end complist = tmp end listnumber["path"] = pathwaylist listnumber["gene"] = genelist listnumber["comp"] = complist length = {"path" => pathwaylist.length} genelist.each_pair do |k, v| v.each do |entry| if !member.has_key?(entry) member[entry] = {} member[entry].default = [] end member[entry]["gene"] = [] if !member[entry].has_key?("gene") member[entry]["gene"].push(k) end end @length["gene"] = member.length complist.each_pair do |k, v| v.each do |entry| if !member.has_key?(entry) member[entry] = {} member[entry].default = [] end member[entry]["comp"] = [] if !member[entry].has_key?("comp") member[entry]["comp"].push(k) end end @length["comp"] = member.length - @length["gene"] return Sylfy::Feature.new(listnumber, member, length) end |
.open(filename, options) ⇒ Object
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 |
# File 'lib/sylfy/feature.rb', line 25 def self.open(filename, ) #@listnumber = {:path => { "path:map00010"=>["Glycolysis / Gluconeogenesis"], ...}, "gene" => {"path:map00010"=>["ko:K00001", "ko:K00002", ...], ...}, "comp" => {... } #"ko:K02790"=>{"gene"=>["path:map00010", "path:map00500", "path:map02060"]} listnumber = {} member = {} length = {} # type group member CSV.open(filename, "rb", ).readlines.each do |row| length[row[0]] = 0 if !length.has_key?(row[0]) listnumber[row[0]] = {} if !listnumber.has_key?(row[0]) listnumber[row[0]][row[1]] = [] if !listnumber[row[0]].has_key?(row[1]) listnumber[row[0]][row[1]].push(row[2]) if row[0] != 'path' if !member.has_key?(row[2]) && member[row[2]] = {} member[row[2]].default = [] length[row[0]] += 1 end member[row[2]][row[0]] = [] if !member[row[2]].has_key?(row[0]) member[row[2]][row[0]].push(row[1]) end end return Sylfy::Feature.new(listnumber, member, length) end |