I have some rangers of numbers, and I want to find their union, BUT only comparing them pair-wise. Example:
25-40,74-93,99-120,130-149 31-47,84-99,107-123,137-151
Output: 31-40,84-93,95-99,107-120,137-149 Problem here is that I get an extra one, i.e. 95-99, because the 3rd range of $set1 partially overlaps with the 2nd range of $set2. Is there a way to tell my script to only create union of strings in a pairwise manner? Like compare 1st range of $set1 to 1st range of $set2, create the union of these two, then proceed to create the union between the 2nd range of $set1 and 2nd range of $set2 etc.use Set::IntSpan; $TM_part1="25-40,74-93,95-120,130-149"; $TM_part2="31-47,84-99,107-123,137-151"; @split_TM1 = split("\t", $TM_part1); @split_TM2 = split("\t", $TM_part2); for ($i=0; $i<=$#split_TM1; $i++) { $tm_range1 = $split_TM1[$i]; $tm_range2 = $split_TM2[$i]; $set1 = new Set::IntSpan $tm_range1; $set2 = new Set::IntSpan $tm_range2; $u_set = intersect $set1 $set2; } print "Union of strings:".$u_set."\n";
In reply to Create union from ranges, but compare respectively by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |