File Coverage

Bio/Map/PositionWithSequence.pm
Criterion Covered Total %
statement 20 20 100.0
branch 7 8 87.5
condition n/a
subroutine 4 4 100.0
pod 2 2 100.0
total 33 34 97.0


line stmt bran cond sub pod time code
1             # $Id: PositionWithSequence.pm,v 1.19 2006/09/20 10:20:01 sendu Exp $
2             #
3             # BioPerl module for Bio::Map::PositionWithSequence
4             #
5             # Please direct questions and support issues to
6             #
7             # Cared for by Sendu Bala
8             #
9             # Copyright Sendu Bala
10             #
11             # You may distribute this module under the same terms as perl itself
12              
13             # POD documentation - main docs before the code
14              
15             =head1 NAME
16              
17             Bio::Map::PositionWithSequence - A position with a sequence.
18              
19             =head1 SYNOPSIS
20              
21             use Bio::Map::PositionWithSequence;
22            
23             my $pos = Bio::Map::PositionWithSequence->new(-map => $map,
24             -element => $element,
25             -start => 0,
26             -seq => 'ATGC');
27              
28              
29             =head1 DESCRIPTION
30              
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.
34              
35             =head1 FEEDBACK
36              
37             =head2 Mailing Lists
38              
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.
42              
43             bioperl-l@bioperl.org - General discussion
44             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
45              
46             =head2 Support
47              
48             Please direct usage questions or support issues to the mailing list:
49              
50             I
51              
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.
56              
57             =head2 Reporting Bugs
58              
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:
62              
63             https://github.com/bioperl/bioperl-live/issues
64              
65             =head1 AUTHOR - Sendu Bala
66              
67             Email bix@sendu.me.uk
68              
69             =head1 APPENDIX
70              
71             The rest of the documentation details each of the object methods.
72             Internal methods are usually preceded with a _
73              
74             =cut
75              
76             # Let the code begin...
77              
78             package Bio::Map::PositionWithSequence;
79 1     1   5 use strict;
  1         1  
  1         30  
80              
81 1     1   4 use base qw(Bio::Map::Position Bio::LocatableSeq);
  1         1  
  1         706  
82              
83             =head2 new
84              
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
94              
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
100              
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
105              
106             =cut
107              
108             sub new {
109 9     9 1 21 my ($class, @args) = @_;
110 9         27 my $self = $class->SUPER::new(@args);
111            
112 9         29 my ($seq) = $self->_rearrange([qw( SEQ )], @args);
113            
114 9 100       27 $self->seq($seq) if $seq;
115            
116 9         20 return $self;
117             }
118              
119             =head2 seq
120              
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).
127              
128             =cut
129              
130             sub seq {
131 17     17 1 12 my ($self, $str, $alpha) = @_;
132            
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
135            
136 17         17 my $seq;
137 17 100       20 if ($str) {
138 3 50       13 $alpha ? ($seq = $self->SUPER::seq($str, $alpha)) : ($seq = $self->SUPER::seq($str));
139             }
140             else {
141 14         36 $seq = $self->SUPER::seq;
142             }
143            
144 17 100       28 if ($seq) {
145 9         23 $self->length(length($seq));
146 9         26 return $seq;
147             }
148 8         9 return;
149             }
150              
151             1;