← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:45:42 2015

Filename/Users/ap13/pathogens/Roary/lib/Bio/Roary/AnalyseGroups.pm
StatementsExecuted 2572935 statements in 4.71s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
72819323.63s5.15sBio::Roary::AnalyseGroups::::_count_num_files_in_groupBio::Roary::AnalyseGroups::_count_num_files_in_group
14926061959ms959msBio::Roary::AnalyseGroups::::CORE:readlineBio::Roary::AnalyseGroups::CORE:readline (opcode)
211543ms3.18sBio::Roary::AnalyseGroups::::_builder__freq_groups_per_genomeBio::Roary::AnalyseGroups::_builder__freq_groups_per_genome
211389ms1.32sBio::Roary::AnalyseGroups::::_builder__files_to_genesBio::Roary::AnalyseGroups::_builder__files_to_genes
211389ms460msBio::Roary::AnalyseGroups::::_builder__groups_to_genesBio::Roary::AnalyseGroups::_builder__groups_to_genes
363891194.6ms94.6msBio::Roary::AnalyseGroups::::CORE:substBio::Roary::AnalyseGroups::CORE:subst (opcode)
363891149.5ms49.5msBio::Roary::AnalyseGroups::::CORE:matchBio::Roary::AnalyseGroups::CORE:match (opcode)
203123.5ms23.5msBio::Roary::AnalyseGroups::::CORE:openBio::Roary::AnalyseGroups::CORE:open (opcode)
211830µs830µsBio::Roary::AnalyseGroups::::CORE:sortBio::Roary::AnalyseGroups::CORE:sort (opcode)
1821821µs821µsBio::Roary::AnalyseGroups::::CORE:closeBio::Roary::AnalyseGroups::CORE:close (opcode)
21184µs4.96sBio::Roary::AnalyseGroups::::BUILDBio::Roary::AnalyseGroups::BUILD
11147µs4.30msBio::Roary::AnalyseGroups::::BEGIN@19Bio::Roary::AnalyseGroups::BEGIN@19
21114µs28µsBio::Roary::AnalyseGroups::::_builder__number_of_isolatesBio::Roary::AnalyseGroups::_builder__number_of_isolates
11110µs96µsBio::Roary::AnalyseGroups::::BEGIN@142Bio::Roary::AnalyseGroups::BEGIN@142
1118µs8µsBio::Roary::AnalyseGroups::::BEGIN@20Bio::Roary::AnalyseGroups::BEGIN@20
0000s0sBio::Roary::AnalyseGroups::::_builder__groupsBio::Roary::AnalyseGroups::_builder__groups
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Bio::Roary::AnalyseGroups;
2
3# ABSTRACT: Take in a groups file and the original FASTA files and create plots and stats
4
5=head1 SYNOPSIS
6
7Take in a groups file and the original FASTA files and create plots and stats
8 use Bio::Roary::AnalyseGroups;
9
10 my $plot_groups_obj = Bio::Roary::AnalyseGroups->new(
11 fasta_files => $fasta_files,
12 groups_filename => $groups_filename,
13 output_filename => $output_filename
14 );
15 $plot_groups_obj->create_plots();
16
17=cut
18
19246µs28.56ms
# spent 4.30ms (47µs+4.26) within Bio::Roary::AnalyseGroups::BEGIN@19 which was called: # once (47µs+4.26ms) by Bio::Roary::PostAnalysis::BEGIN@14 at line 19
use Moose;
# spent 4.30ms making 1 call to Bio::Roary::AnalyseGroups::BEGIN@19 # spent 4.26ms making 1 call to Moose::import
202679µs18µs
# spent 8µs within Bio::Roary::AnalyseGroups::BEGIN@20 which was called: # once (8µs+0s) by Bio::Roary::PostAnalysis::BEGIN@14 at line 20
use Bio::Roary::Exceptions;
# spent 8µs making 1 call to Bio::Roary::AnalyseGroups::BEGIN@20
21
2212µs12.01mshas 'fasta_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
# spent 2.01ms making 1 call to Moose::has
2312µs11.88mshas 'groups_filename' => ( is => 'ro', isa => 'Str', required => 1 );
# spent 1.88ms making 1 call to Moose::has
2412µs11.51mshas 'output_filename' => ( is => 'ro', isa => 'Str', default => 'summary_of_groups' );
# spent 1.51ms making 1 call to Moose::has
25
2612µs11.95mshas '_number_of_isolates' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_builder__number_of_isolates' );
# spent 1.95ms making 1 call to Moose::has
2712µs11.80mshas '_genes_to_file' => ( is => 'rw', isa => 'HashRef' );
# spent 1.80ms making 1 call to Moose::has
2812µs11.92mshas '_files_to_genes' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_builder__files_to_genes' );
# spent 1.92ms making 1 call to Moose::has
2912µs11.92mshas '_freq_groups_per_genome' =>
# spent 1.92ms making 1 call to Moose::has
30 ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_builder__freq_groups_per_genome' );
3112µs11.92mshas '_groups_to_genes' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_builder__groups_to_genes' );
# spent 1.92ms making 1 call to Moose::has
3212µs11.97mshas '_genes_to_groups' => ( is => 'rw', isa => 'HashRef' );
# spent 1.97ms making 1 call to Moose::has
33
3413µs12.23mshas '_groups' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_builder__groups' );
# spent 2.23ms making 1 call to Moose::has
35
36
37
# spent 4.96s (84µs+4.96) within Bio::Roary::AnalyseGroups::BUILD which was called 2 times, avg 2.48s/call: # 2 times (84µs+4.96s) by Bio::Roary::AnalyseGroups::new at line 120 of (eval 25)[Eval/Closure.pm:125], avg 2.48s/call
sub BUILD {
38895µs my ($self) = @_;
39 # This triggers _genes_to_groups to be built
402460ms $self->_groups_to_genes;
# spent 460ms making 2 calls to Bio::Roary::AnalyseGroups::_groups_to_genes, avg 230ms/call
41 # This triggers _genes_to_file to be built
4221.32s $self->_files_to_genes;
# spent 1.32s making 2 calls to Bio::Roary::AnalyseGroups::_files_to_genes, avg 659ms/call
4323.18s $self->_freq_groups_per_genome;
# spent 3.18s making 2 calls to Bio::Roary::AnalyseGroups::_freq_groups_per_genome, avg 1.59s/call
44}
45
46sub _builder__groups
47{
48 my ($self) = @_;
49 my @groups = sort keys %{$self->_groups_to_genes};
50 return \@groups;
51}
52
53
# spent 28µs (14+14) within Bio::Roary::AnalyseGroups::_builder__number_of_isolates which was called 2 times, avg 14µs/call: # 2 times (14µs+14µs) by Bio::Roary::AnalyseGroups::_number_of_isolates at line 12 of (eval 25)[Eval/Closure.pm:125], avg 14µs/call
sub _builder__number_of_isolates {
54419µs my ($self) = @_;
55214µs return @{ $self->fasta_files };
# spent 14µs making 2 calls to Bio::Roary::AnalyseGroups::fasta_files, avg 7µs/call
56}
57
58
# spent 1.32s (389ms+928ms) within Bio::Roary::AnalyseGroups::_builder__files_to_genes which was called 2 times, avg 659ms/call: # 2 times (389ms+928ms) by Bio::Roary::AnalyseGroups::_files_to_genes at line 12 of (eval 25)[Eval/Closure.pm:125], avg 659ms/call
sub _builder__files_to_genes {
5912108µs my ($self) = @_;
60 my %files_to_genes;
61 my %genes_to_file;
62223µs for my $filename ( @{ $self->fasta_files } ) {
# spent 23µs making 2 calls to Bio::Roary::AnalyseGroups::fasta_files, avg 12µs/call
6348738ms1623.3ms open( my $fh, '-|', 'grep \> ' . $filename . ' | awk \'{print $1}\' | sed \'s/>//\' ' );
# spent 23.3ms making 16 calls to Bio::Roary::AnalyseGroups::CORE:open, avg 1.46ms/call
6416711ms while (<$fh>) {
# spent 711ms making 16 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 44.5ms/call
65382310535ms chomp;
66 my $gene_name = $_;
67 next if($gene_name eq "");
68 push( @{ $files_to_genes{$filename} }, $gene_name );
6976462192ms $genes_to_file{$gene_name} = $filename;
# spent 192ms making 76462 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 3µs/call
70 }
7116797µs close($fh);
# spent 797µs making 16 calls to Bio::Roary::AnalyseGroups::CORE:close, avg 50µs/call
72 }
73255µs $self->_genes_to_file(\%genes_to_file);
# spent 55µs making 2 calls to Bio::Roary::AnalyseGroups::_genes_to_file, avg 28µs/call
74
75 return \%files_to_genes;
76}
77
78
# spent 5.15s (3.63+1.52) within Bio::Roary::AnalyseGroups::_count_num_files_in_group which was called 72819 times, avg 71µs/call: # 36389 times (1.70s+738ms) by Bio::Roary::AnalyseGroups::_builder__freq_groups_per_genome at line 131, avg 67µs/call # 18215 times (1.01s+403ms) by Bio::Roary::GroupStatistics::_row at line 131 of lib/Bio/Roary/GroupStatistics.pm, avg 78µs/call # 18215 times (917ms+376ms) by Bio::Roary::GroupStatistics::create_spreadsheet at line 192 of lib/Bio/Roary/GroupStatistics.pm, avg 71µs/call
sub _count_num_files_in_group {
79436914461ms my ( $self, $genes ) = @_;
80 my $count = 0;
81 my %filename_freq;
82 for my $gene ( @{$genes} ) {
8311543361.99s next if ( $gene eq "" );
8411543361.52s if ( defined( $self->_genes_to_file->{$gene} ) ) {
# spent 1.52s making 1154336 calls to Bio::Roary::AnalyseGroups::_genes_to_file, avg 1µs/call
85 $filename_freq{ $self->_genes_to_file->{$gene} }++;
86 }
87 }
88 my @uniq_filenames = keys %filename_freq;
89 return @uniq_filenames;
90}
91
92
# spent 460ms (389+71.5) within Bio::Roary::AnalyseGroups::_builder__groups_to_genes which was called 2 times, avg 230ms/call: # 2 times (389ms+71.5ms) by Bio::Roary::AnalyseGroups::_groups_to_genes at line 12 of (eval 25)[Eval/Closure.pm:125], avg 230ms/call
sub _builder__groups_to_genes {
93142.04ms my ($self) = @_;
94 my %groups_to_genes;
95 my %genes_to_groups;
96
974108µs open( my $fh, $self->groups_filename )
# spent 88µs making 2 calls to Bio::Roary::AnalyseGroups::CORE:open, avg 44µs/call # spent 20µs making 2 calls to Bio::Roary::AnalyseGroups::groups_filename, avg 10µs/call
98 or Bio::Roary::Exceptions::FileNotFound->throw( error => "Group file not found:" . $self->groups_filename );
9921.78ms while (<$fh>) {
# spent 1.78ms making 2 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 888µs/call
100109167186ms chomp;
101 my $line = $_;
10291075125ms7277869.6ms if ( $line =~ /^(.+): (.+)$/ ) {
# spent 49.5ms making 36389 calls to Bio::Roary::AnalyseGroups::CORE:match, avg 1µs/call # spent 20.1ms making 36389 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 551ns/call
103 my $group_name = $1;
104 my $genes = $2;
105 my @elements = split( /[\s\t]+/, $genes );
106 $groups_to_genes{$group_name} = \@elements;
107
108 for my $gene (@elements) {
10914429288.7ms $genes_to_groups{$gene} = $group_name;
110 }
111 }
112 }
113238µs $self->_genes_to_groups(\%genes_to_groups);
# spent 38µs making 2 calls to Bio::Roary::AnalyseGroups::_genes_to_groups, avg 19µs/call
114
115 return \%groups_to_genes;
116}
117
118
# spent 3.18s (543ms+2.64) within Bio::Roary::AnalyseGroups::_builder__freq_groups_per_genome which was called 2 times, avg 1.59s/call: # 2 times (543ms+2.64s) by Bio::Roary::AnalyseGroups::_freq_groups_per_genome at line 12 of (eval 25)[Eval/Closure.pm:125], avg 1.59s/call
sub _builder__freq_groups_per_genome {
119145.21ms my ($self) = @_;
120 my @group_count;
121
1224154µs open( my $fh, $self->groups_filename )
# spent 130µs making 2 calls to Bio::Roary::AnalyseGroups::CORE:open, avg 65µs/call # spent 24µs making 2 calls to Bio::Roary::AnalyseGroups::groups_filename, avg 12µs/call
123 or Bio::Roary::Exceptions::FileNotFound->throw( error => "Group file not found:" . $self->groups_filename );
124223µs while (<$fh>) {
# spent 23µs making 2 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 11µs/call
125254723570ms chomp;
126 my $line = $_;
127
128 #Ā Remove the group name
1293638994.6ms $line =~ s!^(.+: )?!!;
# spent 94.6ms making 36389 calls to Bio::Roary::AnalyseGroups::CORE:subst, avg 3µs/call
130 my @elements = split( /[\s\t]+/, $line );
131363892.44s my $number_of_files_in_group = $self->_count_num_files_in_group( \@elements );
# spent 2.44s making 36389 calls to Bio::Roary::AnalyseGroups::_count_num_files_in_group, avg 67µs/call
1323638968.3ms $number_of_files_in_group = ( $number_of_files_in_group * 100 / $self->_number_of_isolates );
# spent 68.3ms making 36389 calls to Bio::Roary::AnalyseGroups::_number_of_isolates, avg 2µs/call
1333638933.3ms push( @group_count, $number_of_files_in_group );
# spent 33.3ms making 36389 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 915ns/call
134
135 }
136224µs close($fh);
# spent 24µs making 2 calls to Bio::Roary::AnalyseGroups::CORE:close, avg 12µs/call
1372830µs my @sorted_group_count = sort { $b <=> $a } @group_count;
# spent 830µs making 2 calls to Bio::Roary::AnalyseGroups::CORE:sort, avg 415µs/call
138 return \@sorted_group_count;
139}
140
141
142250µs2183µs
# spent 96µs (10+86) within Bio::Roary::AnalyseGroups::BEGIN@142 which was called: # once (10µs+86µs) by Bio::Roary::PostAnalysis::BEGIN@14 at line 142
no Moose;
# spent 96µs making 1 call to Bio::Roary::AnalyseGroups::BEGIN@142 # spent 86µs making 1 call to Moose::unimport
14317µs26.05ms__PACKAGE__->meta->make_immutable;
# spent 6.03ms making 1 call to Class::MOP::Class::make_immutable # spent 20µs making 1 call to Bio::Roary::AnalyseGroups::meta
144
145146µs1;
146
 
# spent 821µs within Bio::Roary::AnalyseGroups::CORE:close which was called 18 times, avg 46µs/call: # 16 times (797µs+0s) by Bio::Roary::AnalyseGroups::_builder__files_to_genes at line 71, avg 50µs/call # 2 times (24µs+0s) by Bio::Roary::AnalyseGroups::_builder__freq_groups_per_genome at line 136, avg 12µs/call
sub Bio::Roary::AnalyseGroups::CORE:close; # opcode
# spent 49.5ms within Bio::Roary::AnalyseGroups::CORE:match which was called 36389 times, avg 1µs/call: # 36389 times (49.5ms+0s) by Bio::Roary::AnalyseGroups::_builder__groups_to_genes at line 102, avg 1µs/call
sub Bio::Roary::AnalyseGroups::CORE:match; # opcode
# spent 23.5ms within Bio::Roary::AnalyseGroups::CORE:open which was called 20 times, avg 1.18ms/call: # 16 times (23.3ms+0s) by Bio::Roary::AnalyseGroups::_builder__files_to_genes at line 63, avg 1.46ms/call # 2 times (130µs+0s) by Bio::Roary::AnalyseGroups::_builder__freq_groups_per_genome at line 122, avg 65µs/call # 2 times (88µs+0s) by Bio::Roary::AnalyseGroups::_builder__groups_to_genes at line 97, avg 44µs/call
sub Bio::Roary::AnalyseGroups::CORE:open; # opcode
# spent 959ms within Bio::Roary::AnalyseGroups::CORE:readline which was called 149260 times, avg 6µs/call: # 76462 times (192ms+0s) by Bio::Roary::AnalyseGroups::_builder__files_to_genes at line 69, avg 3µs/call # 36389 times (33.3ms+0s) by Bio::Roary::AnalyseGroups::_builder__freq_groups_per_genome at line 133, avg 915ns/call # 36389 times (20.1ms+0s) by Bio::Roary::AnalyseGroups::_builder__groups_to_genes at line 102, avg 551ns/call # 16 times (711ms+0s) by Bio::Roary::AnalyseGroups::_builder__files_to_genes at line 64, avg 44.5ms/call # 2 times (1.78ms+0s) by Bio::Roary::AnalyseGroups::_builder__groups_to_genes at line 99, avg 888µs/call # 2 times (23µs+0s) by Bio::Roary::AnalyseGroups::_builder__freq_groups_per_genome at line 124, avg 11µs/call
sub Bio::Roary::AnalyseGroups::CORE:readline; # opcode
# spent 830µs within Bio::Roary::AnalyseGroups::CORE:sort which was called 2 times, avg 415µs/call: # 2 times (830µs+0s) by Bio::Roary::AnalyseGroups::_builder__freq_groups_per_genome at line 137, avg 415µs/call
sub Bio::Roary::AnalyseGroups::CORE:sort; # opcode
# spent 94.6ms within Bio::Roary::AnalyseGroups::CORE:subst which was called 36389 times, avg 3µs/call: # 36389 times (94.6ms+0s) by Bio::Roary::AnalyseGroups::_builder__freq_groups_per_genome at line 129, avg 3µs/call
sub Bio::Roary::AnalyseGroups::CORE:subst; # opcode