File Coverage

lib/Bio/Roary/Output/GroupsMultifastasNucleotide.pm
Criterion Covered Total %
statement 36 39 92.3
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod 0 1 0.0
total 46 51 90.2


line stmt bran cond sub pod time code
1              
2             package Bio::Roary::Output::GroupsMultifastasNucleotide;
3             $Bio::Roary::Output::GroupsMultifastasNucleotide::VERSION = '3.10.1';
4             # ABSTRACT: Take in a set of GFF files and a groups file and output one multifasta file per group with nucleotide sequences.
5              
6              
7 3     3   630 use Moose;
  3         6  
  3         25  
8 3     3   22831 use File::Path qw(make_path);
  3         12  
  3         258  
9 3     3   23 use Bio::Roary::Exceptions;
  3         7  
  3         67  
10 3     3   15 use Bio::Roary::AnalyseGroups;
  3         7  
  3         90  
11 3     3   1372 use Bio::Roary::Output::GroupsMultifastaNucleotide;
  3         11  
  3         1109  
12              
13             has 'gff_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
14             has 'group_names' => ( is => 'ro', isa => 'ArrayRef', required => 0 );
15             has 'annotate_groups' => ( is => 'ro', isa => 'Bio::Roary::AnnotateGroups', required => 1 );
16             has 'output_multifasta_files' => ( is => 'ro', isa => 'Bool', default => 0 );
17             has 'core_definition' => ( is => 'ro', isa => 'Num', default => 1.0 );
18             has 'dont_delete_files' => ( is => 'ro', isa => 'Bool', default => 0 );
19             has 'output_directory' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_output_directory');
20             has '_number_of_groups' => ( is => 'rw', isa => 'Num', lazy => 1, builder => '_build__number_of_groups' );
21             has 'group_limit' => ( is => 'rw', isa => 'Num', default => 50000 );
22              
23             sub _build_output_directory
24             {
25 1     1   2 my ($self) = @_;
26 1         2 my $output_directory = 'pan_genome_sequences';
27 1         435 return $output_directory;
28             }
29              
30             sub _build__number_of_groups {
31 1     1   2 my $self = shift;
32              
33 1         26 return $self->annotate_groups->_group_counter;
34             }
35              
36             sub create_files {
37 1     1 0 3 my ($self) = @_;
38              
39 1         43 my $num_groups = $self->_number_of_groups;
40 1         29 my $limit = $self->group_limit;
41 1 50       3 if ( $num_groups > $limit ){
42 0         0 print STDERR "Number of clusters ($num_groups) exceeds limit ($limit). Multifastas not created. Please check the spreadsheet for contamination from different species or increase the --group_limit parameter.\n";
43 0         0 return 0;
44             }
45              
46 1         25 make_path($self->output_directory);
47 1         7 unlink('pan_genome_reference.fa');
48            
49 1         2 my $number_of_gff_files = @{$self->gff_files};
  1         31  
50 1         2 my %pan_reference_groups_seen;
51             # if its output_multifasta_files == false then you want to create the core genome and delete all intermediate multifasta files
52 1         2 for my $gff_file ( @{ $self->gff_files } )
  1         22  
53             {
54 1         29 my $gff_multifasta = Bio::Roary::Output::GroupsMultifastaNucleotide->new(
55             gff_file => $gff_file,
56             group_names => $self->group_names,
57             output_directory => $self->output_directory,
58             annotate_groups => $self->annotate_groups,
59             output_multifasta_files => $self->output_multifasta_files,
60             pan_reference_groups_seen => \%pan_reference_groups_seen,
61             core_definition => $self->core_definition,
62             dont_delete_files => $self->dont_delete_files,
63             number_of_gff_files => $number_of_gff_files
64             );
65 1         5 $gff_multifasta->populate_files;
66             }
67 0           1;
68             }
69              
70 3     3   30 no Moose;
  3         7  
  3         22  
71             __PACKAGE__->meta->make_immutable;
72              
73             1;
74              
75             __END__
76              
77             =pod
78              
79             =encoding UTF-8
80              
81             =head1 NAME
82              
83             Bio::Roary::Output::GroupsMultifastasNucleotide - Take in a set of GFF files and a groups file and output one multifasta file per group with nucleotide sequences.
84              
85             =head1 VERSION
86              
87             version 3.10.1
88              
89             =head1 SYNOPSIS
90              
91             Take in a set of GFF files and a groups file and output one multifasta file per group with nucleotide sequences.
92             use Bio::Roary::Output::GroupsMultifastasNucleotide;
93              
94             my $obj = Bio::Roary::Output::GroupsMultifastasNucleotide->new(
95             group_names => ['aaa','bbb'],
96             analyse_groups => $analyse_groups
97             );
98             $obj->create_files();
99              
100             =head1 AUTHOR
101              
102             Andrew J. Page <ap13@sanger.ac.uk>
103              
104             =head1 COPYRIGHT AND LICENSE
105              
106             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
107              
108             This is free software, licensed under:
109              
110             The GNU General Public License, Version 3, June 2007
111              
112             =cut