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
|
|
9 BEGIN {
|
|
10 use Test::Most;
|
|
11 use_ok('Bio::Roary::AssemblyStatistics');
|
|
12 }
|
|
13
|
|
14 my $obj;
|
|
15 ok( $obj = Bio::Roary::AssemblyStatistics->new( spreadsheet => 't/data/input_block_spreadsheet.csv' ), 'initialise spreadsheet' );
|
|
16
|
|
17 my @genes = sort keys %{ $obj->_genes_to_rows };
|
|
18 is_deeply(
|
|
19 \@genes,
|
|
20 [
|
|
21 'SBOV29371', 'SBOV38871', 'SBOV43201', 'STY3593', 'STY4162', 'bcsC_1', 'betC_2', 'comM_2',
|
|
22 'dmsA4_1', 'dosC', 'dsbA_3', 'fadH_1', 'fimD_3', 'fliB_2', 'fliF', 'ftsN',
|
|
23 'gatY_1', 'glfT2', 'group_1000', 'group_1001', 'group_1004', 'group_1006', 'group_1009', 'group_220',
|
|
24 'group_277', 'group_281', 'group_283', 'group_284', 'group_288', 'hemD', 'hsrA_2', 'icsA',
|
|
25 'kdpD', 'ligB_1', 'marT_1', 'nepI', 'rffH', 'rpoS', 'selA_1', 'speC_3',
|
|
26 'sptP', 'srgB', 'stp', 'tmcA', 'tub', 'yadA', 'ybbW_1', 'yhaO_2',
|
|
27 'yicJ_1', 'yigZ'
|
|
28 ],
|
|
29 'all gene rows available'
|
|
30 );
|
|
31
|
|
32 is_deeply(
|
|
33 $obj->ordered_genes,
|
|
34 [
|
|
35 'dmsA4_1', 'group_1000', 'group_1001', 'SBOV43201', 'dosC', 'stp', 'fliB_2', 'fliF',
|
|
36 'dsbA_3', 'srgB', 'fimD_3', 'betC_2', 'tmcA', 'tub', 'rffH', 'hemD',
|
|
37 'group_1006', 'STY3593', 'group_1004', 'yigZ', 'group_220', 'glfT2', 'kdpD', 'speC_3',
|
|
38 'ybbW_1', 'sptP', 'SBOV29371', 'rpoS', 'fadH_1', 'yhaO_2', 'bcsC_1', 'STY4162',
|
|
39 'yadA', 'ligB_1', 'icsA', 'marT_1', 'selA_1', 'nepI', 'gatY_1', 'SBOV38871',
|
|
40 'group_288', 'hsrA_2', 'group_281', 'group_283', 'group_284', 'yicJ_1', 'ftsN', 'group_277',
|
|
41 'group_1009', 'comM_2'
|
|
42 ],
|
|
43 'ordered genes'
|
|
44 );
|
|
45
|
|
46 is_deeply(
|
|
47 $obj->sample_names_to_column_index,
|
|
48 {
|
|
49 'threeblocks' => 18,
|
|
50 'nocontigs' => 17,
|
|
51 'contigwithgaps' => 16,
|
|
52 'oneblock' => 14,
|
|
53 'threeblocksinversion' => 19,
|
|
54 'oneblockrev' => 15
|
|
55 },
|
|
56 'sample names to column index'
|
|
57 );
|
|
58
|
|
59 is_deeply( $obj->_sample_statistics('oneblock'), { num_blocks => 1, largest_block_size => 50 }, 'one block' );
|
|
60 is_deeply( $obj->_sample_statistics('oneblockrev'), { num_blocks => 1, largest_block_size => 50 }, 'one block reversed' );
|
|
61 is_deeply(
|
|
62 $obj->_sample_statistics('contigwithgaps'),
|
|
63 { num_blocks => 1, largest_block_size => 50 },
|
|
64 'one block where there are gaps everywhere'
|
|
65 );
|
|
66 is_deeply( $obj->_sample_statistics('nocontigs'), { num_blocks => 50, largest_block_size => 1 }, 'no contiguous blocks' );
|
|
67 is_deeply( $obj->_sample_statistics('threeblocks'), { num_blocks => 3, largest_block_size => 21 }, 'three blocks' );
|
|
68 is_deeply(
|
|
69 $obj->_sample_statistics('threeblocksinversion'),
|
|
70 { num_blocks => 3, largest_block_size => 20 },
|
|
71 'three blocks with an inversion in the middle'
|
|
72 );
|
|
73 is_deeply( $obj->gene_category_count, { core => 50 }, 'Gene category counts' );
|
|
74
|
|
75 # t/data/gene_category_count.csv
|
|
76 ok( $obj = Bio::Roary::AssemblyStatistics->new( spreadsheet => 't/data/gene_category_count.csv' ),
|
|
77 'initialise spreadsheet with variable numbers of genes in samples' );
|
|
78 is_deeply(
|
|
79 $obj->gene_category_count,
|
|
80 {
|
|
81 'core' => 1,
|
|
82 'cloud' => 4,
|
|
83 'soft_core' => 1,
|
|
84 'shell' => 24
|
|
85 },
|
|
86 'Categories as expected'
|
|
87 );
|
|
88 ok($obj->create_summary_output, 'create output file');
|
|
89 compare_ok('summary_statistics.txt', 't/data/expected_summary_statistics.txt', 'summary statistics as expected');
|
|
90
|
|
91
|
|
92 # t/data/gene_category_count.csv
|
|
93 ok( $obj = Bio::Roary::AssemblyStatistics->new( spreadsheet => 't/data/gene_category_count.csv', core_definition => 0.9667 ),
|
|
94 'initialise spreadsheet with core of 96.67%' );
|
|
95 is_deeply(
|
|
96 $obj->gene_category_count,
|
|
97 {
|
|
98 'core' => 1,
|
|
99 'soft_core' => 1,
|
|
100 'cloud' => 4,
|
|
101 'shell' => 24
|
|
102 },
|
|
103 'Categories as expected with cd of 96.67%'
|
|
104 );
|
|
105
|
|
106 # t/data/gene_category_count.csv
|
|
107 ok( $obj = Bio::Roary::AssemblyStatistics->new( spreadsheet => 't/data/gene_category_count.csv', core_definition => 0.9666 ),
|
|
108 'initialise spreadsheet with core of 96.66%' );
|
|
109 is_deeply(
|
|
110 $obj->gene_category_count,
|
|
111 {
|
|
112 'core' => 2,
|
|
113 'cloud' => 4,
|
|
114 'shell' => 24
|
|
115 },
|
|
116 'Categories as expected with cd of 96.66%'
|
|
117 );
|
|
118
|
|
119
|
|
120 unlink('summary_statistics.txt');
|
|
121 done_testing();
|