Module: Genomes1000

Extended by:
Resource
Defined in:
lib/rbbt/sources/genomes1000.rb

Constant Summary collapse

RELEASE_URL =
"ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/release/20110521/ALL.wgs.phase1_release_v3.20101123.snps_indels_sv.sites.vcf.gz"

Class Method Summary collapse

Class Method Details

.mutation_index(organism) ⇒ Object



76
77
78
79
80
81
# File 'lib/rbbt/sources/genomes1000.rb', line 76

def self.mutation_index(organism)
  build = Organism.hg_build(organism)
  file = Genomes1000[build == "hg19" ? "mutations" : "mutations_hg18"]
  @mutation_index ||= {}
  @mutation_index[build] ||= file.tsv :persist => true, :fields => ["Genomic Mutation"], :type => :single, :persist => true
end

.rsid_index(organism, chromosome = nil) ⇒ Object



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