I am new to Perl and have failed to create a specific function in Perl.
The function should find and return all the increasing and decreasing bands. What does it mean? Two positions are neighbors if they are adjacent numbers. those. (2.3) or (8.7). An increase in band is a growing band of neighbors. those. (3,4,5,6). The reduction of the band is determined in a similar way. At the beginning of each array, 0 is added, and at the end, the length of the array is + 1. Unit numbers without neighbors are reduced. 0 and n + 1 increase.
So, if I have an array (0,3,4,5,9,8,6,2,1,7,10), I should get the following results: Increase the band: (3,4,5) (10) (0) Lowering bands: (9.8), (6), (2.1) (7)
I tried to reduce the problem to get only all the decreasing bands, but as far as I understand it: http://pastebin.com/yStbgNme
The code is here:
sub getIncs{
my @$bar = shift;
my %incs;
my $inccount = 0;
my $i=0;
while($i<@bar-1){
for($j=$i; 1; $j++;){
if($bar[$j] == $bar[$j+1]+1){
$incs{$inccount} = ($i,$j);
} else {
$inccount++;
last;
}
}
}
// edit1: I found a Python program that contains the specified getStrips () function, but my python is sporadic at best. http://www.csbio.unc.edu/mcmillan/Media/breakpointReversalSort.txt
// edit2: each number equals exactly one time in the array. Thus, there can be no overlap.