<commit_before>#!/usr/bin/env perl

use 5.010;
use strict;
use warnings;
use Cwd;
use File::Spec;
use File::Path          qw(remove_tree);
use Capture::Tiny       qw(capture);
use IPC::System::Simple qw(system);
use Transposome;

use aliased 'Transposome::Test::TestFixture';
use Test::More tests => 3;

my $program  = File::Spec->catfile('bin', 'transposome');
my $seqfile  = File::Spec->catfile('t', 'test_data', 't_reads.fas.gz');
my $repeatdb = File::Spec->catfile('t', 'test_data', 't_db.fas');
my $outdir   = File::Spec->catdir('t', 'test_transposome_cli_out');

my $test = TestFixture->new(
    seq_file     => $seqfile,
    seq_format   => 'fasta',
    repeat_db    => $repeatdb,
    destroy      => 0,
    build_proper => 1
);

my $conf = $test->config_constructor;
my ($conf_file) = @$conf;
my $trans_obj = Transposome->new( config => $conf_file );
ok( $trans_obj->get_configuration, 'Configuration data loaded from file correctly' );
my $config = $trans_obj->get_configuration;

my $cwd = getcwd();
my $bin = File::Spec->catdir($cwd, 'bin');

local $ENV{PATH} = "$bin:$ENV{PATH}";

my ($stdout, $stderr, @res) = capture { system([0..5], "perl -Iblib/lib $program --config $conf_file"); };

ok( -d $outdir, 'Output of Transposome created' );

# just check if the application completed without errors
for my $line (split /^/, $stderr) {
    chomp $line;
    if ($line =~ /Transposome completed at/) {
	like( $line, qr/Transposome completed at/, 
	      'Transposome CLI application completed successfully' );
    }
}

remove_tree( $outdir, { safe => 1 } );
unlink $conf_file;
unlink glob "t/transposome_mgblast*";
unlink "formatdb.log";<commit_msg>add tests to see we can compress output<commit_after>#!/usr/bin/env perl

use 5.010;
use strict;
use warnings;
use Cwd;
use File::Find;
use File::Spec;
use File::Path          qw(remove_tree);
use Capture::Tiny       qw(capture);
use IPC::System::Simple qw(system);
use Transposome;

use aliased 'Transposome::Test::TestFixture';
use Test::More tests => 4;

my $program  = File::Spec->catfile('bin', 'transposome');
my $seqfile  = File::Spec->catfile('t', 'test_data', 't_reads.fas.gz');
my $repeatdb = File::Spec->catfile('t', 'test_data', 't_db.fas');
my $outdir   = File::Spec->catdir('t', 'test_transposome_cli_out');

my $test = TestFixture->new(
    seq_file     => $seqfile,
    seq_format   => 'fasta',
    repeat_db    => $repeatdb,
    destroy      => 0,
    build_proper => 1
);

my $conf = $test->config_constructor;
my ($conf_file) = @$conf;
my $trans_obj = Transposome->new( config => $conf_file );
ok( $trans_obj->get_configuration, 'Configuration data loaded from file correctly' );
my $config = $trans_obj->get_configuration;

my $cwd = getcwd();
my $bin = File::Spec->catdir($cwd, 'bin');

local $ENV{PATH} = "$bin:$ENV{PATH}";

my ($stdout, $stderr, @res) = capture { system([0..5], "perl -Iblib/lib $program --config $conf_file"); };

ok( -d $outdir, 'Output of Transposome created' );

# just check if the application completed without errors
for my $line (split /^/, $stderr) {
    chomp $line;
    if ($line =~ /Transposome completed at/) {
	like( $line, qr/Transposome completed at/, 
	      'Transposome CLI application completed successfully' );
    }
}

my @results;
find( sub { push @results, $File::Find::name if -f and /\.tgz$/ }, $outdir );
is( scalar(@results), 2, 'Output directories compressed successfully' );

remove_tree( $outdir, { safe => 1 } );
unlink $conf_file;
unlink glob "t/transposome_mgblast*";
unlink "formatdb.log";
{'fraction_non_alphanumeric': 0.17523430843510365, 'fraction_numerical': 0.005964214711729622, 'mean_word_length': 4.410138248847926, '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': '200794', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1249, 'n_words': 331}