lib/rbbt/sources/organism.rb in rbbt-sources-3.1.52 vs lib/rbbt/sources/organism.rb in rbbt-sources-3.2.0

- old
+ new

@@ -70,13 +70,14 @@ Rbbt.claim Rbbt.software.opt.bin.liftOver, :url, "http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/liftOver" def self.hg_build(organism) require 'rbbt/sources/ensembl_ftp' + organism = organism.strip return organism if organism =~ /^hg\d\d$/ - return 'hg19' unless organism =~ /\// + return organism unless organism =~ /\// species, date = organism.split("/") case species when "Hsa" @@ -99,39 +100,47 @@ else raise "Only organism 'Hsa' (Homo sapiens), 'Rno' (Rattus norvegicus), and Mmu (Mus musculus) supported" end end - def self.GRC_build(organism) + def self.GRC_build(organism, with_release = false) require 'rbbt/sources/ensembl_ftp' - return organism if organism =~ /^hg\d\d$/ + return organism if organism =~ /^GRC$/ - return 'hg19' unless organism =~ /\// + if organism == "hg19" || organism == "b37" + return "GRCh37" + elsif organism == "hg38" + return "GRCh38" + end + return self.GRC_build(default_code(organism)) unless organism =~ /\// + species, date = organism.split("/") - case species - when "Hsa" - date = organism.split("/")[1] + build = case species + when "Hsa" + date = organism.split("/")[1] - release = Ensembl.releases[date] + release = Ensembl.releases[date] - release_number = release.sub(/.*-/,'').to_i - if release_number <= 54 - 'GRCh36' - elsif release_number <= 75 - 'GRCh37' - else - 'GRCh38' - end - when "Mmu" - "GRCm38" - when "Rno" - "Rnor_6.0" - else - raise "Only organism 'Hsa' (Homo sapiens) and Mmu (Mus musculus) supported" - end + release_number = release.sub(/.*-/,'').to_i + if release_number <= 54 + 'GRCh36' + elsif release_number <= 75 + 'GRCh37' + else + 'GRCh38' + end + when "Mmu" + "GRCm38" + when "Rno" + "Rnor_6.0" + else + raise "Only organism 'Hsa' (Homo sapiens) and Mmu (Mus musculus) supported" + end + + (release_number && with_release) ? build + "." + release_number.to_s : build end def self.organism_for_build(build) build = build.sub('_noalt', '') @@ -330,6 +339,7 @@ chromosome_sizes[chromosome] = size.to_i end chromosome_sizes end + end