Permalink
Browse files

FTLocationFactory.pm: Fixed a long-standing issue at "from_string()"

and now "join(A..B,join(C..D,join(E..F,G..H)),I..J)" is
equivalent to "join(A..B,C..D,E..F,G..H,J..I)". Updated test.
  • Loading branch information...
1 parent a986017 commit 13b63a5062917e46fb8b86ff41ceb79b9b494de1 @fjossandon fjossandon committed Aug 7, 2014
Showing with 19 additions and 3 deletions.
  1. +18 −1 Bio/Factory/FTLocationFactory.pm
  2. +1 −2 t/SeqFeature/LocationFactory.t
@@ -245,7 +245,24 @@ sub from_string {
$loc_obj->strand(-1);
}
- push @loc_objs, $loc_obj;
+ # For Split-type $loc_obj, if guide strand is set (meaning consistent strand for
+ # all sublocs) and guide strand is the same than the last location from @loc_objs,
+ # then recover the sublocations and add them to @loc_objs. This way,
+ # "join(10..20,join(30..40,50..60))" becomes "join(10..20,30..40,50..60)"
+ my $guide_strand = ($loc_obj->isa('Bio::Location::SplitLocationI')) ? ($loc_obj->guide_strand || 0) : 0;
+ my $last_strand = (scalar @loc_objs > 0) ? $loc_objs[-1]->strand : 0;
+ if ( $guide_strand != 0
+ and $guide_strand == $last_strand
+ and $oparg eq $op # join(,join()) OK, order(join()) NOT OK
+ ) {
+ my @subloc_objs = $loc_obj->sub_Location(0);
+ foreach my $subloc_obj (@subloc_objs) {
+ push @loc_objs, $subloc_obj;
+ }
+ }
+ else {
+ push @loc_objs, $loc_obj;
+ }
}
my $ct = @loc_objs;
if ($op && !($op eq 'join' || $op eq 'order' || $op eq 'bond')
@@ -195,7 +195,6 @@ SKIP: {
# join(1000..2000,join(3000..4000,join(5000..6000,7000..8000)),9000..10000)
# is the same as
# join(1000..2000,3000..4000,5000..6000,7000..8000,9000..10000)
- # But I don't want to bother with it at this point
my @expected = (# intentionally testing same expected string twice
# as I am providing two different encodings
@@ -206,7 +205,7 @@ SKIP: {
'join(20464..20694,21548..22763,complement(join(231520..231669,232596..232990,314652..314672)))',
'join(20464..20694,21548..22763,complement(join(231520..231669,232596..232990,314652..314672)))',
# this is just seen once
- 'join(1000..2000,join(3000..4000,join(5000..6000,7000..8000)),9000..10000)',
+ 'join(1000..2000,3000..4000,5000..6000,7000..8000,9000..10000)',
'order(S67862.1:72..75,join(S67863.1:1..788,1..19))'
);

0 comments on commit 13b63a5

Please sign in to comment.