Class: WingenderTFClass::UniprotInfo

Inherits:
Struct
  • Object
show all
Defined in:
lib/WingenderTFClass/uniprot_info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#uniprot_acObject

Returns the value of attribute uniprot_ac

Returns:

  • (Object)

    the current value of uniprot_ac



2
3
4
# File 'lib/WingenderTFClass/uniprot_info.rb', line 2

def uniprot_ac
  @uniprot_ac
end

#uniprot_idObject

Returns the value of attribute uniprot_id

Returns:

  • (Object)

    the current value of 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