1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
#
# test/unit/bio/db/litdb.rb - Unit test for Bio::LITDB
#
# Copyright:: Copyright (C) 2010 Kazuhiro Hayashi <k.hayashi.info@gmail.com>
# License:: The Ruby License
#
# loading helper routine for testing bioruby
require 'pathname'
load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3,
'bioruby_test_helper.rb')).cleanpath.to_s
# libraries needed for the tests
require 'test/unit'
require 'bio/db/litdb'
require 'bio/reference'
module Bio
class TestBioLITDB < Test::Unit::TestCase
def setup
filename = File.join(BioRubyTestDataPath, 'litdb', '1717226.litdb')
@obj = Bio::LITDB.new(File.read(filename))
end
# it return the reference infromation formatted as part of a Bio::Reference object.
def test_reference
expected =
{:authors=>
["Boyd, L.A.",
"Adam, L.",
"Pelcher, L.E.",
"McHughen, A.",
"Hirji, R.",
" Selvaraj, G."],
:issue=>"1",
:journal=>"Gene",
:pages=>"45-52",
:title=>
"Characterization of an Escherichia coli gene encoding betaine aldehyde dehydrogenase (BADH). Structural similarity to mammalian ALDHs and a plant BADH.",
:volume=>"103",
:year=>"(1991)"}
litdb_ref = @obj.reference
actual = {:authors=>litdb_ref.authors,
:journal=> litdb_ref.journal,
:pages=> litdb_ref.pages,
:volume=>litdb_ref.volume,
:year=>litdb_ref.year,
:issue=>litdb_ref.issue,
:title=>litdb_ref.title
}
assert_equal(expected, actual)
end
#access to the each field with field_fetch method.
#most methods are the same as values of Bio::Refence object.
def test_entry_id
assert_equal("1717226", @obj.entry_id)
end
def test_title
expected = "Characterization of an Escherichia coli gene encoding betaine aldehyde dehydrogenase (BADH). Structural similarity to mammalian ALDHs and a plant BADH."
assert_equal(expected, @obj.title)
end
def test_field
assert_equal("q (sequence analysis)", @obj.field)
end
def test_journal
assert_equal("Gene", @obj.journal)
end
def test_volume
assert_equal("Vol.103, No.1, 45-52 (1991)", @obj.volume)
end
def test_keyword
expected = ["*Betaine Aldehyde Dehydrogenase",
"*betB Gene;E.coli",
"Seq Determination;1854bp;491AAs",
"Hydropathy Plot;*EC1.2.1.8",
"Seq Comparison"]
assert_equal(expected, @obj.keyword)
end
def test_author
expected = "Boyd,L.A.;Adam,L.;Pelcher,L.E.;McHughen,A.;Hirji,R.; Selvaraj,G."
assert_equal(expected, @obj.author)
end
end #class TestBioLITDB
end #module Bio
|