11 $self->{__PACKAGE__."id"} = $id :
12 return $self->{__PACKAGE__."id"};
16 my ($self, @entries) = @_;
17 if (@entries) { $self->{__PACKAGE__."seq"} = [ @entries ] }
20 return defined $self->{__PACKAGE__."seq"} ?
21 @{ $self->{__PACKAGE__."seq"} } :
24 else { return $self->{__PACKAGE__."seq"} }
30 return scalar @{ [ $self->seq ] };
34 # my ($self, $set) = @_;
36 # $self->{__PACKAGE__."numeric"} = $set :
37 # $self->{__PACKAGE__."numeric"};
40 #use Scalar::Util qw(looks_like_number);
42 # my ($self, @entries) = @_;
44 # my $numeric = grep { looks_like_number $_ } @entries;
45 # if ($numeric != 0 && $numeric != @entries) {
46 # die "Can't compress both numeric and non-numeric data";
51 # $self->seq(pack "d*", @entries)
53 # else { $self->seq(join '', @entries) }
61 my ($self, @segments) = @_;
63 my $package = ref $self;
65 return $self->seq unless @segments;
66 confess "Passed an uneven number of segments" unless @segments % 2 == 0;
69 my %segments = @segments;
70 # Find out if there are overlapping segments
71 for my $pri (sort keys %segments) {
72 for my $test (sort keys %segments) {
73 next if $pri == $test;
74 croak "Overlapping segments" if $test < $segments{$pri};
80 my ($i, @seq) = (0, $self->seq);
82 my ($start, $end) = @segments[$i, $i + 1];
84 # Create a new sequence object in the correct package, and put the
86 my $new_seq = $package->new(id => $self->id);
87 $new_seq->seq( @seq[ $start .. $end ] );
88 push @sections, $new_seq;
90 } while ($i < @segments);
101 Sequence - Holds information about a sequence
105 my $seq = Sequence->new;
107 $seq->id("Big wobbly molecule");
108 my @residues = split //, "ASEQENCE";
109 $seq->seq(@residues);
113 Inherits from the Root class.
119 Accessor for the sequence ID.
121 =head2 seq(@sequence_data)
123 Accessor for the sequence. Pass the information in as an array, one piece per position.
125 Returns an array reference if called in a scalar context, otherwise an array of the information.
129 Returns the length of the sequence.
133 Jonathan Barber <jon@compbio.dundee.ac.uk>