| 1 | # -*-CPerl-*- | ||||||||||
| 2 | # Last changed Time-stamp: <2017-06-10 18:20:26 michl> | ||||||||||
| 3 | |||||||||||
| 4 | package Bio::ViennaNGS::Bed; | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Bio::ViennaNGS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use version; our $VERSION = version->declare("$Bio::ViennaNGS::VERSION"); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | extends 'Bio::ViennaNGS::Feature'; | |||||||||
| 14 | |||||||||||
| 15 | 1 | has '+strand' => ( | |||||||||
| 16 | required => 1, | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | 1 | has 'thickStart' => ( | |||||||||
| 20 | is => 'rw', | ||||||||||
| 21 | isa => 'Int', | ||||||||||
| 22 | predicate => 'has_thickStart', | ||||||||||
| 23 | ); | ||||||||||
| 24 | |||||||||||
| 25 | 1 | has 'thickEnd' => ( | |||||||||
| 26 | is => 'rw', | ||||||||||
| 27 | isa => 'Int', | ||||||||||
| 28 | predicate => 'has_thickEnd', | ||||||||||
| 29 | ); | ||||||||||
| 30 | |||||||||||
| 31 | 1 | has 'itemRgb' => ( | |||||||||
| 32 | is => 'rw', | ||||||||||
| 33 | isa => 'Str', | ||||||||||
| 34 | lazy => 1, | ||||||||||
| 35 | default => '0', | ||||||||||
| 36 | ); | ||||||||||
| 37 | |||||||||||
| 38 | 1 | has 'blockCount' => ( | |||||||||
| 39 | is => 'rw', | ||||||||||
| 40 | isa => 'Int', | ||||||||||
| 41 | predicate => 'has_blockCount', | ||||||||||
| 42 | ); | ||||||||||
| 43 | |||||||||||
| 44 | 1 | has 'blockSizes' => ( | |||||||||
| 45 | is => 'rw', | ||||||||||
| 46 | isa => 'Value', | ||||||||||
| 47 | ); | ||||||||||
| 48 | |||||||||||
| 49 | 1 | has 'blockStarts' => ( | |||||||||
| 50 | is => 'rw', | ||||||||||
| 51 | isa => 'Value', | ||||||||||
| 52 | ); | ||||||||||
| 53 | |||||||||||
| 54 | 1 | has 'length' => ( | |||||||||
| 55 | is => 'rw', | ||||||||||
| 56 | isa => 'Int', | ||||||||||
| 57 | builder => '_build_length', | ||||||||||
| 58 | lazy => 1, | ||||||||||
| 59 | predicate => 'has_length', | ||||||||||
| 60 | ); | ||||||||||
| 61 | |||||||||||
| 62 | |||||||||||
| 63 | sub _build_length { | ||||||||||
| 64 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
_build_length: not called CC=3 SCAR=24.8
| |||||||||||
| 65 | 0 | my ($i,$len) = (0)x2; | |||||||||
| 66 | 0 | my $this_function = (caller(0))[3]; | |||||||||
| 67 | 0 | my @blockSizes = split (/,/ ,$self->blockSizes); | |||||||||
| 68 | 0 | my $bc = scalar @blockSizes; | |||||||||
| 69 | 0 | ▶ | croak "ERROR [$this_function] invalid blockSount in BED12 line" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | unless ($bc == $self->blockCount); | ||||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | for ($i=0;$i<$bc;$i++){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | 0 | $len += $blockSizes[$i]; | |||||||||
| 74 | } | ||||||||||
| 75 | 0 | $self->length($len); | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | sub as_bed_line { | ||||||||||
| 79 | 0 | ▶ | my ($self,$n) = @_; | ||||||||
|
Subroutine
as_bed_line: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 80 | 0 | my $this_function = (caller(0))[3]; | |||||||||
| 81 | 0 | ▶ | croak "ERROR [$this_function] no argument provided" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 82 | unless (defined $n); | ||||||||||
| 83 | 0 | ▶ | croak "ERROR [$this_function] argument of as_bed_line() must be 6 or 12" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | unless ( ($n == 6) | ($n == 12) ); | ||||||||||
| 85 | 0 | my $bed6= join ("\t", | |||||||||
| 86 | $self->chromosome, | ||||||||||
| 87 | $self->start, | ||||||||||
| 88 | $self->end, | ||||||||||
| 89 | $self->name, | ||||||||||
| 90 | $self->score, | ||||||||||
| 91 | $self->strand, | ||||||||||
| 92 | ); | ||||||||||
| 93 | 0 | my $bed12 = join ("\t", $bed6, | |||||||||
| 94 | $self->thickStart, | ||||||||||
| 95 | $self->thickEnd, | ||||||||||
| 96 | $self->itemRgb, | ||||||||||
| 97 | $self->blockCount, | ||||||||||
| 98 | $self->blockSizes, | ||||||||||
| 99 | $self->blockStarts, | ||||||||||
| 100 | ); | ||||||||||
| 101 | 0 | ▶ | if ($n ==6){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 102 | 0 | return $bed6; | |||||||||
| 103 | } | ||||||||||
| 104 | else{ | ||||||||||
| 105 | 0 | return $bed12; | |||||||||
| 106 | } | ||||||||||
| 107 | } | ||||||||||
| 108 | |||||||||||
| 109 | # TODO: | ||||||||||
| 110 | # sub from_FeatureLine() | ||||||||||
| 111 | # sub to_FeatureLine() | ||||||||||
| 112 | |||||||||||
| 113 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 114 | |||||||||||
| 115 | 1 | 1; | |||||||||
| 116 | |||||||||||
| 117 | __END__ | ||||||||||
| 118 | |||||||||||
| 119 | =head1 NAME | ||||||||||
| 120 | |||||||||||
| 121 | Bio::ViennaNGS::Bed - Object-oriented interface for manipulation of | ||||||||||
| 122 | genomic interval data in BED format | ||||||||||
| 123 | |||||||||||
| 124 | =head1 SYNOPSIS | ||||||||||
| 125 | |||||||||||
| 126 | use Bio::ViennaNGS::Bed; | ||||||||||
| 127 | |||||||||||
| 128 | my $bedobject = Bio::ViennaNGS::Bed->new(); | ||||||||||
| 129 | |||||||||||
| 130 | # compute the length of a BED12 block | ||||||||||
| 131 | $bedobject->_build_length(); | ||||||||||
| 132 | |||||||||||
| 133 | # dump an object as BED12 line | ||||||||||
| 134 | $bedobject->as_bed_line(12); | ||||||||||
| 135 | |||||||||||
| 136 | =head1 DESCRIPTION | ||||||||||
| 137 | |||||||||||
| 138 | This module provides a L<Moose> interface for storage and manipulation | ||||||||||
| 139 | of genomic interval data. It is primarily used as a convenience | ||||||||||
| 140 | wrapper for BED data with more generic L<Bio::ViennaNGS> classes for | ||||||||||
| 141 | feature annotation, such as L<Bio::ViennaNGS::FeatureInterval>, | ||||||||||
| 142 | L<Bio::ViennaNGS::MinimalFeature>, L<Bio::ViennaNGS::Feature>, | ||||||||||
| 143 | L<Bio::ViennaNGS::FeatureChain> and L<Bio::ViennaNGS::FeatureLine>. | ||||||||||
| 144 | |||||||||||
| 145 | =head1 METHODS | ||||||||||
| 146 | |||||||||||
| 147 | =over | ||||||||||
| 148 | |||||||||||
| 149 | =item _build_length | ||||||||||
| 150 | |||||||||||
| 151 | Title : _build_length | ||||||||||
| 152 | |||||||||||
| 153 | Usage : C<$obj-E<gt>_build_length();> | ||||||||||
| 154 | |||||||||||
| 155 | Function: Compute the length of a BED12 interval block / line, i.e. | ||||||||||
| 156 | the sum over the lengths of all intervals that make up a | ||||||||||
| 157 | BED12 entry. | ||||||||||
| 158 | |||||||||||
| 159 | Args : | ||||||||||
| 160 | |||||||||||
| 161 | Returns : | ||||||||||
| 162 | |||||||||||
| 163 | =item as_bed_line | ||||||||||
| 164 | |||||||||||
| 165 | Title : as_bed_line | ||||||||||
| 166 | |||||||||||
| 167 | Usage : C<$obj-E<gt>as_bed_line($bedtype);> | ||||||||||
| 168 | |||||||||||
| 169 | Function: Dump the contents of the object as BED6 or BED12 line. | ||||||||||
| 170 | |||||||||||
| 171 | Args : C<$bedtype> can either be 6 or 12, determining BED6 or BED12 | ||||||||||
| 172 | output. | ||||||||||
| 173 | |||||||||||
| 174 | Returns : A (tab-separated) BED6 or BED12 line as string. | ||||||||||
| 175 | |||||||||||
| 176 | =back | ||||||||||
| 177 | |||||||||||
| 178 | =head1 DEPENDENCIES | ||||||||||
| 179 | |||||||||||
| 180 | =over | ||||||||||
| 181 | |||||||||||
| 182 | =item L<Moose> | ||||||||||
| 183 | |||||||||||
| 184 | =item L<Carp> | ||||||||||
| 185 | |||||||||||
| 186 | =item L<namespace::autoclean> | ||||||||||
| 187 | |||||||||||
| 188 | =back | ||||||||||
| 189 | |||||||||||
| 190 | =head1 AUTHORS | ||||||||||
| 191 | |||||||||||
| 192 | Michael T. Wolfinger E<lt>michael@wolfinger.euE<gt> | ||||||||||
| 193 | |||||||||||
| 194 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 195 | |||||||||||
| 196 | Copyright (C) 2015-2017 Michael T. Wolfinger E<lt>michael@wolfinger.euE<gt> | ||||||||||
| 197 | |||||||||||
| 198 | This library is free software; you can redistribute it and/or modify | ||||||||||
| 199 | it under the same terms as Perl itself, either Perl version 5.10.0 or, | ||||||||||
| 200 | at your option, any later version of Perl 5 you may have available. | ||||||||||
| 201 | |||||||||||
| 202 | This program is distributed in the hope that it will be useful, but | ||||||||||
| 203 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||
| 204 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||
| 205 | General Public License for more details. | ||||||||||
| 206 | |||||||||||
| 207 | |||||||||||
| 208 | =cut | ||||||||||