<commit_before>#!/usr/bin/perl
use strict;
use warnings;
use Template;
use FindBin '$Bin';
use Test::More 'no_plan';
use Bio::Phylo::IO 'parse';

# maybe provided?
my $outfile = shift;

# test file locations
my $template = $ENV{'SUPERSMART_HOME'} . '/data/BEAST/starbeast.xml';
my $data = $Bin . '/testdata/clade1.xml';
ok( -e $template, "found $template" );
ok( -e $data, "found $data" );

# create outfile locations
my $stem = $data;
$stem =~ s/\..+$//;
my $tree_file  = $stem . '.nex';
my $param_file = $stem . '.log';

# read prepared NeXML
my $project = parse(
	'-format'     => 'nexml',
	'-file'       => $data,
	'-as_project' => 1,
);
isa_ok( $project, 'Bio::Phylo::Project' );

# instantiate Template::Toolkit
my $tt = Template->new({ 'ABSOLUTE' => 1 });
isa_ok( $tt, 'Template' );

my $output;
$tt->process( $template, {
	'data'       => $project,
	'ngens'      => 10_000_000,
	'sfreq'      => 10_000,
	'tree_file'  => $tree_file,
	'param_file' => $param_file,
}, \$output ) || die $tt->error();

ok( $output );

if ( $outfile ) {
	open my $fh, '>', $outfile or die $!;
	print $fh $output;
}<commit_msg>variable names reconciled with StarBEAST.pm<commit_after>#!/usr/bin/perl
use strict;
use warnings;
use Template;
use FindBin '$Bin';
use Test::More 'no_plan';
use Bio::Phylo::IO 'parse';

# maybe provided?
my $beastfile_name = shift;

# test file locations
my $template = $ENV{'SUPERSMART_HOME'} . '/data/BEAST/starbeast.xml';
my $data = $Bin . '/testdata/clade1.xml';
ok( -e $template, "found $template" );
ok( -e $data, "found $data" );

# create outfile locations
my $stem = $data;
$stem =~ s/\..+$//;
my $tree_file  = $stem . '.nex';
my $param_file = $stem . '.log';

# read prepared NeXML
my $project = parse(
	'-format'     => 'nexml',
	'-file'       => $data,
	'-as_project' => 1,
);
isa_ok( $project, 'Bio::Phylo::Project' );

# instantiate Template::Toolkit
my $tt = Template->new({ 'ABSOLUTE' => 1 });
isa_ok( $tt, 'Template' );

my $output;
$tt->process( $template, {
	'data'         => $project,
	'chain_length' => 10_000_000,
	'sample_freq'  => 10_000,
	'outfile_name' => $tree_file,
	'logfile_name' => $param_file,
}, \$output ) || die $tt->error();

ok( $output );

if ( $beastfile_name ) {
	open my $fh, '>', $beastfile_name or die $!;
	print $fh $output;
}
{'fraction_non_alphanumeric': 0.212253829321663, 'fraction_numerical': 0.01400437636761488, 'mean_word_length': 3.9267241379310347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '3904361', 'n_tokens_mistral': 957, 'n_tokens_neox': 902, 'n_words': 230}