18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/rbbt/sources/wgEncodeBroadHmm.rb', line 18
def self.chromosome(tissue, chr, positions)
list = Array === positions ? positions : [positions]
file = Rbbt.share.databases.EBChromatin[tissue]
chromosome_bed = Persistence.persist(file, "EBChromatin[#{tissue}][#{chr}]", :fwt, :chromosome => chr, :range => true) do |file, options|
chromosome = options[:chromosome]
tsv = file.tsv(:persist => false, :type => :list, :grep => "^#{chromosome}:\\|^#")
if tsv.size > 0
tsv.collect do |gene, values|
[gene, values.values_at("Start", "End").collect{|p| p.to_i}]
end
else
raise "No chromatin information for chromosome #{ chr } in tissue #{ tissue }"
end
end
list.collect do |pos| chromosome_bed[pos] end
end
|