sub new {
my $class = shift;
my ($attrib, $start, $end, $alt_seq, $name, $desc, $code) =
rearrange([qw(ATTRIB START END ALT_SEQ NAME DESCRIPTION CODE)], @_);
my $self;
if($attrib) {
if(defined($start) || defined($end) || defined($alt_seq) ||
defined($name) || defined($desc) || defined($code)) {
throw("Cannot specify -ATTRIB argument with additional arguments.");
}
if(!ref($attrib) || !$attrib->isa('Bio::EnsEMBL::Attribute')) {
throw('Bio::EnsEMBL::Attribute argument expected.');
}
($start, $end, $alt_seq) = split(/\s+/, $attrib->value());
if($start !~ /\d+/ || $end !~ /\d+/) {
throw('Could not parse value of attribute: '.$attrib->value());
}
$name = $attrib->name();
$code = $attrib->code();
$desc = $attrib->description();
}
if(defined($end) && defined($start) && $start > $end+1) {
throw("start must be less than or equal to end + 1");
}
if(defined($start) && $start < 1) {
throw("start must be greater than or equal to 1");
}
if(defined($end) && $end < 0) {
throw("end must be greater than or equal to 0");
}
$alt_seq ||= '';
return bless {'start' => $start,
'end' => $end,
'alt_seq' => $alt_seq,
'description' => $desc,
'name' => $name,
'code' => $code}, $class;
}