9 my ( $self, $id ) = @_;
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 return $self->{ __PACKAGE__ . "seq" };
31 return scalar @{ [ $self->seq ] };
35 # my ($self, $set) = @_;
37 # $self->{__PACKAGE__."numeric"} = $set :
38 # $self->{__PACKAGE__."numeric"};
41 #use Scalar::Util qw(looks_like_number);
43 # my ($self, @entries) = @_;
45 # my $numeric = grep { looks_like_number $_ } @entries;
46 # if ($numeric != 0 && $numeric != @entries) {
47 # die "Can't compress both numeric and non-numeric data";
52 # $self->seq(pack "d*", @entries)
54 # else { $self->seq(join '', @entries) }
62 my ( $self, @segments ) = @_;
64 my $package = ref $self;
66 return $self->seq unless @segments;
67 confess "Passed an uneven number of segments" unless @segments % 2 == 0;
70 my %segments = @segments;
72 # Find out if there are overlapping segments
73 for my $pri ( sort keys %segments ) {
74 for my $test ( sort keys %segments ) {
75 next if $pri == $test;
76 croak "Overlapping segments" if $test < $segments{$pri};
82 my ( $i, @seq ) = ( 0, $self->seq );
84 my ( $start, $end ) = @segments[ $i, $i + 1 ];
86 # Create a new sequence object in the correct package, and put the
88 my $new_seq = $package->new( id => $self->id );
89 $new_seq->seq( @seq[ $start .. $end ] );
90 push @sections, $new_seq;
92 } while ( $i < @segments );
103 Sequence - Holds information about a sequence
107 my $seq = Sequence->new;
109 $seq->id("Big wobbly molecule");
110 my @residues = split //, "ASEQENCE";
111 $seq->seq(@residues);
115 Inherits from the Root class.
121 Accessor for the sequence ID.
123 =head2 seq(@sequence_data)
125 Accessor for the sequence. Pass the information in as an array, one piece per position.
127 Returns an array reference if called in a scalar context, otherwise an array of the information.
131 Returns the length of the sequence.
135 Jonathan Barber <jon@compbio.dundee.ac.uk>