line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#Copyright (c) 2010 Joachim Bargsten <code at bargsten dot org>. All rights reserved. |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Bio::Gonzales::Tools::SeqMask; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
191941
|
use Mouse; |
|
1
|
|
|
|
|
29260
|
|
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
940
|
use MouseX::Foreign 'Bio::Root::Root'; |
|
1
|
|
|
|
|
2708
|
|
|
1
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Bio::Gonzales::Role::BioPerl::Constructor'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
12364
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
41
|
|
12
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
13
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
101
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.083'; # VERSION |
16
|
1
|
|
|
1
|
|
23
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has seq => ( is => 'rw' ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 mask |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Title : mask |
23
|
|
|
|
|
|
|
Usage : $obj->mask(10,40,'Z'); |
24
|
|
|
|
|
|
|
$obj->mask(10,40); |
25
|
|
|
|
|
|
|
$obj->mask($bio_location_obj, 'Z'); |
26
|
|
|
|
|
|
|
$obj->mask($bio_location_obj); |
27
|
|
|
|
|
|
|
Function: masks a sequence region by replacing the respective part with a |
28
|
|
|
|
|
|
|
custom character. If the character is omitted, 'X' in case of |
29
|
|
|
|
|
|
|
protein and 'N' in case of DNA/RNA alphabet is used to mask the |
30
|
|
|
|
|
|
|
sequence region. |
31
|
|
|
|
|
|
|
Returns : the object it was invoked on |
32
|
|
|
|
|
|
|
Args : integer for start position |
33
|
|
|
|
|
|
|
integer for end position |
34
|
|
|
|
|
|
|
custom character to use for masking |
35
|
|
|
|
|
|
|
OR |
36
|
|
|
|
|
|
|
Bio::LocationI location for sequence region (strand NOT honored) |
37
|
|
|
|
|
|
|
custom character to use for masking |
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our %UNKNOWN_CHAR = ( |
41
|
|
|
|
|
|
|
dna => 'N', |
42
|
|
|
|
|
|
|
rna => 'N', |
43
|
|
|
|
|
|
|
protein => 'X', |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub mask { |
47
|
8
|
|
|
8
|
1
|
480
|
my ( $self, $start, $end, $char ) = @_; |
48
|
|
|
|
|
|
|
|
49
|
8
|
100
|
66
|
|
|
47
|
if ( ref($start) && $start->isa('Bio::LocationI') ) { |
50
|
2
|
|
|
|
|
5
|
my $loc = $start; |
51
|
2
|
|
|
|
|
4
|
$char = $end; |
52
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
11
|
for my $subloc ( $loc->each_Location() ) { |
54
|
2
|
|
|
|
|
16
|
$self->mask( $subloc->start, $subloc->end, $char ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} else { |
57
|
6
|
100
|
|
|
|
23
|
$char = $UNKNOWN_CHAR{ lc( $self->seq->alphabet ) } |
58
|
|
|
|
|
|
|
unless ($char); |
59
|
|
|
|
|
|
|
|
60
|
6
|
|
|
|
|
60
|
$self->seq->subseq( |
61
|
|
|
|
|
|
|
-start => $start, |
62
|
|
|
|
|
|
|
-end => $end, |
63
|
|
|
|
|
|
|
-replace_with => $char x ( $end - $start + 1 ), |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
8
|
|
|
|
|
483
|
return $self; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub trunc_masked_ends { |
71
|
0
|
|
|
0
|
0
|
|
my ( $self, $char ) = @_; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
$char = $UNKNOWN_CHAR{ lc( $self->seq->alphabet ) } |
74
|
|
|
|
|
|
|
unless ($char); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $seq = $self->seq->seq; |
77
|
0
|
|
|
|
|
|
$seq =~ s/^$char+//; |
78
|
0
|
|
|
|
|
|
$seq =~ s/$char+$//; |
79
|
0
|
|
|
|
|
|
$self->seq->seq($seq); |
80
|
0
|
|
|
|
|
|
return $self; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |