MaxEntScan.pm

filter: Statementstmt 28.7% 29 / 101 Branchbran 0.0% 0 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 36.8% 7 / 19 Podpod 100% 12 / 12 totaltotal 29.2% 48 / 164 CC 18 SCAR 23.0
CC
18
Cov
22%
score_consensus
20.0
score5
20.0
score3
20.0
CRAP 10.0
↑ Summary me2x3acc.pm »
1 package Bio::RNA::SpliceSites::Scoring::MaxEntScan;
2  
3 2 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 #Data submodules; these names are from the original maxEntScan distribution.
9 2 ▶use Bio::RNA::SpliceSites::Scoring::me2x3acc;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Bio::RNA::SpliceSites::Scoring::me2x5;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Bio::RNA::SpliceSites::Scoring::splice5sequences;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 require Exporter;
14  
15 2 our @ISA = qw/ Exporter /;
16 2 our $VERSION = '0.05';
17  
18 2 my $functions = [ qw/ score5 score3 / ];
19 2 our %EXPORT_TAGS = ( 'all' => $functions , );
20 2 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
21 2 our $VERSION = '0.04';
22  
23 0 ▶sub log2 {
Subroutine log2: not called CC=1 SCAR=6.9
Pod documented
24 0 my $number = shift;
25 0 log($number)/log(2);
26 }
27  
28 0 ▶sub is_scalar_reference {
Subroutine is_scalar_reference: not called CC=2 SCAR=17.9
Pod documented
29 0 my $reference_to_validate = shift;
30 0 ▶ ref( $reference_to_validate ) eq "SCALAR" ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $reference_to_validate eq 'SCALAR' ? : 0 0 0
31 }
32  
33 0 ▶sub is_kmer {
Subroutine is_kmer: not called CC=2 SCAR=17.9
Pod documented
34 0 my ( $reference_to_validate , $valid_length ) = @_;
35 0 ▶ length $$reference_to_validate == $valid_length ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
length $$reference_to_validate == $valid_length ? : 0 0 0
36 }
37  
38 0 ▶sub is_genetic_alphabet {
Subroutine is_genetic_alphabet: not called CC=2 SCAR=17.9
Pod documented
39 0 my $reference_to_validate = shift;
40 0 ▶ $$reference_to_validate =~ /^[ACTGactg]+$/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$$reference_to_validate =~ /^[ACTGactg]+$/ ? : 0 0 0
41 }
42  
43 0 ▶sub split_sequence {
Subroutine split_sequence: not called CC=3 SCAR=24.8
Pod documented
44 #Split the provided splice site sequence into the splice donor/acceptor dinucleotide and the concatenated remainder.
45 0 my ( $reference_to_sequence , $splice_site_type ) = @_;
46 0 my @sequence_array = split // , uc( $$reference_to_sequence );
47 0 my ( $dinucleotide , $outer_portion );
48 0 ▶ if ( $splice_site_type == 5 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($splice_site_type == 5) { } 0 0 0
elsif ($splice_site_type == 3) { } 0 0 0
49 0 $dinucleotide = join "" , @sequence_array[3..4]; #Positions 4 and 5 are the splice donor dinucleotide.
50 0 $outer_portion = ( join "" , @sequence_array[0..2] ) . ( join "" , @sequence_array[5..8] );
51 }
52 elsif ( $splice_site_type == 3 ) {
53 0 $dinucleotide = join "" , @sequence_array[18..19]; #Positions 19 and 20 are the splice acceptor dinucleotide.
54 0 $outer_portion = ( join "" , @sequence_array[0..17] ) . ( join "" , @sequence_array[20..22] ); #Join nucleotides 1-18 and 21-23.
55 }
56 else {
57 0 croak "Invalid type of splice site to split: must be either 5 or 3.\n";
58 }
59 0 return ( $dinucleotide , $outer_portion );
60 }
61  
62 0 ▶sub get_splice_5_sequence_matrix_value {
Subroutine get_splice_5_sequence_matrix_value: not called CC=2 SCAR=17.9
Pod documented
63 0 my $outer_portion = shift;
64 exists $Bio::RNA::SpliceSites::Scoring::SpliceModels::splice5sequences::table->{ $outer_portion } ?
65 0 ▶ return $Bio::RNA::SpliceSites::Scoring::SpliceModels::splice5sequences::table->{ $outer_portion } : carp "Unable to find sequence matrix for key $outer_portion.\n";
Branch: 1 branch
BranchTrueFalseTotal
exists $Bio::RNA::SpliceSites::Scoring::SpliceModels::splice5sequences::table->{$outer_portion} ? : 0 0 0
66 }
67  
68 0 ▶sub get_splice_5_score_matrix_value {
Subroutine get_splice_5_score_matrix_value: not called CC=2 SCAR=17.9
Pod documented
69 0 my $sequence_matrix_value = shift; #The term "matrix" was used in the original maxEntScan programming and is retained here for clarity.
70 0 ▶ exists $Bio::RNA::SpliceSites::Scoring::SpliceModels::me2x5::table->[ $sequence_matrix_value ] ?
Branch: 1 branch
BranchTrueFalseTotal
exists $Bio::RNA::SpliceSites::Scoring::SpliceModels::me2x5::table->[$sequence_matrix_value] ? : 0 0 0
71 return $Bio::RNA::SpliceSites::Scoring::SpliceModels::me2x5::table->[ $sequence_matrix_value ] : carp "Index out of score matrix range: $sequence_matrix_value\n";
72 }
73  
74 0 ▶sub score_consensus {
Subroutine score_consensus: not called CC=4 SCAR=30.0
Pod documented
75 0 my ( $dinucleotide , $type ) = @_;
76 0 my %bgd = ( 'A' => 0.27 , 'C' => 0.23 , 'G' => 0.23 , 'T' => 0.27 ); #Shared between each type of splice site.
77 0 my ( %cons1 , %cons2 ); #Populate conditional to splice site type: donor or acceptor.
78  
79 0 ▶ if ( $type == 5 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type == 5) { } 0 0 0
elsif ($type == 3) { } 0 0 0
80 0 ▶ return 15.7507349436393 if $dinucleotide eq 'GT'; #Short circuit for the perfect GT splice donor dinucleotide.
Branch: 1 branch
BranchTrueFalseTotal
if $dinucleotide eq "GT" 0 0 0
81 0 %cons1 = ( 'A' => 0.004 , 'C' => 0.0032 , 'G' => 0.9896 , 'T' => 0.0032 );
82 0 %cons2 = ( 'A' => 0.0034 , 'C' => 0.0039 , 'G' => 0.0042 , 'T' => 0.9884 );
83 }
84 elsif ( $type == 3 ) {
85 #return ????? if $dinucleotide eq 'AG'; #Short circuit for perfect AG splice acceptor dinucleotide.
86 0 %cons1 = ( 'A' => 0.9903 , 'C' => 0.0032 , 'G' => 0.0034 , 'T' => 0.003 );
87 0 %cons2 = ( 'A' => 0.0027 , 'C' => 0.0037 , 'G' => 0.9905 , 'T' => 0.003 );
88 }
89 else {
90 0 croak "Invalid type of splice site to score consensus for: must be either 5 or 3.\n";
91 }
92  
93 0 my ( $first_nucleotide , $second_nucleotide ) = split // , $dinucleotide;
94 0 return ( $cons1{$first_nucleotide} * $cons2{$second_nucleotide} ) / ( $bgd{$first_nucleotide} * $bgd{$second_nucleotide} );
95 }
96  
97 0 ▶sub score5 {
Subroutine score5: not called CC=4 SCAR=30.0
Pod documented
98 0 my $sequence_reference = shift;
99 #Validate argument:
100 0 ▶ unless ( is_scalar_reference( $sequence_reference ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_scalar_reference($sequence_reference)) 0 0 0
101 0 carp "Not a scalar reference.\n";
102 0 return 'invalid_invocation';
103 }
104 0 ▶ unless ( is_kmer( $sequence_reference , 9 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_kmer($sequence_reference, 9)) 0 0 0
105 0 carp "Invalid 5'ss length: must be 9 nucleotides long.\n";
106 0 return 'invalid_length';
107 }
108 0 ▶ unless ( is_genetic_alphabet( $sequence_reference ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_genetic_alphabet($sequence_reference)) 0 0 0
109 0 carp "Invalid alphabet: must be only [ACTGactg] with no 'n' nucleotides.\n";
110 0 return 'invalid_alphabet';
111 }
112  
113 0 my ( $dinucleotide , $outer_portion ) = split_sequence( $sequence_reference , 5 );
114  
115 #Compute the log2 of the product of the score_5_consensus() subroutine return for the entire sequence (left_side_of_product)
116 # and the me2x5 (score matrix) value for the sequence matrix value of the "outer portion" of the splice site, which is the heptamer with the donor dinucleotide removed
117 # from the splice site nonamer, which is assigned to the scalar variable $outer_portion
118  
119 0 my $score = log2( score_consensus( $dinucleotide , 5 ) * get_splice_5_score_matrix_value( get_splice_5_sequence_matrix_value( $outer_portion ) ) );
120 0 return sprintf( "%.2f" , $score ); #2 decimals.
121 }
122  
123 0 ▶sub hash_seq {
Subroutine hash_seq: not called CC=2 SCAR=17.9
Pod documented
124 #Returns a hash key for a sequence as a 4-radix integer.
125 #E.g. given sequence 'CAGAAGT', returns 4619 as a scalar.
126 0 my $sequence = shift;
127 0 $sequence=~ y/ACGT/0123/;
128 0 my @sequence_array = split // , $sequence;
129 0 my $sum = 0;
130 0 my $end = length( $sequence ) - 1;
131  
132 0 my @four_radix = qw/ 1 4 16 64 256 1024 4096 16384 /;
133 0 $sum += $sequence_array[$_] * $four_radix[ $end - $_ ] for 0 .. $end;
134 0 return $sum;
135 }
136  
137 0 ▶sub get_max_ent_score {
Subroutine get_max_ent_score: not called CC=1 SCAR=6.9
Pod documented
138 0 my ( $sequence , $table_ref ) = @_; #Table ref is a reference to an array of references to hashes prepared in the me2x3acc submodule.
139 my @partial_score = ( $table_ref->[0]{ hash_seq( substr $sequence , 0 , 7 ) } ,
140 $table_ref->[1]{ hash_seq( substr $sequence , 7 , 7 ) } ,
141 $table_ref->[2]{ hash_seq( substr $sequence , 14 , 7 ) } ,
142 $table_ref->[3]{ hash_seq( substr $sequence , 4 , 7 ) } ,
143 $table_ref->[4]{ hash_seq( substr $sequence , 11 , 7 ) } ,
144 $table_ref->[5]{ hash_seq( substr $sequence , 4 , 3 ) } ,
145 $table_ref->[6]{ hash_seq( substr $sequence , 7 , 4 ) } ,
146 $table_ref->[7]{ hash_seq( substr $sequence , 11 , 3 ) } ,
147 0 $table_ref->[8]{ hash_seq( substr $sequence , 14 , 4 ) } );
148 0 my $final_score = $partial_score[0] * $partial_score[1] * $partial_score[2] * $partial_score[3] * $partial_score[4] /
149 ( $partial_score[5] * $partial_score[6] * $partial_score[7] * $partial_score[8] );
150 0 return $final_score;
151 }
152  
153 0 ▶sub score3 {
Subroutine score3: not called CC=4 SCAR=30.0
Pod documented
154 0 my $sequence_reference = shift; #Should be 23nt long.
155 #Validate argument:
156 0 ▶ unless ( is_scalar_reference( $sequence_reference ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_scalar_reference($sequence_reference)) 0 0 0
157 0 carp "Not a scalar reference.\n";
158 0 return 'invalid_invocation';
159 }
160 0 ▶ unless ( is_kmer( $sequence_reference , 23 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_kmer($sequence_reference, 23)) 0 0 0
161 0 carp "Invalid 3'ss length: must be 23nt long.\n";
162 0 return 'invalid_length';
163 }
164 0 ▶ unless ( is_genetic_alphabet( $sequence_reference ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_genetic_alphabet($sequence_reference)) 0 0 0
165 0 carp "Invalid alphabet: must be only [ACTGactg] with no 'n' nucleotides.\n";
166 0 return 'invalid_alphabet';
167 }
168  
169 0 my ( $dinucleotide , $outer_portion ) = split_sequence( $sequence_reference , 3 );
170 0 my $score = log2( score_consensus( $dinucleotide , 3 ) * get_max_ent_score( $outer_portion , $Bio::RNA::SpliceSites::Scoring::SpliceModels::me2x3acc::table ) );
171 0 return sprintf( "%.2f" , $score ); #2 decimals.
172 }
173  
174 2 1;
175  
176 __END__
↑ Summary me2x3acc.pm »