in reply to Selecting a random number, and back calculating to chromosome and contig!

Have you concidered replacing your considerably large elsif structure with something like this?
use strict; ... ... my contig; SWITCH: { if ($numbers < 561231) {$contig = 'whatever';last SWITCH;} if ($numbers < 700000) {$contig = 'whatevr1';last SWITCH;} if ($numbers < 720000) {$contig = 'whatevr2';last SWITCH;} .. }
it will make your code much more readable and much easier to find the typos and context errors that other people have noted in your code.


daN.
  • Comment on Re: Selecting a random number, and back calculating to chromosome and contig!
  • Download Code

Replies are listed 'Best First'.
Re: Re: Selecting a random number, and back calculating to chromosome and contig!
by halley (Prior) on Apr 30, 2004 at 17:02 UTC
    Or a lookup table?
    my %table = ( 561231 => 'whatever', 700000 => 'whatevr2', ... ); my @thresh = sort { $a <=> $b } keys %table; $_ = pop(@thresh) while $thresh[0] < $numbers; my $contig = $table{$_};
    Even this can be improved if there's more than ~200 thresholds by using a binary search method instead. I wouldn't bother with that unless it proves to be a bottleneck, though.

    --
    [ e d @ h a l l e y . c c ]