test/rbbt/sources/test_organism.rb in rbbt-sources-1.2.0 vs test/rbbt/sources/test_organism.rb in rbbt-sources-2.0.0

- old
+ new

@@ -1,30 +1,35 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') require 'rbbt/sources/organism' require 'test/unit' +require 'rbbt/sources/ensembl_ftp' -class TestEntrez < Test::Unit::TestCase +class TestOrganism < Test::Unit::TestCase + + def test_known_ids + assert Organism.known_ids("Hsa").include?("Associated Gene Name") + end + def test_location assert_equal "share/organisms/Sce/identifiers", Organism.identifiers('Sce') end - def test_identifiers assert Organism.identifiers('Hsa').tsv(:key_field => "Entrez Gene ID", :persist => true)['1020']["Associated Gene Name"].include?('CDK5') assert Organism.identifiers('Sce').tsv(:persist => true)['S000006120']["Ensembl Gene ID"].include?('YPL199C') - assert Organism::Sce.identifiers.tsv(:persist => true)['S000006120']["Ensembl Gene ID"].include?('YPL199C') + assert Organism.identifiers("Sce").tsv(:persist => true)['S000006120']["Ensembl Gene ID"].include?('YPL199C') end def test_lexicon assert TSV.open(Organism.lexicon('Sce'))['S000006120'].flatten.include?('YPL199C') end def test_guess_id ensembl = %w(YOL044W YDR289C YAL034C YGR246C ARS519 tH(GUG)E2 YDR218C YLR002C YGL224C) gene_name = %w(SNR64 MIP1 MRPS18 TFB2 JEN1 IVY1 TRS33 GAS3) - assert_equal "Associated Gene Name", Organism::Sce.guess_id(gene_name).first - assert_equal "Ensembl Gene ID", Organism::Sce.guess_id(ensembl).first + assert_equal "Associated Gene Name", Organism.guess_id("Sce", gene_name).first + assert_equal "Ensembl Gene ID", Organism.guess_id("Sce", ensembl).first end def test_organisms assert Organism.organisms.include? "Hsa" assert_equal "Hsa", Organism.organism("Homo sapiens") @@ -34,13 +39,27 @@ tsv = TSV.setup({"1020" => []}, :type => :list) tsv.key_field = "Entrez Gene ID" tsv.fields = [] tsv.namespace = "Hsa" - Organism::Hsa.attach_translations tsv, "Associated Gene Name" - Organism::Hsa.attach_translations tsv, "Ensembl Gene ID" + Organism.attach_translations "Hsa", tsv, "Associated Gene Name" + Organism.attach_translations "Hsa", tsv, "Ensembl Gene ID" assert_equal "CDK5", tsv["1020"]["Associated Gene Name"] + end + + def test_entrez_taxids + assert_equal "Hsa", Organism.entrez_taxid_organism('9606') + end + + def test_lift_over + mutation_19 = "19:21131664:T" + mutation_18 = "19:20923504:T" + source_build = "Hsa/jun2011" + target_build = "Hsa/may2009" + + assert_equal mutation_18, Organism.liftOver([mutation_19], source_build, target_build).first + assert_equal mutation_19, Organism.liftOver([mutation_18], target_build, source_build).first end #def test_genes_at_chromosome # pos = [12, 117799500] # assert_equal "ENSG00000089250", Organism::Hsa.genes_at_chromosome_positions(pos.first, pos.last)