3 Bio::DB::GFF::Util::Binning - binning utility for Bio::DB::GFF index
7 use Bio::DB::GFF::Util::Binning qw(bin bin_bot bin_top);
8 my $tier = bin($start,$stop,$min);
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.
19 The remainder of the document describes the function calls. No calls
20 are exported by default, but must be imported explicitly.
26 package Bio
::DB
::GFF
::Util
::Binning
;
30 use vars
qw(@EXPORT @EXPORT_OK);
31 use base qw(Exporter);
32 @EXPORT_OK = qw(bin bin_bot bin_top);
34 use Bio
::Root
::Version
;
36 =item $bin_name = bin($start,$stop,$bin_size)
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.
45 my ($start,$stop,$min) = @_;
46 $start = abs($start); # to allow negative coordinates
49 my ($bin_start,$bin_end);
51 $bin_start = int $start/$tier;
52 $bin_end = int $stop/$tier;
53 last if $bin_start == $bin_end;
56 return wantarray ?
($tier,$bin_start) : bin_name
($tier,$bin_start);
59 =item $bottom = bin_bot($tier,$start)
61 Given a tier name and a range start position, returns the lower end of
69 bin_name
($tier,int(abs($pos)/$tier));
72 =item $top = bin_top($tier,$end)
74 Given a tier name and the end of a range, returns the upper end of the
82 bin_name
($tier,int(abs($pos)/$tier)); # bin_name($tier,int($pos/$tier),+1);
86 my ($tier, $int, $fudge) = @_;
87 my $pos = abs($int) + ($fudge || 0);
89 sprintf("%d.%06d",$tier, $pos);
111 Lincoln Stein E<lt>lstein@cshl.orgE<gt>.
113 Copyright (c) 2001 Cold Spring Harbor Laboratory.
115 This library is free software; you can redistribute it and/or modify
116 it under the same terms as Perl itself.