| Filename | /Users/ap13/pathogens/Roary/lib/Bio/Roary/OrderGenes.pm |
| Statements | Executed 467208 statements in 613ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 401ms | 2.45s | Bio::Roary::OrderGenes::_build__groups_to_file_contigs |
| 2 | 2 | 1 | 170ms | 4.11s | Bio::Roary::OrderGenes::_reorder_connected_components |
| 1 | 1 | 1 | 102ms | 3.95s | Bio::Roary::OrderGenes::_add_groups_to_graph |
| 1 | 1 | 1 | 85.8ms | 193ms | Bio::Roary::OrderGenes::_create_accessory_graph |
| 1 | 1 | 1 | 85.1ms | 2.53s | Bio::Roary::OrderGenes::_build_group_order |
| 1 | 1 | 1 | 57.5ms | 102ms | Bio::Roary::OrderGenes::BEGIN@22 |
| 1 | 1 | 1 | 31.3ms | 9.70s | Bio::Roary::OrderGenes::_build_groups_to_contigs |
| 1 | 1 | 1 | 13.7ms | 23.6ms | Bio::Roary::OrderGenes::_remove_weak_edges_from_graph |
| 1 | 1 | 1 | 845µs | 28.4ms | Bio::Roary::OrderGenes::BEGIN@21 |
| 1 | 1 | 1 | 64µs | 4.69ms | Bio::Roary::OrderGenes::BEGIN@18 |
| 1 | 1 | 1 | 27µs | 410µs | Bio::Roary::OrderGenes::_build_group_graphs |
| 1 | 1 | 1 | 14µs | 140µs | Bio::Roary::OrderGenes::BEGIN@352 |
| 1 | 1 | 1 | 12µs | 26µs | Bio::Roary::OrderGenes::_build_number_of_files |
| 1 | 1 | 1 | 9µs | 9µs | Bio::Roary::OrderGenes::__ANON__[lib/Bio/Roary/OrderGenes.pm:33] |
| 1 | 1 | 1 | 9µs | 9µs | Bio::Roary::OrderGenes::BEGIN@19 |
| 1 | 1 | 1 | 6µs | 6µs | Bio::Roary::OrderGenes::BEGIN@20 |
| 0 | 0 | 0 | 0s | 0s | Bio::Roary::OrderGenes::_build_groups |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Bio::Roary::OrderGenes; | ||||
| 2 | |||||
| 3 | # ABSTRACT: Take in GFF files and create a matrix of what genes are beside what other genes | ||||
| 4 | |||||
| 5 | =head1 SYNOPSIS | ||||
| 6 | |||||
| 7 | Take in the analyse groups and create a matrix of what genes are beside what other genes | ||||
| 8 | use Bio::Roary::OrderGenes; | ||||
| 9 | |||||
| 10 | my $obj = Bio::Roary::OrderGenes->new( | ||||
| 11 | analyse_groups_obj => $analyse_groups_obj, | ||||
| 12 | gff_files => ['file1.gff','file2.gff'] | ||||
| 13 | ); | ||||
| 14 | $obj->groups_to_contigs; | ||||
| 15 | |||||
| 16 | =cut | ||||
| 17 | |||||
| 18 | 2 | 50µs | 2 | 9.31ms | # spent 4.69ms (64µs+4.62) within Bio::Roary::OrderGenes::BEGIN@18 which was called:
# once (64µs+4.62ms) by Bio::Roary::PostAnalysis::BEGIN@20 at line 18 # spent 4.69ms making 1 call to Bio::Roary::OrderGenes::BEGIN@18
# spent 4.62ms making 1 call to Moose::import |
| 19 | 2 | 25µs | 1 | 9µs | # spent 9µs within Bio::Roary::OrderGenes::BEGIN@19 which was called:
# once (9µs+0s) by Bio::Roary::PostAnalysis::BEGIN@20 at line 19 # spent 9µs making 1 call to Bio::Roary::OrderGenes::BEGIN@19 |
| 20 | 2 | 22µs | 1 | 6µs | # spent 6µs within Bio::Roary::OrderGenes::BEGIN@20 which was called:
# once (6µs+0s) by Bio::Roary::PostAnalysis::BEGIN@20 at line 20 # spent 6µs making 1 call to Bio::Roary::OrderGenes::BEGIN@20 |
| 21 | 2 | 160µs | 1 | 28.4ms | # spent 28.4ms (845µs+27.5) within Bio::Roary::OrderGenes::BEGIN@21 which was called:
# once (845µs+27.5ms) by Bio::Roary::PostAnalysis::BEGIN@20 at line 21 # spent 28.4ms making 1 call to Bio::Roary::OrderGenes::BEGIN@21 |
| 22 | 2 | 1.94ms | 1 | 102ms | # spent 102ms (57.5+44.7) within Bio::Roary::OrderGenes::BEGIN@22 which was called:
# once (57.5ms+44.7ms) by Bio::Roary::PostAnalysis::BEGIN@20 at line 22 # spent 102ms making 1 call to Bio::Roary::OrderGenes::BEGIN@22 |
| 23 | |||||
| 24 | 1 | 3µs | 1 | 2.73ms | has 'gff_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); # spent 2.73ms making 1 call to Moose::has |
| 25 | 1 | 3µs | 1 | 2.63ms | has 'analyse_groups_obj' => ( is => 'ro', isa => 'Bio::Roary::AnalyseGroups', required => 1 ); # spent 2.63ms making 1 call to Moose::has |
| 26 | 1 | 4µs | 1 | 2.34ms | has 'group_order' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_build_group_order'); # spent 2.34ms making 1 call to Moose::has |
| 27 | 1 | 3µs | 1 | 2.65ms | has 'group_graphs' => ( is => 'ro', isa => 'Graph', lazy => 1, builder => '_build_group_graphs'); # spent 2.65ms making 1 call to Moose::has |
| 28 | 1 | 3µs | 1 | 2.05ms | has 'groups_to_contigs' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_build_groups_to_contigs'); # spent 2.05ms making 1 call to Moose::has |
| 29 | 1 | 4µs | 1 | 2.14ms | has '_groups_to_file_contigs' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build__groups_to_file_contigs'); # spent 2.14ms making 1 call to Moose::has |
| 30 | |||||
| 31 | 1 | 3µs | 1 | 1.96ms | has '_groups' => ( is => 'ro', isa => 'HashRef', lazy => 1, builder => '_build_groups'); # spent 1.96ms making 1 call to Moose::has |
| 32 | 1 | 3µs | 1 | 2.76ms | has 'number_of_files' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build_number_of_files'); # spent 2.76ms making 1 call to Moose::has |
| 33 | 2 | 17µs | 1 | 1.76ms | # spent 9µs within Bio::Roary::OrderGenes::__ANON__[lib/Bio/Roary/OrderGenes.pm:33] which was called:
# once (9µs+0s) by Bio::Roary::OrderGenes::new at line 52 of (eval 25)[Eval/Closure.pm:125] # spent 1.76ms making 1 call to Moose::has |
| 34 | |||||
| 35 | 1 | 2µs | 1 | 1.54ms | has '_percentage_of_largest_weak_threshold' => ( is => 'ro', isa => 'Num', default => 0.9); # spent 1.54ms making 1 call to Moose::has |
| 36 | |||||
| 37 | sub _build_number_of_files | ||||
| 38 | # spent 26µs (12+13) within Bio::Roary::OrderGenes::_build_number_of_files which was called:
# once (12µs+13µs) by Bio::Roary::OrderGenes::number_of_files at line 12 of (eval 25)[Eval/Closure.pm:125] | ||||
| 39 | 2 | 19µs | my ($self) = @_; | ||
| 40 | 1 | 13µs | return @{$self->gff_files}; # spent 13µs making 1 call to Bio::Roary::OrderGenes::gff_files | ||
| 41 | } | ||||
| 42 | |||||
| 43 | sub _build_groups | ||||
| 44 | { | ||||
| 45 | my ($self) = @_; | ||||
| 46 | my %groups; | ||||
| 47 | for my $group_name (@{$self->analyse_groups_obj->_groups}) | ||||
| 48 | { | ||||
| 49 | $groups{$group_name}++; | ||||
| 50 | } | ||||
| 51 | return \%groups; | ||||
| 52 | } | ||||
| 53 | |||||
| 54 | |||||
| 55 | sub _build__groups_to_file_contigs | ||||
| 56 | # spent 2.45s (401ms+2.05) within Bio::Roary::OrderGenes::_build__groups_to_file_contigs which was called:
# once (401ms+2.05s) by Bio::Roary::OrderGenes::_groups_to_file_contigs at line 12 of (eval 25)[Eval/Closure.pm:125] | ||||
| 57 | 5 | 50µs | my ($self) = @_; | ||
| 58 | my @groups_to_contigs; | ||||
| 59 | my @overlapping_hypothetical_gene_ids; | ||||
| 60 | |||||
| 61 | # Open each GFF file | ||||
| 62 | 1 | 10µs | for my $filename (@{$self->gff_files}) # spent 10µs making 1 call to Bio::Roary::OrderGenes::gff_files | ||
| 63 | { | ||||
| 64 | 16 | 837µs | 8 | 894µs | my $contigs_to_ids_obj = Bio::Roary::ContigsToGeneIDsFromGFF->new(gff_file => $filename); # spent 894µs making 8 calls to Bio::Roary::ContigsToGeneIDsFromGFF::new, avg 112µs/call |
| 65 | |||||
| 66 | # Loop over each contig in the GFF file | ||||
| 67 | 1 | 57.1ms | 16 | 1.40s | for my $contig_name (keys %{$contigs_to_ids_obj->contig_to_ids}) # spent 1.40s making 8 calls to Bio::Roary::ContigsToGeneIDsFromGFF::contig_to_ids, avg 175ms/call
# spent 180µs making 8 calls to Bio::Roary::ContigsToGeneIDsFromGFF::DESTROY, avg 23µs/call |
| 68 | { | ||||
| 69 | 1332 | 2.04ms | my @groups_on_contig; | ||
| 70 | #Â loop over each gene in each contig in the GFF file | ||||
| 71 | 444 | 1.15ms | for my $gene_id (@{$contigs_to_ids_obj->contig_to_ids->{$contig_name}}) # spent 1.15ms making 444 calls to Bio::Roary::ContigsToGeneIDsFromGFF::contig_to_ids, avg 3µs/call | ||
| 72 | { | ||||
| 73 | #Â convert to group name | ||||
| 74 | 155372 | 203ms | 80016 | 108ms | my $group_name = $self->analyse_groups_obj->_genes_to_groups->{$gene_id}; # spent 54.5ms making 40008 calls to Bio::Roary::OrderGenes::analyse_groups_obj, avg 1µs/call
# spent 53.8ms making 40008 calls to Bio::Roary::AnalyseGroups::_genes_to_groups, avg 1µs/call |
| 75 | next unless(defined($group_name)); | ||||
| 76 | |||||
| 77 | 37725 | 536ms | if($contigs_to_ids_obj->overlapping_hypothetical_protein_ids->{$gene_id}) # spent 536ms making 37678 calls to Bio::Roary::ContigsToGeneIDsFromGFF::overlapping_hypothetical_protein_ids, avg 14µs/call
# spent 266µs making 47 calls to Bio::Roary::OrderGenes::_groups_qc, avg 6µs/call | ||
| 78 | { | ||||
| 79 | $self->_groups_qc->{$group_name} = 'Hypothetical protein with no hits to refseq/uniprot/clusters/cdd/tigrfams/pfam overlapping another protein with hits'; | ||||
| 80 | } | ||||
| 81 | push(@groups_on_contig, $group_name); | ||||
| 82 | } | ||||
| 83 | push(@groups_to_contigs,\@groups_on_contig); | ||||
| 84 | } | ||||
| 85 | } | ||||
| 86 | |||||
| 87 | return \@groups_to_contigs; | ||||
| 88 | |||||
| 89 | } | ||||
| 90 | |||||
| 91 | sub _build_group_order | ||||
| 92 | # spent 2.53s (85.1ms+2.45) within Bio::Roary::OrderGenes::_build_group_order which was called:
# once (85.1ms+2.45s) by Bio::Roary::OrderGenes::group_order at line 12 of (eval 25)[Eval/Closure.pm:125] | ||||
| 93 | 4 | 54µs | my ($self) = @_; | ||
| 94 | my %group_order; | ||||
| 95 | |||||
| 96 | 1 | 2.45s | for my $groups_on_contig (@{$self->_groups_to_file_contigs}) # spent 2.45s making 1 call to Bio::Roary::OrderGenes::_groups_to_file_contigs | ||
| 97 | { | ||||
| 98 | 149860 | 64.9ms | for(my $i = 1; $i < @{$groups_on_contig}; $i++) | ||
| 99 | { | ||||
| 100 | my $group_from = $groups_on_contig->[$i -1]; | ||||
| 101 | my $group_to = $groups_on_contig->[$i]; | ||||
| 102 | $group_order{$group_from}{$group_to}++; | ||||
| 103 | # TODO: remove because you only need half the matix | ||||
| 104 | $group_order{$group_to}{$group_from}++; | ||||
| 105 | } | ||||
| 106 | 42 | 36µs | if(@{$groups_on_contig} == 1) | ||
| 107 | { | ||||
| 108 | my $group_from = $groups_on_contig->[0]; | ||||
| 109 | my $group_to = $groups_on_contig->[0]; | ||||
| 110 | $group_order{$group_from}{$group_to}++; | ||||
| 111 | } | ||||
| 112 | } | ||||
| 113 | |||||
| 114 | return \%group_order; | ||||
| 115 | } | ||||
| 116 | |||||
| 117 | sub _build_group_graphs | ||||
| 118 | # spent 410µs (27+383) within Bio::Roary::OrderGenes::_build_group_graphs which was called:
# once (27µs+383µs) by Bio::Roary::OrderGenes::group_graphs at line 12 of (eval 25)[Eval/Closure.pm:125] | ||||
| 119 | 2 | 33µs | my($self) = @_; | ||
| 120 | 1 | 383µs | return Graph->new(undirected => 1); # spent 383µs making 1 call to Graph::new | ||
| 121 | } | ||||
| 122 | |||||
| 123 | |||||
| 124 | sub _add_groups_to_graph | ||||
| 125 | # spent 3.95s (102ms+3.85) within Bio::Roary::OrderGenes::_add_groups_to_graph which was called:
# once (102ms+3.85s) by Bio::Roary::OrderGenes::_build_groups_to_contigs at line 204 | ||||
| 126 | 2 | 930µs | my($self) = @_; | ||
| 127 | |||||
| 128 | 1 | 2.53s | for my $current_group (keys %{$self->group_order()}) # spent 2.53s making 1 call to Bio::Roary::OrderGenes::group_order | ||
| 129 | { | ||||
| 130 | 4871 | 20.7ms | 4871 | 9.74ms | for my $group_to (keys %{$self->group_order->{$current_group}}) # spent 9.74ms making 4871 calls to Bio::Roary::OrderGenes::group_order, avg 2µs/call |
| 131 | { | ||||
| 132 | 19534 | 45.2ms | 9767 | 17.8ms | my $weight = 1.0/($self->group_order->{$current_group}->{$group_to} ); # spent 17.8ms making 9767 calls to Bio::Roary::OrderGenes::group_order, avg 2µs/call |
| 133 | 19534 | 1.29s | $self->group_graphs->add_weighted_edge($current_group,$group_to, $weight); # spent 1.27s making 9767 calls to Graph::add_weighted_edge, avg 131µs/call
# spent 17.6ms making 9767 calls to Bio::Roary::OrderGenes::group_graphs, avg 2µs/call | ||
| 134 | } | ||||
| 135 | } | ||||
| 136 | |||||
| 137 | } | ||||
| 138 | |||||
| 139 | |||||
| 140 | sub _reorder_connected_components | ||||
| 141 | # spent 4.11s (170ms+3.94) within Bio::Roary::OrderGenes::_reorder_connected_components which was called 2 times, avg 2.05s/call:
# once (165ms+3.81s) by Bio::Roary::OrderGenes::_build_groups_to_contigs at line 233
# once (4.71ms+127ms) by Bio::Roary::OrderGenes::_build_groups_to_contigs at line 214 | ||||
| 142 | 14 | 139µs | my($self, $graph_groups) = @_; | ||
| 143 | |||||
| 144 | my @ordered_graph_groups; | ||||
| 145 | |||||
| 146 | my @paths_and_weights; | ||||
| 147 | |||||
| 148 | for my $graph_group( @{$graph_groups}) | ||||
| 149 | { | ||||
| 150 | |||||
| 151 | 432 | 61.7ms | 36 | 5.46ms | my $graph = Graph->new(undirected => 1); # spent 5.46ms making 36 calls to Graph::new, avg 152µs/call |
| 152 | my %groups; | ||||
| 153 | $groups{$_}++ for (@{$graph_group}); | ||||
| 154 | |||||
| 155 | my $total_weight =0; | ||||
| 156 | my $number_of_edges = 0; | ||||
| 157 | for my $current_group (keys %groups) | ||||
| 158 | { | ||||
| 159 | 4991 | 16.5ms | 4991 | 9.88ms | for my $group_to (keys %{$self->group_order->{$current_group}}) # spent 9.88ms making 4991 calls to Bio::Roary::OrderGenes::group_order, avg 2µs/call |
| 160 | { | ||||
| 161 | 50034 | 49.7ms | next if(! defined($groups{$group_to})); | ||
| 162 | 9998 | 70.4ms | next if($graph->has_edge($group_to,$current_group)); # spent 70.4ms making 9998 calls to Graph::has_edge, avg 7µs/call | ||
| 163 | 5005 | 9.03ms | my $current_weight = $self->group_order->{$current_group}->{$group_to} ; # spent 9.03ms making 5005 calls to Bio::Roary::OrderGenes::group_order, avg 2µs/call | ||
| 164 | 5005 | 8.85ms | $current_weight = $self->number_of_files if($current_weight > $self->number_of_files); # spent 8.85ms making 5005 calls to Bio::Roary::OrderGenes::number_of_files, avg 2µs/call | ||
| 165 | 5005 | 7.64ms | my $weight = ($self->number_of_files - $current_weight) +1; # spent 7.64ms making 5005 calls to Bio::Roary::OrderGenes::number_of_files, avg 2µs/call | ||
| 166 | |||||
| 167 | 5005 | 753ms | $graph->add_weighted_edge($current_group,$group_to, $weight); # spent 753ms making 5005 calls to Graph::add_weighted_edge, avg 150µs/call | ||
| 168 | $total_weight += $weight; | ||||
| 169 | $number_of_edges++; | ||||
| 170 | } | ||||
| 171 | } | ||||
| 172 | |||||
| 173 | my $average_weight ; | ||||
| 174 | 36 | 46µs | if($number_of_edges <= 0) | ||
| 175 | { | ||||
| 176 | $average_weight = $self->number_of_files; | ||||
| 177 | } | ||||
| 178 | else | ||||
| 179 | { | ||||
| 180 | $average_weight = $total_weight/$number_of_edges; | ||||
| 181 | } | ||||
| 182 | |||||
| 183 | 36 | 1.80s | my $minimum_spanning_tree = $graph->minimum_spanning_tree; # spent 1.80s making 36 calls to Graph::MST_Prim, avg 50.0ms/call | ||
| 184 | 36 | 20.7ms | my $dfs_obj = Graph::Traversal::DFS->new($minimum_spanning_tree); # spent 20.7ms making 36 calls to Graph::Traversal::new, avg 575µs/call | ||
| 185 | 36 | 1.26s | my @reordered_dfs_groups = $dfs_obj->dfs; # spent 1.26s making 36 calls to Graph::Traversal::postorder, avg 34.9ms/call | ||
| 186 | |||||
| 187 | push(@paths_and_weights, { | ||||
| 188 | path => \@reordered_dfs_groups, | ||||
| 189 | average_weight => $average_weight | ||||
| 190 | }); | ||||
| 191 | |||||
| 192 | } | ||||
| 193 | |||||
| 194 | 2 | 64µs | my @ordered_paths_and_weights = sort { $a->{average_weight} <=> $b->{average_weight} } @paths_and_weights; # spent 64µs making 2 calls to Bio::Roary::OrderGenes::CORE:sort, avg 32µs/call | ||
| 195 | |||||
| 196 | @ordered_graph_groups = map { $_->{path}} @ordered_paths_and_weights; | ||||
| 197 | |||||
| 198 | return \@ordered_graph_groups; | ||||
| 199 | } | ||||
| 200 | |||||
| 201 | sub _build_groups_to_contigs | ||||
| 202 | # spent 9.70s (31.3ms+9.66) within Bio::Roary::OrderGenes::_build_groups_to_contigs which was called:
# once (31.3ms+9.66s) by Bio::Roary::OrderGenes::groups_to_contigs at line 12 of (eval 25)[Eval/Closure.pm:125] | ||||
| 203 | 19 | 1.95ms | my($self) = @_; | ||
| 204 | 1 | 3.95s | $self->_add_groups_to_graph; # spent 3.95s making 1 call to Bio::Roary::OrderGenes::_add_groups_to_graph | ||
| 205 | |||||
| 206 | my %groups_to_contigs; | ||||
| 207 | my $counter = 1; | ||||
| 208 | my $overall_counter = 1 ; | ||||
| 209 | my $counter_filtered = 1; | ||||
| 210 | |||||
| 211 | # Accessory | ||||
| 212 | 1 | 193ms | my $accessory_graph = $self->_create_accessory_graph; # spent 193ms making 1 call to Bio::Roary::OrderGenes::_create_accessory_graph | ||
| 213 | 1 | 34.7ms | my @group_graphs = $accessory_graph->connected_components(); # spent 34.7ms making 1 call to Graph::connected_components | ||
| 214 | 1 | 132ms | my $reordered_graphs = $self->_reorder_connected_components(\@group_graphs); # spent 132ms making 1 call to Bio::Roary::OrderGenes::_reorder_connected_components | ||
| 215 | |||||
| 216 | for my $contig_groups (@{$reordered_graphs}) | ||||
| 217 | { | ||||
| 218 | 24 | 9µs | my $order_counter = 1; | ||
| 219 | |||||
| 220 | for my $group_name (@{$contig_groups}) | ||||
| 221 | { | ||||
| 222 | 580 | 195µs | $groups_to_contigs{$group_name}{accessory_label} = $counter; | ||
| 223 | $groups_to_contigs{$group_name}{accessory_order} = $order_counter; | ||||
| 224 | $groups_to_contigs{$group_name}{'accessory_overall_order'} = $overall_counter; | ||||
| 225 | $order_counter++; | ||||
| 226 | $overall_counter++; | ||||
| 227 | } | ||||
| 228 | $counter++; | ||||
| 229 | } | ||||
| 230 | |||||
| 231 | # Core + accessory | ||||
| 232 | 2 | 1.37s | my @group_graphs_all = $self->group_graphs->connected_components(); # spent 1.37s making 1 call to Graph::connected_components
# spent 6µs making 1 call to Bio::Roary::OrderGenes::group_graphs | ||
| 233 | 1 | 3.98s | my $reordered_graphs_all = $self->_reorder_connected_components(\@group_graphs_all); # spent 3.98s making 1 call to Bio::Roary::OrderGenes::_reorder_connected_components | ||
| 234 | |||||
| 235 | $overall_counter = 1; | ||||
| 236 | $counter = 1; | ||||
| 237 | $counter_filtered = 1; | ||||
| 238 | for my $contig_groups (@{$reordered_graphs_all}) | ||||
| 239 | { | ||||
| 240 | 84 | 29µs | my $order_counter = 1; | ||
| 241 | |||||
| 242 | for my $group_name (@{$contig_groups}) | ||||
| 243 | { | ||||
| 244 | 34076 | 17.6ms | $groups_to_contigs{$group_name}{label} = $counter; | ||
| 245 | $groups_to_contigs{$group_name}{comment} = ''; | ||||
| 246 | $groups_to_contigs{$group_name}{order} = $order_counter; | ||||
| 247 | $groups_to_contigs{$group_name}{'core_accessory_overall_order'} = $overall_counter; | ||||
| 248 | |||||
| 249 | 9704 | 2.12ms | 4884 | 6.39ms | if(@{$contig_groups} <= 2) # spent 6.39ms making 4884 calls to Bio::Roary::OrderGenes::_groups_qc, avg 1µs/call |
| 250 | { | ||||
| 251 | $groups_to_contigs{$group_name}{comment} = 'Investigate'; | ||||
| 252 | } | ||||
| 253 | elsif($self->_groups_qc->{$group_name}) | ||||
| 254 | { | ||||
| 255 | $groups_to_contigs{$group_name}{comment} = $self->_groups_qc->{$group_name}; | ||||
| 256 | } | ||||
| 257 | else | ||||
| 258 | { | ||||
| 259 | $groups_to_contigs{$group_name}{'core_accessory_overall_order_filtered'} = $counter_filtered; | ||||
| 260 | $counter_filtered++; | ||||
| 261 | } | ||||
| 262 | $order_counter++; | ||||
| 263 | $overall_counter++; | ||||
| 264 | } | ||||
| 265 | $counter++; | ||||
| 266 | } | ||||
| 267 | |||||
| 268 | $counter_filtered = 1; | ||||
| 269 | for my $contig_groups (@{$reordered_graphs}) | ||||
| 270 | { | ||||
| 271 | 8 | 5µs | for my $group_name (@{$contig_groups}) | ||
| 272 | { | ||||
| 273 | 346 | 174µs | if( (!defined($groups_to_contigs{$group_name}{comment})) || (defined($groups_to_contigs{$group_name}{comment}) && $groups_to_contigs{$group_name}{comment} eq '') ) | ||
| 274 | { | ||||
| 275 | $groups_to_contigs{$group_name}{'accessory_overall_order_filtered'} = $counter_filtered; | ||||
| 276 | $counter_filtered++; | ||||
| 277 | } | ||||
| 278 | } | ||||
| 279 | } | ||||
| 280 | |||||
| 281 | |||||
| 282 | return \%groups_to_contigs; | ||||
| 283 | } | ||||
| 284 | |||||
| 285 | sub _create_accessory_graph | ||||
| 286 | # spent 193ms (85.8+107) within Bio::Roary::OrderGenes::_create_accessory_graph which was called:
# once (85.8ms+107ms) by Bio::Roary::OrderGenes::_build_groups_to_contigs at line 212 | ||||
| 287 | 7 | 4.13ms | my($self) = @_; | ||
| 288 | 1 | 145µs | my $graph = Graph->new(undirected => 1); # spent 145µs making 1 call to Graph::new | ||
| 289 | |||||
| 290 | my %core_groups; | ||||
| 291 | |||||
| 292 | 1 | 2µs | for my $current_group (keys %{$self->group_order()}) # spent 2µs making 1 call to Bio::Roary::OrderGenes::group_order | ||
| 293 | { | ||||
| 294 | 14613 | 28.0ms | my $sum_of_weights = 0; | ||
| 295 | 4871 | 10.1ms | for my $group_to (keys %{$self->group_order->{$current_group}}) # spent 10.1ms making 4871 calls to Bio::Roary::OrderGenes::group_order, avg 2µs/call | ||
| 296 | { | ||||
| 297 | 9767 | 20.5ms | 9767 | 19.9ms | $sum_of_weights += $self->group_order->{$current_group}->{$group_to}; # spent 19.9ms making 9767 calls to Bio::Roary::OrderGenes::group_order, avg 2µs/call |
| 298 | } | ||||
| 299 | 4871 | 9.53ms | if($sum_of_weights >= $self->number_of_files ) # spent 9.53ms making 4871 calls to Bio::Roary::OrderGenes::number_of_files, avg 2µs/call | ||
| 300 | { | ||||
| 301 | $core_groups{$current_group}++; | ||||
| 302 | } | ||||
| 303 | } | ||||
| 304 | |||||
| 305 | 1 | 10µs | for my $current_group (keys %{$self->group_order()}) # spent 10µs making 1 call to Bio::Roary::OrderGenes::group_order | ||
| 306 | { | ||||
| 307 | 5034 | 3.48ms | next if(defined($core_groups{$current_group})); | ||
| 308 | 163 | 471µs | for my $group_to (keys %{$self->group_order->{$current_group}}) # spent 471µs making 163 calls to Bio::Roary::OrderGenes::group_order, avg 3µs/call | ||
| 309 | { | ||||
| 310 | 770 | 1.74ms | next if(defined($core_groups{$group_to})); | ||
| 311 | 462 | 1.12ms | my $weight = ($self->number_of_files - $self->group_order->{$current_group}->{$group_to}) +1; # spent 609µs making 231 calls to Bio::Roary::OrderGenes::number_of_files, avg 3µs/call
# spent 515µs making 231 calls to Bio::Roary::OrderGenes::group_order, avg 2µs/call | ||
| 312 | 231 | 42.5ms | $graph->add_weighted_edge($current_group,$group_to, $weight); # spent 42.5ms making 231 calls to Graph::add_weighted_edge, avg 184µs/call | ||
| 313 | } | ||||
| 314 | } | ||||
| 315 | 1 | 23.6ms | $self->_remove_weak_edges_from_graph($graph); # spent 23.6ms making 1 call to Bio::Roary::OrderGenes::_remove_weak_edges_from_graph | ||
| 316 | return $graph; | ||||
| 317 | } | ||||
| 318 | |||||
| 319 | sub _remove_weak_edges_from_graph | ||||
| 320 | # spent 23.6ms (13.7+9.91) within Bio::Roary::OrderGenes::_remove_weak_edges_from_graph which was called:
# once (13.7ms+9.91ms) by Bio::Roary::OrderGenes::_create_accessory_graph at line 315 | ||||
| 321 | 2 | 737µs | my($self, $graph) = @_; | ||
| 322 | |||||
| 323 | 1 | 3µs | for my $current_group (keys %{$self->group_order()}) # spent 3µs making 1 call to Bio::Roary::OrderGenes::group_order | ||
| 324 | { | ||||
| 325 | 5355 | 6.36ms | 4871 | 9.00ms | next unless($graph->has_vertex($current_group)); # spent 9.00ms making 4871 calls to Graph::has_vertex, avg 2µs/call |
| 326 | |||||
| 327 | my $largest = 0; | ||||
| 328 | 120 | 201µs | for my $group_to (keys %{$self->group_order->{$current_group}}) # spent 201µs making 120 calls to Bio::Roary::OrderGenes::group_order, avg 2µs/call | ||
| 329 | { | ||||
| 330 | 239 | 522µs | 361 | 529µs | if($largest < $self->group_order->{$current_group}->{$group_to}) # spent 529µs making 361 calls to Bio::Roary::OrderGenes::group_order, avg 1µs/call |
| 331 | { | ||||
| 332 | $largest = $self->group_order->{$current_group}->{$group_to}; | ||||
| 333 | } | ||||
| 334 | } | ||||
| 335 | 120 | 160µs | my $threshold_link = int($largest*$self->_percentage_of_largest_weak_threshold); # spent 160µs making 120 calls to Bio::Roary::OrderGenes::_percentage_of_largest_weak_threshold, avg 1µs/call | ||
| 336 | next if($threshold_link <= 1); | ||||
| 337 | |||||
| 338 | 4 | 6µs | for my $group_to (keys %{$self->group_order->{$current_group}}) # spent 6µs making 4 calls to Bio::Roary::OrderGenes::group_order, avg 2µs/call | ||
| 339 | { | ||||
| 340 | 6 | 10µs | 6 | 9µs | if($self->group_order->{$current_group}->{$group_to} < $threshold_link && $graph->has_edge($current_group,$group_to)) # spent 9µs making 6 calls to Bio::Roary::OrderGenes::group_order, avg 1µs/call |
| 341 | { | ||||
| 342 | $graph->delete_edge($current_group, $group_to); | ||||
| 343 | } | ||||
| 344 | } | ||||
| 345 | } | ||||
| 346 | |||||
| 347 | } | ||||
| 348 | |||||
| - - | |||||
| 352 | 2 | 58µs | 2 | 265µs | # spent 140µs (14+125) within Bio::Roary::OrderGenes::BEGIN@352 which was called:
# once (14µs+125µs) by Bio::Roary::PostAnalysis::BEGIN@20 at line 352 # spent 140µs making 1 call to Bio::Roary::OrderGenes::BEGIN@352
# spent 125µs making 1 call to Moose::unimport |
| 353 | 1 | 7µs | 2 | 7.09ms | __PACKAGE__->meta->make_immutable; # spent 7.08ms making 1 call to Class::MOP::Class::make_immutable
# spent 14µs making 1 call to Bio::Roary::OrderGenes::meta |
| 354 | |||||
| 355 | 1 | 97µs | 1; |