test/rbbt/sources/test_biomart.rb in rbbt-sources-3.3.0 vs test/rbbt/sources/test_biomart.rb in rbbt-sources-3.4.1

- old
+ new

@@ -1,44 +1,82 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') require 'rbbt/sources/pubmed' require 'test/unit' require 'rbbt/sources/biomart' +require 'rbbt/sources/organism' require 'rbbt/util/tmpfile' require 'test/unit' class TestBioMart < Test::Unit::TestCase def setup - BioMart.set_archive Organism.default_code("Hsa") + BioMart.set_archive "feb2014" end def teardown BioMart.unset_archive end - def _test_get + def test_get_Sce assert_raise BioMart::QueryError do BioMart.get('scerevisiae_gene_ensembl','entrezgene', ['protein_id'],['with_unknownattr']) end - data = BioMart.get('scerevisiae_gene_ensembl','entrezgene', ['protein_id'],[], nil, :nocache => false, :merge => true, :wget_options => {:quiet => false}) + BioMart.set_archive "feb2023-fungi" + data = BioMart.get('scerevisiae_eg_gene','entrezgene_id', ['protein_id'],[], nil, :nocache => true, :merge => true, :wget_options => {:quiet => false}) tsv = TSV.open data, :double, :merge => true - assert(tsv['852236'][0].include? 'CAA84864') + assert(tsv['852236'][0].include? 'CAA84864.1') - data = BioMart.get('scerevisiae_gene_ensembl','entrezgene', ['external_gene_id'],[], data, :nocache => false, :wget_options => { :quiet => false} ) + data = BioMart.get('scerevisiae_eg_gene','entrezgene_id', ['external_gene_id'],[], data, :nocache => false, :wget_options => { :quiet => false} ) tsv = TSV.open data, :double, :merge => true assert(tsv['852236'][1].include? 'YBL044W') end - def _test_query + def test_get_Hsa + Log.severity = 0 + data = BioMart.get('hsapiens_gene_ensembl','entrezgene', ['protein_id'],[], nil, :nocache => true, :merge => true, :wget_options => {:quiet => false}) + tsv = TSV.open data, :double, :merge => true + assert(tsv['852236'][0].include? 'CAA84864.1') + end + + + def test_query data = BioMart.query('scerevisiae_gene_ensembl','entrezgene', ['protein_id','refseq_peptide','external_gene_id','ensembl_gene_id'], [], nil, :nocache => false, :wget_options => { :quiet => false}) assert(data['852236']['external_gene_id'].include? 'YBL044W') TmpFile.with_file do |f| filename = BioMart.query('scerevisiae_gene_ensembl','entrezgene', ['protein_id','refseq_peptide','external_gene_id','ensembl_gene_id'], [], nil, :nocache => false, :wget_options => { :quiet => false}, :filename => f) data = TSV.open Open.open(filename) assert(data['852236']['external_gene_id'].include? 'YBL044W') + end + end + + def __test_transcrip_exons + Log.with_severity 1 do + TmpFile.with_file do |f| + fields = ['ensembl_transcript_id','ensembl_exon_id','rank'] + main = fields[0] + attrs = fields.values_at(1, 2) + attrs_first = [attrs.first] + attrs_last = [attrs.last] + database = 'hsapiens_gene_ensembl' + + filename = BioMart.get(database, main, attrs, {"ensembl_transcript_id" => ['ENST00000357654']}, nil, :nocache => false, :wget_options => {:quiet => false}, :filename => f) + ppp Open.read(filename) + + filename = BioMart.get(database, main, attrs_first, {"ensembl_transcript_id" => ['ENST00000357654']}, nil, :nocache => false, :wget_options => {:quiet => false}, :filename => f) + ppp Open.read(filename) + + filename = BioMart.get(database, main, attrs_last, {"ensembl_transcript_id" => ['ENST00000357654']}, nil, :nocache => false, :wget_options => {:quiet => false}, :filename => f) + ppp Open.read(filename) + + filename = BioMart.query(database, main, attrs, {"ensembl_transcript_id" => ['ENST00000357654']}, nil, :nocache => true, :wget_options => {:quiet => false}, :filename => f) + ppp Open.read(filename) + + data = TSV.open Open.open(filename) + assert(data['852236']['external_gene_id'].include? 'YBL044W') + end end end def test_tsv data = BioMart.tsv('scerevisiae_gene_ensembl',['Entrez Gene', 'entrezgene'], [['Protein ID', 'protein_id'],['RefSeq Peptide','refseq_peptide']], [], nil, :nocache => false, :wget_options => { :quiet => false})