Filename | /Users/ap13/pathogens/Roary/lib/Bio/Roary/AnalyseGroups.pm |
Statements | Executed 2572935 statements in 4.71s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
72819 | 3 | 2 | 3.63s | 5.15s | _count_num_files_in_group | Bio::Roary::AnalyseGroups::
149260 | 6 | 1 | 959ms | 959ms | CORE:readline (opcode) | Bio::Roary::AnalyseGroups::
2 | 1 | 1 | 543ms | 3.18s | _builder__freq_groups_per_genome | Bio::Roary::AnalyseGroups::
2 | 1 | 1 | 389ms | 1.32s | _builder__files_to_genes | Bio::Roary::AnalyseGroups::
2 | 1 | 1 | 389ms | 460ms | _builder__groups_to_genes | Bio::Roary::AnalyseGroups::
36389 | 1 | 1 | 94.6ms | 94.6ms | CORE:subst (opcode) | Bio::Roary::AnalyseGroups::
36389 | 1 | 1 | 49.5ms | 49.5ms | CORE:match (opcode) | Bio::Roary::AnalyseGroups::
20 | 3 | 1 | 23.5ms | 23.5ms | CORE:open (opcode) | Bio::Roary::AnalyseGroups::
2 | 1 | 1 | 830µs | 830µs | CORE:sort (opcode) | Bio::Roary::AnalyseGroups::
18 | 2 | 1 | 821µs | 821µs | CORE:close (opcode) | Bio::Roary::AnalyseGroups::
2 | 1 | 1 | 84µs | 4.96s | BUILD | Bio::Roary::AnalyseGroups::
1 | 1 | 1 | 47µs | 4.30ms | BEGIN@19 | Bio::Roary::AnalyseGroups::
2 | 1 | 1 | 14µs | 28µs | _builder__number_of_isolates | Bio::Roary::AnalyseGroups::
1 | 1 | 1 | 10µs | 96µs | BEGIN@142 | Bio::Roary::AnalyseGroups::
1 | 1 | 1 | 8µs | 8µs | BEGIN@20 | Bio::Roary::AnalyseGroups::
0 | 0 | 0 | 0s | 0s | _builder__groups | Bio::Roary::AnalyseGroups::
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 # 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 # 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 | ||||
38 | 2 | 2µs | my ($self) = @_; | ||
39 | # This triggers _genes_to_groups to be built | ||||
40 | 2 | 31µs | 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 | 24µs | 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 | 38µs | 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 | ||||
54 | 2 | 2µs | my ($self) = @_; | ||
55 | 2 | 17µs | 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 | ||||
59 | 2 | 2µs | my ($self) = @_; | ||
60 | 2 | 500ns | my %files_to_genes; | ||
61 | 2 | 200ns | my %genes_to_file; | ||
62 | 2 | 23µs | 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 | 24.6ms | 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 | 712ms | 16 | 711ms | while (<$fh>) { # spent 711ms making 16 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 44.5ms/call |
65 | 76462 | 12.3ms | chomp; | ||
66 | 76462 | 12.1ms | my $gene_name = $_; | ||
67 | 76462 | 8.63ms | next if($gene_name eq ""); | ||
68 | 76462 | 62.0ms | push( @{ $files_to_genes{$filename} }, $gene_name ); | ||
69 | 76462 | 440ms | 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 | 1.40ms | 16 | 797µs | close($fh); # spent 797µs making 16 calls to Bio::Roary::AnalyseGroups::CORE:close, avg 50µs/call |
72 | } | ||||
73 | 2 | 35µs | 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 | 2 | 47µs | 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 | ||||
79 | 72819 | 29.4ms | my ( $self, $genes ) = @_; | ||
80 | 72819 | 9.69ms | my $count = 0; | ||
81 | 72819 | 3.63ms | my %filename_freq; | ||
82 | 72819 | 51.3ms | for my $gene ( @{$genes} ) { | ||
83 | 577168 | 70.1ms | next if ( $gene eq "" ); | ||
84 | 577168 | 1.92s | 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 | 72819 | 154ms | my @uniq_filenames = keys %filename_freq; | ||
89 | 72819 | 212ms | 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 | ||||
93 | 2 | 5µs | my ($self) = @_; | ||
94 | 2 | 800ns | my %groups_to_genes; | ||
95 | 2 | 200ns | my %genes_to_groups; | ||
96 | |||||
97 | 2 | 138µs | 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.81ms | 2 | 1.78ms | while (<$fh>) { # spent 1.78ms making 2 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 888µs/call |
100 | 36389 | 4.42ms | chomp; | ||
101 | 36389 | 4.86ms | my $line = $_; | ||
102 | 36389 | 177ms | 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 | 18215 | 9.79ms | my $group_name = $1; | ||
104 | 18215 | 4.50ms | my $genes = $2; | ||
105 | 18215 | 87.2ms | my @elements = split( /[\s\t]+/, $genes ); | ||
106 | 18215 | 14.0ms | $groups_to_genes{$group_name} = \@elements; | ||
107 | |||||
108 | 18215 | 9.55ms | for my $gene (@elements) { | ||
109 | 144292 | 88.7ms | $genes_to_groups{$gene} = $group_name; | ||
110 | } | ||||
111 | } | ||||
112 | } | ||||
113 | 2 | 19µs | 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 | 2 | 66µs | 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 | ||||
119 | 2 | 2µs | my ($self) = @_; | ||
120 | 2 | 1µs | my @group_count; | ||
121 | |||||
122 | 2 | 172µs | 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 | 35µs | 2 | 23µs | while (<$fh>) { # spent 23µs making 2 calls to Bio::Roary::AnalyseGroups::CORE:readline, avg 11µs/call |
125 | 36389 | 5.94ms | chomp; | ||
126 | 36389 | 8.05ms | my $line = $_; | ||
127 | |||||
128 | #Ā Remove the group name | ||||
129 | 36389 | 149ms | 36389 | 94.6ms | $line =~ s!^(.+: )?!!; # spent 94.6ms making 36389 calls to Bio::Roary::AnalyseGroups::CORE:subst, avg 3µs/call |
130 | 36389 | 161ms | my @elements = split( /[\s\t]+/, $line ); | ||
131 | 36389 | 50.4ms | 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 | 53.3ms | 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 | 142ms | 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 | 52µs | 2 | 24µs | close($fh); # spent 24µs making 2 calls to Bio::Roary::AnalyseGroups::CORE:close, avg 12µs/call |
137 | 2 | 4.27ms | 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 | 2 | 681µs | 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 # 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 | |||||
# 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 | |||||
# 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 | |||||
# 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 | |||||
# 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 | |||||
# 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 |