← 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:46:06 2015

Filename/Users/ap13/pathogens/Roary/lib/Bio/Roary/InflateClusters.pm
StatementsExecuted 42071 statements in 90.1ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11185.9ms172msBio::Roary::InflateClusters::::inflateBio::Roary::InflateClusters::inflate
485114.90ms37.0msBio::Roary::InflateClusters::::_inflate_geneBio::Roary::InflateClusters::_inflate_gene
410113.59ms40.6msBio::Roary::InflateClusters::::_inflate_lineBio::Roary::InflateClusters::_inflate_line
111136µs5.78msBio::Roary::InflateClusters::::BEGIN@20Bio::Roary::InflateClusters::BEGIN@20
11139µs4.17msBio::Roary::InflateClusters::::BEGIN@19Bio::Roary::InflateClusters::BEGIN@19
11133µs64µsBio::Roary::InflateClusters::::_build__mcl_fhBio::Roary::InflateClusters::_build__mcl_fh
11119µs392µsBio::Roary::InflateClusters::::_build__output_fhBio::Roary::InflateClusters::_build__output_fh
11111µs116µsBio::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
1package 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
7Take 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
19246µs28.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
202618µs15.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
2113µs120.8mswith 'Bio::Roary::ClustersRole';
# spent 20.8ms making 1 call to Moose::with
22
2313µs11.63mshas 'mcl_filename' => ( is => 'ro', isa => 'Str', required => 1 );
# spent 1.63ms making 1 call to Moose::has
2412µs11.60mshas 'output_file' => ( is => 'ro', isa => 'Str', default => 'inflated_results' );
# spent 1.60ms making 1 call to Moose::has
2512µs11.54mshas '_mcl_fh' => ( is => 'ro',lazy => 1, builder => '_build__mcl_fh' );
# spent 1.54ms making 1 call to Moose::has
2612µs11.52mshas '_output_fh' => ( is => 'ro',lazy => 1, builder => '_build__output_fh' );
# spent 1.52ms making 1 call to Moose::has
2712µs13.36mshas 'cdhit_groups_filename' => ( is => 'ro', isa => 'Maybe[Str]' );
# spent 3.36ms making 1 call to Moose::has
28
29sub _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]
{
311800ns my($self) = @_;
321381µs2373µ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
3315µs return $fh;
34}
35
36sub _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]
{
3811µs my($self) = @_;
39151µs231µ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
4015µs return $fh;
41}
42
43sub _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
{
45410177µs my($self, $line) = @_;
4641032µs my @inflated_genes;
4741065µs chomp($line);
48410630µs my @gene_names = split(/[\t\s]+/, $line);
49410166µs for my $gene_name (@gene_names)
50 {
51485896µs48537.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 }
534101.09ms return join(' ',@inflated_genes);
54}
55
56sub _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
{
58485208µs my($self, $gene_name) = @_;
5948585µs my $inflated_gene = $gene_name;
60485673µs48530.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 {
62324842µs324578µ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
63324931µs324576µs delete($self->_clustered_genes->{$gene_name});
# spent 576µs making 324 calls to Bio::Roary::InflateClusters::_clustered_genes, avg 2µs/call
64 }
654851.09ms return $inflated_gene;
66}
67
68sub 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
{
7011µs my($self) = @_;
7114µs186µ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
74120µs112µs while(<$mcl_fh>)
# spent 12µs making 1 call to Bio::Roary::InflateClusters::CORE:readline
75 {
7641095µs my $line = $_;
774102.79ms164042.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
81173µs13µs for my $gene_name(keys %{$self->_clustered_genes})
# spent 3µs making 1 call to Bio::Roary::InflateClusters::_clustered_genes
82 {
83161272µs161340µ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
8715µs15µs if(defined($self->cdhit_groups_filename))
88 {
89 # Add clusters which were excluded because the groups were full at the cdhit stage
90148µs240µ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
91151µs119µs while(<$cdhit_fh>)
# spent 19µs making 1 call to Bio::Roary::InflateClusters::CORE:readline
92 {
93177642.92ms my $line = $_;
94
951776475.5ms5329242.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
1021301µs2292µ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
10314µs 1;
104}
105
106245µs2221µ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
10718µs220.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
109142µs1;