Class: WingenderTFClass::UniprotInfo
- Inherits:
-
Struct
- Object
- Struct
- WingenderTFClass::UniprotInfo
- Defined in:
- lib/WingenderTFClass/uniprot_info.rb
Instance Attribute Summary collapse
-
#uniprot_ac ⇒ Object
Returns the value of attribute uniprot_ac.
-
#uniprot_id ⇒ Object
Returns the value of attribute uniprot_id.
Class Method Summary collapse
- .each_in_file(filename, &block) ⇒ Object
- .from_string(line) ⇒ Object
- .uniprot_ac_list_by_id_from_file(filename) ⇒ Object
Instance Attribute Details
#uniprot_ac ⇒ Object
Returns the value of attribute uniprot_ac
2 3 4 |
# File 'lib/WingenderTFClass/uniprot_info.rb', line 2 def uniprot_ac @uniprot_ac end |
#uniprot_id ⇒ Object
Returns the value of attribute uniprot_id
2 3 4 |
# File 'lib/WingenderTFClass/uniprot_info.rb', line 2 def uniprot_id @uniprot_id end |
Class Method Details
.each_in_file(filename, &block) ⇒ Object
8 9 10 |
# File 'lib/WingenderTFClass/uniprot_info.rb', line 8 def self.each_in_file(filename, &block) File.readlines(filename).drop(1).map{|line| self.from_string(line) }.each(&block) end |
.from_string(line) ⇒ Object
3 4 5 6 |
# File 'lib/WingenderTFClass/uniprot_info.rb', line 3 def self.from_string(line) uniprot_ac, uniprot_id = line.chomp.split("\t", 2) self.new(uniprot_ac, uniprot_id) end |
.uniprot_ac_list_by_id_from_file(filename) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/WingenderTFClass/uniprot_info.rb', line 12 def self.uniprot_ac_list_by_id_from_file(filename) result = self.each_in_file(filename) .group_by(&:uniprot_id) .map{|uniprot_id, uniprots| [uniprot_id, uniprots.map(&:uniprot_ac)] }.to_h result.default_proc = ->(h,k){h[k] = [] } result end |