Bio/DB/GFF/Util/Binning.pm

filter: Statementstmt 37.8% 14 / 37 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 37.5% 3 / 8 Podpod 60.0% 3 / 5 totaltotal 33.9% 20 / 59 CC 5 SCAR 19.1
CC
5
Cov
31%
bin
12.0
bin_name
12.0
bin_bot
2.0
CRAP 6.8
« Bio/SeqIO/msout.pm ↑ Summary Bio/Tools/GuessSeqFormat.pm »
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 2 $Bio::DB::GFF::Util::Binning::VERSION = '1.7.8';
28 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 2 require Exporter;
30 2 ▶use vars qw(@EXPORT @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
31 2 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
32 2 @EXPORT_OK = qw(bin bin_bot bin_top);
33 2 @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 0 ▶sub bin {
Subroutine bin: not called CC=3 SCAR=24.8
Pod documented
44 0 my ($start,$stop,$min) = @_;
45 0 $start = abs($start); # to allow negative coordinates
46 0 $stop = abs($stop);
47 0 my $tier = $min;
48 0 my ($bin_start,$bin_end);
49 0 while (1) {
50 0 $bin_start = int $start/$tier;
51 0 $bin_end = int $stop/$tier;
52 0 ▶ last if $bin_start == $bin_end;
Branch: 1 branch
BranchTrueFalseTotal
if $bin_start == $bin_end 0 0 0
53 0 $tier *= 10;
54 }
55 0 ▶ return wantarray ? ($tier,$bin_start) : bin_name($tier,$bin_start);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
56 }
57  
58 =item $bottom = bin_bot($tier,$start)
59  
60 Given a tier name and a range start position, returns the lower end of
61 the bin range.
62  
63 =cut
64  
65 0 ▶sub bin_bot {
Subroutine bin_bot: not called CC=1 SCAR=6.9
Pod documented
66 0 my $tier = shift;
67 0 my $pos = shift;
68 0 bin_name($tier,int(abs($pos)/$tier));
69 }
70  
71 =item $top = bin_top($tier,$end)
72  
73 Given a tier name and the end of a range, returns the upper end of the
74 bin range.
75  
76 =cut
77  
78 0 ▶sub bin_top {
Subroutine bin_top: not called CC=1 SCAR=6.9
Pod documented
79 0 my $tier = shift;
80 0 my $pos = shift;
81 0 bin_name($tier,int(abs($pos)/$tier)); # bin_name($tier,int($pos/$tier),+1);
82 }
83  
84 0 ▶sub bin_name {
Subroutine bin_name: not called CC=3 SCAR=24.8
Pod undocumented
85 0 my ($tier, $int, $fudge) = @_;
86 0 ▶ my $pos = abs($int) + ($fudge || 0);
Condition0%0/2
$fudge || 0
l!l
00
MC/DC0%0/1
$fudge || 0
$fudge
Truth table0%0/2
A
A= $fudge
Aresult
11
00
87 0 ▶ $pos = 0 if $pos < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $pos < 0 0 0 0
88 0 sprintf("%d.%06d",$tier, $pos);
89 }
90  
91 0 ▶sub log10 {
Subroutine log10: not called CC=1 SCAR=6.9
Pod undocumented
92 0 my $i = shift;
93 0 log($i)/log(10);
94 }
95  
96 2 1;
97  
98 =back
99  
100 =head1 BUGS
101  
102 None known yet.
103  
104 =head1 SEE ALSO
105  
106 L<Bio::DB::GFF>,
107  
108 =head1 AUTHOR
109  
110 Lincoln Stein E<lt>lstein@cshl.orgE<gt>.
111  
112 Copyright (c) 2001 Cold Spring Harbor Laboratory.
113  
114 This library is free software; you can redistribute it and/or modify
115 it under the same terms as Perl itself.
116  
117 =cut
« Bio/SeqIO/msout.pm ↑ Summary Bio/Tools/GuessSeqFormat.pm »