This is used as parent for exon and intron classes.
sub new
{ my ($thing, %args) = @_;
my $class = ref($thing) || $thing;
my ($obj,%range);
my ($seq,$start,$end,$strand)=($args{-seq},$args{-start},$args{-end},$args{-strand});
$obj =\% range;
$obj = bless $obj, $class;
unless ($seq->valid($start)) {
$obj->warn("$class not initialised because start label not valid");
return (-1);
}
unless ($seq->valid($end)) {
$obj->warn("$class not initialised because end label not valid");
return (-1);
}
unless (defined $strand) {
$strand = 1;
}
if (($strand != 1)&&($strand != -1)) {
$obj->warn("$class not initialised because strand identifier not valid. Use 1 (forward strand) or -1 (reverse strand).");
return (-1);
}
if ($start eq $end) {
$obj->warn("$class reports: start and end label are the same....");
} else {
unless ($seq->follows($start,$end,$strand)==1) {
$obj->warn("Fatal: end label $end doesn't follow start label $start for strand $strand!");
return (-1);
}
}
$obj->{'seq'}=$seq;
$obj->{'start'}=$start;
$obj->{'end'}=$end;
$obj->{'strand'}=$strand;
return $obj; } |