Remove manipulation of @INC and use of lib - require install for use.
[bioperl-live.git] / lib / Bio / Map / PositionWithSequence.pm
blob901c0bfd2b870e2d996c071798559c0f46671993
1 # $Id: PositionWithSequence.pm,v 1.19 2006/09/20 10:20:01 sendu Exp $
3 # BioPerl module for Bio::Map::PositionWithSequence
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Sendu Bala <bix@sendu.me.uk>
9 # Copyright Sendu Bala
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
15 =head1 NAME
17 Bio::Map::PositionWithSequence - A position with a sequence.
19 =head1 SYNOPSIS
21 use Bio::Map::PositionWithSequence;
23 my $pos = Bio::Map::PositionWithSequence->new(-map => $map,
24 -element => $element,
25 -start => 0,
26 -seq => 'ATGC');
29 =head1 DESCRIPTION
31 Have a position with a sequence, eg. define what the binding site sequence of
32 a certain transcription factor binding site is by modelling it as one of these
33 objects with the -element assigned to a Bio::Map::TranscriptionFactor instance.
35 =head1 FEEDBACK
37 =head2 Mailing Lists
39 User feedback is an integral part of the evolution of this and other
40 Bioperl modules. Send your comments and suggestions preferably to
41 the Bioperl mailing list. Your participation is much appreciated.
43 bioperl-l@bioperl.org - General discussion
44 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
46 =head2 Support
48 Please direct usage questions or support issues to the mailing list:
50 I<bioperl-l@bioperl.org>
52 rather than to the module maintainer directly. Many experienced and
53 reponsive experts will be able look at the problem and quickly
54 address it. Please include a thorough description of the problem
55 with code and data examples if at all possible.
57 =head2 Reporting Bugs
59 Report bugs to the Bioperl bug tracking system to help us keep track
60 of the bugs and their resolution. Bug reports can be submitted via the
61 web:
63 https://github.com/bioperl/bioperl-live/issues
65 =head1 AUTHOR - Sendu Bala
67 Email bix@sendu.me.uk
69 =head1 APPENDIX
71 The rest of the documentation details each of the object methods.
72 Internal methods are usually preceded with a _
74 =cut
76 # Let the code begin...
78 package Bio::Map::PositionWithSequence;
79 use strict;
81 use base qw(Bio::Map::Position Bio::LocatableSeq);
83 =head2 new
85 Title : new
86 Usage : my $obj = Bio::Map::PositionWithSequence->new();
87 Function: Builds a new Bio::Map::PositionWithSequence object
88 Returns : Bio::Map::PositionWithSequence
89 Args : -map => Bio::Map::GeneMap object
90 -element => Bio::Map::Gene object
91 -relative => Bio::Map::GeneRelative object
92 -seq => string, length of this string will set the length
93 of this position's range
95 * If this position has no range, or if a single value can describe
96 the range *
97 -value => scalar : something that describes the single
98 point position or range of this
99 Position, most likely an int
101 * Or if this position has a range, at least two of *
102 -start => int : value of the start co-ordinate
103 -end => int : value of the end co-ordinate
104 -length => int : length of the range
106 =cut
108 sub new {
109 my ($class, @args) = @_;
110 my $self = $class->SUPER::new(@args);
112 my ($seq) = $self->_rearrange([qw( SEQ )], @args);
114 $self->seq($seq) if $seq;
116 return $self;
119 =head2 seq
121 Title : seq
122 Usage : my $string = $obj->seq();
123 Function: Get/set the sequence as a string of letters.
124 Returns : scalar
125 Args : Optionally on set the new value (a string). An optional second
126 argument presets the alphabet (otherwise it will be guessed).
128 =cut
130 sub seq {
131 my ($self, $str, $alpha) = @_;
133 # done like this because SUPER will set seq to undef if undef supplied,
134 # but GeneMap wants to send undef, undef, 1 to decendants of this method
136 my $seq;
137 if ($str) {
138 $alpha ? ($seq = $self->SUPER::seq($str, $alpha)) : ($seq = $self->SUPER::seq($str));
140 else {
141 $seq = $self->SUPER::seq;
144 if ($seq) {
145 $self->length(length($seq));
146 return $seq;
148 return;