Module: BioExominer::Symbols

Defined in:
lib/bio-exominer/symbols.rb

Class Method Summary collapse

Class Method Details

.each(fn) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bio-exominer/symbols.rb', line 29

def Symbols::each(fn)
  is_bin = fn =~ /.bin$/

  if is_bin
    u = MessagePack::Unpacker.new(File.new(fn,'rb'))
    begin
      u.each do |obj|
        # print obj[0],"\t",(obj[1] ? obj[1].join('|') : "NA"),"\t",obj[2],"\n"
        yield obj[0],obj[1],obj[2]
      end
    rescue EOFError
    end
  else
    File.open(fn).each_line do | line |
      yield parse_line(line)
    end
  end
end

.parse_line(line) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/bio-exominer/symbols.rb', line 18

def Symbols::parse_line(line)
  symbol,aliases,descr = line.strip.split(/\t/)
  aliases = 
    if aliases == 'NA'
      nil
    else
      aliases.split(/\|/)
    end
  return symbol,aliases,(descr ? descr.strip : "")
end

.uri(symbol, hugo) ⇒ Object

Make a full URI out of a symbol



9
10
11
12
13
14
15
16
# File 'lib/bio-exominer/symbols.rb', line 9

def Symbols::uri(symbol,hugo)
  if hugo[symbol]
    # http://bio2rdf.org/hugo:RAD51C
    "hgnc:"+RDF::make_identifier(symbol)
  else
    "ncbigene:"+RDF::make_identifier(symbol)  # remove all non-printable
  end
end