Profile of lib/Bio/Roary/InflateClusters.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:41 2015

Filename | /Users/ap13/pathogens/Roary/lib/Bio/Roary/InflateClusters.pm
Statements | Executed 42071 statements in 90.1ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 85.9ms | 172ms | Bio::Roary::InflateClusters::::inflateBio::Roary::InflateClusters::inflate
485 | 1 | 1 | 4.90ms | 37.0ms | Bio::Roary::InflateClusters::::_inflate_geneBio::Roary::InflateClusters::_inflate_gene
410 | 1 | 1 | 3.59ms | 40.6ms | Bio::Roary::InflateClusters::::_inflate_lineBio::Roary::InflateClusters::_inflate_line
1 | 1 | 1 | 136µs | 5.78ms | Bio::Roary::InflateClusters::::BEGIN@20Bio::Roary::InflateClusters::BEGIN@20
1 | 1 | 1 | 39µs | 4.17ms | Bio::Roary::InflateClusters::::BEGIN@19Bio::Roary::InflateClusters::BEGIN@19
1 | 1 | 1 | 33µs | 64µs | Bio::Roary::InflateClusters::::_build__mcl_fhBio::Roary::InflateClusters::_build__mcl_fh
1 | 1 | 1 | 19µs | 392µs | Bio::Roary::InflateClusters::::_build__output_fhBio::Roary::InflateClusters::_build__output_fh
1 | 1 | 1 | 11µs | 116µs | Bio::Roary::InflateClusters::::BEGIN@106Bio::Roary::InflateClusters::BEGIN@106

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::InflateClusters;
2 |  |  |  |  |
3 |  |  |  |  | # ABSTRACT: Take the clusters file from cd-hit and use it to inflate the output of MCL
4 |  |  |  |  |
5 |  |  |  |  | =head1 SYNOPSIS
6 |  |  |  |  |
7 |  |  |  |  | Take the clusters file from cd-hit and use it to inflate the output of MCL
8 |  |  |  |  | use Bio::Roary::InflateClusters;
9 |  |  |  |  |
10 |  |  |  |  | my $obj = Bio::Roary::InflateClusters->new(
11 |  |  |  |  | clusters_filename => 'example.clstr',
12 |  |  |  |  | mcl_filename => 'example.mcl',
13 |  |  |  |  | output_file => 'example.output'
14 |  |  |  |  | );
15 |  |  |  |  | $obj->inflate;
16 |  |  |  |  |
17 |  |  |  |  | =cut
18 |  |  |  |  |
19 | 2 | 46µs | 2 | 8.30ms | # spent 4.17ms (39µs+4.13) within Bio::Roary::InflateClusters::BEGIN@19 which was called: # once (39µs+4.13ms) by Bio::Roary::PostAnalysis::BEGIN@13 at line 19 use Moose; # spent 4.17ms making 1 call to Bio::Roary::InflateClusters::BEGIN@19 # spent 4.13ms making 1 call to Moose::import
20 | 2 | 618µs | 1 | 5.78ms | # spent 5.78ms (136µs+5.64) within Bio::Roary::InflateClusters::BEGIN@20 which was called: # once (136µs+5.64ms) by Bio::Roary::PostAnalysis::BEGIN@13 at line 20 use Bio::Roary::Exceptions; # spent 5.78ms making 1 call to Bio::Roary::InflateClusters::BEGIN@20
21 | 1 | 3µs | 1 | 20.8ms | with 'Bio::Roary::ClustersRole'; # spent 20.8ms making 1 call to Moose::with
22 |  |  |  |  |
23 | 1 | 3µs | 1 | 1.63ms | has 'mcl_filename' => ( is => 'ro', isa => 'Str', required => 1 ); # spent 1.63ms making 1 call to Moose::has
24 | 1 | 2µs | 1 | 1.60ms | has 'output_file' => ( is => 'ro', isa => 'Str', default => 'inflated_results' ); # spent 1.60ms making 1 call to Moose::has
25 | 1 | 2µs | 1 | 1.54ms | has '_mcl_fh' => ( is => 'ro',lazy => 1, builder => '_build__mcl_fh' ); # spent 1.54ms making 1 call to Moose::has
26 | 1 | 2µs | 1 | 1.52ms | has '_output_fh' => ( is => 'ro',lazy => 1, builder => '_build__output_fh' ); # spent 1.52ms making 1 call to Moose::has
27 | 1 | 2µs | 1 | 3.36ms | has 'cdhit_groups_filename' => ( is => 'ro', isa => 'Maybe[Str]' ); # spent 3.36ms making 1 call to Moose::has
28 |  |  |  |  |
29 |  |  |  |  | sub _build__output_fh
30 |  |  |  |  | # spent 392µs (19+373) within Bio::Roary::InflateClusters::_build__output_fh which was called: # once (19µs+373µs) by Bio::Roary::InflateClusters::_output_fh at line 11 of (eval 25)[Eval/Closure.pm:125] {
31 | 3 | 387µs |  |  | my($self) = @_;
32 |  |  | 2 | 373µs | open(my $fh, '>', $self->output_file) or Bio::Roary::Exceptions::CouldntWriteToFile->throw( error => 'Cant write to file: ' . $self->output_file ); # spent 369µs making 1 call to Bio::Roary::InflateClusters::CORE:open # spent 4µs making 1 call to Bio::Roary::InflateClusters::output_file
33 |  |  |  |  | return $fh;
34 |  |  |  |  | }
35 |  |  |  |  |
36 |  |  |  |  | sub _build__mcl_fh
37 |  |  |  |  | # spent 64µs (33+31) within Bio::Roary::InflateClusters::_build__mcl_fh which was called: # once (33µs+31µs) by Bio::Roary::InflateClusters::_mcl_fh at line 11 of (eval 25)[Eval/Closure.pm:125] {
38 | 3 | 57µs |  |  | my($self) = @_;
39 |  |  | 2 | 31µs | open(my $fh, $self->mcl_filename) or Bio::Roary::Exceptions::FileNotFound->throw( error => 'Cant open file: ' . $self->mcl_filename ); # spent 27µs making 1 call to Bio::Roary::InflateClusters::CORE:open # spent 5µs making 1 call to Bio::Roary::InflateClusters::mcl_filename
40 |  |  |  |  | return $fh;
41 |  |  |  |  | }
42 |  |  |  |  |
43 |  |  |  |  | sub _inflate_line
44 |  |  |  |  | # spent 40.6ms (3.59+37.0) within Bio::Roary::InflateClusters::_inflate_line which was called 410 times, avg 99µs/call: # 410 times (3.59ms+37.0ms) by Bio::Roary::InflateClusters::inflate at line 77, avg 99µs/call {
45 | 2460 | 2.16ms |  |  | my($self, $line) = @_;
46 |  |  |  |  | my @inflated_genes;
47 |  |  |  |  | chomp($line);
48 |  |  |  |  | my @gene_names = split(/[\t\s]+/, $line);
49 |  |  |  |  | for my $gene_name (@gene_names)
50 |  |  |  |  | {
51 | 485 | 896µs | 485 | 37.0ms | push(@inflated_genes, $self->_inflate_gene($gene_name)); # spent 37.0ms making 485 calls to Bio::Roary::InflateClusters::_inflate_gene, avg 76µs/call
52 |  |  |  |  | }
53 |  |  |  |  | return join(' ',@inflated_genes);
54 |  |  |  |  | }
55 |  |  |  |  |
56 |  |  |  |  | sub _inflate_gene
57 |  |  |  |  | # spent 37.0ms (4.90+32.1) within Bio::Roary::InflateClusters::_inflate_gene which was called 485 times, avg 76µs/call: # 485 times (4.90ms+32.1ms) by Bio::Roary::InflateClusters::_inflate_line at line 51, avg 76µs/call {
58 | 1940 | 2.05ms |  |  | my($self, $gene_name) = @_;
59 |  |  |  |  | my $inflated_gene = $gene_name;
60 | 648 | 1.77ms | 485 | 30.9ms | if(defined($self->_clustered_genes->{$gene_name})) # spent 30.9ms making 485 calls to Bio::Roary::InflateClusters::_clustered_genes, avg 64µs/call
61 |  |  |  |  | {
62 |  |  | 324 | 578µs | $inflated_gene = $inflated_gene."\t". join("\t",@{$self->_clustered_genes->{$gene_name}}); # spent 578µs making 324 calls to Bio::Roary::InflateClusters::_clustered_genes, avg 2µs/call
63 |  |  | 324 | 576µs | delete($self->_clustered_genes->{$gene_name}); # spent 576µs making 324 calls to Bio::Roary::InflateClusters::_clustered_genes, avg 2µs/call
64 |  |  |  |  | }
65 |  |  |  |  | return $inflated_gene;
66 |  |  |  |  | }
67 |  |  |  |  |
68 |  |  |  |  | sub inflate
69 |  |  |  |  | # spent 172ms (85.9+86.1) within Bio::Roary::InflateClusters::inflate which was called: # once (85.9ms+86.1ms) by Bio::Roary::PostAnalysis::run at line 64 of lib/Bio/Roary/PostAnalysis.pm {
70 | 7 | 390µs |  |  | my($self) = @_;
71 |  |  | 1 | 86µs | my $mcl_fh = $self->_mcl_fh; # spent 86µs making 1 call to Bio::Roary::InflateClusters::_mcl_fh
72 |  |  |  |  |
73 |  |  |  |  | # Inflate genes from cdhit which were sent to mcl
74 |  |  | 1 | 12µs | while(<$mcl_fh>) # spent 12µs making 1 call to Bio::Roary::InflateClusters::CORE:readline
75 |  |  |  |  | {
76 | 820 | 2.89ms |  |  | my $line = $_;
77 |  |  | 1640 | 42.3ms | print { $self->_output_fh } $self->_inflate_line($line) . "\n"; # spent 40.6ms making 410 calls to Bio::Roary::InflateClusters::_inflate_line, avg 99µs/call # spent 1.22ms making 410 calls to Bio::Roary::InflateClusters::_output_fh, avg 3µs/call # spent 322µs making 410 calls to Bio::Roary::InflateClusters::CORE:print, avg 785ns/call # spent 216µs making 410 calls to Bio::Roary::InflateClusters::CORE:readline, avg 528ns/call
78 |  |  |  |  | }
79 |  |  |  |  |
80 |  |  |  |  | #Â Inflate any clusters that were in the clusters file but not sent to mcl
81 |  |  | 1 | 3µs | for my $gene_name(keys %{$self->_clustered_genes}) # spent 3µs making 1 call to Bio::Roary::InflateClusters::_clustered_genes
82 |  |  |  |  | {
83 | 161 | 289µs | 161 | 340µs | next unless(defined($self->_clustered_genes->{$gene_name})); # spent 340µs making 161 calls to Bio::Roary::InflateClusters::_clustered_genes, avg 2µs/call
84 |  |  |  |  | print { $self->_output_fh } $gene_name."\t". join("\t",@{$self->_clustered_genes->{$gene_name}})."\n";
85 |  |  |  |  | }
86 |  |  |  |  |
87 | 2 | 99µs | 1 | 5µs | if(defined($self->cdhit_groups_filename)) # spent 5µs making 1 call to Bio::Roary::InflateClusters::cdhit_groups_filename
88 |  |  |  |  | {
89 |  |  |  |  | #Â Add clusters which were excluded because the groups were full at the cdhit stage
90 |  |  | 2 | 40µs | open(my $cdhit_fh, $self->cdhit_groups_filename) or Bio::Roary::Exceptions::FileNotFound->throw( error => "CD hit group file not found: " . $self->cdhit_groups_filename); # spent 38µs making 1 call to Bio::Roary::InflateClusters::CORE:open # spent 2µs making 1 call to Bio::Roary::InflateClusters::cdhit_groups_filename
91 |  |  | 1 | 19µs | while(<$cdhit_fh>) # spent 19µs making 1 call to Bio::Roary::InflateClusters::CORE:readline
92 |  |  |  |  | {
93 | 35528 | 78.4ms |  |  | my $line = $_;
94 |  |  |  |  |
95 |  |  | 53292 | 42.9ms | if(defined($line)) # spent 27.0ms making 17764 calls to Bio::Roary::InflateClusters::_output_fh, avg 2µs/call # spent 8.92ms making 17764 calls to Bio::Roary::InflateClusters::CORE:readline, avg 502ns/call # spent 7.03ms making 17764 calls to Bio::Roary::InflateClusters::CORE:print, avg 396ns/call
96 |  |  |  |  | {
97 |  |  |  |  | print { $self->_output_fh } $line ;
98 |  |  |  |  | }
99 |  |  |  |  | }
100 |  |  |  |  | }
101 |  |  |  |  |
102 |  |  | 2 | 292µs | close($self->_output_fh); # spent 290µs making 1 call to Bio::Roary::InflateClusters::CORE:close # spent 2µs making 1 call to Bio::Roary::InflateClusters::_output_fh
103 |  |  |  |  | 1;
104 |  |  |  |  | }
105 |  |  |  |  |
106 | 2 | 45µs | 2 | 221µs | # spent 116µs (11+105) within Bio::Roary::InflateClusters::BEGIN@106 which was called: # once (11µs+105µs) by Bio::Roary::PostAnalysis::BEGIN@13 at line 106 no Moose; # spent 116µs making 1 call to Bio::Roary::InflateClusters::BEGIN@106 # spent 105µs making 1 call to Moose::unimport
107 | 1 | 8µs | 2 | 20.2ms | __PACKAGE__->meta->make_immutable; # spent 20.2ms making 1 call to Class::MOP::Class::make_immutable # spent 15µs making 1 call to Bio::Roary::InflateClusters::meta
108 |  |  |  |  |
109 | 1 | 42µs |  |  | 1;