53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/rbbt/sources/genomes1000.rb', line 53
def self.rsid_index(organism, chromosome = nil)
build = Organism.hg_build(organism)
tag = [build, chromosome] * ":"
Persist.persist("StaticPosIndex for Genomes1000 [#{ tag }]", :fwt, :persist => true) do
value_size = 0
file = Genomes1000[build == "hg19" ? "mutations" : "mutations_hg18"]
chr_positions = []
Open.read(CMD.cmd("grep '\t#{chromosome}:'", :in => file.open, :pipe => true)) do |line|
next if line[0] == "#"[0]
rsid, mutation = line.split("\t")
next if mutation.nil? or mutation.empty?
chr, pos = mutation.split(":")
next if chr != chromosome or pos.nil? or pos.empty?
chr_positions << [rsid, pos.to_i]
value_size = rsid.length if rsid.length > value_size
end
fwt = FixWidthTable.new :memory, value_size
fwt.add_point(chr_positions)
fwt
end
end
|