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.11.0';
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   631 use Moose;
  3         6  
  3         20  
8 3     3   17638 use File::Path qw(make_path);
  3         5  
  3         182  
9 3     3   48 use Bio::Roary::Exceptions;
  3         7  
  3         64  
10 3     3   14 use Bio::Roary::AnalyseGroups;
  3         6  
  3         69  
11 3     3   826 use Bio::Roary::Output::GroupsMultifastaNucleotide;
  3         7  
  3         885  
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         24 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         32 my $num_groups = $self->_number_of_groups;
40 1         26 my $limit = $self->group_limit;
41 1 50       10 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         27 make_path($self->output_directory);
47 1         6 unlink('pan_genome_reference.fa');
48            
49 1         2 my $number_of_gff_files = @{$self->gff_files};
  1         30  
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         1 for my $gff_file ( @{ $self->gff_files } )
  1         22  
53             {
54 1         25 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         8 $gff_multifasta->populate_files;
66             }
67 0           1;
68             }
69              
70 3     3   28 no Moose;
  3         6  
  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.11.0
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