<commit_before>#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Bio::Phylo::PhyLoTA::Config;
use Bio::Tools::Run::Phylo::StarBEAST;
use Bio::Phylo::Util::Logger ':levels';
use Bio::Phylo::PhyLoTA::Service::ParallelService 'mpi'; # can be either 'pthreads' or 'mpi';

=head1 NAME

parallel_infer_clades.pl - infers species-level subtree

=head1 SYNOPSYS

 $ parallel_infer_clades.pl -workdir <directory> -ngens <100000> -sfreq <10000> -lfreq <10000>\
   [--verbose] [-file <file>] [--overwrite] 

=head1 DESCRIPTION

Infers a species-level phylogeny using the multi-species, multi-locus coalescent as
implemented in *BEAST. Given a C<directory>, traverses it, looks for subdirectories
and files that match the pattern C<clade\d+/clade\d+\.xml>. These must be NeXML files
with one or more alignments that link to the same taxa block in them. Given a C<file>
argument, analyses a single file. *BEAST is run for each clade with one chain. Here we 
make use of parallel processing by simultaneously running *BEAST for different clades
on different processors. 

=over

=item ngens

Specifies the number of generations. The default, which is strictly for testing, is 100.
Instead this should be something that is more on the order of 30_000_000 if not much
more.

=item sfreq
    
Specifies the sampling frequency. The default, which is strictly for testing, is 100.
Instead this should be something that is more on the order of 300_000 if not much
more. For example, this could be 0.1% of ngens so that you end up with a thousand trees.

=item lfreq

Species the logging frequency. The default, which is strictly for testing, is 100.
Instead this should be something that is more on the order of 300_000 if not much
more. For example, this could be 0.1% of ngens so that you end up with a thousand logged
samples.

=item overwrite

Overwrites any previously existing output files.

=cut

# process command line objects
my $verbosity = WARN;
my ( $ngens, $sfreq, $lfreq ) = ( 100, 100, 100 );
my $workdir;
my $file;
my $overwrite;
GetOptions(
	'workdir=s' => \$workdir,
	'ngens=i'   => \$ngens,
	'sfreq=i'   => \$sfreq,
	'lfreq=i'   => \$lfreq,
	'verbose+'  => \$verbosity,
	'file=s'    => \$file,
	'overwrite' => \$overwrite,
);

# instantiate helper objects
my $config = Bio::Phylo::PhyLoTA::Config->new;
my $beast  = Bio::Tools::Run::Phylo::StarBEAST->new;
my $logger = Bio::Phylo::Util::Logger->new( 
	'-level' => $verbosity, 
	'-class' => [ 
		'main',
		'Bio::Tools::Run::Phylo::StarBEAST',
		#'Bio::Phylo::Parsers::Nexml',
                #'Bio::Phylo::PhyLoTA::Service::ParallelService',
        ],
);

# configure beast
$logger->info( "setting beast executable to " . $config->BEAST_BIN );
$beast->executable( $config->BEAST_BIN );
<commit_msg>adding ParallelService to list of logged classes.<commit_after>#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Bio::Phylo::PhyLoTA::Config;
use Bio::Tools::Run::Phylo::StarBEAST;
use Bio::Phylo::Util::Logger ':levels';
use Bio::Phylo::PhyLoTA::Service::ParallelService 'mpi'; # can be either 'pthreads' or 'mpi';

=head1 NAME

parallel_infer_clades.pl - infers species-level subtree

=head1 SYNOPSYS

 $ parallel_infer_clades.pl -workdir <directory> -ngens <100000> -sfreq <10000> -lfreq <10000>\
   [--verbose] [-file <file>] [--overwrite] 

=head1 DESCRIPTION

Infers a species-level phylogeny using the multi-species, multi-locus coalescent as
implemented in *BEAST. Given a C<directory>, traverses it, looks for subdirectories
and files that match the pattern C<clade\d+/clade\d+\.xml>. These must be NeXML files
with one or more alignments that link to the same taxa block in them. Given a C<file>
argument, analyses a single file. *BEAST is run for each clade with one chain. Here we 
make use of parallel processing by simultaneously running *BEAST for different clades
on different processors. 

=over

=item ngens

Specifies the number of generations. The default, which is strictly for testing, is 100.
Instead this should be something that is more on the order of 30_000_000 if not much
more.

=item sfreq
    
Specifies the sampling frequency. The default, which is strictly for testing, is 100.
Instead this should be something that is more on the order of 300_000 if not much
more. For example, this could be 0.1% of ngens so that you end up with a thousand trees.

=item lfreq

Species the logging frequency. The default, which is strictly for testing, is 100.
Instead this should be something that is more on the order of 300_000 if not much
more. For example, this could be 0.1% of ngens so that you end up with a thousand logged
samples.

=item overwrite

Overwrites any previously existing output files.

=cut

# process command line objects
my $verbosity = WARN;
my ( $ngens, $sfreq, $lfreq ) = ( 100, 100, 100 );
my $workdir;
my $file;
my $overwrite;
GetOptions(
	'workdir=s' => \$workdir,
	'ngens=i'   => \$ngens,
	'sfreq=i'   => \$sfreq,
	'lfreq=i'   => \$lfreq,
	'verbose+'  => \$verbosity,
	'file=s'    => \$file,
	'overwrite' => \$overwrite,
);

# instantiate helper objects
my $config = Bio::Phylo::PhyLoTA::Config->new;
my $beast  = Bio::Tools::Run::Phylo::StarBEAST->new;
my $logger = Bio::Phylo::Util::Logger->new( 
	'-level' => $verbosity, 
	'-class' => [ 
		'main',
		'Bio::Tools::Run::Phylo::StarBEAST',
        'Bio::Phylo::PhyLoTA::Service::ParallelService',
        ],
);

# configure beast
$logger->info( "setting beast executable to " . $config->BEAST_BIN );
$beast->executable( $config->BEAST_BIN );

{'fraction_non_alphanumeric': 0.1218274111675127, 'fraction_numerical': 0.022117476432197244, 'mean_word_length': 4.424778761061947, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2223441', 'n_tokens_mistral': 1982, 'n_tokens_neox': 1790, 'n_words': 671}