[BioRuby] GSOC: Bioruby PhyloXML update 12

Naohisa GOTO ngoto at gen-info.osaka-u.ac.jp
Mon Sep 14 13:10:57 UTC 2009


Hi Diana,

On Mon, 10 Aug 2009 15:54:55 -0400
Diana Jaunzeikare <rozziite at gmail.com> wrote:

> * Testing. added more unit tests (now writer has 9 tests, 26 assertions;
> parser: 40 tests, 134 assertions)

test/unit/bio/db/test_phyloxml_writer.rb failed with libxml-ruby 1.1.3.
There are possibly 3 reasons.

1. Incompatible changes to XML::Document#save in libxml-ruby 0.9.6.
The method now takes options as a hash. The following patch fixes the bug.

======================================================================
--- a/lib/bio/db/phyloxml/phyloxml_writer.rb
+++ b/lib/bio/db/phyloxml/phyloxml_writer.rb
@@ -92,5 +92,5 @@ module Bio
       #@doc.encoding = XML::Encoding::UTF_8
 
-      @doc.save(@filename, true)
+      @doc.save(@filename, :indent => true)
       end
 
@@ -126,5 +126,5 @@ module Bio
             [:objarr, 'property', 'properties']] )
 
-        @doc.save(@filename, @indent)
+        @doc.save(@filename, :indent => @indent)
       end #writer#write
 
@@ -150,5 +150,5 @@ module Bio
           @root << other_obj.to_xml
         end
-        @doc.save(@filename, @indent)
+        @doc.save(@filename, :indent => @indent)
       end
 
======================================================================

2. TypeError raised in the following tests.

test_made_up_xml_file(Bio::TestPhyloXMLWriter):
TypeError: wrong argument type Float (expected String)
    ./lib/bio/db/phyloxml/phyloxml_elements.rb:381:in `initialize'

test_phyloxml_examples_file(Bio::TestPhyloXMLWriter):
TypeError: wrong argument type Float (expected String)
    ./lib/bio/db/phyloxml/phyloxml_elements.rb:280:in `initialize'

test_phyloxml_examples_sequence_relation(Bio::TestPhyloXMLWriter):
TypeError: wrong argument type Float (expected String)
    ./lib/bio/db/phyloxml/phyloxml_elements.rb:280:in `initialize'

test_phyloxml_examples_tree2(Bio::TestPhyloXMLWriter):
TypeError: wrong argument type Float (expected String)
    ./lib/bio/db/phyloxml/phyloxml_elements.rb:280:in `initialize'

test_phyloxml_examples_tree4(Bio::TestPhyloXMLWriter):
TypeError: wrong argument type Float (expected String)
    ./lib/bio/db/phyloxml/phyloxml_elements.rb:381:in `initialize'

etc.

The following patch fixes the error, but I'm not sure it is correct.

======================================================================
--- a/lib/bio/db/phyloxml/phyloxml_elements.rb
+++ b/lib/bio/db/phyloxml/phyloxml_elements.rb
@@ -278,5 +278,5 @@ module PhyloXML
       if branch_length != nil       
         if write_branch_length_as_subelement
-          clade << XML::Node.new('branch_length', branch_length)
+          clade << XML::Node.new('branch_length', branch_length.to_s)
         else
           clade["branch_length"] = branch_length.to_s
@@ -379,5 +379,5 @@ module PhyloXML
           raise "Type is a required attribute for confidence."
         else
-          confidence = XML::Node.new('confidence', @value.to_f)
+          confidence = XML::Node.new('confidence', @value.to_s)
           confidence["type"] = @type          
           return confidence
======================================================================

3. The file "ncbi_taxonomy_mollusca_short.xml" specified in test_init
does not exist. Putting the file, or changing the file name can fix
the problem.


Thanks,

Naohisa Goto
ngoto at gen-info.osaka-u.ac.jp / ng at bioruby.org



More information about the BioRuby mailing list