<commit_before># this is an object oriented perl module

package Bio::Phylo::PhyLoTA::Domain::BigTree;
use strict;
use warnings;
use Cwd;
use File::Copy;
use File::Basename;
use Bio::Phylo::PhyLoTA::Config;
use Bio::Phylo::Util::Logger;
use Bio::Phylo::Util::Exceptions 'throw';

my $conf = Bio::Phylo::PhyLoTA::Config->new;
my $log  = Bio::Phylo::Util::Logger->new;
my $cwd  = getcwd();

sub new {
    my $class = shift;
    my $self = bless {}, $class;
    return $self;
}

sub build_tree {
    my $self = shift;
    my %args = @_;
    
    # these are required arguments
    my $seqfile  = $args{'-seq_file'}  or throw 'BadArgs' => "need -seq_file argument";
    my $treefile = $args{'-tree_file'} or throw 'BadArgs' => "need -tree_file argument";
    my $seqfile_basename = basename($seqfile);
    my $treefile_basename = basename($treefile);
    
    # these are normally derived from the config file
    my $work_dir   = $args{'-work_dir'}   || $conf->WORK_DIR;
    my $examl_bin  = $args{'-examl_bin'}  || $conf->EXAML_BIN;
    my $parser_bin = $args{'-parser_bin'} || $conf->PARSER_BIN;
    my $examl_args = $args{'-examl_args'} || $conf->EXAML_ARGS;
    
    # create outfile from infile, if not provided
    my $outfile = $args{'-outfile'} || "${seqfile_basename}.dnd";
    
    # first create the binary representation of the seq file, if it doesn't exist yet
    if ( not -e "${work_dir}/${seqfile_basename}.binary" ) {
        $log->info("going to create binary compressed alignment file ${work_dir}/${seqfile_basename}.binary");
        chdir $work_dir;
        my $command = "$parser_bin -s $seqfile_basename -n $seqfile_basename -m DNA > /dev/null";
        $log->info("going to run '$command'");
        system( $command ) == 0 or throw 'BadArgs' => $?;
        chdir $cwd;
    }
    else {
        $log->info("binary compressed alignment file ${work_dir}/${seqfile_basename}.binary already existed");
    }
    
    # copy the starting tree to the working dir if it's not already there
    if ( not -e "${work_dir}/${treefile_basename}" ) {
        $log->info("copying $treefile to $work_dir");
        copy( $treefile, "${work_dir}/${treefile_basename}" );
    }
    
    # now run the tree search
    {
        chdir $work_dir;
        my $command = "$examl_bin $examl_args -s ${seqfile_basename}.binary -t $treefile_basename -n $outfile > /dev/null";
        $log->info("going to run '$command'");
        system( $command ) == 0 or throw 'BadArgs' => $?;
        chdir $cwd;
    }
    return "$work_dir/ExaML_result.$outfile";
}
<commit_msg>changed examl invocation to use mpirun<commit_after># this is an object oriented perl module

package Bio::Phylo::PhyLoTA::Domain::BigTree;
use strict;
use warnings;
use Cwd;
use File::Copy;
use File::Basename;
use Bio::Phylo::PhyLoTA::Config;
use Bio::Phylo::Util::Logger;
use Bio::Phylo::Util::Exceptions 'throw';

my $conf = Bio::Phylo::PhyLoTA::Config->new;
my $log  = Bio::Phylo::Util::Logger->new;
my $cwd  = getcwd();

sub new {
    my $class = shift;
    my $self = bless {}, $class;
    return $self;
}

sub build_tree {
    my $self = shift;
    my %args = @_;
    
    # these are required arguments
    my $seqfile  = $args{'-seq_file'}  or throw 'BadArgs' => "need -seq_file argument";
    my $treefile = $args{'-tree_file'} or throw 'BadArgs' => "need -tree_file argument";
    my $seqfile_basename = basename($seqfile);
    my $treefile_basename = basename($treefile);
    
    # these are normally derived from the config file
    my $work_dir   = $args{'-work_dir'}   || $conf->WORK_DIR;
    my $examl_bin  = $args{'-examl_bin'}  || $conf->EXAML_BIN;
    my $parser_bin = $args{'-parser_bin'} || $conf->PARSER_BIN;
    my $examl_args = $args{'-examl_args'} || $conf->EXAML_ARGS;
    my $mpirun_bin = $args{'-mpirun_bin'} || $conf->MPIRUN_BIN;
    my $nodes      = $args{'-nodes'}      || $conf->NODES;
    
    # create outfile from infile, if not provided
    my $outfile = $args{'-outfile'} || "${seqfile_basename}.dnd";
    
    # first create the binary representation of the seq file, if it doesn't exist yet
    if ( not -e "${work_dir}/${seqfile_basename}.binary" ) {
        $log->info("going to create binary compressed alignment file ${work_dir}/${seqfile_basename}.binary");
        chdir $work_dir;
        my $command = "$parser_bin -s $seqfile_basename -n $seqfile_basename -m DNA > /dev/null";
        $log->info("going to run '$command'");
        system( $command ) == 0 or throw 'BadArgs' => $?;
        chdir $cwd;
    }
    else {
        $log->info("binary compressed alignment file ${work_dir}/${seqfile_basename}.binary already existed");
    }
    
    # copy the starting tree to the working dir if it's not already there
    if ( not -e "${work_dir}/${treefile_basename}" ) {
        $log->info("copying $treefile to $work_dir");
        copy( $treefile, "${work_dir}/${treefile_basename}" );
    }
    
    # now run the tree search
    {
        chdir $work_dir;
        my $command = "$mpirun_bin -np $nodes $examl_bin $examl_args -s ${seqfile_basename}.binary -t $treefile_basename -n $outfile > /dev/null";
        $log->info("going to run '$command'");
        system( $command ) == 0 or throw 'BadArgs' => $?;
        chdir $cwd;
    }
    return "$work_dir/ExaML_result.$outfile";
}

{'fraction_non_alphanumeric': 0.15876911459316595, 'fraction_numerical': 0.0007551444213705871, 'mean_word_length': 3.2114467408585057, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '353932', 'n_tokens_mistral': 1843, 'n_tokens_neox': 1830, 'n_words': 478}