~ubuntu-branches/ubuntu/lucid/bioperl/lucid

« back to all changes in this revision

Viewing changes to Bio/DB/GFF/Util/Binning.pm

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2004-04-18 14:24:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040418142411-gr92uexquw4w8liq
Tags: 1.4-1
* New upstream release
* Examples and working code are installed by default to usr/bin,
  this has been moved to usr/share/doc/bioperl/bin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
=head1 NAME
 
2
 
 
3
Bio::DB::GFF::Util::Binning - binning utility for Bio::DB::GFF index
 
4
 
 
5
=head1 SYNOPSIS
 
6
 
 
7
 use Bio::DB::GFF::Util::Binning qw(bin bin_bot bin_top);
 
8
 my $tier = bin($start,$stop,$min);
 
9
 
 
10
=head1 DESCRIPTION
 
11
 
 
12
This is a utility module that exports the functions bin(), bin_bot()
 
13
and bin_top().  These functions translate a range on the genome into a
 
14
named bin that is used as an index in the Bio::DB::GFF schema.  The
 
15
index makes certain range retrieval queries much faster.
 
16
 
 
17
=head1 API
 
18
 
 
19
The remainder of the document describes the function calls.  No calls
 
20
are exported by default, but must be imported explicitly.
 
21
 
 
22
=over 4
 
23
 
 
24
=cut
 
25
 
1
26
package Bio::DB::GFF::Util::Binning;
2
27
 
3
28
use strict;
4
29
require Exporter;
5
 
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
 
30
use vars qw(@ISA @EXPORT @EXPORT_OK);
6
31
@ISA = 'Exporter';
7
32
@EXPORT_OK = qw(bin bin_bot bin_top);
8
33
@EXPORT = @EXPORT_OK;
 
34
use Bio::Root::Version;
 
35
 
 
36
=item $bin_name = bin($start,$stop,$bin_size)
 
37
 
 
38
Given a start, stop and bin size on the genome, translate this
 
39
location into a bin name.  In a list context, returns the bin tier
 
40
name and the position that the bin begins.
 
41
 
 
42
=cut
9
43
 
10
44
sub bin {
11
45
  my ($start,$stop,$min) = @_;
20
54
  return wantarray ? ($tier,$bin_start) : bin_name($tier,$bin_start);
21
55
}
22
56
 
 
57
=item $bottom = bin_bot($tier,$start)
 
58
 
 
59
Given a tier name and a range start position, returns the lower end of
 
60
the bin range.
 
61
 
 
62
=cut
 
63
 
23
64
sub bin_bot {
24
65
  my $tier = shift;
25
66
  my $pos  = shift;
26
67
  bin_name($tier,int($pos/$tier));
27
68
}
 
69
 
 
70
=item $top = bin_top($tier,$end)
 
71
 
 
72
Given a tier name and the end of a range, returns the upper end of the
 
73
bin range.
 
74
 
 
75
=cut
 
76
 
28
77
*bin_top = \&bin_bot;
29
78
 
30
 
sub bin_name { sprintf("%d.%06d",@_) }
 
79
sub bin_name {my ($tier, $int) = @_;  sprintf("%d.%06d",$tier, abs($int)) }
31
80
 
32
81
sub log10 {
33
82
  my $i = shift;
35
84
}
36
85
 
37
86
1;
 
87
 
 
88
=back
 
89
 
 
90
=head1 BUGS
 
91
 
 
92
None known yet.
 
93
 
 
94
=head1 SEE ALSO
 
95
 
 
96
L<Bio::DB::GFF>,
 
97
 
 
98
=head1 AUTHOR
 
99
 
 
100
Lincoln Stein E<lt>lstein@cshl.orgE<gt>.
 
101
 
 
102
Copyright (c) 2001 Cold Spring Harbor Laboratory.
 
103
 
 
104
This library is free software; you can redistribute it and/or modify
 
105
it under the same terms as Perl itself.
 
106
 
 
107
=cut