1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use File::Path qw(remove_tree);
use Test::Files;
BEGIN { unshift( @INC, './lib' ) }
$ENV{PATH} .= ":./bin";
BEGIN {
use Test::Most;
use_ok('Bio::Roary::ReformatInputGFFs');
}
my $obj;
remove_tree('fixed_input_files');
ok($obj = Bio::Roary::ReformatInputGFFs->new(gff_files => ['t/data/reformat_input_gffs/query_1.gff']), 'initialise with one input gff');
ok($obj->fix_duplicate_gene_ids, 'fix duplicates with one input gff');
is_deeply($obj->fixed_gff_files, ['t/data/reformat_input_gffs/query_1.gff'] ,'list of gff files with one input gff, nothing should change');
ok(!( -d 'fixed_input_files'), 'Directory shouldnt exist because there arent any fixed input files');
ok($obj = Bio::Roary::ReformatInputGFFs->new(gff_files => ['t/data/reformat_input_gffs/query_1.gff', 't/data/reformat_input_gffs/query_2.gff',]), 'initialise with 2 input gffs');
ok(!( -d 'fixed_input_files'), 'Directory shouldnt exist before running');
is_deeply($obj->_get_ids_for_gff_file('t/data/reformat_input_gffs/query_1.gff'),[
'1_1',
'abc_00002',
'abc_00003',
'abc_00004',
'1_2'
],'extract ids');
is_deeply($obj->_get_ids_for_gff_file('t/data/reformat_input_gffs/query_2.gff'),[
'1_1',
'abc_00002',
'abc_00003',
'abc_00004',
'1_2'
],'extract ids');
ok($obj->fix_duplicate_gene_ids, 'fix duplicates with 2 input gffs');
ok(( -d 'fixed_input_files'), 'Directory should exist because there is one gff thats fixed');
is_deeply($obj->fixed_gff_files, ['t/data/reformat_input_gffs/query_1.gff','fixed_input_files/query_2.gff' ] ,'list of gff files one in the fixed directory');
ok(( -e 'fixed_input_files/query_2.gff'), 'fixed file should exist');
compare_ok('fixed_input_files/query_2.gff', 't/data/reformat_input_gffs/expected_fixed_query_2.gff', 'fixed file should have expected changes');
remove_tree('fixed_input_files');
ok($obj = Bio::Roary::ReformatInputGFFs->new(gff_files => ['t/data/reformat_input_gffs/query_1.gff', 't/data/reformat_input_gffs/query_2.gff', 't/data/reformat_input_gffs/query_3.gff']), 'initialise with 3 input gffs, 2 identical duplicates');
ok(!( -d 'fixed_input_files'), 'Directory shouldnt exist before running');
ok($obj->fix_duplicate_gene_ids, 'fix duplicates with 3 input gffs');
ok(( -d 'fixed_input_files'), 'Directory should exist because there are 2 gffs thats fixed');
is_deeply($obj->fixed_gff_files, ['t/data/reformat_input_gffs/query_1.gff','fixed_input_files/query_2.gff' ] ,'list of gff files 2 in the fixed directory');
ok(( -e 'fixed_input_files/query_2.gff'), 'fixed file should exist');
ok(!( -e 'fixed_input_files/query_3.gff'), 'fixed file should exist');
compare_ok('fixed_input_files/query_2.gff','t/data/reformat_input_gffs/expected_fixed_query_2.gff', 'fixed file should have expected changes');
remove_tree('fixed_input_files');
ok($obj = Bio::Roary::ReformatInputGFFs->new(gff_files => ['t/data/reformat_input_gffs/real_1.gff']), 'initialise with 1 gff that has shown to have a bug');
ok(my $fixed_file = $obj->_add_suffix_to_gene_ids_and_return_new_file('t/data/reformat_input_gffs/real_1.gff', 'id__'), 'fix duplicates');
ok(( -e 'fixed_input_files/real_1.gff'), 'fixed file should exist');
compare_ok('fixed_input_files/real_1.gff', 't/data/reformat_input_gffs/expected_real_1.gff', 'fixed file should have expected changes');
remove_tree('fixed_input_files');
done_testing();
|