BioPerl
view release on metacpan or search on metacpan
Bio/Location/Fuzzy.pm view on Meta::CPAN
if(@args) {
$self->{'_min_start'} = $args[0]; # the value may be undef!
}
return $self->{'_min_start'};
}
=head2 max_start
Title : max_start
Usage : my $maxstart = $location->max_start();
Function: Get/set maximum starting location of feature startpoint
Returns : integer or undef if no maximum starting point.
Args : integer or undef on set
=cut
sub max_start {
my ($self,@args) = @_;
if(@args) {
$self->{'_max_start'} = $args[0]; # the value may be undef!
}
return $self->{'_max_start'};
}
=head2 start_pos_type
Title : start_pos_type
Usage : my $start_pos_type = $location->start_pos_type();
Function: Get/set start position type.
Returns : type of position coded as text
('BEFORE','AFTER','EXACT','WITHIN','BETWEEN','UNCERTAIN')
Args : a string on set
=cut
sub start_pos_type {
my ($self,$value) = @_;
if(defined $value && $value =~ /^\d+$/ ) {
if( $value == 0 ) { $value = 'EXACT'; }
else {
my $v = $LOCATIONCODESBSANE[$value];
if( ! defined $v ) {
$self->warn("Provided value $value which I don't understand,".
" reverting to 'EXACT'");
$v = 'EXACT';
}
$value = $v;
}
}
if(defined($value)) {
$self->{'_start_pos_type'} = $value;
}
return $self->{'_start_pos_type'};
}
=head2 min_end
Title : min_end
Usage : my $minend = $location->min_end();
Function: Get/set minimum ending location of feature endpoint
Returns : integer or undef if no minimum ending point.
Args : integer or undef on set
=cut
sub min_end {
my ($self,@args) = @_;
if(@args) {
$self->{'_min_end'} = $args[0]; # the value may be undef!
}
return $self->{'_min_end'};
}
=head2 max_end
Title : max_end
Usage : my $maxend = $location->max_end();
Function: Get/set maximum ending location of feature endpoint
Returns : integer or undef if no maximum ending point.
Args : integer or undef on set
=cut
sub max_end {
my ($self,@args) = @_;
if(@args) {
$self->{'_max_end'} = $args[0]; # the value may be undef!
}
return $self->{'_max_end'};
}
=head2 end_pos_type
Title : end_pos_type
Usage : my $end_pos_type = $location->end_pos_type();
Function: Get/set end position type.
Returns : type of position coded as text
('BEFORE','AFTER','EXACT','WITHIN','BETWEEN','UNCERTAIN')
Args : a string on set
=cut
sub end_pos_type {
my ($self,$value) = @_;
if( defined $value && $value =~ /^\d+$/ ) {
if( $value == 0 ) { $value = 'EXACT'; }
else {
my $v = $LOCATIONCODESBSANE[$value];
if( ! defined $v ) {
$self->warn("Provided value $value which I don't understand,".
" reverting to 'EXACT'");
$v = 'EXACT';
}
$value = $v;
}
}
if(defined($value)) {
$self->{'_end_pos_type'} = $value;
}
return $self->{'_end_pos_type'};
}
=head2 seq_id
Title : seq_id
Usage : my $seqid = $location->seq_id();
Function: Get/Set seq_id that location refers to
Returns : seq_id
Args : [optional] seq_id value to set
=cut
=head2 coordinate_policy
Title : coordinate_policy
Bio/Location/Fuzzy.pm view on Meta::CPAN
$strs{$point} .= $FUZZYCODES{$vals{$point."_code"}};
$strs{$point} .= $vals{"$point"};
}
if( defined $vals{$point."_code"} &&
($vals{$point."_code"} eq 'WITHIN' ||
$vals{$point."_code"} eq 'BETWEEN'))
{
# Expect odd results with anything but WidestCoordPolicy for now
$strs{$point} .= ($point eq 'start') ?
$vals{"$point"}.
$FUZZYCODES{$vals{$point."_code"}}.
$vals{'max_'.$point}
:
$vals{'min_'.$point}.
$FUZZYCODES{$vals{$point."_code"}}.
$vals{"$point"};
$strs{$point} = "(".$strs{$point}.")";
}
} elsif ($vals{$point."_code"} eq 'UNCERTAIN') {
$strs{$point} = $FUZZYCODES{$vals{$point."_code"}};
$strs{$point} .= $vals{$point} if defined $vals{$point};
} else {
$strs{$point} = $vals{$point};
}
}
my $str = $strs{'start'} . $delimiter . $strs{'end'};
if($self->is_remote() && $self->seq_id()) {
$str = $self->seq_id() . ":" . $str;
}
if( defined $self->strand &&
$self->strand == -1 &&
$self->location_type() ne "UNCERTAIN") {
$str = "complement(" . $str . ")";
} elsif($self->location_type() eq "WITHIN") {
$str = "(".$str.")";
}
return $str;
}
=head2 valid_Location
Title : valid_Location
Usage : if ($location->valid_location) {...};
Function: boolean method to determine whether location is considered valid
(has minimum requirements for Simple implementation)
Returns : Boolean value: true if location is valid, false otherwise
Args : none
=cut
=head2 _fuzzypointdecode
Title : _fuzzypointdecode
Usage : ($type,$min,$max) = $self->_fuzzypointdecode('<5');
Function: Decode a fuzzy string.
Returns : A 3-element array consisting of the type of location, the
minimum integer, and the maximum integer describing the range
of coordinates this start or endpoint refers to. Minimum or
maximum coordinate may be undefined.
: Returns empty array on fail.
Args : fuzzypoint string
=cut
sub _fuzzypointdecode {
my ($self, $string) = @_;
return () if( !defined $string);
# strip off leading and trailing space
$string =~ s/^\s*(\S+)\s*/$1/;
foreach my $pattern ( keys %FUZZYPOINTENCODE ) {
if( $string =~ /^$pattern$/ ) {
my ($min,$max) = ($1,$2) unless (($1 eq '') && (!defined $2));
if( ($FUZZYPOINTENCODE{$pattern} eq 'EXACT') ||
($FUZZYPOINTENCODE{$pattern} eq 'UNCERTAIN')
) {
$max = $min;
} else {
$max = undef if((defined $max) && (length($max) == 0));
$min = undef if((defined $min) && (length($min) == 0));
}
return ($FUZZYPOINTENCODE{$pattern},$min,$max);
}
}
if( $self->verbose >= 1 ) {
$self->warn("could not find a valid fuzzy encoding for $string");
}
return ();
}
1;
( run in 1.030 second using v1.01-cache-2.11-cpan-39bf76dae61 )