1
package Bio::Graphics::Util;
3
# $Id: Util.pm,v 1.4.4.1 2006/10/02 23:10:19 sendu Exp $
4
# Non object-oriented utilities used here-and-there in Bio::Graphics modules
8
Bio::Graphics::Util - non-object-oriented utilities used in Bio::Graphics modules
14
use base qw(Exporter);
15
use vars '@EXPORT','@EXPORT_OK';
16
@EXPORT = 'frame_and_offset';
17
use Bio::Root::Version;
21
=item ($frame,$offset) = frame_and_offset($pos,$strand,$phase)
23
Calculate the reading frame for a given genomic position, strand and
24
phase. The offset is the offset from $pos to the first nucleotide
27
In a scalar context, returns the frame only.
33
sub frame_and_offset {
34
my ($pos,$strand,$phase) = @_;
37
my $codon_start = $strand >= 0
39
: $pos - $phase; # probably wrong
40
my $frame = ($codon_start-1) % 3;
41
# my $frame = $strand >= 0
42
# ? ($pos - $phase - 1) % 3
43
# : (1 - $pos - $phase) % 3;
44
my $offset = $strand >= 0 ? $phase : -$phase;
45
return wantarray ? ($frame,$offset) : $frame;