http://www.perlmonks.org?node_id=1047512

jmmitc06 has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks:

I am a bioinformatics programmer and I am currently running a very large calculation looking for subgraph isomorphisms. I have optimized it to the best of my abilities (I'm limited to the scale of my rewriting since the underlying objects/modules are used in much of my other code)

Below is a subroutine that currently consumes 74% of the time in my multiday calculation, even when using a cluster with torque. I have tried various different things, but I cannot beat what I have and any improvement would save me considerable time.

sub equate2 { my ($self, $other, $mapping) = @_; foreach my $row_index (0..$#$mapping) { return 0 if (grep { $$self{Matrix}[$row_index][$_] != $$other{Matr +ix}[$$mapping[$row_index]][$$mapping[$_]]); } (0..$#$mapping)); } return 1; }

I can provide more information if necessary, but in short this subroutine finds if elements of two matrices, i and j determined by a vector: $mapping.

Any advice and any tips for improving performance would be greatly appreciated. I have tried switching out the grep and foreach with for statements to no avail.

Thanks to all the monks for the help you have given in the past.