From 6316ca89f8aecc9fe0e2c5996182811432ed134a Mon Sep 17 00:00:00 2001 From: cjfields Date: Tue, 20 Jan 2009 05:18:29 +0000 Subject: [PATCH] sync with main trunk svn path=/bioperl-live/branches/branch-1-6/; revision=15407 --- Bio/Annotation/AnnotationFactory.pm | 90 +-- Bio/Annotation/TagTree.pm | 2 +- Bio/Assembly/IO/phrap.pm | 4 +- Bio/Root/RootI.pm | 39 +- Bio/Root/Test.pm | 25 +- Build.PL | 2 +- t/Annotation/Annotation.t | 41 +- t/Assembly/Assembly.t | 22 +- t/LocalDB/BioDBGFF.t | 24 +- t/LocalDB/SeqFeature.t | 32 +- t/RemoteDB/SeqRead_fail.t | 6 +- t/Root/RootI.t | 36 +- t/SearchIO/blast.t | 101 +-- t/SearchIO/blast_pull.t | 28 +- t/SearchIO/blasttable.t | 2 +- t/SearchIO/blastxml.t | 18 +- t/SearchIO/erpin.t | 14 +- t/SearchIO/fasta.t | 16 +- t/SearchIO/hmmer.t | 20 +- t/SearchIO/hmmer_pull.t | 12 +- t/SearchIO/infernal.t | 52 +- t/SearchIO/rnamotif.t | 8 +- t/SeqIO/asciitree.t | 6 +- t/SeqIO/phd.t | 13 +- t/Tools/Match.t | 3 +- t/Tools/Phylo/Gerp.t | 3 +- t/Tree/TreeIO/phyloxml.t | 1401 ++++++++++++++++++----------------- 27 files changed, 1081 insertions(+), 939 deletions(-) rewrite t/Tree/TreeIO/phyloxml.t (98%) diff --git a/Bio/Annotation/AnnotationFactory.pm b/Bio/Annotation/AnnotationFactory.pm index c0abdaabb..96158f6f2 100644 --- a/Bio/Annotation/AnnotationFactory.pm +++ b/Bio/Annotation/AnnotationFactory.pm @@ -141,18 +141,18 @@ sub create_object { # we need to guess this $type = $self->_guess_type(@args); if(! $type) { - $self->throw("No annotation type set and unable to guess."); + $self->throw("No annotation type set and unable to guess."); } # load dynamically if it hasn't been loaded yet if(! $self->{'_loaded_types'}->{$type}) { - eval { - $self->_load_module($type); - $self->{'_loaded_types'}->{$type} = 1; - }; - if($@) { - $self->throw("Bio::AnnotationI implementation $type ". - "failed to load: ".$@); - } + eval { + $self->_load_module($type); + $self->{'_loaded_types'}->{$type} = 1; + }; + if($@) { + $self->throw("Bio::AnnotationI implementation $type ". + "failed to load: ".$@); + } } } return $type->new(-verbose => $self->verbose, @args); @@ -177,23 +177,23 @@ sub type{ my $self = shift; if(@_) { - my $type = shift; - if($type && (! $self->{'_loaded_types'}->{$type})) { - eval { - $self->_load_module($type); - }; - if( $@ ) { - $self->throw("Annotation class '$type' failed to load: ". - $@); - } - my $a = bless {},$type; - if( ! $a->isa('Bio::AnnotationI') ) { - $self->throw("'$type' does not implement Bio::AnnotationI. ". - "Too bad."); - } - $self->{'_loaded_types'}->{$type} = 1; - } - return $self->{'type'} = $type; + my $type = shift; + if($type && (! $self->{'_loaded_types'}->{$type})) { + eval { + $self->_load_module($type); + }; + if( $@ ) { + $self->throw("Annotation class '$type' failed to load: ". + $@); + } + my $a = bless {},$type; + if( ! $a->isa('Bio::AnnotationI') ) { + $self->throw("'$type' does not implement Bio::AnnotationI. ". + "Too bad."); + } + $self->{'_loaded_types'}->{$type} = 1; + } + return $self->{'type'} = $type; } return $self->{'type'}; } @@ -218,23 +218,27 @@ sub _guess_type{ my $type; # we can only guess from a certain number of arguments - my ($val,$db,$text,$name,$authors, $start) = - $self->_rearrange([qw(VALUE - DATABASE - TEXT - NAME - AUTHORS - START - )], @args); - SWITCH: { - $val && do { $type = "SimpleValue"; last SWITCH; }; - $authors && do { $type = "Reference"; last SWITCH; }; - $db && do { $type = "DBLink"; last SWITCH; }; - $text && do { $type = "Comment"; last SWITCH; }; - $name && do { $type = "OntologyTerm"; last SWITCH; }; - $start && do { $type = "Target"; last SWITCH; }; - # what else could we look for? - } + my ($val, $db, $text, $name, $authors, $start, $tree, $node) = + $self->_rearrange([qw(VALUE + DATABASE + TEXT + NAME + AUTHORS + START + TREE_OBJ + NODE + )], @args); + SWITCH: { + $val && do { $type = ref($val) ? "TagTree" : "SimpleValue"; last SWITCH; }; + $authors && do { $type = "Reference"; last SWITCH; }; + $db && do { $type = "DBLink"; last SWITCH; }; + $text && do { $type = "Comment"; last SWITCH; }; + $name && do { $type = "OntologyTerm"; last SWITCH; }; + $start && do { $type = "Target"; last SWITCH; }; + $tree && do { $type = "Tree"; last SWITCH; }; + $node && do { $type = "TagTree"; last SWITCH; }; + # what else could we look for? + } $type = "Bio::Annotation::".$type; return $type; diff --git a/Bio/Annotation/TagTree.pm b/Bio/Annotation/TagTree.pm index a8dd4e00e..e4908976e 100644 --- a/Bio/Annotation/TagTree.pm +++ b/Bio/Annotation/TagTree.pm @@ -282,7 +282,7 @@ sub value { # get mode? # How do we return a data structure? # for now, we use the output (if there is a Data::Stag node present) - # may need to an an eval {} to catch Data::Stag output errors + # may need to run an eval {} to catch Data::Stag output errors $self->node->$format; } diff --git a/Bio/Assembly/IO/phrap.pm b/Bio/Assembly/IO/phrap.pm index 7ec5921df..4013fbf22 100644 --- a/Bio/Assembly/IO/phrap.pm +++ b/Bio/Assembly/IO/phrap.pm @@ -200,7 +200,8 @@ sub next_assembly { -id => $singletID, -primary_id => $singletID, -alphabet => 'dna'); - my $singletOBJ = Bio::Assembly::Singlet->new(-seqref=>$seq); + my $singletOBJ = Bio::Assembly::Singlet->new(-seqref=>$seq, + -verbose => $self->verbose); my $feat = Bio::SeqFeature::Generic->new( -start => 1, -end => $length, @@ -217,6 +218,7 @@ sub next_assembly { /^Contig (\d+)\.\s+(\d+) reads?; (\d+) bp \(untrimmed\), (\d+) \(trimmed\)\./ && do { my ($contigID, $nof_reads, $length, $trimmed_length) = ($1, $2, $3, $4); $contigOBJ = Bio::Assembly::Contig->new( -id => $contigID, + -verbose => $self->verbose, -source => 'phrap' ); my $feat = Bio::SeqFeature::Generic->new( -start => 1, diff --git a/Bio/Root/RootI.pm b/Bio/Root/RootI.pm index 4bd94acbc..be42b12da 100644 --- a/Bio/Root/RootI.pm +++ b/Bio/Root/RootI.pm @@ -194,18 +194,45 @@ sub warn { Title : deprecated Usage : $obj->deprecated("Method X is deprecated"); - Function: Prints a message about deprecation - unless verbose is < 0 (which means be quiet) + $obj->deprecated("Method X is deprecated", 1.007); + $obj->deprecated(-message => "Method X is deprecated"); + $obj->deprecated(-message => "Method X is deprecated", + -version => 1.007); + Function: Prints a message about deprecation unless verbose is < 0 + (which means be quiet) Returns : none Args : Message string to print to STDERR + Version of BioPerl where use of the method results in an exception + Notes : The method can be called two ways, either by positional arguments: + + $obj->deprecated('This module is deprecated', 1.006); + + or by named arguments: + + $obj->deprecated( + -message => 'use of the method foo() is deprecated, use bar() instead', + -version => 1.006); + + The version is optional but highly suggested. For proper comparisons + one must use a version in lines with the current versioning scheme + for Perl and BioPerl, (i.e. where 1.006000 indicates v1.6.0, 5.010000 + for v5.10.0, etc.). =cut sub deprecated{ - my ($self,$msg) = @_; - if( $self->verbose >= 0 ) { - print STDERR $msg, "\n", $self->stack_trace_dump; - } + my ($self) = shift; + my ($msg, $version) = $self->_rearrange([qw(MESSAGE VERSION)], @_); + # delegate to either warn or throw based on whether a version is given + if ($version) { + $self->throw('Version must be numerical, such as 1.006000 for v1.6.0, not '. + $version) unless $version =~ /^\d+\.\d+$/; + if ($Bio::Root::Version::VERSION >= $version) { + $self->throw($msg) + } + } + # passing this on to warn() should deal properly with verbosity issues + $self->warn($msg); } =head2 stack_trace_dump diff --git a/Bio/Root/Test.pm b/Bio/Root/Test.pm index 5ee62dba3..f705c5ca6 100644 --- a/Bio/Root/Test.pm +++ b/Bio/Root/Test.pm @@ -167,12 +167,13 @@ our @EXPORT = qw(ok use_ok require_ok test_output_dir test_input_file test_network - test_debug); + test_debug + float_is + ); our $GLOBAL_FRAMEWORK = 'Test::More'; our @TEMP_FILES; - =head2 test_begin Title : test_begin @@ -371,6 +372,26 @@ sub test_debug { return $ENV{'BIOPERLDEBUG'} || 0; } +=head2 float_is + + Title : float_is + Usage : float_is($val1, $val2); + Function: test two floating point values for equality + Returns : Boolean based on test (can use in combination with diag) + Args : two scalar values (floating point numbers) (required via prototype) + test message (optional) + +=cut + +sub float_is ($$;$) { + my ($val1, $val2, $message) = @_; + # catch any potential undefined values and directly compare + if (!defined $val1 || !defined $val2) { + is($val1, $val2 ,$message); + } else { + is(sprintf("%g",$val1), sprintf("%g",$val2),$message); + } +} # decide if should skip and generate skip message sub _skip { diff --git a/Build.PL b/Build.PL index 1150a3a8f..7ec07f863 100755 --- a/Build.PL +++ b/Build.PL @@ -29,7 +29,7 @@ my $build = Bio::Root::Build->new( 'perl' => '5.6.1', 'IO::String' => 0, 'DB_File' => 0, - 'Data::Stag' => 0.10, # Bio::SeqIO::swiss, we can change to 'recommend' if needed + 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed 'Scalar::Util' => 0 # not in Perl 5.6.1, arrived in core in 5.7.3 }, build_requires => { diff --git a/t/Annotation/Annotation.t b/t/Annotation/Annotation.t index e4654f273..740d64b43 100644 --- a/t/Annotation/Annotation.t +++ b/t/Annotation/Annotation.t @@ -7,7 +7,7 @@ BEGIN { use lib '.'; use Bio::Root::Test; - test_begin(-tests => 155); + test_begin(-tests => 159); use_ok('Bio::Annotation::Collection'); use_ok('Bio::Annotation::DBLink'); @@ -178,12 +178,16 @@ SKIP: { # AnnotatableI my $seq = Bio::Seq->new(); isa_ok($seq,"Bio::AnnotatableI"); -my $fea = Bio::SeqFeature::Annotated->new(); -isa_ok($fea, "Bio::SeqFeatureI",'isa SeqFeatureI'); -isa_ok($fea, "Bio::AnnotatableI",'isa AnnotatableI'); -$fea = Bio::SeqFeature::Generic->new(); -isa_ok($fea, "Bio::SeqFeatureI",'isa SeqFeatureI'); -isa_ok($fea, "Bio::AnnotatableI",'isa AnnotatableI'); +SKIP: { + test_skip(-requires_module => 'URI::Escape', + -tests => 4); + my $fea = Bio::SeqFeature::Annotated->new(); + isa_ok($fea, "Bio::SeqFeatureI",'isa SeqFeatureI'); + isa_ok($fea, "Bio::AnnotatableI",'isa AnnotatableI'); + $fea = Bio::SeqFeature::Generic->new(); + isa_ok($fea, "Bio::SeqFeatureI",'isa SeqFeatureI'); + isa_ok($fea, "Bio::AnnotatableI",'isa AnnotatableI'); +} my $clu = Bio::Cluster::UniGene->new(); isa_ok($clu, "Bio::AnnotatableI"); my $aln = Bio::SimpleAlign->new(); @@ -197,22 +201,21 @@ isa_ok($factory, 'Bio::Factory::ObjectFactoryI'); # defaults to SimpleValue $ann = $factory->create_object(-value => 'peroxisome', -tagname => 'cellular component'); -like(ref $ann, qr(Bio::Annotation::SimpleValue)); +isa_ok($ann, 'Bio::Annotation::SimpleValue'); $factory->type('Bio::Annotation::OntologyTerm'); $ann = $factory->create_object(-name => 'peroxisome', -tagname => 'cellular component'); ok(defined $ann); -like(ref($ann), qr(Bio::Annotation::OntologyTerm)); +isa_ok($ann, 'Bio::Annotation::OntologyTerm'); +# unset type() +$factory->type(undef); $ann = $factory->create_object(-text => 'this is a comment'); ok(defined $ann,'Bio::Annotation::Comment'); -TODO: { - local $TODO = "Create Annotation::Comment based on parameter only"; - isa_ok($ann,'Bio::Annotation::Comment'); -} +isa_ok($ann,'Bio::Annotation::Comment'); ok $factory->type('Bio::Annotation::Comment'); $ann = $factory->create_object(-text => 'this is a comment'); @@ -273,6 +276,12 @@ for my $treeblock ( $aln->annotation->get_Annotations('tree') ) { is( $str, "MDDKELEIPVEHSTAFGQLV", "get seq from node id"); } +# factory guessing the type: Tree +$factory = Bio::Annotation::AnnotationFactory->new(); +$ann = $factory->create_object(-tree_obj => $tree); +ok defined $ann; +isa_ok($ann,'Bio::Annotation::Tree'); + #tagtree my $struct = [ 'genenames' => [ ['genename' => [ @@ -377,3 +386,9 @@ for my $tagtree ( $ac->get_Annotations('genenames') ) { } } is($ct,3); + +# factory guessing the type: TagTree +$factory = Bio::Annotation::AnnotationFactory->new(); +$ann = $factory->create_object(-value => $struct); +ok defined $ann; +isa_ok($ann,'Bio::Annotation::TagTree'); diff --git a/t/Assembly/Assembly.t b/t/Assembly/Assembly.t index fab699aa2..69bf87e58 100644 --- a/t/Assembly/Assembly.t +++ b/t/Assembly/Assembly.t @@ -7,7 +7,7 @@ BEGIN { use lib '.'; use Bio::Root::Test; - test_begin(-tests => 50, + test_begin(-tests => 51, -requires_module => 'DB_File'); use_ok('Bio::Assembly::IO'); @@ -26,10 +26,24 @@ my $in = Bio::Assembly::IO->new isa_ok($in, 'Bio::Assembly::IO'); -diag('If there are warnings here, it\'s because the phrap parser doesn\'t include the sequence string in the sequence objects.'); -my $sc = $in->next_assembly; +my $sc; -isa_ok($sc, 'Bio::Assembly::Scaffold'); +TODO: { + local $TODO = "phrap parser doesn't include the sequence string in the sequence objects."; + $in->verbose(2); + eval {$sc = $in->next_assembly}; + ok(!$@); +} + +$in = Bio::Assembly::IO->new + (-file => test_input_file('consed_project','edit_dir','test_project.phrap.out')); + +$in->verbose(-1); + +$sc = $in->next_assembly; + +isa_ok($sc, + 'Bio::Assembly::Scaffold'); # # Testing Scaffold diff --git a/t/LocalDB/BioDBGFF.t b/t/LocalDB/BioDBGFF.t index 826077850..e35b175fe 100644 --- a/t/LocalDB/BioDBGFF.t +++ b/t/LocalDB/BioDBGFF.t @@ -419,16 +419,20 @@ SKIP: { } } - # test ability to pass adaptors across a fork - if (my $child = open(F,"-|")) { # parent reads from child - ok(scalar ); - close F; - } - else { # in child - $db->clone; - my @f = $db->features(); - print @f>0; - exit 0; + SKIP: { + test_skip(-tests => 1, -excludes_os => 'mswin'); + + # test ability to pass adaptors across a fork + if (my $child = open(F,"-|")) { # parent reads from child + ok(scalar ); + close F; + } + else { # in child + $db->clone; + my @f = $db->features(); + print @f>0; + exit 0; + } } ok(!defined eval{$db->delete()}); diff --git a/t/LocalDB/SeqFeature.t b/t/LocalDB/SeqFeature.t index 23fe48a78..21a389eb8 100644 --- a/t/LocalDB/SeqFeature.t +++ b/t/LocalDB/SeqFeature.t @@ -170,20 +170,24 @@ is (@lines, 2); ok("@lines" !~ /Parent=/s); ok("@lines" =~ /ID=/s); -if (my $child = open(F,"-|")) { # parent reads from child - cmp_ok(scalar ,'>',0); - close F; - # The challenge is to make sure that the handle - # still works in the parent! - my @f = $db->features(); - cmp_ok(scalar @f,'>',0); -} -else { # in child - $db->clone; - my @f = $db->features(); - my $feature_count = @f; - print $feature_count; - exit 0; +SKIP: { + test_skip(-tests => 1, -excludes_os => 'mswin'); + + if (my $child = open(F,"-|")) { # parent reads from child + cmp_ok(scalar ,'>',0); + close F; + # The challenge is to make sure that the handle + # still works in the parent! + my @f = $db->features(); + cmp_ok(scalar @f,'>',0); + } + else { # in child + $db->clone; + my @f = $db->features(); + my $feature_count = @f; + print $feature_count; + exit 0; + } } # test the -ignore_seqregion flag diff --git a/t/RemoteDB/SeqRead_fail.t b/t/RemoteDB/SeqRead_fail.t index 9f03b1ec8..c540b0a2c 100644 --- a/t/RemoteDB/SeqRead_fail.t +++ b/t/RemoteDB/SeqRead_fail.t @@ -27,9 +27,11 @@ sub fetch { my ($id, $class) = @_; print "###################### $class ####################################\n" if $verbose; my $seq; - ok defined ( my $gb = new $class('-verbose'=>$verbose,'-delay'=>0) ), "defined for $class"; + ok defined( my $gb = $class->new('-verbose'=>$verbose, + '-delay'=>0, + '-retrievaltype' => 'tempfile') ), "defined for $class"; eval { $seq = $gb->get_Seq_by_id($id) }; - if ($@ or not defined $seq) { + if ($@ || !defined $seq) { ok 1, "error or undef for $class"; return; } diff --git a/t/Root/RootI.t b/t/Root/RootI.t index b9288599c..e5c1377dd 100644 --- a/t/Root/RootI.t +++ b/t/Root/RootI.t @@ -7,7 +7,7 @@ BEGIN { use lib '.'; use Bio::Root::Test; - test_begin(-tests => 37); + test_begin(-tests => 50); use_ok('Bio::Root::Root'); use_ok('Bio::Seq'); @@ -79,6 +79,40 @@ ok $@ =~ /Bio::Root::NotImplemented/; is shift @vals, 'up the'; is shift @vals, 'stairs'; +# test deprecated() + +# class method +warning_like{ Bio::Root::Root->deprecated('Test1') } qr/Test1/, 'simple'; +warning_like{ Bio::Root::Root->deprecated(-message => 'Test2') } qr/Test2/, 'simple'; +warning_like{ Bio::Root::Root->deprecated('Test3', 999.999) } qr/Test3/, + 'warns for versions below current version '.$Bio::Root::Version::VERSION; +warning_like{ Bio::Root::Root->deprecated(-message => 'Test4', + -version => 999.999) } qr/Test4/, + 'warns for versions below current version '.$Bio::Root::Version::VERSION; +throws_ok{ Bio::Root::Root->deprecated('Test5', 0.001) } qr/Test5/, + 'throws for versions above '.$Bio::Root::Version::VERSION; +throws_ok{ Bio::Root::Root->deprecated(-message => 'Test6', + -version => 0.001) } qr/Test6/, + 'throws for versions above '.$Bio::Root::Version::VERSION; +throws_ok{ Bio::Root::Root->deprecated(-message => 'Test6', + -version => $Bio::Root::Version::VERSION) } qr/Test6/, + 'throws for versions equal to '.$Bio::Root::Version::VERSION; + +# object method +my $root = Bio::Root::Root->new(); +warning_like{ $root->deprecated('Test1') } qr/Test1/, 'simple'; +warning_like{ $root->deprecated(-message => 'Test2') } qr/Test2/, 'simple'; +warning_like{ $root->deprecated('Test3', 999.999) } qr/Test3/, + 'warns for versions below current version '.$Bio::Root::Version::VERSION; +warning_like{ $root->deprecated(-message => 'Test4', + -version => 999.999) } qr/Test4/, + 'warns for versions below current version '.$Bio::Root::Version::VERSION; +throws_ok{ $root->deprecated('Test5', 0.001) } qr/Test5/, + 'throws for versions above '.$Bio::Root::Version::VERSION; +throws_ok{ $root->deprecated(-message => 'Test6', + -version => 0.001) } qr/Test6/, + 'throws for versions above '.$Bio::Root::Version::VERSION; + # tests for _set_from_args() # Let's not pollute Bio::Root::Root namespace if possible # Create temp classes instead which inherit Bio::Root::Root, then test diff --git a/t/SearchIO/blast.t b/t/SearchIO/blast.t index 57f8b321e..f0624a1dc 100644 --- a/t/SearchIO/blast.t +++ b/t/SearchIO/blast.t @@ -45,7 +45,7 @@ is($result->get_parameter('gapopen'), 11); is($result->get_parameter('gapext'), 1); is($result->get_statistic('S2'), '92'); is($result->get_statistic('S2_bits'), '40.0'); -is($result->get_parameter('expect'), '1.0e-03'); +float_is($result->get_parameter('expect'), '1.0e-03'); is($result->get_statistic('num_extensions'), '82424'); @@ -59,7 +59,7 @@ while( $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->bits, shift @$d ); is($hit->raw_score, shift @$d ); @@ -74,7 +74,7 @@ while( $hit = $result->next_hit ) { is($hsp->start('hit'), $hsp->hit->start); is($hsp->end('query'), $hsp->query->end); is($hsp->strand('sbjct'), $hsp->subject->strand);# alias for hit - is($hsp->evalue, '0.0'); + float_is($hsp->evalue, 0.0); is($hsp->score, 4058); is($hsp->bits,1567); is(sprintf("%.2f",$hsp->percent_identity), 98.29); @@ -148,7 +148,7 @@ while( $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); if( $count == 0 ) { @@ -160,8 +160,8 @@ while( $hit = $result->next_hit ) { is($hsp->hit->end, 820); is($hsp->length('total'), 820); - is($hsp->evalue, '0.0'); - is($hsp->pvalue, '0.0'); + float_is($hsp->evalue, 0.0); + float_is($hsp->pvalue, '0.0'); is($hsp->score, 4141); is($hsp->bits,1462.8); is($hsp->percent_identity, 100); @@ -226,7 +226,7 @@ while( $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); if( $count == 0 ) { @@ -238,8 +238,8 @@ while( $hit = $result->next_hit ) { is($hsp->hit->end, 820); is($hsp->length('total'), 820); - is($hsp->evalue , '0.'); - is($hsp->pvalue , '0.'); + float_is($hsp->evalue, 0.); + float_is($hsp->pvalue , '0.'); is($hsp->score, 4141); is($hsp->bits,1462.8); is($hsp->percent_identity, 100); @@ -296,7 +296,7 @@ while( $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is($hit->significance, shift @$d ); + float_is($hit->significance, shift @$d); is($hit->bits, shift @$d ); is($hit->raw_score, shift @$d ); @@ -313,7 +313,7 @@ while( $hit = $result->next_hit ) { is($hsp->strand('sbjct'), $hsp->subject->strand); is($hsp->length('total'), 26); - is($hsp->evalue , 0.13); + float_is($hsp->evalue, 0.13); is($hsp->score, 67); is($hsp->bits,33.6); is(sprintf("%.2f",$hsp->percent_identity), 42.31); @@ -384,7 +384,7 @@ while( my $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->bits, shift @$d ); is($hit->raw_score, shift @$d ); is($hit->start, shift @$d); @@ -400,7 +400,7 @@ while( my $hit = $result->next_hit ) { is($hsp->hit->end, 212); is($hsp->hit->strand, 1); is($hsp->length('total'), 60); - is(sprintf("%g",$hsp->evalue), sprintf("%g",'3e-18')); + float_is($hsp->evalue, 3e-18); is($hsp->score, 48); is($hsp->bits,95.6); is(sprintf("%.2f",$hsp->percent_identity), 96.67); @@ -459,7 +459,7 @@ while( my $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); is(sprintf("%.4f",$hit->frac_identical('query')), '0.3640'); is(sprintf("%.4f",$hit->frac_identical('hit')), '0.3660'); @@ -478,8 +478,8 @@ while( my $hit = $result->next_hit ) { is($hsp->hit->end, 413); is($hsp->hit->strand, 0); is($hsp->length('total'), 421); - is(sprintf("%g",$hsp->evalue), sprintf("%g",'1.1e-74')); - is(sprintf("%g",$hsp->pvalue), sprintf("%g",'1.1e-74')); + float_is($hsp->evalue, 1.1e-74); + float_is($hsp->pvalue, '1.1e-74'); is($hsp->score,671); is($hsp->bits,265.8); is(sprintf("%.2f",$hsp->percent_identity), 35.87); @@ -590,7 +590,7 @@ while( my $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); if( $count == 0 ) { @@ -603,8 +603,8 @@ while( my $hit = $result->next_hit ) { is($hsp->hit->end, 6016); is($hsp->hit->strand, 1); is($hsp->length('total'), 421); - cmp_ok($hsp->evalue,'==',1.4e-73); - cmp_ok($hsp->pvalue,'==',1.4e-73); + float_is($hsp->evalue, 1.4e-73); + float_is($hsp->pvalue,1.4e-73); is($hsp->score,671); is($hsp->bits,265.8); is(sprintf("%.2f",$hsp->percent_identity), 35.87); @@ -665,7 +665,7 @@ while( my $hit = $result->next_hit ) { is($hit->length, shift @$d); is($hit->accession, shift @$d); # using e here to deal with 0.9992 coming out right here as well - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); is($hit->bits, shift @$d ); if( $count == 0 ) { @@ -681,8 +681,8 @@ while( my $hit = $result->next_hit ) { is($hsp->hit->end, 5368); is($hsp->hit->strand, 1); is($hsp->length('total'), 59); - cmp_ok($hsp->evalue,'==',6.4e-70); - cmp_ok($hsp->pvalue,'==',6.4e-70); + float_is($hsp->evalue, 6.4e-70); + float_is($hsp->pvalue,6.4e-70); is($hsp->score,85); is($hsp->bits,41.8); is(sprintf("%.2f",$hsp->percent_identity), '32.20'); @@ -715,8 +715,8 @@ while( my $hit = $result->next_hit ) { is($hsp->hit->end, 4227); is($hsp->hit->strand, -1); is($hsp->length('total'), 40); - is($hsp->evalue , 7.1); - is($hsp->pvalue , '1.00'); + float_is($hsp->evalue, 7.1); + float_is($hsp->pvalue , '1.00'); is($hsp->score,59); is($hsp->bits,29.9); is(sprintf("%.2f",$hsp->percent_identity), '37.50'); @@ -770,7 +770,7 @@ while( $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); if( $count == 0 ) { @@ -782,8 +782,8 @@ while( $hit = $result->next_hit ) { is($hsp->hit->end, 1936); is($hsp->length('total'), 1936); - is($hsp->evalue , '0.'); - is($hsp->pvalue , '0.'); + float_is($hsp->evalue, 0.); + float_is($hsp->pvalue , '0.'); is($hsp->score, 9680); is($hsp->bits,1458.4); is($hsp->percent_identity, 100); @@ -829,11 +829,11 @@ is($hit->description, 'F22B7.10 protein - Caenorhabditis elegans'); is($hit->name, 'PIR2:S44629'); is($hit->length, 628); is($hit->accession, 'PIR2:S44629'); -is($hit->significance, '2e-08' ); +float_is($hit->significance, 2e-08); is($hit->raw_score, 136 ); is($hit->bits, '57.0' ); $hsp = $hit->next_hsp; -cmp_ok($hsp->evalue, '==', 2e-08); +float_is($hsp->evalue, 2e-08); is($hsp->bits, '57.0'); is($hsp->score, 136); is(int($hsp->percent_identity), 28); @@ -939,11 +939,11 @@ while( my $hit = $r->next_hit ) { is($hit->length, shift @$d); is($hit->raw_score, shift @$d); is($hit->bits, shift @$d); - is($hit->significance, shift @$d); + float_is($hit->significance, shift @$d); my $hsp = $hit->next_hsp; is($hsp->bits, shift @$d); - cmp_ok($hsp->evalue, '==', shift @$d); + float_is($hsp->evalue, shift @$d); is($hsp->score, shift @$d); is($hsp->num_identical, shift @$d); is($hsp->gaps('total'), shift @$d); @@ -968,7 +968,7 @@ is($r->query_gi, 1786183); is($r->num_hits, 7); $hit = $r->next_hit; is($hit->name, 'gnl|CDD|3919'); -is($hit->significance, 0.064); +float_is($hit->significance, 0.064); is($hit->bits, 28.3); is($hit->raw_score, 63); $hsp = $hit->next_hsp; @@ -1033,7 +1033,7 @@ while( $iter = $result->next_iteration ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->bits, shift @$d ); if( $hit_count == 1 ) { @@ -1047,7 +1047,7 @@ while( $iter = $result->next_iteration ) { is($hsp->start('hit'), $hsp->hit->start); is($hsp->end('query'), $hsp->query->end); is($hsp->strand('sbjct'), $hsp->subject->strand);# alias for hit - cmp_ok($hsp->evalue, '==', 1e-75); + float_is($hsp->evalue, 1e-75); is($hsp->score, 712); is($hsp->bits, 281); is(sprintf("%.1f",$hsp->percent_identity), 46.5); @@ -1138,7 +1138,7 @@ $hsp = $hit->next_hsp; is($hsp->score, 481); is($hsp->bits, 191); is(int $hsp->percent_identity, 34); -cmp_ok($hsp->evalue, '==', 2e-53); +float_is($hsp->evalue, 2e-53); is(int($hsp->frac_conserved*$hsp->length), 167); is($hsp->query->start, 28); is($hsp->query->end, 343); @@ -1161,7 +1161,7 @@ $hsp = $hit->next_hsp; is($hsp->score, 27); is($hsp->bits, '54.0'); is(int $hsp->percent_identity, 88); -cmp_ok($hsp->evalue, '==', 2e-12); +float_is($hsp->evalue, 2e-12); is(int($hsp->frac_conserved*$hsp->length), 83); is($hsp->query->start, 94); is($hsp->query->end, 180); @@ -1186,7 +1186,7 @@ $hsp = $hit->next_hsp; is($hsp->score, 27); is($hsp->bits, '54.0'); is(int $hsp->percent_identity, 88); -cmp_ok($hsp->evalue,'==', 2e-12); +float_is($hsp->evalue, 2e-12); is(int($hsp->frac_conserved*$hsp->length), 83); is($hsp->query->start, 94); is($hsp->query->end, 180); @@ -1214,7 +1214,7 @@ $hsp = $hit->next_hsp; is($hsp->score, 1626); is($hsp->bits, 637); is(int $hsp->percent_identity, 66); -cmp_ok($hsp->evalue, '==', 0.0); +float_is($hsp->evalue, 0.0); is(int($hsp->frac_conserved*$hsp->length), 330); is($hsp->query->start, 121); is($hsp->query->end, 469); @@ -1244,7 +1244,7 @@ $hsp = $hit->next_hsp; is($hsp->score, 634); is($hsp->bits, 248); is(int $hsp->percent_identity, 100); -cmp_ok($hsp->evalue, '==' ,2e-70); +float_is($hsp->evalue, 2e-70); is(int($hsp->frac_conserved*$hsp->length), 128); is($hsp->query->start, 1); is($hsp->query->end, 384); @@ -1274,7 +1274,7 @@ $hsp = $hit->next_hsp; is($hsp->score, 1118); is($hsp->bits, 515); is(int $hsp->percent_identity, 95); -cmp_ok($hsp->evalue, '==', 1e-151); +float_is($hsp->evalue, 1e-151); is(int($hsp->frac_conserved*$hsp->length), 229); is($hsp->query->start, 1); is($hsp->query->end, 720); @@ -1304,13 +1304,13 @@ $hit = $result->next_hit; is($hit->name, 'mgri:MG00189.3'); is($hit->description, 'hypothetical protein 6892 8867 +'); is($hit->bits, 3098); -is($hit->significance, '0.'); +float_is($hit->significance, 0.); $hit = $result->next_hit; is($hit->name, 'fgram:FG01141.1'); is($hit->description, 'hypothetical protein 47007 48803 -'); is($hit->bits, 2182); -is($hit->significance, '4.2e-226'); +float_is($hit->significance, 4.2e-226); is($result->num_hits, 415); # Let's now test if _guess_format is doing its job correctly my %pair = ( 'filename.blast' => 'blast', @@ -1401,7 +1401,7 @@ is($result->get_parameter('gapopen'), 5); is($result->get_parameter('gapext'), 2); is($result->get_statistic('S2'), '60'); is($result->get_statistic('S2_bits'), '119.4'); -is($result->get_parameter('expect'), '1e-23'); +float_is($result->get_parameter('expect'), '1e-23'); is($result->get_statistic('num_extensions'), '117843'); @valid = ( [ 'gi|41400296|gb|AE016958.1|', 4829781, 'AE016958', 41400296, '6e-059', 119, 236], @@ -1415,7 +1415,7 @@ while( $hit = $result->next_hit ) { is($hit->length, shift @$d); is($hit->accession, shift @$d); is($hit->ncbi_gi, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); is($hit->bits, shift @$d ); @@ -1431,7 +1431,7 @@ while( $hit = $result->next_hit ) { is($hsp->start('hit'), $hsp->hit->start); is($hsp->end('query'), $hsp->query->end); is($hsp->strand('sbjct'), $hsp->subject->strand);# alias for hit - cmp_ok($hsp->evalue, '==', 6e-59); + float_is($hsp->evalue, 6e-59); is($hsp->score, 119); is($hsp->bits,236); is(sprintf("%.2f",$hsp->percent_identity), 85.22); @@ -1488,7 +1488,7 @@ is $hit->length, 0; is $hit->accession, 'UniRef50_Q9X0H5'; is $hit->description, 'Cluster: Histidyl-tRNA synthetase; n=4; Thermoto...'; is $hit->bits, 23; -is $hit->significance, 650; +float_is($hit->significance, 650); # Bug 1986 $searchio = Bio::SearchIO->new(-format => 'blast', @@ -1502,7 +1502,7 @@ is $hit->accession, 'ENSP00000350182'; is $hit->description, 'pep:novel clone::BX322644.8:4905:15090:-1 gene:ENSG00000137397 transcript:ENST00000357569 '; is $hit->raw_score, 301; is $hit->bits, 120; -is $hit->significance, 3e-27; +float_is($hit->significance, 3e-27); $hit = $result->next_hit; is $hit->name, 'ENSP00000327738'; is $hit->length, 468; @@ -1510,7 +1510,7 @@ is $hit->accession, 'ENSP00000327738'; is $hit->description, 'pep:known-ccds chromosome:NCBI36:4:189297592:189305643:1 gene:ENSG00000184108 transcript:ENST00000332517 CCDS3851.1'; is $hit->raw_score, 289; is $hit->bits, 115; -is $hit->significance, 8e-26; +float_is($hit->significance, 8e-26); # Bug 1986, pt. 2 @@ -1584,3 +1584,8 @@ while(my $query = $searchio->next_result) { } } is($total_n, 10); + +sub cmp_evalue ($$) { + my ($tval, $aval) = @_; + is(sprintf("%g",$tval), sprintf("%g",$aval)); +} diff --git a/t/SearchIO/blast_pull.t b/t/SearchIO/blast_pull.t index c12b2b034..a20412d9a 100644 --- a/t/SearchIO/blast_pull.t +++ b/t/SearchIO/blast_pull.t @@ -37,7 +37,7 @@ is $result->get_parameter('gapopen'), 5; is $result->get_parameter('gapext'), 2; is $result->get_statistic('S2'), 60; is $result->get_statistic('S2_bits'), 119.4; -is $result->get_parameter('expect'), 1e-23; +float_is $result->get_parameter('expect'), 1e-23; is $result->get_statistic('num_extensions'), 117843; my @valid = ( [ 'gi|41400296|gb|AE016958.1|', 4829781, 'AE016958', '6e-059', 236], @@ -50,7 +50,7 @@ while (my $hit = $result->next_hit ) { is $hit->name, shift @$d; is $hit->length, shift @$d; is $hit->accession, shift @$d; - is sprintf("%g",$hit->significance), sprintf("%g",shift @$d); + float_is($hit->significance, shift @$d); is $hit->raw_score, shift @$d; if( $count == 0 ) { @@ -64,7 +64,7 @@ while (my $hit = $result->next_hit ) { is $hsp->start('hit'), $hsp->hit->start; is $hsp->end('query'), $hsp->query->end; is $hsp->strand('sbjct'), $hsp->subject->strand;# alias for hit - is $hsp->evalue, 6e-59; + float_is($hsp->evalue, 6e-59); is $hsp->score, 119; is $hsp->bits,236; is sprintf("%.1f",$hsp->percent_identity), 85.2; @@ -118,7 +118,7 @@ is($result->get_parameter('gapopen'), 11); is($result->get_parameter('gapext'), 1); is($result->get_statistic('S2'), '92'); is($result->get_statistic('S2_bits'), '40.0'); -is($result->get_parameter('expect'), '1.0e-03'); +float_is($result->get_parameter('expect'), '1.0e-03'); is($result->get_statistic('num_extensions'), '82424'); @@ -132,7 +132,7 @@ while (my $hit = $result->next_hit) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); if( $count == 0 ) { @@ -146,7 +146,7 @@ while (my $hit = $result->next_hit) { is($hsp->start('hit'), $hsp->hit->start); is($hsp->end('query'), $hsp->query->end); is($hsp->strand('sbjct'), $hsp->subject->strand);# alias for hit - is($hsp->evalue, '0.0'); + float_is($hsp->evalue, 0.0); is($hsp->score, 4058); is($hsp->bits,1567); is(sprintf("%.2f",$hsp->percent_identity), 98.29); @@ -205,7 +205,7 @@ while( my $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); is($hit->start, shift @$d); is($hit->end,shift @$d); @@ -220,7 +220,7 @@ while( my $hit = $result->next_hit ) { is($hsp->hit->end, 212); is($hsp->hit->strand, 1); is($hsp->length('hsp'), 60); - is(sprintf("%g",$hsp->evalue), sprintf("%g",'3e-18')); + float_is($hsp->evalue, 3e-18); is($hsp->score, 48); is($hsp->bits,95.6); is(sprintf("%.2f",$hsp->percent_identity), 96.67); @@ -328,7 +328,7 @@ is($result->get_parameter('gapopen'), 5); is($result->get_parameter('gapext'), 2); is($result->get_statistic('S2'), '60'); is($result->get_statistic('S2_bits'), '119.4'); -is($result->get_parameter('expect'), '1e-23'); +float_is($result->get_parameter('expect'), '1e-23'); is($result->get_statistic('num_extensions'), '117843'); @valid = ( [ 'gi|41400296|gb|AE016958.1|', 4829781, 'AE016958', '6e-059', 236], @@ -341,7 +341,7 @@ while( $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); if( $count == 0 ) { @@ -355,7 +355,7 @@ while( $hit = $result->next_hit ) { is($hsp->start('hit'), $hsp->hit->start); is($hsp->end('query'), $hsp->query->end); is($hsp->strand('sbjct'), $hsp->subject->strand);# alias for hit - cmp_ok($hsp->evalue, '==', 6e-59); + float_is($hsp->evalue, 6e-59); is($hsp->score, 119); is($hsp->bits,236); is(sprintf("%.2f",$hsp->percent_identity), 85.22); @@ -384,7 +384,7 @@ is($result->query_length, 193); my @hits = $result->hits; is(scalar(@hits), 10); is($hits[1]->accession,'1W30'); -is($hits[4]->significance,'2e-72'); +float_is($hits[4]->significance,'2e-72'); is($hits[7]->score,'254'); $result = $searchio->next_result; is($result->database_entries, 4460989); @@ -396,7 +396,7 @@ is($result->query_length, 423); @hits = $result->hits; is(scalar(@hits), 10); is($hits[1]->accession,'ZP_00972546'); -is($hits[4]->significance, '0.0'); +float_is($hits[4]->significance, '0.0'); is($hits[7]->score, 624); # Bug 2246 @@ -410,6 +410,6 @@ is $hit->length, undef; is $hit->accession, 'UniRef50_Q9X0H5'; is $hit->description, 'Cluster: Histidyl-tRNA synthetase; n=4; Thermoto...'; is $hit->raw_score, 23; -is $hit->significance, 650; +float_is($hit->significance, 650); #*** need to /fully/ test a multi-result, multi-hit, multi-hsp report! diff --git a/t/SearchIO/blasttable.t b/t/SearchIO/blasttable.t index c57aa6253..62200ea69 100644 --- a/t/SearchIO/blasttable.t +++ b/t/SearchIO/blasttable.t @@ -63,7 +63,7 @@ while(my $res = $searchio->next_result) { $hit = $res->next_hit; my $hsp = $hit->next_hsp; is($hsp->bits, 331); - is($hsp->evalue, '2e-91'); + float_is($hsp->evalue, 2e-91); is($hsp->start('hit'), 16); is($hsp->end('hit'), 805); is($hsp->start('query'), 5); diff --git a/t/SearchIO/blastxml.t b/t/SearchIO/blastxml.t index 9f1699cb7..283882e47 100644 --- a/t/SearchIO/blastxml.t +++ b/t/SearchIO/blastxml.t @@ -73,7 +73,7 @@ SKIP: { is($hsp->hit->seq_id, $hit->name,'hitname'); is($hsp->hit->seqdesc, $hit->description,'hitdesc'); is($hsp->pvalue, undef); - is(sprintf("%g",$hsp->evalue), sprintf("%g",'1.46134e-90')); + float_is($hsp->evalue, 1.46134e-90); is($hsp->score, 838); is($hsp->bits,327.405); is($hsp->query->start, 498); @@ -182,7 +182,7 @@ SKIP: { is($hsp->hit->seq_id, $hit->name,'hitname'); is($hsp->hit->seqdesc, $hit->description,'hitdesc'); is($hsp->pvalue, undef); - is(sprintf("%g",$hsp->evalue), sprintf("%g",'0')); + float_is($hsp->evalue, 0); is($hsp->score, 2251); is($hsp->bits,871.692); is($hsp->query->start, 1); @@ -222,7 +222,7 @@ SKIP: { is($hsp->hit->seq_id, $hit->name,'hitname'); is($hsp->hit->seqdesc, $hit->description,'hitdesc'); is($hsp->pvalue, undef); - is(sprintf("%g",$hsp->evalue), sprintf("%g",'0')); + float_is($hsp->evalue, 0); is($hsp->score, 1780); is($hsp->bits,690.263); is($hsp->query->start, 1); @@ -259,7 +259,7 @@ SKIP: { is($result->get_statistic('dbentries'), 88780); is($result->get_statistic('effective_hsplength'), 49); } - is($result->get_statistic('effectivespace'), '6.44279e+07'); + float_is($result->get_statistic('effectivespace'), '6.44279e+07'); is($result->get_parameter('matrix'), 'BLOSUM62'); is($result->get_parameter('gapopen'), 11); is($result->get_parameter('gapext'), 1); @@ -292,7 +292,7 @@ SKIP: { is($hit->length, shift @$d); is($hit->accession, shift @$d); is($hit->ncbi_gi, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->bits, shift @$d ); if( $hit_count == 1 ) { my $hsps_left = 1; @@ -305,7 +305,7 @@ SKIP: { is($hsp->start('hit'), $hsp->hit->start); is($hsp->end('query'), $hsp->query->end); is($hsp->strand('sbjct'), $hsp->subject->strand);# alias for hit - cmp_ok($hsp->evalue, '==', 0.000286309); + float_is($hsp->evalue, 0.000286309); is($hsp->score, 86); is($hsp->bits, 37.7354); is(sprintf("%.1f",$hsp->percent_identity), 20.9); @@ -338,7 +338,7 @@ SKIP: { is($result->get_statistic('kappa') , 0.0450367); cmp_ok($result->get_statistic('lambda'), '==', 0.267); cmp_ok($result->get_statistic('entropy'), '==', 0.14); - is($result->get_statistic('effectivespace'), '1.88702e+08'); + float_is($result->get_statistic('effectivespace'), '1.88702e+08'); is($result->get_parameter('matrix'), 'BLOSUM62'); is($result->get_parameter('gapopen'), 11); is($result->get_parameter('gapext'), 1); @@ -372,7 +372,7 @@ SKIP: { is($hit->length, shift @$d); is($hit->accession, shift @$d); is($hit->ncbi_gi, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->bits, shift @$d ); if( $hit_count == 1 ) { my $hsps_left = 1; @@ -385,7 +385,7 @@ SKIP: { is($hsp->start('hit'), $hsp->hit->start); is($hsp->end('query'), $hsp->query->end); is($hsp->strand('sbjct'), $hsp->subject->strand);# alias for hit - cmp_ok($hsp->evalue, '==', 0.0242028); + float_is($hsp->evalue, 0.0242028); is($hsp->score, 73); is($hsp->bits, 32.7278); is(sprintf("%.1f",$hsp->percent_identity), '24.0'); diff --git a/t/SearchIO/erpin.t b/t/SearchIO/erpin.t index db0e22aec..111a77909 100644 --- a/t/SearchIO/erpin.t +++ b/t/SearchIO/erpin.t @@ -56,12 +56,12 @@ is($hit->query_length, undef, "Hit query_length"); is($hit->rank, 1, "Hit rank"); is($hit->raw_score, 31.64, "Hit raw_score"); is($hit->score, 31.64, "Hit score"); -is($hit->significance, '4.44e-06', "Hit significance"); +float_is($hit->significance, 4.44e-06); $hsp = $hit->next_hsp; isa_ok($hsp, 'Bio::Search::HSP::HSPI'); is($hsp->algorithm, 'ERPIN', "HSP algorithm"); -is($hsp->evalue, '1.68e-05', "HSP evalue"); +float_is($hsp->evalue, 1.68e-05); isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity'); isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity'); is($hsp->frame('query'), 0, "HSP frame"); @@ -83,8 +83,8 @@ is($hsp->query_string, "HSP query_string"); is($hsp->range, 37, "HSP range"); is($hsp->rank, 1, "HSP rank"); -is($hsp->significance, '1.68e-05', "HSP significance"); -is($hsp->expect, '1.68e-05', "HSP expect"); +float_is($hsp->significance, 1.68e-05); +float_is($hsp->expect, '1.68e-05', "HSP expect"); isa_ok($hsp->seq, 'Bio::LocatableSeq'); is($hsp->seq_str, '', @@ -105,7 +105,7 @@ like($@, qr'Missing query string, can\'t build alignment','ERPIN get_aln warning $hsp = $hit->next_hsp; isa_ok($hsp, 'Bio::Search::HSP::HSPI'); is($hsp->algorithm, 'ERPIN', "HSP algorithm"); -is($hsp->evalue, '5.61e-05', "HSP evalue"); +float_is($hsp->evalue, 5.61e-05); isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity'); isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity'); is($hsp->frame('query'), 0, "HSP frame"); @@ -127,9 +127,9 @@ is($hsp->links, undef, "HSP links"); isa_ok($hsp->query, 'Bio::SeqFeature::Similarity'); is($hsp->range, 37, "HSP range"); is($hsp->rank, 2, "HSP rank"); -is($hsp->significance, '5.61e-05', "HSP significance"); +float_is($hsp->significance, 5.61e-05); is($hsp->end, 37, "HSP end"); -is($hsp->expect, '5.61e-05', "HSP expect"); +float_is($hsp->expect, '5.61e-05', "HSP expect"); isa_ok($hsp->seq, 'Bio::LocatableSeq'); is($hsp->seq_str, '', "HSP seq_str"); is($hsp->start, 1, "HSP start"); diff --git a/t/SearchIO/fasta.t b/t/SearchIO/fasta.t index 513112c69..72f55c826 100644 --- a/t/SearchIO/fasta.t +++ b/t/SearchIO/fasta.t @@ -44,7 +44,7 @@ while( my $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is($hit->significance, shift @$d ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); is($hit->rank, $count + 1); if( $count == 0 ) { @@ -57,7 +57,7 @@ while( my $hit = $result->next_hit ) { is($hsp->hit->start, 64902); is($hsp->hit->strand, 1); is($hsp->length('total'), 267); - is($hsp->evalue , 0.017); + float_is($hsp->evalue, 0.017); is($hsp->score, 134.5); is($hsp->bits,44.2); is(sprintf("%.2f",$hsp->percent_identity), '57.30'); @@ -128,7 +128,7 @@ while( my $hit = $result->next_hit ) { is($hit->length, shift @$d); is($hit->accession, shift @$d); is($hit->ncbi_gi, shift @$d); - is($hit->significance, shift @$d ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); if( $count == 0 ) { @@ -141,7 +141,7 @@ while( my $hit = $result->next_hit ) { is($hsp->hit->end, 181); is($hsp->hit->strand, 0); is($hsp->length('total'), 188); - is($hsp->evalue , 1.2); + float_is($hsp->evalue, 1.2); is($hsp->score, 109.2); is($hsp->bits,29.2); is(sprintf("%.2f",$hsp->percent_identity), 23.94); @@ -215,7 +215,7 @@ while( my $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); if( $count == 0 ) { @@ -228,7 +228,7 @@ while( my $hit = $result->next_hit ) { is($hsp->hit->end, 341); is($hsp->hit->strand, 0); is($hsp->length('total'), 345); - is(sprintf("%g",$hsp->evalue), sprintf("%g",'3.1e-59') ); + float_is($hsp->evalue, 3.1e-59); is($hsp->score, 1170.6); is($hsp->bits,227.8); is(sprintf("%.2f",$hsp->percent_identity), 53.04); @@ -294,7 +294,7 @@ while( my $hit = $result->next_hit ) { is($hit->name, shift @$d); is($hit->length, shift @$d); is($hit->accession, shift @$d); - is(sprintf("%g",$hit->significance), sprintf("%g",shift @$d) ); + float_is($hit->significance, shift @$d); is($hit->raw_score, shift @$d ); if ( $count == 1 ) { @@ -308,7 +308,7 @@ while( my $hit = $result->next_hit ) { is($hsp->hit->strand, 0); is($hsp->length('total'), 330); - is(sprintf("%g",$hsp->evalue), sprintf("%g",'1.3e-25')); + float_is($hsp->evalue, 1.3e-25); is($hsp->score, 563.4); is($hsp->bits,'117.1'); is(sprintf("%.2f",$hsp->percent_identity), 54.24); diff --git a/t/SearchIO/hmmer.t b/t/SearchIO/hmmer.t index 8c18eb4d4..8dc6c305e 100644 --- a/t/SearchIO/hmmer.t +++ b/t/SearchIO/hmmer.t @@ -28,7 +28,7 @@ while( my $result = $searchio->next_result ) { if( $hit = $result->next_model ) { is($hit->name, 'SEED'); is($hit->raw_score, '146.1'); - is($hit->significance, '6.3e-40'); + float_is($hit->significance, 6.3e-40); is(ref($hit), 'Bio::Search::Hit::HMMERHit'); is($hit->num_hsps, 1); @@ -38,7 +38,7 @@ while( my $result = $searchio->next_result ) { is($hsp->query->start, 33); is($hsp->query->end, 103); is($hsp->score, 71.2); - is($hsp->evalue, '2.2e-17'); + float_is($hsp->evalue, 2.2e-17); is($hsp->query_string, 'LFIGGLDYRTTDENLKAHFEKWGNIVDVVVMKD-----PRTKRSRGFGFITYSHSSMIDEAQK--SRpHKIDGRVVEP'); is($hsp->gaps('query'), 7); is($hsp->hit_string, 'lfVgNLppdvteedLkdlFskfGpivsikivrDiiekpketgkskGfaFVeFeseedAekAlealnG-kelggrklrv'); @@ -54,7 +54,7 @@ while( my $result = $searchio->next_result ) { is($hsp->query->start, 124); is($hsp->query->end, 194); is($hsp->score, 75.5); - is($hsp->evalue, '1.1e-18'); + float_is($hsp->evalue, 1.1e-18); is($hsp->query_string, 'LFVGALKDDHDEQSIRDYFQHFGNIVDINIVID-----KETGKKRGFAFVEFDDYDPVDKVVL-QKQHQLNGKMVDV'); is($hsp->gaps('query'), 6); is($hsp->hit_string, 'lfVgNLppdvteedLkdlFskfGpivsikivrDiiekpketgkskGfaFVeFeseedAekAlealnGkelggrklrv'); @@ -80,11 +80,11 @@ while( my $result = $searchio->next_result ) { my $hit = $result->next_model; is($hit->name, 'Q91581'); is($hit->description,'Q91581 POLYADENYLATION FACTOR 64 KDA SUBUN'); - is($hit->significance, '2e-31'); + float_is($hit->significance, 2e-31); is($hit->raw_score, 119.7); my $hsp = $hit->next_domain; is($hsp->score,119.7); - is($hsp->evalue, '2e-31'); + float_is($hsp->evalue, 2e-31); is($hsp->query->start, 18); is($hsp->query->end, 89); is($hsp->hit->start, 1); @@ -108,11 +108,11 @@ while( my $result = $searchio->next_result ) { my $hit = $result->next_hit; is($hit->name, 'Methylase_M'); is($hit->description,'Type I restriction modification system, M'); - is($hit->significance, '0.0022'); + float_is($hit->significance, 0.0022); is($hit->raw_score, -105.2); my $hsp = $hit->next_hsp; is($hsp->score,-105.2); - is($hsp->evalue, '0.0022'); + float_is($hsp->evalue, 0.0022); is($hsp->query->start, 280); is($hsp->query->end, 481); is($hsp->hit->start, 1); @@ -147,11 +147,11 @@ while( my $result = $searchio->next_result ) { my $hit = $result->next_hit; is($hit->name, 'CATL_RAT'); is($hit->description,''); - is($hit->significance, '2e-135'); + float_is($hit->significance, 2e-135); is($hit->raw_score, 449.4); my $hsp = $hit->next_hsp; is($hsp->score,449.4); - is($hsp->evalue, '2e-135'); + float_is($hsp->evalue, 2e-135); is($hsp->query->start, 1); is($hsp->query->end, 337); is($hsp->hit->start, 114); @@ -164,7 +164,7 @@ while( my $result = $searchio->next_result ) { $hit = $result->next_hit; is($hit->name, 'CATL_HUMAN'); is($hit->description,''); - is($hit->significance, '6.1e-134'); + float_is($hit->significance, 6.1e-134); is($hit->raw_score, 444.5); } diff --git a/t/SearchIO/hmmer_pull.t b/t/SearchIO/hmmer_pull.t index 480115b88..00b9f7d4d 100644 --- a/t/SearchIO/hmmer_pull.t +++ b/t/SearchIO/hmmer_pull.t @@ -62,8 +62,8 @@ while (my $result = $searchio->next_result) { is $hit->name, shift @{$hit_data[0]}; is $hit->raw_score, shift @{$hit_data[1]}; is $hit->score, $hit->raw_score; - is $hit->significance, shift @{$hit_data[2]}; - is $hit->p, $hit->significance; + float_is $hit->significance, shift @{$hit_data[2]}; + float_is $hit->p, $hit->significance; is $hit->num_hsps, shift @{$hit_data[3]}; is $hit->n, $hit->num_hsps; is $hit->algorithm, $result->algorithm; @@ -97,9 +97,9 @@ while (my $result = $searchio->next_result) { if ($hit->name eq 'SEED') { my $best = $hit->hsp('best'); - is $best->evalue, 1.1e-18; + float_is($best->evalue, 1.1e-18); my $worst = $hit->hsp('worst'); - is $worst->evalue, 2.2e-17; + float_is($worst->evalue, 2.2e-17); is $hit->start('query'), 33; is $hit->start('hit'), 1; is $hit->end('query'), 194; @@ -154,9 +154,9 @@ while (my $result = $searchio->next_result) { is $hsp->strand('query'), 1; is $hsp->score, shift @{$hsp_data[4]}; ok ! $hsp->bits; - is $hsp->evalue, shift @{$hsp_data[5]}; + float_is($hsp->evalue, shift @{$hsp_data[5]}); ok ! $hsp->pvalue; - is $hsp->significance, $hsp->evalue; + float_is($hsp->significance, $hsp->evalue); is $hsp->algorithm, $result->algorithm; is $hsp->rank, shift @{$hsp_data[12]}; my @range = $hsp->range; diff --git a/t/SearchIO/infernal.t b/t/SearchIO/infernal.t index 3c2a50714..cefd921ec 100644 --- a/t/SearchIO/infernal.t +++ b/t/SearchIO/infernal.t @@ -114,12 +114,12 @@ is($hit->query_length, 102, "Hit query_length"); is($hit->rank, 1, "Hit rank"); is($hit->raw_score, 81.29, "Hit raw_score"); is($hit->score, 81.29, "Hit score"); -is($hit->significance, undef, "Hit significance"); +float_is($hit->significance, undef); $hsp = $hit->next_hsp; isa_ok($hsp, 'Bio::Search::HSP::HSPI'); is($hsp->algorithm, 'CMSEARCH', "HSP algorithm"); -is($hsp->evalue, undef, "HSP evalue"); +float_is($hsp->evalue, undef); isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity'); isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity'); ($meta) = $hsp->feature1->get_tag_values('meta'); @@ -143,16 +143,16 @@ is($hsp->hsp_length, 103, "HSP hsp_length"); is($hsp->length, 103, "HSP length"); is($hsp->links, undef, "HSP links"); is($hsp->n, '', "HSP n"); -is($hsp->pvalue, undef, "HSP pvalue"); +float_is($hsp->pvalue, undef, "HSP pvalue"); isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query"); is($hsp->query_string, 'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcG.aGuaAauauuaaauauuu', "HSP query_string"); is($hsp->range, 102, "HSP range"); is($hsp->rank, 1, "HSP rank"); -is($hsp->significance, undef, "HSP significance"); +float_is($hsp->significance, undef); is($hsp->end, 102, "HSP end"); -is($hsp->expect, undef, "HSP expect"); +float_is($hsp->expect, undef, "HSP expect"); $hsp->verbose(2); # These Bio::Search::HSP::HSPI methods are currently unimplemented in # Bio::Search::HSP::ModelHSP; they may be integrated over time but will require @@ -191,7 +191,7 @@ is($hsp->strand('hit'), 1, "HSP strand"); $hsp = $hit->next_hsp; isa_ok($hsp, 'Bio::Search::HSP::HSPI'); is($hsp->algorithm, 'CMSEARCH', "HSP algorithm"); -is($hsp->evalue, undef, "HSP evalue"); +float_is($hsp->evalue, undef); isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity'); isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity'); is($hsp->frame('query'), 0, "HSP frame"); @@ -210,16 +210,16 @@ is($hsp->hsp_length, 103, "HSP hsp_length"); is($hsp->length, 103, "HSP length"); is($hsp->links, undef, "HSP links"); is($hsp->n, '', "HSP n"); -is($hsp->pvalue, undef, "HSP pvalue"); +float_is($hsp->pvalue, undef, "HSP pvalue"); isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query"); is($hsp->query_string, 'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu', "HSP query_string"); is($hsp->range, 102, "HSP range"); is($hsp->rank, 2, "HSP rank"); -is($hsp->significance, undef, "HSP significance"); +float_is($hsp->significance, undef); is($hsp->end, 102, "HSP end"); -is($hsp->expect, undef, "HSP expect"); +float_is($hsp->expect, undef, "HSP expect"); #is($hsp->matches, 2, "HSP matches"); isa_ok($hsp->seq, 'Bio::LocatableSeq'); # this should probably default to the hit string @@ -252,14 +252,14 @@ is($hit->query_length, 102, "Hit query_length"); is($hit->rank, 2, "Hit rank"); is($hit->raw_score, 79.36, "Hit raw_score"); is($hit->score, 79.36, "Hit score"); -is($hit->significance, undef, "Hit significance"); +float_is($hit->significance, undef); # one more HSP... $hsp = $hit->next_hsp; isa_ok($hsp, 'Bio::Search::HSP::HSPI'); is($hsp->algorithm, 'CMSEARCH', "HSP algorithm"); -is($hsp->evalue, undef, "HSP evalue"); +float_is($hsp->evalue, undef); isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity'); isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity'); is($hsp->frame('query'), 0, "HSP frame"); @@ -283,9 +283,9 @@ is($hsp->query_string, "HSP query_string"); is($hsp->range, 102, "HSP range"); is($hsp->rank, 1, "HSP rank"); -is($hsp->significance, undef, "HSP significance"); +float_is($hsp->significance, undef); is($hsp->end, 102, "HSP end"); -is($hsp->expect, undef, "HSP expect"); +float_is($hsp->expect, undef, "HSP expect"); isa_ok($hsp->seq, 'Bio::LocatableSeq'); is($hsp->seq_str, 'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu', @@ -393,12 +393,12 @@ is($hit->query_length, 102, "Hit query_length"); is($hit->rank, 1, "Hit rank"); is($hit->raw_score, 79.36, "Hit raw_score"); is($hit->score, 79.36, "Hit score"); -is($hit->significance, 1.945e-07, "Hit significance"); +float_is($hit->significance, 1.945e-07); $hsp = $hit->next_hsp; isa_ok($hsp, 'Bio::Search::HSP::HSPI'); is($hsp->algorithm, 'CMSEARCH', "HSP algorithm"); -is($hsp->evalue, 1.945e-07, "HSP evalue"); +float_is($hsp->evalue, 1.945e-07); isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity'); isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity'); ($meta) = $hsp->feature1->get_tag_values('meta'); @@ -422,16 +422,16 @@ is($hsp->hsp_length,102, "HSP hsp_length"); is($hsp->length, 102, "HSP length"); is($hsp->links, undef, "HSP links"); is($hsp->n, '', "HSP n"); -is($hsp->pvalue, 1.945e-07, "HSP pvalue"); +float_is($hsp->pvalue, 1.945e-07, "HSP pvalue"); isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query"); is($hsp->query_string, 'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu', "HSP query_string"); is($hsp->range, 102, "HSP range"); is($hsp->rank, 1, "HSP rank"); -is($hsp->significance, 1.945e-07, "HSP significance"); +float_is($hsp->significance, 1.945e-07); is($hsp->end, 102, "HSP end"); -is($hsp->expect, 1.945e-07, "HSP expect"); +float_is($hsp->expect, 1.945e-07, "HSP expect"); isa_ok($hsp->seq, 'Bio::LocatableSeq'); is($hsp->seq_str, @@ -447,7 +447,7 @@ is($hsp->strand('hit'), 1, "HSP strand"); $hsp = $hit->next_hsp; isa_ok($hsp, 'Bio::Search::HSP::HSPI'); is($hsp->algorithm, 'CMSEARCH', "HSP algorithm"); -is($hsp->evalue, 6.802, "HSP evalue"); +float_is($hsp->evalue, 6.802); isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity'); isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity'); is($hsp->frame('query'), 0, "HSP frame"); @@ -466,16 +466,16 @@ is($hsp->hsp_length, 102, "HSP hsp_length"); is($hsp->length, 102, "HSP length"); is($hsp->links, undef, "HSP links"); is($hsp->n, '', "HSP n"); -is($hsp->pvalue, 0.9989, "HSP pvalue"); +float_is($hsp->pvalue, 0.9989, "HSP pvalue"); isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query"); is($hsp->query_string, 'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGAC.UAcGaGuaAauauuaaauauuu', "HSP query_string"); is($hsp->range, 102, "HSP range"); is($hsp->rank, 2, "HSP rank"); -is($hsp->significance, 6.802, "HSP significance"); +float_is($hsp->significance, 6.802); is($hsp->end, 102, "HSP end"); -is($hsp->expect, 6.802, "HSP expect"); +float_is($hsp->expect, 6.802, "HSP expect"); #is($hsp->matches, 2, "HSP matches"); isa_ok($hsp->seq, 'Bio::LocatableSeq'); # this should probably default to the hit string @@ -508,14 +508,14 @@ is($hit->query_length, 102, "Hit query_length"); is($hit->rank, 2, "Hit rank"); is($hit->raw_score, 81.29, "Hit raw_score"); is($hit->score, 81.29, "Hit score"); -is($hit->significance, 1.259e-07, "Hit significance"); +float_is($hit->significance, 1.259e-07); # one more HSP... $hsp = $hit->next_hsp; isa_ok($hsp, 'Bio::Search::HSP::HSPI'); is($hsp->algorithm, 'CMSEARCH', "HSP algorithm"); -is($hsp->evalue, 1.259e-07, "HSP evalue"); +float_is($hsp->evalue, 1.259e-07); isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity'); isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity'); is($hsp->frame('query'), 0, "HSP frame"); @@ -539,9 +539,9 @@ is($hsp->query_string, "HSP query_string"); is($hsp->range, 102, "HSP range"); is($hsp->rank, 1, "HSP rank"); -is($hsp->significance, 1.259e-07, "HSP significance"); +float_is($hsp->significance, 1.259e-07); is($hsp->end, 102, "HSP end"); -is($hsp->expect, 1.259e-07, "HSP expect"); +float_is($hsp->expect, 1.259e-07, "HSP expect"); isa_ok($hsp->seq, 'Bio::LocatableSeq'); is($hsp->seq_str, 'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu', diff --git a/t/SearchIO/rnamotif.t b/t/SearchIO/rnamotif.t index 422fb3050..25662cad0 100644 --- a/t/SearchIO/rnamotif.t +++ b/t/SearchIO/rnamotif.t @@ -58,12 +58,12 @@ is($hit->overlap, 0, "Hit overlap"); is($hit->rank, 1, "Hit rank"); is($hit->raw_score, 0, "Hit raw_score"); is($hit->score, 0, "Hit score"); -is($hit->significance, undef, "Hit significance"); +float_is($hit->significance, undef); $hsp = $hit->next_hsp; isa_ok($hsp, 'Bio::Search::HSP::HSPI'); is($hsp->algorithm, 'RNAMOTIF', "HSP algorithm"); -is($hsp->evalue, undef, "HSP evalue"); +float_is($hsp->evalue, undef); isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity'); isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity'); is($hsp->frame('query'), 0, "HSP frame"); @@ -90,9 +90,9 @@ is($hsp->query_string, "HSP query_string"); is($hsp->range, 75, "HSP range"); is($hsp->rank, 1, "HSP rank"); -is($hsp->significance, undef, "HSP significance"); +float_is($hsp->significance, undef); is($hsp->end, 75, "HSP end"); -is($hsp->expect, undef, "HSP expect"); +float_is($hsp->expect, undef, "HSP expect"); isa_ok($hsp->seq, 'Bio::LocatableSeq'); is($hsp->seq_str, '', diff --git a/t/SeqIO/asciitree.t b/t/SeqIO/asciitree.t index eb2ba18fb..379130162 100644 --- a/t/SeqIO/asciitree.t +++ b/t/SeqIO/asciitree.t @@ -23,8 +23,8 @@ my $in = Bio::SeqIO->new(-format => 'genbank', my $seq = $in->next_seq; my $out_file = test_output_file(); -my $out = Bio::SeqIO->new(-file => ">$out_file", - -verbose => $verbose, - -format => 'asciitree'); +my $out = Bio::SeqIO->new(-file => ">".$out_file, + -verbose => $verbose, + -format => 'asciitree'); $out->write_seq($seq); ok (-s $out_file); diff --git a/t/SeqIO/phd.t b/t/SeqIO/phd.t index b61962c7a..8d767a593 100644 --- a/t/SeqIO/phd.t +++ b/t/SeqIO/phd.t @@ -7,7 +7,7 @@ BEGIN { use lib '.'; use Bio::Root::Test; - test_begin(-tests => 18); + test_begin(-tests => 17); use_ok('Bio::SeqIO::phd'); } @@ -92,8 +92,15 @@ is($phd->chromat_file(),'ML4924R','$phd->chromat_file()'); $phd->chromat_file('ML4924R.esd'); is($phd->chromat_file(), 'ML4924R.esd','$phd->chromat_file()'); $phd->touch(); -my $localtime = localtime(); -is($phd->time, "$localtime"); + +# Commented out 1/17/09. +# This isn't exactly a stable regression test as the comparison tests +# localtime() called from two different timepoints. They can differ if the calls +# occurred before and after a change in seconds, for example. + +#my $localtime = localtime(); +#is($phd->time, "$localtime", $phd->time.':'.$localtime); + if ($DEBUG){ print "Testing the sequence ...\n"; print ">",$phd->id," ",$phd->desc,"\n",$phd->seq,"\n"; diff --git a/t/Tools/Match.t b/t/Tools/Match.t index 158cc2401..7e94c94de 100644 --- a/t/Tools/Match.t +++ b/t/Tools/Match.t @@ -7,7 +7,8 @@ BEGIN { use lib '.'; use Bio::Root::Test; - test_begin(-tests => 38); + test_begin(-tests => 38, + -requires_module => 'URI::Escape'); use_ok('Bio::Tools::Match'); } diff --git a/t/Tools/Phylo/Gerp.t b/t/Tools/Phylo/Gerp.t index 7a022401d..453056654 100644 --- a/t/Tools/Phylo/Gerp.t +++ b/t/Tools/Phylo/Gerp.t @@ -7,7 +7,8 @@ BEGIN { use lib '.'; use Bio::Root::Test; - test_begin(-tests => 33); + test_begin(-tests => 33, + -requires_module => 'URI::Escape'); use_ok('Bio::Tools::Phylo::Gerp'); } diff --git a/t/Tree/TreeIO/phyloxml.t b/t/Tree/TreeIO/phyloxml.t dissimilarity index 98% index a868ee0d2..8dfa52cfc 100644 --- a/t/Tree/TreeIO/phyloxml.t +++ b/t/Tree/TreeIO/phyloxml.t @@ -1,700 +1,701 @@ -# -*-Perl-*- Test Harness script for Bioperl - -use strict; -use warnings; - -BEGIN { - use lib '.'; - use Bio::Root::Test; - - test_begin(-tests => 97, - -requires_modules => [qw(XML::LibXML XML::LibXML::Reader)], - ); - if (1000*$] < 5008) { - plan skip_all => "Reader interface only supported in Perl >= 5.8"; - exit; - } elsif (XML::LibXML::LIBXML_VERSION() <= 20620) { - plan skip_all => "Reader not supported for libxml2 <= 2.6.20"; - exit; - } - use_ok('Bio::TreeIO'); - use_ok('Bio::TreeIO::phyloxml'); -} - -my $verbose = test_debug(); - -if ($verbose) { - diag("libxml version: ", XML::LibXML::LIBXML_VERSION()); -} - -ok my $treeio = Bio::TreeIO->new( - -verbose => $verbose, - -format => 'phyloxml', - -file => test_input_file('phyloxml_examples.xml')); - -# tree1: clade and attribute -# -{ - if ($verbose > 0) { - diag("\ntree1: clade and attribute"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - is($tree->id, 'example from Prof. Joe Felsenstein\'s book "Inferring Phylogenies"'); - is($tree->get_tag_values('description'), 'phyloXML allows to use either a "branch_length" attribute or element to indicate branch lengths.'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - diag("tree description: ", $tree->get_tag_values('description')); - } - is($tree->get_tag_values('rooted'), 'true'); - my @nodes = $tree->get_nodes; - is(@nodes, 5); - my ($A) = $tree->find_node('A'); - ok($A); - is($A->branch_length, '0.102'); - if ($verbose > 0) { - diag("node A: branch_length ", $A->branch_length); - } - is($A->ancestor->id, ''); - is($A->ancestor->branch_length, '0.06'); - my $leaves_string = $tree->simplify_to_leaves_string(); - if ($verbose > 0) { - diag($leaves_string); - } - is($leaves_string, '((A,B),C)'); - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree2: branch_length -# -{ - if ($verbose > 0) { - diag("\ntree2: branch_length"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my @nodes = $tree->get_nodes; - is(@nodes, 5); - my $A = $tree->find_node('A'); - ok($A); - is($A->branch_length, '0.102'); - if ($verbose > 0) { - diag("node A: branch_length ", $A->branch_length); - } - is($A->ancestor->id, ''); - is($A->ancestor->branch_length, '0.06'); - my $leaves_string = $tree->simplify_to_leaves_string(); - if ($verbose > 0) { - diag($leaves_string); - } - is($leaves_string, '((A,B),C)'); - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree3: confidence (bootstrap) -# -{ - if ($verbose > 0) { - diag("\ntree3: confidence (bootstrap)"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my $AB = $tree->find_node('AB'); - ok($AB); - is($AB->bootstrap, '89'); - if ($verbose > 0) { - diag("node AB: bootstrap ", $AB->bootstrap); - } - my $leaves_string = $tree->simplify_to_leaves_string(); - if ($verbose > 0) { - diag($leaves_string); - } - is($leaves_string, '((A,B),C)'); - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree4: species and sequence -# -{ - if ($verbose > 0) { - diag("\ntree4: taxonomy and sequence"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my $C = $tree->find_node('C'); - my ($ac) = $C->annotation->get_Annotations('taxonomy'); - isa_ok( $ac, 'Bio::Annotation::Collection'); - my ($ac2) = $ac->get_Annotations('scientific_name'); - isa_ok( $ac2, 'Bio::Annotation::Collection'); - my ($scientificname) = $ac2->get_Annotations('_text'); - is($scientificname->value, 'C. elegans'); - if ($verbose > 0) { - diag( "Node C Scientific Name: ",$scientificname->value); - } - my ($ac3) = $C->annotation->get_nested_Annotations(-keys=>['scientific_name'], -recursive=>1); - isa_ok( $ac3, 'Bio::Annotation::Collection'); - ($scientificname) = $ac2->get_Annotations('_text'); - is($scientificname->value, 'C. elegans'); - if ($verbose > 0) { - diag( "Node C Scientific Name: ",$scientificname->value); - } - my ($seq) = @{$C->sequence}; - isa_ok( $seq, 'Bio::SeqI'); - my ($seqac) = $seq->annotation; - isa_ok( $seqac, 'Bio::Annotation::Collection'); - my ($descac) = $seqac->get_nested_Annotations(-keys=>['desc'], -recursive=>1); - my ($desc) = $descac->get_Annotations('_text'); - is($desc->value, 'alcohol dehydrogenase'); - if ($verbose > 0) { - diag( "Node C Sequence description: ",$desc->value); - } - ($descac) = $seqac->get_nested_Annotations(-keys=>['desc'], -recursive=>1); - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree5: homolog relationship and sequence relationship -# -# -{ - if ($verbose > 0) { - diag("\ntree5: events and relations"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my $node = $tree->get_root_node; - my ($speciationsac) = $node->annotation->get_nested_Annotations(-keys=>['speciations'], -recursive=>1); - my ($speciationval) = $speciationsac->get_Annotations('_text'); - is($speciationval->value, '1'); - if ($verbose > 0) { - diag("root node speciation event: ", $speciationval->value); - } - my @children = ($node); - for (@children) { - push @children, $_->each_Descendent(); - } - my @leaves = (); - for (@children) { - push @leaves, $_ if $_->is_Leaf; - } - my ($z) = $leaves[0]; - my $z_seq = $z->sequence->[0]; - isa_ok ($z_seq, 'Bio::SeqI'); - my ($z_id) = $z_seq->annotation->get_nested_Annotations('-keys'=>['id_source'], '-recursive'=>1); - my ($z_id_text) = $z_id->value; - my @seq_rels = $z_seq->annotation->get_nested_Annotations('-keys'=>['sequence_relation'], '-recursive'=>1); - foreach my $rel (@seq_rels) { - isa_ok($rel, 'Bio::Annotation::Relation'); - is ($rel->tagname, 'sequence_relation'); - my $seqto = $rel->to; - isa_ok ($seqto, 'Bio::SeqI'); - my ($seqto_id) = $seqto->annotation->get_nested_Annotations('-keys'=>['id_source'], '-recursive'=>1); - my $seqto_text = $seqto_id->value; - if ($verbose > 0) { - diag( "node ", $z_id_text, " has ", $rel->type, " relation to ", $seqto_text); - } - } - my ($x) = $leaves[1]; - - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree6: detailed sequence data -# -{ - if ($verbose > 0) { - diag("\ntree6: detailed sequence annotation"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my @children = ($tree->get_root_node); - for (@children) { - push @children, $_->each_Descendent(); - } - my @leaves = (); - for (@children) { - push @leaves, $_ if $_->is_Leaf; - } - my ($z) = $leaves[0]; - my $z_seq = $z->sequence->[0]; - isa_ok ($z_seq, 'Bio::SeqI'); - my ($z_seqname) = $z_seq->annotation->get_nested_Annotations('-keys'=>['name'], '-recursive'=>1); - my ($z_seqname_text) = $z_seqname->get_Annotations('_text'); - is ($z_seqname_text->value, 'NADH-dependent butanol dehydrogenase B'); - my ($z_molseq) = $z_seq->seq; - is ($z_molseq, 'MVDFEYSIPTRIFFGKDKINVLGRELKKYGSKVLIVYGGGSIKRNGIYDK'); - if ($verbose > 0) { - diag("Sequence ", $z_seqname_text->value, " is ", $z_molseq); - } - my ($z_seqname_text2) = $treeio->read_annotation('-obj'=>$z_seq, '-path'=>'name'); - is ($z_seqname_text->value, $z_seqname_text2); - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree7: network -# @id_source & @id_ref -{ - if ($verbose > 0) { - diag("\ntree7: network using id_source/id_ref"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my @children = ($tree->get_root_node); - for (@children) { - push @children, $_->each_Descendent(); - } - my @leaves = (); - for (@children) { - push @leaves, $_ if $_->is_Leaf; - } - my ($c) = $leaves[0]; - my ($c_id) = $c->annotation->get_nested_Annotations('-keys'=>['id_source'], '-recursive'=>1); - my @clade_rels = $c->annotation->get_nested_Annotations('-keys'=>['clade_relation'], '-recursive'=>1); - foreach my $rel (@clade_rels) { - isa_ok($rel, 'Bio::Annotation::Relation'); - is ($rel->tagname, 'clade_relation'); - my $nodeto = $rel->to; - isa_ok ($nodeto, 'Bio::Tree::AnnotatableNode'); - my ($nodeto_id) = $nodeto->annotation->get_nested_Annotations('-keys'=>['id_source'], '-recursive'=>1); - is ($nodeto_id->value, 'b'); - my ($nodeto_id2) = $treeio->read_annotation('-obj'=>$nodeto, '-path'=>'id_source', '-attr'=>1); - is ($nodeto_id->value, $nodeto_id2); - if ($verbose > 0) { - diag( "node ", $c_id->value, " has ", $rel->type, " relation to ", $nodeto_id->value); - } - } - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree8: property elements -# -{ - if ($verbose > 0) { - diag("\ntree8: property"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my ($A) = $tree->find_node('A'); - isa_ok($A, 'Bio::Tree::AnnotatableNode'); - my ($ac) = $A->annotation(); - isa_ok($ac, 'Bio::AnnotationCollectionI'); - my (@annotations) = $ac->get_Annotations('property'); - isa_ok( $annotations[0], 'Bio::Annotation::Collection'); - diag("property:",$annotations[0]) if $verbose; - my (@keys) = $annotations[0]->get_all_annotation_keys(); - diag("keys:",@keys) if $verbose; - my (@value) = $annotations[0]->get_Annotations('_text'); - is($value[0]->value, ' 1200 '); - if ($verbose > 0) { - diag( "Annotation NOAA:depth ",$value[0]->value); - } - my $leaves_string = $tree->simplify_to_leaves_string(); - if ($verbose > 0) { - diag($leaves_string); - } - is($leaves_string, '((A,B),C)'); - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree9: property outside tree topology using id refs -# @id_source @id_ref -{ - if ($verbose > 0) { - diag("\ntree9: property using id_source/id_ref"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my $A = $tree->find_node('A'); - isa_ok($A, 'Bio::Tree::AnnotatableNode'); - my $ac = $A->annotation(); - isa_ok($ac, 'Bio::AnnotationCollectionI'); - my @annotations = $ac->get_Annotations('property'); - isa_ok( $annotations[0], 'Bio::Annotation::Collection'); - my @value = $annotations[0]->get_Annotations('_text'); - is($value[0]->value, ' 1200 '); - if ($verbose > 0) { - diag( "Annotation NOAA:depth ",$value[0]->value); - } - my $leaves_string = $tree->simplify_to_leaves_string(); - if ($verbose > 0) { - diag($leaves_string); - } - is($leaves_string, '((A,B),C)'); - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree10: detailed taxonomy and distribution -# -{ - if ($verbose > 0) { - diag("\ntree10: taxonomy and distribution"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my $node = $tree->get_root_node; - my @leaves; - my @children = ($node); - for (@children) { - push @children, $_->each_Descendent(); - } - for (@children) { - push @leaves, $_ if $_->is_Leaf; - } - my ($A) = $leaves[0]; - my ($scientificname) = $A->annotation->get_nested_Annotations('-keys'=>['scientific_name'], '-recursive'=>1); - my ($scientificname_text) = $scientificname->get_Annotations('_text'); - my ($commonname) = $A->annotation->get_nested_Annotations('-keys'=>['common_name'], '-recursive'=>1); - my ($commonname_text) = $commonname->get_Annotations('_text'); - my ($rank) = $A->annotation->get_nested_Annotations('-keys'=>['rank'], '-recursive'=>1); - my ($rank_text) = $rank->get_Annotations('_text'); - if ($verbose > 0) { - diag("node rank is ", $rank_text->value); - diag("node scientific name is ", $scientificname_text->value); - diag("node common name is ", $commonname_text->value); - } - my ($distribution) = $A->annotation->get_nested_Annotations('-keys'=>['distribution'], '-recursive'=>1); - my ($desc) = $distribution->get_Annotations('desc'); - my ($desc_text) = $desc->get_Annotations('_text'); - if ($verbose > 0) { - diag("node distribution is ", $desc_text->value); - } - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree11: phylogeographic information -# -{ - if ($verbose > 0) { - diag("\ntree11: phylogenographic information"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my $node = $tree->get_root_node; - my @leaves; - my @children = ($node); - for (@children) { - push @children, $_->each_Descendent(); - } - for (@children) { - push @leaves, $_ if $_->is_Leaf; - } - my ($D) = $leaves[0]; - my ($point) = $treeio->read_annotation('-obj'=>$D, '-path'=>'distribution/point/geodetic_datum', '-attr'=>1); - is ($point, 'WGS84'); - my ($lat) = $treeio->read_annotation('-obj'=>$D, '-path'=>'distribution/point/lat'); - my ($long) = $treeio->read_annotation('-obj'=>$D, '-path'=>'distribution/point/long'); - my ($alt) = $treeio->read_annotation('-obj'=>$D, '-path'=>'distribution/point/alt'); - is ($lat, '32.880933'); - is ($long, '-117.217543'); - is ($alt, '104'); - if ($verbose > 0) { - diag("node distribution lat: $lat long $long alt $alt"); - } - - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree12: date information -# -{ - if ($verbose > 0) { - diag("\ntree12: date"); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my $node = $tree->get_root_node; - my @leaves; - my @children = ($node); - for (@children) { - push @children, $_->each_Descendent(); - } - for (@children) { - push @leaves, $_ if $_->is_Leaf; - } - my ($D) = $leaves[0]; - my ($dateunit) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/unit', '-attr'=>1); - my ($daterange) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/range', '-attr'=>1); - my ($datevalue) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/value'); - is ($dateunit, 'mya'); - is ($daterange, '30'); - is ($datevalue, '600'); - if ($verbose > 0) { - diag("node date unit: $dateunit range $daterange value $datevalue"); - } - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - -# tree13: alignment outside -# -{ - if ($verbose > 0) { - diag("\ntree13: alignment outside "); - } - my $tree = $treeio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - if ($verbose > 0) { - diag("tree id: ",$tree->id); - } - my $leaves_string = $tree->simplify_to_leaves_string(); - if ($verbose > 0) { - diag($leaves_string); - } - is($leaves_string, '((A,B),C)'); - -# add annotation in phyloxml - if ($verbose > 0) { - diag("test add annotation in phyloXML format"); - } - my $node = $tree->get_root_node; - my @leaves; - my @children = ($node); - for (@children) { - push @children, $_->each_Descendent(); - } - for (@children) { - push @leaves, $_ if $_->is_Leaf; - } - my ($D) = $leaves[0]; - isa_ok($D, 'Bio::Tree::AnnotatableNode'); - $treeio->add_phyloXML_annotation( - -obj => $D, - -xml => " D - - my date - veryveryold - -" - ); - my ($dateunit) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/unit', '-attr'=>1); - my ($daterange) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/range', '-attr'=>1); - my ($datevalue) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/value'); - is ($dateunit, 'mya'); - is ($daterange, '30'); - is ($datevalue, 'veryveryold'); - -# write_tree - if ($verbose > 0) { - diag("\ntest write_tree"); - } - my $FILE1 = test_output_file(); - my $treeio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $treeio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - - -# convert between nhx-phyloxml -{ - if ($verbose > 0) { - diag("\n test translation between nhx and phyloxml"); - } - ok my $nhxio = Bio::TreeIO->new( - -verbose => $verbose, - -format => 'nhx', - -file => test_input_file('test.nhx')); - my $tree = $nhxio->next_tree; - isa_ok($tree, 'Bio::Tree::TreeI'); - my $FILE1 = test_output_file(); - my $phyloxmlio = Bio::TreeIO->new(-verbose => $verbose, - -format => 'phyloxml', - -file => ">$FILE1"); - $phyloxmlio->write_tree($tree); - ok -s $FILE1; - if ($verbose > 0) { - diag(`cat $FILE1`); - } -} - +# -*-Perl-*- Test Harness script for Bioperl + +use strict; +use warnings; + +BEGIN { + use lib '.'; + use Bio::Root::Test; + + test_begin(-tests => 97, + -requires_modules => [qw(XML::LibXML XML::LibXML::Reader)]); + + use_ok('Bio::TreeIO'); +} + +my $verbose = test_debug(); + +SKIP: { + if (1000*$] < 5008) { + skip("Reader interface only supported in Perl >= 5.8",96); + } elsif (XML::LibXML::LIBXML_VERSION() <= 20620) { + skip("Reader not supported for libxml2 <= 2.6.20",96); + } + use_ok('Bio::TreeIO::phyloxml'); + + if ($verbose) { + diag("libxml version: ", XML::LibXML::LIBXML_VERSION()); + } + + ok my $treeio = Bio::TreeIO->new( + -verbose => $verbose, + -format => 'phyloxml', + -file => test_input_file('phyloxml_examples.xml')); + + # tree1: clade and attribute + # + { + if ($verbose > 0) { + diag("\ntree1: clade and attribute"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + is($tree->id, 'example from Prof. Joe Felsenstein\'s book "Inferring Phylogenies"'); + is($tree->get_tag_values('description'), 'phyloXML allows to use either a "branch_length" attribute or element to indicate branch lengths.'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + diag("tree description: ", $tree->get_tag_values('description')); + } + is($tree->get_tag_values('rooted'), 'true'); + my @nodes = $tree->get_nodes; + is(@nodes, 5); + my ($A) = $tree->find_node('A'); + ok($A); + is($A->branch_length, '0.102'); + if ($verbose > 0) { + diag("node A: branch_length ", $A->branch_length); + } + is($A->ancestor->id, ''); + is($A->ancestor->branch_length, '0.06'); + my $leaves_string = $tree->simplify_to_leaves_string(); + if ($verbose > 0) { + diag($leaves_string); + } + is($leaves_string, '((A,B),C)'); + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree2: branch_length + # + { + if ($verbose > 0) { + diag("\ntree2: branch_length"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my @nodes = $tree->get_nodes; + is(@nodes, 5); + my $A = $tree->find_node('A'); + ok($A); + is($A->branch_length, '0.102'); + if ($verbose > 0) { + diag("node A: branch_length ", $A->branch_length); + } + is($A->ancestor->id, ''); + is($A->ancestor->branch_length, '0.06'); + my $leaves_string = $tree->simplify_to_leaves_string(); + if ($verbose > 0) { + diag($leaves_string); + } + is($leaves_string, '((A,B),C)'); + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree3: confidence (bootstrap) + # + { + if ($verbose > 0) { + diag("\ntree3: confidence (bootstrap)"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my $AB = $tree->find_node('AB'); + ok($AB); + is($AB->bootstrap, '89'); + if ($verbose > 0) { + diag("node AB: bootstrap ", $AB->bootstrap); + } + my $leaves_string = $tree->simplify_to_leaves_string(); + if ($verbose > 0) { + diag($leaves_string); + } + is($leaves_string, '((A,B),C)'); + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree4: species and sequence + # + { + if ($verbose > 0) { + diag("\ntree4: taxonomy and sequence"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my $C = $tree->find_node('C'); + my ($ac) = $C->annotation->get_Annotations('taxonomy'); + isa_ok( $ac, 'Bio::Annotation::Collection'); + my ($ac2) = $ac->get_Annotations('scientific_name'); + isa_ok( $ac2, 'Bio::Annotation::Collection'); + my ($scientificname) = $ac2->get_Annotations('_text'); + is($scientificname->value, 'C. elegans'); + if ($verbose > 0) { + diag( "Node C Scientific Name: ",$scientificname->value); + } + my ($ac3) = $C->annotation->get_nested_Annotations(-keys=>['scientific_name'], -recursive=>1); + isa_ok( $ac3, 'Bio::Annotation::Collection'); + ($scientificname) = $ac2->get_Annotations('_text'); + is($scientificname->value, 'C. elegans'); + if ($verbose > 0) { + diag( "Node C Scientific Name: ",$scientificname->value); + } + my ($seq) = @{$C->sequence}; + isa_ok( $seq, 'Bio::SeqI'); + my ($seqac) = $seq->annotation; + isa_ok( $seqac, 'Bio::Annotation::Collection'); + my ($descac) = $seqac->get_nested_Annotations(-keys=>['desc'], -recursive=>1); + my ($desc) = $descac->get_Annotations('_text'); + is($desc->value, 'alcohol dehydrogenase'); + if ($verbose > 0) { + diag( "Node C Sequence description: ",$desc->value); + } + ($descac) = $seqac->get_nested_Annotations(-keys=>['desc'], -recursive=>1); + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree5: homolog relationship and sequence relationship + # + # + { + if ($verbose > 0) { + diag("\ntree5: events and relations"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my $node = $tree->get_root_node; + my ($speciationsac) = $node->annotation->get_nested_Annotations(-keys=>['speciations'], -recursive=>1); + my ($speciationval) = $speciationsac->get_Annotations('_text'); + is($speciationval->value, '1'); + if ($verbose > 0) { + diag("root node speciation event: ", $speciationval->value); + } + my @children = ($node); + for (@children) { + push @children, $_->each_Descendent(); + } + my @leaves = (); + for (@children) { + push @leaves, $_ if $_->is_Leaf; + } + my ($z) = $leaves[0]; + my $z_seq = $z->sequence->[0]; + isa_ok ($z_seq, 'Bio::SeqI'); + my ($z_id) = $z_seq->annotation->get_nested_Annotations('-keys'=>['id_source'], '-recursive'=>1); + my ($z_id_text) = $z_id->value; + my @seq_rels = $z_seq->annotation->get_nested_Annotations('-keys'=>['sequence_relation'], '-recursive'=>1); + foreach my $rel (@seq_rels) { + isa_ok($rel, 'Bio::Annotation::Relation'); + is ($rel->tagname, 'sequence_relation'); + my $seqto = $rel->to; + isa_ok ($seqto, 'Bio::SeqI'); + my ($seqto_id) = $seqto->annotation->get_nested_Annotations('-keys'=>['id_source'], '-recursive'=>1); + my $seqto_text = $seqto_id->value; + if ($verbose > 0) { + diag( "node ", $z_id_text, " has ", $rel->type, " relation to ", $seqto_text); + } + } + my ($x) = $leaves[1]; + + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree6: detailed sequence data + # + { + if ($verbose > 0) { + diag("\ntree6: detailed sequence annotation"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my @children = ($tree->get_root_node); + for (@children) { + push @children, $_->each_Descendent(); + } + my @leaves = (); + for (@children) { + push @leaves, $_ if $_->is_Leaf; + } + my ($z) = $leaves[0]; + my $z_seq = $z->sequence->[0]; + isa_ok ($z_seq, 'Bio::SeqI'); + my ($z_seqname) = $z_seq->annotation->get_nested_Annotations('-keys'=>['name'], '-recursive'=>1); + my ($z_seqname_text) = $z_seqname->get_Annotations('_text'); + is ($z_seqname_text->value, 'NADH-dependent butanol dehydrogenase B'); + my ($z_molseq) = $z_seq->seq; + is ($z_molseq, 'MVDFEYSIPTRIFFGKDKINVLGRELKKYGSKVLIVYGGGSIKRNGIYDK'); + if ($verbose > 0) { + diag("Sequence ", $z_seqname_text->value, " is ", $z_molseq); + } + my ($z_seqname_text2) = $treeio->read_annotation('-obj'=>$z_seq, '-path'=>'name'); + is ($z_seqname_text->value, $z_seqname_text2); + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree7: network + # @id_source & @id_ref + { + if ($verbose > 0) { + diag("\ntree7: network using id_source/id_ref"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my @children = ($tree->get_root_node); + for (@children) { + push @children, $_->each_Descendent(); + } + my @leaves = (); + for (@children) { + push @leaves, $_ if $_->is_Leaf; + } + my ($c) = $leaves[0]; + my ($c_id) = $c->annotation->get_nested_Annotations('-keys'=>['id_source'], '-recursive'=>1); + my @clade_rels = $c->annotation->get_nested_Annotations('-keys'=>['clade_relation'], '-recursive'=>1); + foreach my $rel (@clade_rels) { + isa_ok($rel, 'Bio::Annotation::Relation'); + is ($rel->tagname, 'clade_relation'); + my $nodeto = $rel->to; + isa_ok ($nodeto, 'Bio::Tree::AnnotatableNode'); + my ($nodeto_id) = $nodeto->annotation->get_nested_Annotations('-keys'=>['id_source'], '-recursive'=>1); + is ($nodeto_id->value, 'b'); + my ($nodeto_id2) = $treeio->read_annotation('-obj'=>$nodeto, '-path'=>'id_source', '-attr'=>1); + is ($nodeto_id->value, $nodeto_id2); + if ($verbose > 0) { + diag( "node ", $c_id->value, " has ", $rel->type, " relation to ", $nodeto_id->value); + } + } + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree8: property elements + # + { + if ($verbose > 0) { + diag("\ntree8: property"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my ($A) = $tree->find_node('A'); + isa_ok($A, 'Bio::Tree::AnnotatableNode'); + my ($ac) = $A->annotation(); + isa_ok($ac, 'Bio::AnnotationCollectionI'); + my (@annotations) = $ac->get_Annotations('property'); + isa_ok( $annotations[0], 'Bio::Annotation::Collection'); + diag("property:",$annotations[0]) if $verbose; + my (@keys) = $annotations[0]->get_all_annotation_keys(); + diag("keys:",@keys) if $verbose; + my (@value) = $annotations[0]->get_Annotations('_text'); + is($value[0]->value, ' 1200 '); + if ($verbose > 0) { + diag( "Annotation NOAA:depth ",$value[0]->value); + } + my $leaves_string = $tree->simplify_to_leaves_string(); + if ($verbose > 0) { + diag($leaves_string); + } + is($leaves_string, '((A,B),C)'); + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree9: property outside tree topology using id refs + # @id_source @id_ref + { + if ($verbose > 0) { + diag("\ntree9: property using id_source/id_ref"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my $A = $tree->find_node('A'); + isa_ok($A, 'Bio::Tree::AnnotatableNode'); + my $ac = $A->annotation(); + isa_ok($ac, 'Bio::AnnotationCollectionI'); + my @annotations = $ac->get_Annotations('property'); + isa_ok( $annotations[0], 'Bio::Annotation::Collection'); + my @value = $annotations[0]->get_Annotations('_text'); + is($value[0]->value, ' 1200 '); + if ($verbose > 0) { + diag( "Annotation NOAA:depth ",$value[0]->value); + } + my $leaves_string = $tree->simplify_to_leaves_string(); + if ($verbose > 0) { + diag($leaves_string); + } + is($leaves_string, '((A,B),C)'); + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree10: detailed taxonomy and distribution + # + { + if ($verbose > 0) { + diag("\ntree10: taxonomy and distribution"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my $node = $tree->get_root_node; + my @leaves; + my @children = ($node); + for (@children) { + push @children, $_->each_Descendent(); + } + for (@children) { + push @leaves, $_ if $_->is_Leaf; + } + my ($A) = $leaves[0]; + my ($scientificname) = $A->annotation->get_nested_Annotations('-keys'=>['scientific_name'], '-recursive'=>1); + my ($scientificname_text) = $scientificname->get_Annotations('_text'); + my ($commonname) = $A->annotation->get_nested_Annotations('-keys'=>['common_name'], '-recursive'=>1); + my ($commonname_text) = $commonname->get_Annotations('_text'); + my ($rank) = $A->annotation->get_nested_Annotations('-keys'=>['rank'], '-recursive'=>1); + my ($rank_text) = $rank->get_Annotations('_text'); + if ($verbose > 0) { + diag("node rank is ", $rank_text->value); + diag("node scientific name is ", $scientificname_text->value); + diag("node common name is ", $commonname_text->value); + } + my ($distribution) = $A->annotation->get_nested_Annotations('-keys'=>['distribution'], '-recursive'=>1); + my ($desc) = $distribution->get_Annotations('desc'); + my ($desc_text) = $desc->get_Annotations('_text'); + if ($verbose > 0) { + diag("node distribution is ", $desc_text->value); + } + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree11: phylogeographic information + # + { + if ($verbose > 0) { + diag("\ntree11: phylogenographic information"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my $node = $tree->get_root_node; + my @leaves; + my @children = ($node); + for (@children) { + push @children, $_->each_Descendent(); + } + for (@children) { + push @leaves, $_ if $_->is_Leaf; + } + my ($D) = $leaves[0]; + my ($point) = $treeio->read_annotation('-obj'=>$D, '-path'=>'distribution/point/geodetic_datum', '-attr'=>1); + is ($point, 'WGS84'); + my ($lat) = $treeio->read_annotation('-obj'=>$D, '-path'=>'distribution/point/lat'); + my ($long) = $treeio->read_annotation('-obj'=>$D, '-path'=>'distribution/point/long'); + my ($alt) = $treeio->read_annotation('-obj'=>$D, '-path'=>'distribution/point/alt'); + is ($lat, '32.880933'); + is ($long, '-117.217543'); + is ($alt, '104'); + if ($verbose > 0) { + diag("node distribution lat: $lat long $long alt $alt"); + } + + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree12: date information + # + { + if ($verbose > 0) { + diag("\ntree12: date"); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my $node = $tree->get_root_node; + my @leaves; + my @children = ($node); + for (@children) { + push @children, $_->each_Descendent(); + } + for (@children) { + push @leaves, $_ if $_->is_Leaf; + } + my ($D) = $leaves[0]; + my ($dateunit) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/unit', '-attr'=>1); + my ($daterange) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/range', '-attr'=>1); + my ($datevalue) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/value'); + is ($dateunit, 'mya'); + is ($daterange, '30'); + is ($datevalue, '600'); + if ($verbose > 0) { + diag("node date unit: $dateunit range $daterange value $datevalue"); + } + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + # tree13: alignment outside + # + { + if ($verbose > 0) { + diag("\ntree13: alignment outside "); + } + my $tree = $treeio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + if ($verbose > 0) { + diag("tree id: ",$tree->id); + } + my $leaves_string = $tree->simplify_to_leaves_string(); + if ($verbose > 0) { + diag($leaves_string); + } + is($leaves_string, '((A,B),C)'); + + # add annotation in phyloxml + if ($verbose > 0) { + diag("test add annotation in phyloXML format"); + } + my $node = $tree->get_root_node; + my @leaves; + my @children = ($node); + for (@children) { + push @children, $_->each_Descendent(); + } + for (@children) { + push @leaves, $_ if $_->is_Leaf; + } + my ($D) = $leaves[0]; + isa_ok($D, 'Bio::Tree::AnnotatableNode'); + $treeio->add_phyloXML_annotation( + -obj => $D, + -xml => " D + + my date + veryveryold + + " + ); + my ($dateunit) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/unit', '-attr'=>1); + my ($daterange) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/range', '-attr'=>1); + my ($datevalue) = $treeio->read_annotation('-obj'=>$D, '-path'=>'date/value'); + is ($dateunit, 'mya'); + is ($daterange, '30'); + is ($datevalue, 'veryveryold'); + + # write_tree + if ($verbose > 0) { + diag("\ntest write_tree"); + } + my $FILE1 = test_output_file(); + my $treeio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $treeio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + + + # convert between nhx-phyloxml + { + if ($verbose > 0) { + diag("\n test translation between nhx and phyloxml"); + } + ok my $nhxio = Bio::TreeIO->new( + -verbose => $verbose, + -format => 'nhx', + -file => test_input_file('test.nhx')); + my $tree = $nhxio->next_tree; + isa_ok($tree, 'Bio::Tree::TreeI'); + my $FILE1 = test_output_file(); + my $phyloxmlio = Bio::TreeIO->new(-verbose => $verbose, + -format => 'phyloxml', + -file => ">$FILE1"); + $phyloxmlio->write_tree($tree); + ok -s $FILE1; + if ($verbose > 0) { + diag(`cat $FILE1`); + } + } + +} \ No newline at end of file -- 2.11.4.GIT