From b9669489749d627874b5c1ab29a0b3150ec95a87 Mon Sep 17 00:00:00 2001 From: Lee Katz - Aspen Date: Fri, 27 Mar 2020 13:24:28 -0400 Subject: [PATCH] fixed version number; added bootstrapping test for fofn option --- lib/Mashtree.pm | 2 +- t/08_bootstrap.t | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/lib/Mashtree.pm b/lib/Mashtree.pm index c2e99ba..a6c2e9e 100644 --- a/lib/Mashtree.pm +++ b/lib/Mashtree.pm @@ -26,7 +26,7 @@ local $0=basename $0; ###### # CONSTANTS -our $VERSION = "1.0.4"; +our $VERSION = "1.1.2"; our $MASHTREE_VERSION=$VERSION; our @fastqExt=qw(.fastq.gz .fastq .fq .fq.gz); our @fastaExt=qw(.fasta .fna .faa .mfa .fas .fsa .fa); diff --git a/t/08_bootstrap.t b/t/08_bootstrap.t index 773a653..936db45 100644 --- a/t/08_bootstrap.t +++ b/t/08_bootstrap.t @@ -11,13 +11,13 @@ use Bio::TreeIO; use IO::String; use Scalar::Util qw/looks_like_number/; -use Test::More tests => 4; +use Test::More tests => 5; use_ok 'Mashtree'; use Mashtree; use Mashtree::Db; -$ENV{PATH}="./bin:$ENV{PATH}"; +$ENV{PATH}="$RealBin/../bin:$ENV{PATH}"; my $correctMashtree="((sample2:0.0020443525,sample1:0.0021037373)66:0.0000540274,sample3:0.0019622177,sample4:0.0020673526)83;"; $correctMashtree=~s/(\d+\.)(\d+)/$1 . substr($2,0,4)/ge; # global and expression @@ -61,3 +61,32 @@ subtest "Parts of the tree file intact" => sub{ is $correctNodeString, $nodeString, "Taxon names in the tree: $nodeString"; }; +# Address the bug fix https://github.com/lskatz/mashtree/issues/51#issuecomment-604495598 +subtest "file-of-filenames" => sub{ + plan tests=>2; + + # Make the file of filenames + my $fofn = "$RealBin/lambda/lambda.fofn"; + my @file = glob("$RealBin/lambda/*.fastq.gz"); + open(my $fh, ">", $fofn) or die "ERROR: could not write to $fofn: $!"; + for my $f(@file){ + print $fh "$f\n"; + } + close $fh; + + my $mashtreeFofn = `mashtree_bootstrap.pl --tempdir $RealBin/lambda/jackknife.tmp --reps 100 --numcpus 2 -- --file-of-files $fofn 2>$RealBin/lambda/jackknife.log`; + note $mashtreeFofn; + + my $treeFh = IO::String->new($mashtree); + my $tree = Bio::TreeIO->new(-fh=>$treeFh, -format=>"newick")->next_tree; + $passed = is(ref($tree),"Bio::Tree::Tree","Produced a BioPerl tree object"); + if(!$passed){ + diag "Tree string produced was $mashtree"; + BAIL_OUT("Tree object was not produced out of the tree string"); + } + + my @leaf = sort map{$_->id} grep{$_->is_Leaf} $tree->get_nodes; + is(scalar(@leaf), 4, "correct number of nodes"); + note "@leaf"; +}; +