Sha256: 7d90bf5910b7fdbe2e9d697ac0928fefc83c71afb6eb460a964dc6f52193033d

Contents?: true

Size: 708 Bytes

Versions: 4

Compression:

Stored size: 708 Bytes

Contents

module WingenderTFClass
  UniprotInfo = Struct.new(:uniprot_ac, :uniprot_id) do
    def self.from_string(line)
      uniprot_ac, uniprot_id = line.chomp.split("\t", 2)
      self.new(uniprot_ac, uniprot_id)
    end

    def self.each_in_file(filename, &block)
      File.readlines(filename).drop(1).map{|line| self.from_string(line) }.each(&block)
    end

    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
WingenderTFClass-0.1.3 lib/WingenderTFClass/uniprot_info.rb
WingenderTFClass-0.1.2 lib/WingenderTFClass/uniprot_info.rb
WingenderTFClass-0.1.1 lib/WingenderTFClass/uniprot_info.rb
WingenderTFClass-0.1.0 lib/WingenderTFClass/uniprot_info.rb