Mercurial > repos > dereeper > roary_plots
comparison Roary/t/Bio/Roary/CommandLine/Roary.t @ 0:c47a5f61bc9f draft
Uploaded
author | dereeper |
---|---|
date | Fri, 14 May 2021 20:27:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c47a5f61bc9f |
---|---|
1 #!/usr/bin/env perl | |
2 use Moose; | |
3 use Data::Dumper; | |
4 use File::Path qw( remove_tree); | |
5 use File::Which; | |
6 use File::Path qw(make_path); | |
7 use Cwd qw(abs_path getcwd); | |
8 use File::Find::Rule; | |
9 | |
10 #Test changes current working directory so relative paths can get out of sync | |
11 local $ENV{PERL5LIB} = join(':', ("$ENV{PERL5LIB}", abs_path('./lib'), abs_path('./t/lib'))); | |
12 local $ENV{PATH} = join(':', ("$ENV{PATH}", abs_path('./bin'))); | |
13 | |
14 BEGIN { unshift( @INC, abs_path('./lib') ) } | |
15 BEGIN { unshift( @INC, abs_path('./t/lib') ) } | |
16 with 'TestHelper'; | |
17 | |
18 BEGIN { | |
19 use Test::Most; | |
20 use_ok('Bio::Roary::CommandLine::Roary'); | |
21 use_ok('Bio::Roary::CommandLine::CreatePanGenome'); | |
22 use Bio::Roary::SequenceLengths; | |
23 } | |
24 my $script_name = 'Bio::Roary::CommandLine::Roary'; | |
25 my $cwd = getcwd(); | |
26 | |
27 local $ENV{PATH} = "$ENV{PATH}:./bin"; | |
28 my %scripts_and_expected_files; | |
29 system('touch empty_file'); | |
30 cleanup_files(); | |
31 | |
32 %scripts_and_expected_files = ( | |
33 ' -j Parallel --dont_split_groups t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff ' => | |
34 [ 'gene_presence_absence.csv', 't/data/overall_gene_presence_absence.csv' ], | |
35 ' -j Local -t 1 --dont_split_groups t/data/genbank_gbff/genbank1.gff t/data/genbank_gbff/genbank2.gff t/data/genbank_gbff/genbank3.gff' => | |
36 [ 'gene_presence_absence.csv', 't/data/genbank_gbff/genbank_gene_presence_absence.csv' ], | |
37 '-h' => [ 'empty_file', 't/data/empty_file' ], | |
38 ); | |
39 | |
40 mock_execute_script_and_check_output_sorted( $script_name, \%scripts_and_expected_files, [ 0, 6, 7, 8, 9 ] ); | |
41 | |
42 cleanup_files(); | |
43 | |
44 stderr_should_have($script_name,'-a', 'Looking for'); | |
45 | |
46 my $current_cwd = getcwd(); | |
47 stderr_should_have($script_name,'-v --output_directory t/data/directory_which_doesnt_exist t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff', 'Output directory created'); | |
48 ok( ( -e 't/data/directory_which_doesnt_exist/clustered_proteins' ), 'pan genome files should be in directory' ); | |
49 is(getcwd(),$current_cwd , 'current working directory should not have changed after script is finished'); | |
50 | |
51 SKIP: | |
52 { | |
53 skip "prank not installed", 11 unless ( which('prank') ); | |
54 | |
55 %scripts_and_expected_files = | |
56 ( '-j Local --dont_delete_files --dont_split_groups --output_multifasta_files t/data/real_data_1.gff t/data/real_data_2.gff' => | |
57 [ 'pan_genome_sequences/mdoH.fa.aln', 't/data/mdoH.fa.aln' ], ); | |
58 mock_execute_script_and_check_output( $script_name, \%scripts_and_expected_files ); | |
59 | |
60 ok( -e 'core_gene_alignment.aln', 'Core gene alignment exists' ); | |
61 | |
62 ok( | |
63 my $seq_len = Bio::Roary::SequenceLengths->new( | |
64 fasta_file => 'core_gene_alignment.aln', | |
65 ), | |
66 'Check size of the core_gene_alignment.aln init' | |
67 ); | |
68 | |
69 my @keys = keys %{ $seq_len->sequence_lengths }; | |
70 is( $seq_len->sequence_lengths->{ $keys[0] }, 64983, 'length of first sequence' ); | |
71 | |
72 ok( -e 'core_alignment_header.embl', 'Core gene alignment header exists' ); | |
73 | |
74 ok( -e 'accessory.tab' ); | |
75 ok( -e 'core_accessory.tab' ); | |
76 ok( -e 'number_of_conserved_genes.Rtab' ); | |
77 ok( -e 'number_of_genes_in_pan_genome.Rtab' ); | |
78 ok( -e 'number_of_new_genes.Rtab' ); | |
79 ok( -e 'number_of_unique_genes.Rtab' ); | |
80 ok( -e 'blast_identity_frequency.Rtab' ); | |
81 | |
82 cleanup_files(); | |
83 %scripts_and_expected_files = | |
84 ( | |
85 '-j Local --output_multifasta_files t/data/core_alignment_gene_lookup/query_1.gff t/data/core_alignment_gene_lookup/query_2.gff t/data/core_alignment_gene_lookup/query_3.gff' | |
86 => [ 'core_gene_alignment.aln', 't/data/core_alignment_gene_lookup/expected_core_gene_alignment.aln' ], ); | |
87 mock_execute_script_and_check_output( $script_name, \%scripts_and_expected_files ); | |
88 | |
89 cleanup_files(); | |
90 } | |
91 | |
92 SKIP: | |
93 { | |
94 skip "extended tests not run", 40 unless ( defined($ENV{ROARY_FULL_TESTS})); | |
95 | |
96 %scripts_and_expected_files = ( | |
97 '-o some_different_output -i 90 -p 2 --translation_table 1 t/data/real_data_1.gff t/data/real_data_2.gff' => [ 'some_different_output', 't/data/expected_some_different_output' ], | |
98 ); | |
99 mock_execute_script_and_check_output_sorted( $script_name, \%scripts_and_expected_files, [ 0 ] ); | |
100 | |
101 stderr_should_have($script_name,'--translation_table 1 -o some_different_output --core_definition 60 -p 2 -e --mafft --group_limit 10 t/data/real_data_1.gff t/data/real_data_2.gff', 'Exiting early because number of clusters is too high'); | |
102 stderr_should_have($script_name,'--verbose_stats --group_limit 10 -e t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff', 'Exiting early because number of clusters is too high'); | |
103 stderr_should_not_have($script_name,'-e --group_limit 10 t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff ', 'Cant access the multifasta base directory'); | |
104 stderr_should_have($script_name,'-i 90 --core_definition 60 -p 2 -v t/data/real_data_1.gff t/data/real_data_2.gff ','Cleaning up files'); | |
105 stderr_should_have($script_name,'-i 30 t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff','The percentage identity is too low'); | |
106 stderr_should_not_have($script_name,'--dont_delete_files -v t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff ','Cleaning up files'); | |
107 stderr_should_have($script_name,'-v --group_limit 100000 -e t/data/query_1.gff t/data/query_2.gff t/data/query_5.gff ' ,'Running command: pan_genome_core_alignment'); | |
108 stderr_should_have($script_name,'--translation_table 1 -v t/data/real_data_1.gff t/data/real_data_2.gff ' ,'Cleaning up files'); | |
109 stderr_should_have($script_name,'-e -v t/data/real_data_1.gff t/data/real_data_2.gff ','Creating files with the nucleotide sequences for every cluster'); | |
110 | |
111 SKIP: | |
112 { | |
113 skip "kraken not installed", 2 unless ( which('kraken') ); | |
114 skip "kraken-report not installed", 2 unless ( which('kraken-report') ); | |
115 stderr_should_have($script_name,'-v --qc t/data/real_data_1.gff t/data/real_data_2.gff' ,'Running Kraken on each input assembly'); | |
116 } | |
117 | |
118 %scripts_and_expected_files = ( | |
119 # output | |
120 '-o some_different_output -e --dont_delete_files t/data/real_data_1.gff t/data/real_data_2.gff' => | |
121 [ 'pan_genome_sequences/mdoH.fa.aln', 't/data/mdoH.fa.aln' ], | |
122 '-o some_different_output --core_definition 60 t/data/real_data_1.gff t/data/real_data_2.gff' => | |
123 [ 'summary_statistics.txt', 't/data/expected_core_60_summary_statistics.txt' ], | |
124 '-e -i 95.3 --translation_table 1 -v --group_limit 100000 --qc t/data/real_data_1.gff t/data/real_data_2.gff' => [ 'core_gene_alignment.aln', 't/data/expected_real_data_core_gene_alignment.aln' ], | |
125 | |
126 '-e --verbose_stats t/data/real_data_1.gff t/data/real_data_2.gff' => [ 'core_gene_alignment.aln', 't/data/expected_real_data_core_gene_alignment.aln' ], | |
127 '--core_definition 60 t/data/real_data_1.gff t/data/real_data_2.gff' => [ 'summary_statistics.txt', 't/data/expected_core_60_summary_statistics.txt' ], | |
128 '-p 2 -e --dont_delete_files t/data/real_data_1.gff t/data/real_data_2.gff' => [ 'pan_genome_sequences/mdoH.fa.aln', 't/data/mdoH.fa.aln' ], | |
129 '-p 2 --core_definition 60 t/data/real_data_1.gff t/data/real_data_2.gff' => [ 'summary_statistics.txt', 't/data/expected_core_60_summary_statistics.txt' ], | |
130 '-p 2 -e --mafft t/data/real_data_1.gff t/data/real_data_2.gff' => [ 'core_gene_alignment.aln', 't/data/expected_mafft_real_data_core_gene_alignment.aln' ], | |
131 | |
132 ); | |
133 mock_execute_script_and_check_output_sorted( $script_name, \%scripts_and_expected_files ); | |
134 | |
135 } | |
136 | |
137 cleanup_files(); | |
138 | |
139 done_testing(); | |
140 | |
141 sub cleanup_files { | |
142 remove_tree('pan_genome_sequences'); | |
143 remove_tree('fixed_input_files'); | |
144 remove_tree('t/data/directory_which_doesnt_exist'); | |
145 remove_tree('locus_tags_gffs_output'); | |
146 unlink('_blast_results'); | |
147 unlink('_clustered'); | |
148 unlink('_clustered.bak.clstr'); | |
149 unlink('_clustered.clstr'); | |
150 unlink('_combined_files'); | |
151 unlink('_combined_files.groups'); | |
152 unlink('_fasta_files'); | |
153 unlink('_gff_files'); | |
154 unlink('_inflated_mcl_groups'); | |
155 unlink('_inflated_unsplit_mcl_groups'); | |
156 unlink('_labeled_mcl_groups'); | |
157 unlink('_uninflated_mcl_groups'); | |
158 unlink('accessory.header.embl'); | |
159 unlink('accessory.header.tab'); | |
160 unlink('accessory.tab'); | |
161 unlink('blast_identity_frequency.Rtab'); | |
162 unlink('clustered_proteins'); | |
163 unlink('core_accessory.header.embl'); | |
164 unlink('core_accessory.header.tab'); | |
165 unlink('core_accessory.tab'); | |
166 unlink('core_gene_alignment.aln'); | |
167 unlink('database_masking.asnb'); | |
168 unlink('example_1.faa.tmp.filtered.fa'); | |
169 unlink('example_2.faa.tmp.filtered.fa'); | |
170 unlink('example_3.faa.tmp.filtered.fa'); | |
171 unlink('gene_presence_absence.csv'); | |
172 unlink('number_of_conserved_genes.Rtab'); | |
173 unlink('number_of_genes_in_pan_genome.Rtab'); | |
174 unlink('number_of_new_genes.Rtab'); | |
175 unlink('number_of_unique_genes.Rtab'); | |
176 unlink('pan_genome.fa'); | |
177 unlink('query_1.gff.proteome.faa'); | |
178 unlink('query_2.gff.proteome.faa'); | |
179 unlink('query_3.gff.proteome.faa'); | |
180 unlink('query_5.gff.proteome.faa'); | |
181 unlink('real_data_1.gff.proteome.faa'); | |
182 unlink('real_data_2.gff.proteome.faa'); | |
183 unlink('pan_genome_reference.fa'); | |
184 unlink('accessory_graph.dot'); | |
185 unlink('core_accessory_graph.dot'); | |
186 unlink('some_different_output'); | |
187 unlink('core_alignment_header.embl'); | |
188 } |