BioPerl

 view release on metacpan or  search on metacpan

Bio/Location/Simple.pm  view on Meta::CPAN

=head2 length

 Title   : length
 Usage   : $len = $loc->length();
 Function: get the length in the coordinate space this location spans
 Example :
 Returns : an integer
 Args    : none

=cut

sub length {
    my ($self) = @_;
    if ($self->location_type eq 'IN-BETWEEN' ) {
        return 0;
    } else {
        return abs($self->end - $self->start) + 1;
    }
}


=head2 min_start

  Title   : min_start
  Usage   : my $minstart = $location->min_start();
  Function: Get minimum starting location of feature startpoint
  Returns : integer or undef if no minimum starting point.
  Args    : none

=cut

=head2 max_start

  Title   : max_start
  Usage   : my $maxstart = $location->max_start();
  Function: Get maximum starting location of feature startpoint.

            In this implementation this is exactly the same as min_start().

  Returns : integer or undef if no maximum starting point.
  Args    : none

=cut

=head2 start_pos_type

  Title   : start_pos_type
  Usage   : my $start_pos_type = $location->start_pos_type();
  Function: Get start position type (ie <,>, ^).

  Returns : type of position coded as text 
            ('BEFORE', 'AFTER', 'EXACT','WITHIN', 'BETWEEN')
  Args    : none

=cut

=head2 min_end

  Title   : min_end
  Usage   : my $minend = $location->min_end();
  Function: Get minimum ending location of feature endpoint 
  Returns : integer or undef if no minimum ending point.
  Args    : none

=cut


=head2 max_end

  Title   : max_end
  Usage   : my $maxend = $location->max_end();
  Function: Get maximum ending location of feature endpoint 

            In this implementation this is exactly the same as min_end().

  Returns : integer or undef if no maximum ending point.
  Args    : none

=cut

=head2 end_pos_type

  Title   : end_pos_type
  Usage   : my $end_pos_type = $location->end_pos_type();
  Function: Get end position type (ie <,>, ^) 

  Returns : type of position coded as text 
            ('BEFORE', 'AFTER', 'EXACT','WITHIN', 'BETWEEN')
  Args    : none

=cut

=head2 location_type

  Title   : location_type
  Usage   : my $location_type = $location->location_type();
  Function: Get location type encoded as text
  Returns : string ('EXACT' or 'IN-BETWEEN')
  Args    : 'EXACT' or '..' or 'IN-BETWEEN' or '^'

=cut

sub location_type {
    my ($self, $value) = @_;

    if( defined $value || ! defined $self->{'_location_type'} ) {
        $value = 'EXACT' unless defined $value;
        $value = uc $value;
        if (! defined $RANGEDECODE{$value}) {
            $value = '\^' if $value eq '^';
            $value = '\.\.' if $value eq '..';
            $value = $RANGEENCODE{$value};
        }
        $self->throw("Did not specify a valid location type. [$value] is no good")
            unless defined $value;
        $self->{'_location_type'} = $value;
    }
    $self->throw("Only adjacent residues when location type ".
            "is IN-BETWEEN. Not [". $self->{'_start'}. "] and [".
            $self->{'_end'}. "]" )
        if $self->{'_location_type'} eq 'IN-BETWEEN' &&
        defined $self->{'_start'} &&
        defined $self->{'_end'} &&
            ($self->{'_end'} - 1 != $self->{'_start'});

    return $self->{'_location_type'};
}

=head2 is_remote

 Title   : is_remote
 Usage   : $is_remote_loc = $loc->is_remote()



( run in 0.577 second using v1.01-cache-2.11-cpan-39bf76dae61 )