[BioRuby-cvs] bioruby/test/unit/bio/db/embl test_embl_to_bioseq.rb, NONE, 1.1.2.1 test_embl.rb, 1.5, 1.5.2.1 test_embl_rel89.rb, 1.2, 1.2.2.1

Jan Aerts aerts at dev.open-bio.org
Wed Feb 20 09:56:24 UTC 2008


Update of /home/repository/bioruby/bioruby/test/unit/bio/db/embl
In directory dev.open-bio.org:/tmp/cvs-serv15755/test/unit/bio/db/embl

Modified Files:
      Tag: BRANCH-biohackathon2008
	test_embl.rb test_embl_rel89.rb 
Added Files:
      Tag: BRANCH-biohackathon2008
	test_embl_to_bioseq.rb 
Log Message:
* Rewrote some of the code for converting EMBL files into Bio::Sequence.
* Added functionality to export Bio::Sequence to EMBL format.

Changes:
* renamed Sequence::Format#wrap and #fold to String#wrap and #fold (stored in bio.rb)
* lib/bio/db/common.rb:
    - rewrote def ref and def references
    - added to_biosequence
    - def references now returns an Array instead of a Bio::References object (tests changed accordingly)
* lib/bio/db/embl/embl.rb
    - def ft now returns Array instead of Bio::Features object (tests changed accordingly)
* lib/bio/db/embl/format.erb
* lib/bio/sequence/common.rb
    - added def format_embl


--- NEW FILE: test_embl_to_bioseq.rb ---
#
# test/unit/bio/db/embl/test_embl.rb - Unit test for Bio::EMBL
#
# Copyright::  Copyright (C) 2005, 2008
#                 Mitsuteru Nakao <n at bioruby.org>
#                 Jan Aerts <jan.aerts at bbsrc.ac.uk>
# License::    The Ruby License
#
#  $Id: test_embl_to_bioseq.rb,v 1.1.2.1 2008/02/20 09:56:22 aerts Exp $
#

require 'pathname'
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5, 'lib')).cleanpath.to_s
$:.unshift(libpath) unless $:.include?(libpath)

require 'test/unit'
require 'bio'
require 'bio/db/embl/embl'

module Bio
  class TestEMBLToBioSequence < Test::Unit::TestCase
    
    def setup
      bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5)).cleanpath.to_s
      input = File.open(File.join(bioruby_root, 'test', 'data', 'embl', 'AB090716.embl.rel89')).read
      embl_object = Bio::EMBL.new(input)
      embl_object.instance_eval { @data['OS'] = "Haplochromis sp. 'muzu rukwa'" }
      @bio_seq = embl_object.to_biosequence
    end

    def test_entry_id
      assert_equal('AB090716', @bio_seq.entry_id)
    end
    
    def test_primary_accession
      assert_equal('AB090716', @bio_seq.primary_accession)
    end
    
    def test_secondary_accessions
      assert_equal([], @bio_seq.secondary_accessions)
    end
    
    def test_molecule_type
      assert_equal('genomic DNA', @bio_seq.molecule_type)
    end
    
    def test_definition
      assert_equal("Haplochromis sp. 'muzu, rukwa' LWS gene for long wavelength-sensitive opsin, partial cds, specimen_voucher:specimen No. HT-9361.", @bio_seq.definition)
    end

    def test_topology
      assert_equal('linear', @bio_seq.topology)
    end
    
    def test_dates
      assert_equal('25-OCT-2002 (Rel. 73, Created)', @bio_seq.date_created)
      assert_equal('14-NOV-2006 (Rel. 89, Last updated, Version 3)', @bio_seq.date_modified)
    end
    
    def test_division
      assert_equal('VRT', @bio_seq.division)
    end
    
    def test_sequence_version
      assert_equal(1, @bio_seq.sequence_version)
    end
    
    def test_keywords
      assert_equal([], @bio_seq.keywords)
    end
    
    def test_species
      assert_equal("Haplochromis sp. 'muzu, rukwa'", @bio_seq.species)
    end
    
    def test_classification
      assert_equal(['Eukaryota','Metazoa','Chordata','Craniata','Vertebrata','Euteleostomi','Actinopterygii','Neopterygii','Teleostei','Euteleostei','Neoteleostei','Acanthomorpha','Acanthopterygii','Percomorpha','Perciformes','Labroidei','Cichlidae','African cichlids','Pseudocrenilabrinae','Haplochromini','Haplochromis'], @bio_seq.classification)
      

    end

    def test_references
      assert_equal(2, @bio_seq.references.length)
      assert_equal(Bio::Reference, @bio_seq.references[0].class)
    end
    
    def test_features
      assert_equal(3, @bio_seq.features.length)
      assert_equal(Bio::Feature, @bio_seq.features[0].class)
    end
    
  end

  # To really test the Bio::EMBL to Bio::Sequence conversion, we need to test if
  # that Bio::Sequence can be made into a valid Bio::EMBL again.
  class TestEMBLToBioSequenceRoundTrip < Test::Unit::TestCase
    def setup
      bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 5)).cleanpath.to_s
      input = File.open(File.join(bioruby_root, 'test', 'data', 'embl', 'AB090716.embl.rel89')).read
      embl_object_1 = Bio::EMBL.new(input)
      embl_object_1.instance_eval { @data['OS'] = "Haplochromis sp. 'muzu rukwa'" }
      @bio_seq_1 = embl_object_1.to_biosequence
      embl_object_2 = Bio::EMBL.new(@bio_seq_1.output(:embl))
      @bio_seq_2 = embl_object_2.to_biosequence
    end
    
    def test_entry_id
      assert_equal('AB090716', @bio_seq_2.entry_id)
    end
    
    def test_primary_accession
      assert_equal('AB090716', @bio_seq_2.primary_accession)
    end
    
    def test_secondary_accessions
      assert_equal([], @bio_seq_2.secondary_accessions)
    end
    
    def test_molecule_type
      assert_equal('genomic DNA', @bio_seq_2.molecule_type)
    end
    
    def test_definition
      assert_equal("Haplochromis sp. 'muzu, rukwa' LWS gene for long wavelength-sensitive opsin, partial cds, specimen_voucher:specimen No. HT-9361.", @bio_seq_2.definition)
    end

    def test_topology
      assert_equal('linear', @bio_seq_2.topology)
    end
    
    def test_dates
      assert_equal('25-OCT-2002 (Rel. 73, Created)', @bio_seq_2.date_created)
      assert_equal('14-NOV-2006 (Rel. 89, Last updated, Version 3)', @bio_seq_2.date_modified)
    end
    
    def test_division
      assert_equal('VRT', @bio_seq_2.division)
    end
    
    def test_sequence_version
      assert_equal(1, @bio_seq_2.sequence_version)
    end
    
    def test_keywords
      assert_equal([], @bio_seq_2.keywords)
    end
    
    def test_species
      assert_equal("Haplochromis sp. 'muzu, rukwa'", @bio_seq_2.species)
    end
    
    def test_classification
      assert_equal(['Eukaryota','Metazoa','Chordata','Craniata','Vertebrata','Euteleostomi','Actinopterygii','Neopterygii','Teleostei','Euteleostei','Neoteleostei','Acanthomorpha','Acanthopterygii','Percomorpha','Perciformes','Labroidei','Cichlidae','African cichlids','Pseudocrenilabrinae','Haplochromini','Haplochromis'], @bio_seq_2.classification)
      

    end

    def test_references
      assert_equal(2, @bio_seq_2.references.length)
      assert_equal(Bio::Reference, @bio_seq_2.references[0].class)
    end
    
    def test_features a
      assert_equal(3, @bio_seq_2.features.length)
      assert_equal(Bio::Feature, @bio_seq_2.features[0].class)
    end
  end
end


Index: test_embl_rel89.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/test/unit/bio/db/embl/test_embl_rel89.rb,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** test_embl_rel89.rb	5 Apr 2007 23:35:43 -0000	1.2
--- test_embl_rel89.rb	20 Feb 2008 09:56:22 -0000	1.2.2.1
***************
*** 156,160 ****
      # Bio::EMBLDB::COMMON#references
      def test_references 
!       assert_equal(Bio::References, @obj.references.class)
      end
  
--- 156,160 ----
      # Bio::EMBLDB::COMMON#references
      def test_references 
!       assert_equal(Array, @obj.references.class)
      end
  
***************
*** 169,173 ****
  
      def test_ft
!       assert_equal(Bio::Features, @obj.ft.class)
      end
  
--- 169,173 ----
  
      def test_ft
!       assert_equal(Array, @obj.ft.class)
      end
  
***************
*** 179,183 ****
  
      def test_ft_accessor
!       assert_equal('CDS', @obj.ft.features[1].feature)
      end
  
--- 179,183 ----
  
      def test_ft_accessor
!       assert_equal('CDS', @obj.ft[1].feature)
      end
  

Index: test_embl.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/test/unit/bio/db/embl/test_embl.rb,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C2 -d -r1.5 -r1.5.2.1
*** test_embl.rb	5 Apr 2007 23:35:43 -0000	1.5
--- test_embl.rb	20 Feb 2008 09:56:22 -0000	1.5.2.1
***************
*** 151,155 ****
      # Bio::EMBLDB::COMMON#references
      def test_references 
!       assert_equal(Bio::References, @obj.references.class)
      end
  
--- 151,155 ----
      # Bio::EMBLDB::COMMON#references
      def test_references 
!       assert_equal(Array, @obj.references.class)
      end
  
***************
*** 164,168 ****
  
      def test_ft
!       assert_equal(Bio::Features, @obj.ft.class)
      end
  
--- 164,168 ----
  
      def test_ft
!       assert_equal(Array, @obj.ft.class)
      end
  
***************
*** 174,178 ****
  
      def test_ft_accessor
!       assert_equal('CDS', @obj.ft.features[1].feature)
      end
  
--- 174,178 ----
  
      def test_ft_accessor
!       assert_equal('CDS', @obj.ft[1].feature)
      end
  




More information about the bioruby-cvs mailing list