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