diff --git a/lib/Bio/Factory/FTLocationFactory.pm b/lib/Bio/Factory/FTLocationFactory.pm index 544b675..ebaf433 100644 --- a/lib/Bio/Factory/FTLocationFactory.pm +++ b/lib/Bio/Factory/FTLocationFactory.pm @@ -26,6 +26,10 @@ method from_string($locstr is copy ,$op?) { # convert ABC123:(X..Y) to ABC123:[X..Y] # we should never see the above # $locstr =~ s{:\((\d+\.{2}\d+)\)}{:\[$1\]}g; + while ($locstr ~~ / \: \( (\d+ \. ** 2 \d+) \)/ ) { + $locstr ~~ s/ \: \( (\d+ \. ** 2 \d+) \) /\:\[$0\]/; + } + } # if ($locstr =~ m{(.*?)\(($LOCREG)\)(.*)}o) { # any matching parentheses? @@ -52,7 +56,6 @@ method from_string($locstr is copy ,$op?) { # && $sub !~~ m{(?:join|order|bond)}) { my @splitlocs = split(',' , $sub); - $loc_obj = Bio::Role::Location::Split.new(#verbose => 1, splittype => $oparg); @@ -109,15 +112,15 @@ method from_string($locstr is copy ,$op?) { -method !parse_location($locstr) { +method !parse_location($locstr is copy) { my ($loc, $seqid); #self.debug( "Location parse, processing $locstr\n"); # 'remote' location? - # if($locstr =~ m{^(\S+):(.*)$}o) { - # # yes; memorize remote ID and strip from location string - # $seqid = $1; - # $locstr = $2; - # } + if ($locstr ~~ /^(\S+)\:(.*)$/) { + # yes; memorize remote ID and strip from location string + $seqid = $0; + $locstr = $1; + } # split into start and end my ($start, $end) = split(/\.\./, $locstr); @@ -126,7 +129,10 @@ method !parse_location($locstr) { # possibly surrounding the entire location the parentheses around start # and/or may be asymmetrical # Note: these are from X.Y fuzzy locations, which are deprecated! + # $start =~ s/(?:^\[+|\]+$)//g if $start; + $start ~~ s/^\[+|\]+// if $start; + $end ~~ s/^\[+|\]+// if $end; # $end =~ s/(?:^\[+|\]+$)//g if $end; # Is this a simple (exact) or a fuzzy location? Simples have exact start @@ -167,8 +173,6 @@ method !parse_location($locstr) { if ( $start_num > $end_num && $loctype ne '?') { ($start,$end,$strand) = ($end,$start,-1); } - - # instantiate location and initialize $loc = $locclass.new(#verbose => self.verbose, start => $start, diff --git a/lib/Bio/Role/Location/Split.pm b/lib/Bio/Role/Location/Split.pm index 93894d1..f5e4b5b 100644 --- a/lib/Bio/Role/Location/Split.pm +++ b/lib/Bio/Role/Location/Split.pm @@ -213,7 +213,7 @@ multi method strand($value?) { if ((! $lstrand) || ($strand && ($strand != $lstrand)) || $loc.is_remote()) { - $strand = Mu; + $strand = Any; last; } elsif (! $strand) { $strand = $lstrand; diff --git a/t/Factory/FTLocationFactory.t b/t/Factory/FTLocationFactory.t index 02a9d33..1aef146 100644 --- a/t/Factory/FTLocationFactory.t +++ b/t/Factory/FTLocationFactory.t @@ -48,16 +48,16 @@ my %testcases = ( # 2691, 2691, "EXACT", 5163, 5163, "EXACT", "EXACT", 2, -1], # "complement(34..(122.126))" => [$fuzzy_impl, # 34, 34, "EXACT", 122, 126, "WITHIN", "EXACT", 1, -1], -# "J00194:100..202" => [$simple_impl, -# 100, 100, "EXACT", 202, 202, "EXACT", "EXACT", 1, 1], + "J00194:100..202" => [$simple_impl, + 100, 100, "EXACT", 202, 202, "EXACT", "EXACT", 1, 1], # # this variant is not really allowed by the FT definition # # document but we want to be able to cope with it -# "J00194:(100..202)" => [$simple_impl, -# 100, 100, "EXACT", 202, 202, "EXACT", "EXACT", 1, 1], + "J00194:(100..202)" => [$simple_impl, + 100, 100, "EXACT", 202, 202, "EXACT", "EXACT", 1, 1], # "((122.133)..(204.221))" => [$fuzzy_impl, # 122, 133, "WITHIN", 204, 221, "WITHIN", "EXACT", 1, 1], -# "join(AY016290.1:108..185,AY016291.1:1546..1599)"=> [$split_impl, -# 108, 108, "EXACT", 185, 185, "EXACT", "EXACT", 2, undef], + "join(AY016290.1:108..185,AY016291.1:1546..1599)"=> [$split_impl, + 108, 108, "EXACT", 185, 185, "EXACT", "EXACT", 2, Any], # # UNCERTAIN locations and positions (Swissprot) # "?2465..2774" => [$fuzzy_impl, @@ -85,10 +85,10 @@ my $locfac = Bio::Factory::FTLocationFactory.new(); ok($locfac ~~ Bio::Factory::FTLocationFactory, 'Is Bio::Location::FTLocationFactory Role'); # sorting is to keep the order constant from one run to the next -for keys %testcases -> $locstr { +for keys %testcases -> $locstr is copy { my $loc = $locfac.from_string($locstr); if ($locstr eq "join(AY016290.1:108..185,AY016291.1:1546..1599)") { - $loc.seq_id("AY016295.1"); + $loc.seq_id ="AY016295.1"; } my @res = @(%testcases{$locstr}); is($loc.WHAT, @res[0], @res[0]); @@ -111,6 +111,7 @@ for keys %testcases -> $locstr { is($ftstr, $locstr, "Location String: $locstr"); # test strand production is($loc.strand(), @res[9]); + } # SKIP: {