Skip to content

Commit

Permalink
add genome reader
Browse files Browse the repository at this point in the history
  • Loading branch information
sfchen committed Mar 20, 2016
1 parent 9966276 commit c31c388
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Reference/Genome/Genome.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export genome_dir,
download_genome
download_genome,
load_genome

include("config.jl")
include("downloader.jl")
include("downloader.jl")
include("reader.jl")
22 changes: 22 additions & 0 deletions src/Reference/Genome/reader.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function load_genome(assembly)
if !haskey(human_genomes, assembly)
error("$assembly is not supported, please use hg19/hg38")
end

# check if the assembly already exists
folder = joinpath(genome_dir(), assembly)
if isdir(folder) || !verify_human_genome_folder(folder)
if !download_genome(assembly)
error("Cannot download assembly $assembly")
end
end

chr_folder = joinpath(folder, "chroms")
chroms = readdir(chr_folder)
genome = Dict{ASCIIString, FastaRead}()
for chr in chroms
chrname = replace(chr, ".fa", "")
genome[chrname] = fasta_read(fasta_open(joinpath(chr_folder, chr)))
end
return genome
end

0 comments on commit c31c388

Please sign in to comment.