140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/rbbt/sources/dbSNP.rb', line 140
def self.rsid_index(organism, chromosome = nil)
build = Organism.hg_build(organism)
tag = [build, chromosome] * ":"
Persist.persist("StaticPosIndex for dbSNP [#{ tag }]", :fwt, :persist => true) do
value_size = 0
file = DbSNP[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
|