Bio-ViennaNGS

 view release on metacpan or  search on metacpan

lib/Bio/ViennaNGS/FeatureInterval.pm  view on Meta::CPAN

# -*-CPerl-*-
# Last changed Time-stamp: <2018-11-25 21:40:36 mtw>

package Bio::ViennaNGS::FeatureInterval;

use Bio::ViennaNGS;
use namespace::autoclean;
use Carp;
use Moose;
use version; our $VERSION = version->declare("$Bio::ViennaNGS::VERSION");

has 'chromosome' => (
		     is  => 'rw',
		     isa => 'Str',
		     required => 1,
		     predicate => 'has_chromosome',
		    );

has 'start' => (
		is      => 'rw',
		isa     => 'Int',
		required => 1,
		predicate => 'has_start',
	       );

has 'end' => (
	      is      => 'rw',
	      isa     => 'Int',
	      required => 1,
	      predicate => 'has_end',
	     );

has '_length' => ( # length of interval
		  is => 'rw',
		  isa => 'Int',
		  predicate => 'length',
		  init_arg => undef, # make this unsettable via constructor
		 );

with 'Bio::ViennaNGS::FeatureBase';

sub BUILD { # call a parser method, depending on $self->instanceOf
  my $self = shift;
  my $this_function = (caller(0))[3];
  my $len = undef;

  if ($self->base == 0){
    confess "ERROR [$this_function] \$self->end must be > than \$self->start for 0-based start coordinates [==> start ".eval($self->start)." end ".eval($self->end)." <==]"
      unless ($self->end > $self->start);
    $len = eval($self->end)-eval($self->start)-1;
    $self->_length($len);
  }
  else {
    confess "ERROR [$this_function] \$self->end must be >= than \$self->start for 0-based start coordinates [==> start ".eval($self->start)." end ".eval($self->end)." <==]"
      unless ($self->end >= $self->start);
    $len = $self->end-$self->start;
    $self->_length($len);
  }
}

sub dump {
  my $self = shift;
  print join("\t",
	     $self->chromosome,
	     $self->start,
	     $self->end),
	       "\n";



( run in 1.570 second using v1.01-cache-2.11-cpan-99c4e6809bf )