script/subs-forest.pl untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod n/a totaltotal 0.0% 0 / 65 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 # PODNAME: subs-forest.pl
3 # ABSTRACT: Subsample forest (multiple trees) files (and restore ids)
4  
5 use Modern::Perl '2011';
6 use autodie;
7  
8 use Getopt::Euclid qw(:vars);
9 use Smart::Comments;
10  
11 use Bio::MUST::Core;
12 use Bio::MUST::Core::Utils qw(change_suffix secure_outfile);
13 use aliased 'Bio::MUST::Core::IdMapper';
14 use aliased 'Bio::MUST::Core::Tree::Forest';
15  
16  
17 for my $infile (@ARGV_infiles) {
18  
19 ### Processing: $infile
20 my $forest = Forest->load($infile);
21  
22 $infile =~ s/$_//xms for @ARGV_in_strip;
23  
24 if ($ARGV_map_ids) {
25 my $idmfile = change_suffix($infile, '.idm');
26 my $idm = IdMapper->load($idmfile);
27 ### Restoring seq ids from: $idmfile
28 $forest->restore_ids($idm);
29 }
30  
31 if (%ARGV_x) {
32 my ($burnin, $every, $until) = @ARGV_x{ qw(burnin every until) };
33 $until = $forest->count_trees
34 if !$until || $until > $forest->count_trees;
35 die "<burnin> ($burnin) larger than <until> ($until); aborting!\n"
36 if $burnin > $until;
37 ### Subsampling using: "-x $burnin $every $until"
38  
39 my @trees;
40 for (my $i = $burnin; $i < $until ; $i += $every) {
41 push @trees, $forest->get_tree($i);
42 }
43 $forest = Forest->new( trees => \@trees );
44 }
45  
46 my $outfile = secure_outfile($infile, $ARGV_out_suffix);
47 $forest->store($outfile);
48 }
49  
50 __END__