Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Faulty Control Structures?

by Errto (Vicar)
on Jan 28, 2008 at 20:33 UTC ( #664769=note: print w/ replies, xml ) Need Help??


in reply to Faulty Control Structures?

I tried running the program on the data you provided but it exited instantly and printed no output in output.txt so I assume that data is not representative. I don't exactly understand what the code is doing but I don't see anything that could cause an infinite loop. I see two things that make me suspicious: 1) your range data is all numbers but you're using the character-operators lt and eq to compare them, and 2) these lines:

# look to see if the windows don't overlap if ($test lt $window[0]) {return 0;} # look to see if the windows don't overlap elsif ($test2 lt $probe[0]) {return 0;}
are inside a loop in which the iterator variable is $value1, yet they don't consider that value.

Update: Second thought - the second part of the code seems, if I understand it, to be designed to take two ranges of numbers and see if they overlap. To do so, it actually expands the ranges into lists and compares them one-by-one. This becomes, in the worst case, an N^2 calculation for what should be a constant operation:

sub range_overlap { my ($start1, $end1, $start2, $end2); return ($end1 >= $start2 || $start1 <= $end2) && ($end2 >= $start1 || $start2 <= $end1); }
untested but it should be about right.


Comment on Re: Faulty Control Structures?
Select or Download Code
Replies are listed 'Best First'.
Re^2: Faulty Control Structures?
by bioinformatics (Friar) on Jan 28, 2008 at 20:46 UTC
    Mmmm... The data won't match up your right. I can adjust the window values and chromosome numbers to match up so that you do get output however. I just threw up data to illustrate.
    Bioinformatics

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://664769]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (14)
As of 2015-07-31 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (282 votes), past polls