0
|
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
|
|
26 package Bio::DB::GFF::Util::Binning;
|
|
27
|
|
28 use strict;
|
|
29 require Exporter;
|
|
30 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
|
|
31 @ISA = 'Exporter';
|
|
32 @EXPORT_OK = qw(bin bin_bot bin_top);
|
|
33 @EXPORT = @EXPORT_OK;
|
|
34
|
|
35 =item $bin_name = bin($start,$stop,$bin_size)
|
|
36
|
|
37 Given a start, stop and bin size on the genome, translate this
|
|
38 location into a bin name. In a list context, returns the bin tier
|
|
39 name and the position that the bin begins.
|
|
40
|
|
41 =cut
|
|
42
|
|
43 sub bin {
|
|
44 my ($start,$stop,$min) = @_;
|
|
45 my $tier = $min;
|
|
46 my ($bin_start,$bin_end);
|
|
47 while (1) {
|
|
48 $bin_start = int $start/$tier;
|
|
49 $bin_end = int $stop/$tier;
|
|
50 last if $bin_start == $bin_end;
|
|
51 $tier *= 10;
|
|
52 }
|
|
53 return wantarray ? ($tier,$bin_start) : bin_name($tier,$bin_start);
|
|
54 }
|
|
55
|
|
56 =item $bottom = bin_bot($tier,$start)
|
|
57
|
|
58 Given a tier name and a range start position, returns the lower end of
|
|
59 the bin range.
|
|
60
|
|
61 =cut
|
|
62
|
|
63 sub bin_bot {
|
|
64 my $tier = shift;
|
|
65 my $pos = shift;
|
|
66 bin_name($tier,int($pos/$tier));
|
|
67 }
|
|
68
|
|
69 =item $top = bin_top($tier,$end)
|
|
70
|
|
71 Given a tier name and the end of a range, returns the upper end of the
|
|
72 bin range.
|
|
73
|
|
74 =cut
|
|
75
|
|
76 *bin_top = \&bin_bot;
|
|
77
|
|
78 sub bin_name { sprintf("%d.%06d",@_) }
|
|
79
|
|
80 sub log10 {
|
|
81 my $i = shift;
|
|
82 log($i)/log(10);
|
|
83 }
|
|
84
|
|
85 1;
|
|
86
|
|
87 =back
|
|
88
|
|
89 =head1 BUGS
|
|
90
|
|
91 None known yet.
|
|
92
|
|
93 =head1 SEE ALSO
|
|
94
|
|
95 L<Bio::DB::GFF>,
|
|
96
|
|
97 =head1 AUTHOR
|
|
98
|
|
99 Lincoln Stein E<lt>lstein@cshl.orgE<gt>.
|
|
100
|
|
101 Copyright (c) 2001 Cold Spring Harbor Laboratory.
|
|
102
|
|
103 This library is free software; you can redistribute it and/or modify
|
|
104 it under the same terms as Perl itself.
|
|
105
|
|
106 =cut
|