Profile of lib/Bio/Roary/AnalyseGroups.pm

← 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:27 2015

Filename | /Users/ap13/pathogens/Roary/lib/Bio/Roary/AnalyseGroups.pm
Statements | Executed 2572935 statements in 4.71s

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
72819 | 3 | 2 | 3.63s | 5.15s | Bio::Roary::AnalyseGroups::::_count_num_files_in_groupBio::Roary::AnalyseGroups::_count_num_files_in_group
149260 | 6 | 1 | 959ms | 959ms | Bio::Roary::AnalyseGroups::::CORE:readlineBio::Roary::AnalyseGroups::CORE:readline (opcode)
2 | 1 | 1 | 543ms | 3.18s | Bio::Roary::AnalyseGroups::::_builder__freq_groups_per_genomeBio::Roary::AnalyseGroups::_builder__freq_groups_per_genome
2 | 1 | 1 | 389ms | 1.32s | Bio::Roary::AnalyseGroups::::_builder__files_to_genesBio::Roary::AnalyseGroups::_builder__files_to_genes
2 | 1 | 1 | 389ms | 460ms | Bio::Roary::AnalyseGroups::::_builder__groups_to_genesBio::Roary::AnalyseGroups::_builder__groups_to_genes
36389 | 1 | 1 | 94.6ms | 94.6ms | Bio::Roary::AnalyseGroups::::CORE:substBio::Roary::AnalyseGroups::CORE:subst (opcode)
36389 | 1 | 1 | 49.5ms | 49.5ms | Bio::Roary::AnalyseGroups::::CORE:matchBio::Roary::AnalyseGroups::CORE:match (opcode)
20 | 3 | 1 | 23.5ms | 23.5ms | Bio::Roary::AnalyseGroups::::CORE:openBio::Roary::AnalyseGroups::CORE:open (opcode)
2 | 1 | 1 | 830µs | 830µs | Bio::Roary::AnalyseGroups::::CORE:sortBio::Roary::AnalyseGroups::CORE:sort (opcode)
18 | 2 | 1 | 821µs | 821µs | Bio::Roary::AnalyseGroups::::CORE:closeBio::Roary::AnalyseGroups::CORE:close (opcode)
2 | 1 | 1 | 84µs | 4.96s | Bio::Roary::AnalyseGroups::::BUILDBio::Roary::AnalyseGroups::BUILD
1 | 1 | 1 | 47µs | 4.30ms | Bio::Roary::AnalyseGroups::::BEGIN@19Bio::Roary::AnalyseGroups::BEGIN@19
2 | 1 | 1 | 14µs | 28µs | Bio::Roary::AnalyseGroups::::_builder__number_of_isolatesBio::Roary::AnalyseGroups::_builder__number_of_isolates
1 | 1 | 1 | 10µs | 96µs | Bio::Roary::AnalyseGroups::::BEGIN@142Bio::Roary::AnalyseGroups::BEGIN@142
1 | 1 | 1 | 8µs | 8µs | Bio::Roary::AnalyseGroups::::BEGIN@20Bio::Roary::AnalyseGroups::BEGIN@20
0 | 0 | 0 | 0s | 0s | Bio::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
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package 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 |  |  |  |  |
7 |  |  |  |  | Take 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 |  |  |  |  |
19 | 2 | 46µs | 2 | 8.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
20 | 2 | 679µs | 1 | 8µ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 |  |  |  |  |
22 | 1 | 2µs | 1 | 2.01ms | has 'fasta_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); # spent 2.01ms making 1 call to Moose::has
23 | 1 | 2µs | 1 | 1.88ms | has 'groups_filename' => ( is => 'ro', isa => 'Str', required => 1 ); # spent 1.88ms making 1 call to Moose::has
24 | 1 | 2µs | 1 | 1.51ms | has 'output_filename' => ( is => 'ro', isa => 'Str', default => 'summary_of_groups' ); # spent 1.51ms making 1 call to Moose::has
25 |  |  |  |  |
26 | 1 | 2µs | 1 | 1.95ms | has '_number_of_isolates' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_builder__number_of_isolates' ); # spent 1.95ms making 1 call to Moose::has
27 | 1 | 2µs | 1 | 1.80ms | has '_genes_to_file' => ( is => 'rw', isa => 'HashRef' ); # spent 1.80ms making 1 call to Moose::has
28 | 1 | 2µs | 1 | 1.92ms | has '_files_to_genes' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_builder__files_to_genes' ); # spent 1.92ms making 1 call to Moose::has
29 | 1 | 2µs | 1 | 1.92ms | has '_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' );
31 | 1 | 2µs | 1 | 1.92ms | has '_groups_to_genes' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_builder__groups_to_genes' ); # spent 1.92ms making 1 call to Moose::has
32 | 1 | 2µs | 1 | 1.97ms | has '_genes_to_groups' => ( is => 'rw', isa => 'HashRef' ); # spent 1.97ms making 1 call to Moose::has
33 |  |  |  |  |
34 | 1 | 3µs | 1 | 2.23ms | has '_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 {
38 | 8 | 95µs |  |  | my ($self) = @_;
39 |  |  |  |  | # This triggers _genes_to_groups to be built
40 |  |  | 2 | 460ms | $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
42 |  |  | 2 | 1.32s | $self->_files_to_genes; # spent 1.32s making 2 calls to Bio::Roary::AnalyseGroups::_files_to_genes, avg 659ms/call
43 |  |  | 2 | 3.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 |  |  |  |  |
46 |  |  |  |  | sub _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 {
54 | 4 | 19µs |  |  | my ($self) = @_;
55 |  |  | 2 | 14µ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 {
59 | 382370 | 1.27s |  |  | my ($self) = @_;
60 |  |  |  |  | my %files_to_genes;
61 |  |  |  |  | my %genes_to_file;
62 |  |  | 2 | 23µs | for my $filename ( @{ $self->fasta_files } ) { # spent 23µs making 2 calls to Bio::Roary::AnalyseGroups::fasta_files, avg 12µs/call
63 |  |  | 16 | 23.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
64 |  |  | 16 | 711ms | while (<$fh>) { # spent 711ms making 16 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 44.5ms/call
65 |  |  |  |  | chomp;
66 |  |  |  |  | my $gene_name = $_;
67 |  |  |  |  | next if($gene_name eq "");
68 |  |  |  |  | push( @{ $files_to_genes{$filename} }, $gene_name );
69 |  |  | 76462 | 192ms | $genes_to_file{$gene_name} = $filename; # spent 192ms making 76462 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 3µs/call
70 |  |  |  |  | }
71 |  |  | 16 | 797µs | close($fh); # spent 797µs making 16 calls to Bio::Roary::AnalyseGroups::CORE:close, avg 50µs/call
72 |  |  |  |  | }
73 |  |  | 2 | 55µ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 {
79 | 1591250 | 2.45s |  |  | my ( $self, $genes ) = @_;
80 |  |  |  |  | my $count = 0;
81 |  |  |  |  | my %filename_freq;
82 |  |  |  |  | for my $gene ( @{$genes} ) {
83 |  |  |  |  | next if ( $gene eq "" );
84 |  |  | 1154336 | 1.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 {
93 | 344548 | 402ms |  |  | my ($self) = @_;
94 |  |  |  |  | my %groups_to_genes;
95 |  |  |  |  | my %genes_to_groups;
96 |  |  |  |  |
97 |  |  | 4 | 108µ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 );
99 |  |  | 2 | 1.78ms | while (<$fh>) { # spent 1.78ms making 2 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 888µs/call
100 |  |  |  |  | chomp;
101 |  |  |  |  | my $line = $_;
102 |  |  | 72778 | 69.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) {
109 |  |  |  |  | $genes_to_groups{$gene} = $group_name;
110 |  |  |  |  | }
111 |  |  |  |  | }
112 |  |  |  |  | }
113 |  |  | 2 | 38µ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 {
119 | 254737 | 576ms |  |  | my ($self) = @_;
120 |  |  |  |  | my @group_count;
121 |  |  |  |  |
122 |  |  | 4 | 154µ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 );
124 |  |  | 2 | 23µs | while (<$fh>) { # spent 23µs making 2 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 11µs/call
125 |  |  |  |  | chomp;
126 |  |  |  |  | my $line = $_;
127 |  |  |  |  |
128 |  |  |  |  | #Ā Remove the group name
129 |  |  | 36389 | 94.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 );
131 |  |  | 36389 | 2.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
132 |  |  | 36389 | 68.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
133 |  |  | 36389 | 33.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 |  |  |  |  | }
136 |  |  | 2 | 24µs | close($fh); # spent 24µs making 2 calls to Bio::Roary::AnalyseGroups::CORE:close, avg 12µs/call
137 |  |  | 2 | 830µ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 |  |  |  |  |
142 | 2 | 50µs | 2 | 183µ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
143 | 1 | 7µs | 2 | 6.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 |  |  |  |  |
145 | 1 | 46µs |  |  | 1;
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