[bug 2714]
[bioperl-live.git] / Bio / Map / PositionWithSequence.pm
blob3c531c68b67025c574c58a009b34c1c388b87272
1 # $Id: PositionWithSequence.pm,v 1.19 2006/09/20 10:20:01 sendu Exp $
3 # BioPerl module for Bio::Map::PositionWithSequence
5 # Cared for by Sendu Bala <bix@sendu.me.uk>
7 # Copyright Sendu Bala
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
13 =head1 NAME
15 Bio::Map::PositionWithSequence - A position with a sequence.
17 =head1 SYNOPSIS
19 use Bio::Map::PositionWithSequence;
21 my $pos = Bio::Map::PositionWithSequence->new(-map => $map,
22 -element => $element,
23 -start => 0,
24 -seq => 'ATGC');
27 =head1 DESCRIPTION
29 Have a position with a sequence, eg. define what the binding site sequence of
30 a certain transcription factor binding site is by modelling it as one of these
31 objects with the -element assigned to a Bio::Map::TranscriptionFactor instance.
33 =head1 FEEDBACK
35 =head2 Mailing Lists
37 User feedback is an integral part of the evolution of this and other
38 Bioperl modules. Send your comments and suggestions preferably to
39 the Bioperl mailing list. Your participation is much appreciated.
41 bioperl-l@bioperl.org - General discussion
42 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
44 =head2 Reporting Bugs
46 Report bugs to the Bioperl bug tracking system to help us keep track
47 of the bugs and their resolution. Bug reports can be submitted via the
48 web:
50 http://bugzilla.open-bio.org/
52 =head1 AUTHOR - Sendu Bala
54 Email bix@sendu.me.uk
56 =head1 APPENDIX
58 The rest of the documentation details each of the object methods.
59 Internal methods are usually preceded with a _
61 =cut
63 # Let the code begin...
65 package Bio::Map::PositionWithSequence;
66 use strict;
68 use base qw(Bio::Map::Position Bio::LocatableSeq);
70 =head2 new
72 Title : new
73 Usage : my $obj = Bio::Map::PositionWithSequence->new();
74 Function: Builds a new Bio::Map::PositionWithSequence object
75 Returns : Bio::Map::PositionWithSequence
76 Args : -map => Bio::Map::GeneMap object
77 -element => Bio::Map::Gene object
78 -relative => Bio::Map::GeneRelative object
79 -seq => string, length of this string will set the length
80 of this position's range
82 * If this position has no range, or if a single value can describe
83 the range *
84 -value => scalar : something that describes the single
85 point position or range of this
86 Position, most likely an int
88 * Or if this position has a range, at least two of *
89 -start => int : value of the start co-ordinate
90 -end => int : value of the end co-ordinate
91 -length => int : length of the range
93 =cut
95 sub new {
96 my ($class, @args) = @_;
97 my $self = $class->SUPER::new(@args);
99 my ($seq) = $self->_rearrange([qw( SEQ )], @args);
101 $self->seq($seq) if $seq;
103 return $self;
106 =head2 seq
108 Title : seq
109 Usage : my $string = $obj->seq();
110 Function: Get/set the sequence as a string of letters.
111 Returns : scalar
112 Args : Optionally on set the new value (a string). An optional second
113 argument presets the alphabet (otherwise it will be guessed).
115 =cut
117 sub seq {
118 my ($self, $str, $alpha) = @_;
120 # done like this because SUPER will set seq to undef if undef supplied,
121 # but GeneMap wants to send undef, undef, 1 to decendants of this method
123 my $seq;
124 if ($str) {
125 $alpha ? ($seq = $self->SUPER::seq($str, $alpha)) : ($seq = $self->SUPER::seq($str));
127 else {
128 $seq = $self->SUPER::seq;
131 if ($seq) {
132 $self->length(length($seq));
133 return $seq;
135 return;