Skip to content

Commit

Permalink
fixed version number; added bootstrapping test for fofn option
Browse files Browse the repository at this point in the history
  • Loading branch information
lskatz committed Mar 27, 2020
1 parent 612b7a1 commit b966948
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Mashtree.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 31 additions & 2 deletions t/08_bootstrap.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
};

0 comments on commit b966948

Please sign in to comment.