blib/lib/Bio/Gonzales/Feat/IO/BED.pm

filter: Statementstmt 98.3% 61 / 62 Branchbran 90.0% 9 / 10 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 2 totaltotal 94.3% 83 / 88 CC 9 SCAR 10.1
CC
9
Cov
97%
_to_bed
5.0
__ANON__
3.0
write_feat
3.0
CRAP 2.7
« blib/lib/Bio/Gonzales/Util/Math.pm ↑ Summary blib/lib/Bio/Gonzales/Seq/Filter/DuplicateSeqs.pm »
1 package Bio::Gonzales::Feat::IO::BED;
2  
3 1 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our $VERSION = '0.062'; # VERSION
13  
14 1 extends 'Bio::Gonzales::Feat::IO::Base';
15  
16 1 has 'parent_handler' => ( is => 'rw' );
17 1 has 'track_name' => ( is => 'rw', default => 'unknown' );
18 1 has _wrote_sth_before => ( is => 'rw' );
19  
20 sub write_feat {
21 56 ▶ my ( $self, @feats ) = @_;
Subroutine write_feat: called CC=3 SCAR=11.0
Pod undocumented
22 56 my $fh = $self->fh;
23  
24 56 ▶ $self->_write_header
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_wrote_sth_before 1 55 56
25 unless ( $self->_wrote_sth_before );
26  
27 56 for my $f (@feats) {
28 56 $self->_collect_feat($f);
29 }
30  
31 56 return;
32 }
33  
34 sub _write_header {
35 1 ▶ my ($self) = @_;
Subroutine _write_header: called CC=1 SCAR=0.0
36  
37 1 my $fh = $self->fh;
38 #get track name right
39 1 my $track_name = $self->track_name;
40 1 say $fh "track name=$track_name";
41  
42 1 $self->_wrote_sth_before(1);
43 }
44  
45 sub write_collected_feats {
46 0 ▶ confess 'this function is deprecated';
Subroutine write_collected_feats: not called CC=1 SCAR=6.9
Pod undocumented
47 }
48  
49 override 'close' => sub {
50 1 ▶ my ($self) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
51 1 my $fh = $self->fh;
52  
53 1 $self->_connect_feats;
54 1 my $parents = $self->_find_parent_feats;
55  
56 1 for my $p (@$parents) {
57 25 ▶ $self->parent_handler->($p) if ( $self->parent_handler );
Branch: 1 branch
BranchTrueFalseTotal
if $self->parent_handler 0 25 25
58 25 print $fh _to_bed($p);
59 }
60  
61 1 super;
62  
63 1 return;
64 1 };
65  
66 sub _to_bed {
67 25 ▶ my ($f) = @_;
Subroutine _to_bed: called CC=5 SCAR=16.1
68  
69 25 my $strand;
70 25 ▶ if ( $f->strand < 0 ) { $strand = '-'; }
Branch: 1 branch
BranchTrueFalseTotal
if ($f->strand < 0) { } 5 20 25
71 20 else { $strand = '+'; }
72  
73 #chr_id
74 #scf_id
75 #start
76 #end
77 #name
78 #score // 0
79 #strand +-
80 #start (thick) == start
81 #end (thick) == end
82 #rgb == 0
83 #block count
84 #block sizes
85 #block starts
86  
87 my @line
88 25 ▶ = ( $f->scf_id, $f->start - 1, $f->end, $f->id, $f->score // 0, $strand, ( $f->start - 1 ), $f->end, 0 );
Condition100%2/2
$f->score // 0
l!l
421
MC/DC100%1/1
$f->score // 0
$f->score
Truth table100%2/2
A
A= $f->score
Aresult
11
00
89  
90 25 my @sf = $f->recurse_subfeats;
91 25 ▶ if ( @sf > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@sf > 0) 5 20 25
92  
93 #my %sf = (map { $_->start . '_' . $_->end => $_ } @sf);
94  
95 5 ▶ @sf = sort { ( $a->start <=> $b->start ) || ( $b->end <=> $a->end ) } @sf;
Branch: 1 branch
BranchTrueFalseTotal
$a->start <=> $b->start or $b->end <=> $a->end 16 49 65
96 5 push @line, scalar @sf;
97  
98 5 push @line, join( ',', map { $_->end - $_->start + 1 } @sf );
99 5 push @line, join( ',', map { ( $_->start - $f->start ) } @sf );
100 }
101  
102 25 return join( "\t", @line ), "\n";
103 }
104  
105 1 __PACKAGE__->meta->make_immutable;
106  
107 1 1;
« blib/lib/Bio/Gonzales/Util/Math.pm ↑ Summary blib/lib/Bio/Gonzales/Seq/Filter/DuplicateSeqs.pm »