~ubuntu-branches/ubuntu/saucy/bioperl/saucy-proposed

« back to all changes in this revision

Viewing changes to Bio/Graphics/Util.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package Bio::Graphics::Util;
2
 
 
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
5
 
 
6
 
=head1 NAME
7
 
 
8
 
Bio::Graphics::Util - non-object-oriented utilities used in Bio::Graphics modules
9
 
 
10
 
=cut
11
 
 
12
 
use strict;
13
 
require Exporter;
14
 
use base qw(Exporter);
15
 
use vars '@EXPORT','@EXPORT_OK';
16
 
@EXPORT = 'frame_and_offset';
17
 
use Bio::Root::Version;
18
 
 
19
 
=over 4
20
 
 
21
 
=item ($frame,$offset) = frame_and_offset($pos,$strand,$phase)
22
 
 
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
25
 
of the reading frame.
26
 
 
27
 
In a scalar context, returns the frame only.
28
 
 
29
 
=back
30
 
 
31
 
=cut
32
 
 
33
 
sub frame_and_offset {
34
 
  my ($pos,$strand,$phase) = @_;
35
 
  $strand ||= +1;
36
 
  $phase  ||= 0;
37
 
  my $codon_start =  $strand >= 0
38
 
                   ? $pos + $phase
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;
46
 
}
47
 
 
48
 
 
49
 
1;