|
6 | 6 | use strict; |
7 | 7 | use Getopt::Long qw(:config no_ignore_case bundling); |
8 | 8 | use Pod::Usage; |
9 | | -use Bio::Range; |
10 | 9 | use Bio::ToolBox::Data; |
11 | 10 | use Bio::ToolBox::db_helper qw( |
12 | 11 | open_db_connection |
|
15 | 14 | ); |
16 | 15 | use Bio::ToolBox::utility qw(format_with_commas); |
17 | 16 |
|
18 | | -our $VERSION = '2.00'; |
| 17 | +our $VERSION = '2.04'; |
19 | 18 |
|
20 | 19 | print "\n A script to pull out overlapping features\n\n"; |
21 | 20 |
|
@@ -574,18 +573,22 @@ sub determine_overlap { |
574 | 573 | # work (what!!!!????), intersection and overlap_extent fail to |
575 | 574 | # give proper end values, just returns "-end" |
576 | 575 |
|
577 | | - # the workaround is to create a new simple Bio::Range object |
578 | | - # using the coordinates from the reference region, and then determine the |
579 | | - # overlap between it and the target feature |
580 | | - my $a = Bio::Range->new( |
581 | | - -start => $reference->start, |
582 | | - -end => $reference->end, |
583 | | - -strand => $ref_strand, |
584 | | - ); |
585 | | - |
586 | | - # find the overlap |
587 | | - my $int = $a->intersection($target); |
588 | | - return $int->length; |
| 576 | + # the workaround is to just calculate the intersection ourself |
| 577 | + my ( $istart, $istop ); |
| 578 | + if ( $reference->start <= $target->start ) { |
| 579 | + $istart = $reference->start; |
| 580 | + } |
| 581 | + else { |
| 582 | + $istart = $target->start; |
| 583 | + } |
| 584 | + if ( $reference->end >= $target->end ) { |
| 585 | + $istop = $reference->end; |
| 586 | + } |
| 587 | + else { |
| 588 | + $istop = $target->end; |
| 589 | + } |
| 590 | + return 0 if $istart > $istop; |
| 591 | + return ($istop - $istart + 1); |
589 | 592 | } |
590 | 593 |
|
591 | 594 | sub summarize_found_features { |
|
0 commit comments