0
|
1 #!/usr/bin/env perl
|
|
2 use strict;
|
|
3 use warnings;
|
|
4 use Data::Dumper;
|
|
5 use Test::Files;
|
|
6
|
|
7 BEGIN { unshift( @INC, './lib' ) }
|
|
8 $ENV{PATH} .= ":./bin";
|
|
9
|
|
10 BEGIN {
|
|
11 use Test::Most;
|
|
12 use_ok('Bio::Roary::GroupStatistics');
|
|
13 }
|
|
14
|
|
15 my $annotate_groups = Bio::Roary::AnnotateGroups->new(
|
|
16 gff_files => ['t/data/query_1.gff','t/data/query_2.gff','t/data/query_3.gff'],
|
|
17 groups_filename => 't/data/query_groups',
|
|
18 );
|
|
19
|
|
20 my $analyse_groups = Bio::Roary::AnalyseGroups->new(
|
|
21 fasta_files => ['t/data/query_1.fa','t/data/query_2.fa','t/data/query_3.fa'],
|
|
22 groups_filename => 't/data/query_groups'
|
|
23 );
|
|
24
|
|
25 my $obj;
|
|
26
|
|
27 ok($obj = Bio::Roary::GroupStatistics->new(
|
|
28 annotate_groups_obj => $annotate_groups,
|
|
29 analyse_groups_obj => $analyse_groups
|
|
30 ),'Initialise group statistics object');
|
|
31 ok($obj->create_spreadsheet,'Create the CSV file');
|
|
32 ok(-e 'gene_presence_absence.csv', 'CSV file exists');
|
|
33 compare_ok('gene_presence_absence.csv','t/data/expected_group_statitics.csv', 'Spreadsheet content as expected');
|
|
34 ok($obj->create_rtab,'Create the Rtab file');
|
|
35 ok(-e 'gene_presence_absence.Rtab', 'Rtab file exists');
|
|
36 compare_ok('gene_presence_absence.Rtab','t/data/expected_gene_presence_and_absence.Rtab', 'Rtab matrix content as expected');
|
|
37
|
|
38 unlink('gene_presence_absence.csv');
|
|
39 unlink('gene_presence_absence.Rtab');
|
|
40
|
|
41 ############################
|
|
42
|
|
43 my $annotate_groups_2 = Bio::Roary::AnnotateGroups->new(
|
|
44 gff_files => ['t/data/query_1.gff','t/data/query_2.gff','t/data/query_3.gff','t/data/query_4_missing_genes.gff'],
|
|
45 groups_filename => 't/data/query_groups_missing_genes',
|
|
46 );
|
|
47
|
|
48 my $analyse_groups_2 = Bio::Roary::AnalyseGroups->new(
|
|
49 fasta_files => ['t/data/query_1.fa','t/data/query_2.fa','t/data/query_3.fa','t/data/query_4_missing_genes.fa'],
|
|
50 groups_filename => 't/data/query_groups_missing_genes'
|
|
51 );
|
|
52
|
|
53 ok($obj = Bio::Roary::GroupStatistics->new(
|
|
54 annotate_groups_obj => $annotate_groups_2,
|
|
55 analyse_groups_obj => $analyse_groups_2,
|
|
56 output_filename => 'missing_genes_stats.csv'
|
|
57 ),'Initialise group statistics object where one isolate has only 1 gene');
|
|
58 ok($obj->create_spreadsheet,'Create the CSV file');
|
|
59 ok(-e 'missing_genes_stats.csv', 'CSV file exists');
|
|
60 compare_ok('missing_genes_stats.csv','t/data/expected_group_statitics_missing_genes.csv', 'Spreadsheet content as expected with missing genes');
|
|
61
|
|
62 unlink('missing_genes_stats.csv');
|
|
63
|
|
64
|
|
65 ## TEST VERBOSE STATS ##
|
|
66
|
|
67 ok($obj = Bio::Roary::GroupStatistics->new(
|
|
68 annotate_groups_obj => $annotate_groups,
|
|
69 analyse_groups_obj => $analyse_groups,
|
|
70 _verbose => 1,
|
|
71 output_filename => 'verbose_stats.csv'
|
|
72 ),'Initialise group statistics object');
|
|
73 ok($obj->create_spreadsheet,'Create the CSV file');
|
|
74 ok(-e 'verbose_stats.csv', 'CSV file exists');
|
|
75 compare_ok('verbose_stats.csv','t/data/expected_group_statitics_verbose.csv', 'Verbose spreadsheet content as expected');
|
|
76
|
|
77 unlink('verbose_stats.csv');
|
|
78
|
|
79 done_testing();
|