| 1 | #--------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | Bio::Matrix::PSM::SiteMatrix - SiteMatrixI implementation, holds a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | position scoring matrix (or position weight matrix) and log-odds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | use Bio::Matrix::PSM::SiteMatrix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # Create from memory by supplying probability matrix hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # both as strings or arrays | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # where the frequencies $a,$c,$g and $t are supplied either as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # arrayref or string. Accordingly, lA, lC, lG and lT are the log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # odds (only as arrays, no checks done right now) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | my ($a,$c,$g,$t,$score,$ic, $mid)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | #or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | my ($a,$c,$g,$t,$score,$ic,$mid)=('05a011','110550','400001', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | '100104',0.001,19.2,'CRE1'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | #Where a stands for all (this frequency=1), see explanation below | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | my %param=(-pA=>$a,-pC=>$c,-pG=>$g,-pT=>$t, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | -lA=>$la, -lC=>$lc,-lG=>$lg,-lT=>$l, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | -IC=>$ic,-e_val=>$score, -id=>$mid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | my $site=Bio::Matrix::PSM::SiteMatrix->new(%param); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | #Or get it from a file: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | use Bio::Matrix::PSM::IO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | my $psmIO= Bio::Matrix::PSM::IO->new(-file=>$file, -format=>'transfac'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | while (my $psm=$psmIO->next_psm) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | #Now we have a Bio::Matrix::PSM::Psm object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # see Bio::Matrix::PSM::PsmI for details | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | #This is a Bio::Matrix::PSM::SiteMatrix object now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | my $matrix=$psm->matrix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # Get a simple consensus, where alphabet is {A,C,G,T,N}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # choosing the character that both satisfies a supplied or default threshold | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # frequency and is the most frequenct character at each position, or N. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # So for the position with A, C, G, T frequencies of 0.5, 0.25, 0.10, 0.15, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # the simple consensus character will be 'A', whilst for 0.5, 0.5, 0, 0 it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # would be 'N'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | my $consensus=$site->consensus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # Get the IUPAC ambiguity code representation of the data in the matrix. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # Because the frequencies may have been pseudo-count corrected, insignificant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # frequences (below 0.05 by default) are ignored. So a position with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # A, C, G, T frequencies of 0.5, 0.5, 0.01, 0.01 will get the IUPAC code 'M', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # while 0.97, 0.01, 0.01, 0.01 will get the code 'A' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # 0.25, 0.25, 0.25, 0.25 would get 'N'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | my $iupac=$site->IUPAC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # Getting/using regular expression (a representation of the IUPAC string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | my $regexp=$site->regexp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | my $count=grep($regexp,$seq); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | my $count=($seq=~ s/$regexp/$1/eg); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | print "Motif $mid is present $count times in this sequence\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | SiteMatrix is designed to provide some basic methods when working with position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | scoring (weight) matrices, such as transcription factor binding sites for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | example. A DNA PSM consists of four vectors with frequencies {A,C,G,T}. This is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | the minimum information you should provide to construct a PSM object. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | vectors can be provided as strings with frequenciesx10 rounded to an int, going | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | from {0..a} and 'a' represents the maximum (10). This is like MEME's compressed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | representation of a matrix and it is quite useful when working with relational | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | DB. If arrays are provided as an input (references to arrays actually) they can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | be any number, real or integer (frequency or count). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | When creating the object you can ask the constructor to make a simple pseudo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | count correction by adding a number (typically 1) to all positions (with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | -correction option). After adding the number the frequencies will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | calculated. Only use correction when you supply counts, not frequencies. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | Throws an exception if: You mix as an input array and string (for example A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | matrix is given as array, C - as string). The position vector is (0,0,0,0). One | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | of the probability vectors is shorter than the rest. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | Summary of the methods I use most frequently (details below): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | iupac - return IUPAC compliant consensus as a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | score - Returns the score as a real number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | IC - information content. Returns a real number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | id - identifier. Returns a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | accession - accession number. Returns a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | next_pos - return the sequence probably for each letter, IUPAC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | symbol, IUPAC probability and simple sequence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | consenus letter for this position. Rewind at the end. Returns a hash. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | pos - current position get/set. Returns an integer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | regexp - construct a regular expression based on IUPAC consensus. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | For example AGWV will be [Aa][Gg][AaTt][AaCcGg] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | width - site width | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | get_string - gets the probability vector for a single base as a string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | get_array - gets the probability vector for a single base as an array. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | get_logs_array - gets the log-odds vector for a single base as an array. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | New methods, which might be of interest to anyone who wants to store | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | PSM in a relational database without creating an entry for each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | position is the ability to compress the PSM vector into a string with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | losing usually less than 1% of the data. this can be done with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | my $str=$matrix->get_compressed_freq('A'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | my $str=$matrix->get_compressed_logs('A'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | Loading from a database should be done with new, but is not yest implemented. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | However you can still uncompress such string with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | my @arr=Bio::Matrix::PSM::_uncompress_string ($str,1,1); for PSM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | my @arr=Bio::Matrix::PSM::_uncompress_string ($str,1000,2); for log odds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | Bioperl modules. Send your comments and suggestions preferably to one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | of the Bioperl mailing lists. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | =head2 Support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | web: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | =head1 AUTHOR - Stefan Kirov | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | Email skirov@utk.edu | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | =head1 CONTRIBUTORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | Sendu Bala, bix@sendu.me.uk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # Let the code begin... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | package Bio::Matrix::PSM::SiteMatrix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 15 | $Bio::Matrix::PSM::SiteMatrix::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 15 | ▶ | use base qw(Bio::Root::Root Bio::Matrix::PSM::SiteMatrixI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | Title : new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | Usage : my $site=Bio::Matrix::PSM::SiteMatrix->new(-pA=>$a,-pC=>$c, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | -pG=>$g,-pT=>$t, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | -IC=>$ic, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | -e_val=>$score, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | -id=>$mid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | Function: Creates a new Bio::Matrix::PSM::SiteMatrix object from memory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | Throws : If inconsistent data for all vectors (A,C,G and T) is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | provided, if you mix input types (string vs array) or if a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | position freq is 0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | Returns : Bio::Matrix::PSM::SiteMatrix object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | Args : -pA => vector with the frequencies or counts of A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | -pC => vector for C | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | -pG => vector for G | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | -pt => vector for T | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | -lA => vector for the log of A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | -lC => vector for the log of C | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | -lG => vector for the log of G | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | -lT => vector for the log of T | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | -IC => real number, the information content of this matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | -e_val => real number, the expect value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | -id => string, an identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | -width => int, width of the matrix in nucleotides | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | -sites => int, the number of sites that went into this matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | -model => hash ref, background frequencies for A, C, G and T | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | -correction => number, the number to add to all positions to achieve | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | pseudo count correction (default 0: no correction) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | NB: do not use correction when your input is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | frequences! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | -accession_number => string, an accession number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | Vectors can be strings of the frequencies where the frequencies are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | multiplied by 10 and rounded to the nearest whole number, and where | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 'a' is used to denote the maximal frequency 10. There should be no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | punctuation (spaces etc.) in the string. For example, 'a0501'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | Alternatively frequencies or counts can be represented by an array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | ref containing the counts, frequencies or logs as any kind of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | number. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 13 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=29 SCAR=35.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 13 | my ($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 13 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 13 | my $consensus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # Too many things to rearrange, and I am creating simultanuously >500 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # such objects routinely, so this becomes performance issue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | my %input; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 13 | ▶ | while (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 100 | (my $key = shift @args) =~ s/-//g; #deletes all dashes (only dashes)! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 100 | $input{$key} = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 13 | $self->{_position} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 13 | $self->{IC} = $input{IC}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 13 | $self->{e_val} = $input{e_val}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 13 | $self->{width} = $input{width}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 13 | $self->{logA} = $input{lA}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 13 | $self->{logC} = $input{lC}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 13 | $self->{logG} = $input{lG}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 13 | $self->{logT} = $input{lT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 13 | $self->{sites} = $input{sites}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 13 | ▶ | $self->{id} = $input{id} || 'null'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$input{'id'} || 'null'
MC/DC100%1/1
$input{'id'} || 'null'
$input{'id'}
Truth table100%2/2
A
A= $input{'id'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 13 | ▶ | $self->{correction} = $input{correction} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$input{'correction'} || 0
MC/DC0%0/1
$input{'correction'} || 0
$input{'correction'}
Truth table50%1/2
A
A= $input{'correction'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 13 | $self->{accession_number} = $input{accession_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 13 | ▶ | return $self unless (defined($input{pA}) && defined($input{pC}) && defined($input{pG}) && defined($input{pT})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
defined $input{"pA"} and defined $input{"pC"} and defined $input{"pG"} and defined $input{"pT"}
defined $input{"pA"} and defined $input{"pC"} and defined $input{"pG"}
defined $input{"pA"} and defined $input{"pC"}
MC/DC25%1/4
defined $input{"pA"} and defined $input{"pC"} and defined $input{"pG"} and defined $input{"pT"}
defined $input{"pA"}
defined $input{"pC"}
defined $input{"pG"}
defined $input{"pT"}
Truth table40%2/5
A and B and C and D
A= defined $input{"pA"}B= defined $input{"pC"}C= defined $input{"pG"}D= defined $input{"pT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # This should go to _initialize? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # Check for input type- no mixing alllowed, throw ex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 11 | ▶ | if (ref($input{pA}) =~ /ARRAY/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 10 | ▶ | $self->throw("Mixing matrix data types not allowed: C is not reference") unless(ref($input{pC})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 10 | ▶ | $self->throw("Mixing matrix data types not allowed: G is not reference") unless (ref($input{pG})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 10 | ▶ | $self->throw("Mixing matrix data types not allowed: T is not reference") unless (ref($input{pT})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 10 | $self->{probA} = $input{pA}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 10 | $self->{probC} = $input{pC}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 10 | $self->{probG} = $input{pG}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 10 | $self->{probT} = $input{pT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | ▶ | $self->throw("Mixing matrix data types not allowed: C is reference") if (ref($input{pC})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | ▶ | $self->throw("Mixing matrix data types not allowed: G is reference") if (ref($input{pG})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | ▶ | $self->throw("Mixing matrix data types not allowed: T is reference") if (ref($input{pT})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | $self->{probA} = [split(//,$input{pA})]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | $self->{probC} = [split(//,$input{pC})]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | $self->{probG} = [split(//,$input{pG})]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | $self->{probT} = [split(//,$input{pT})]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | ▶ | for (my $i=0; $i<= @{$self->{probA}}+1; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # we implictely assume these are MEME-style frequencies x 10, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # 'a' represents the 'maximum', 10. Other positions can actually | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # add up to over 10 due to rounding, but I don't think that is a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # problem? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 7 | ▶ | if (${$self->{probA}}[$i] and ${$self->{probA}}[$i] eq 'a') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
do {
$$self{"probA"}
}->[$i] and do {
$$self{"probA"}
}->[$i] eq "a"
MC/DC100%2/2
do {
$$self{"probA"}
}->[$i] and do {
$$self{"probA"}
}->[$i] eq "a"
do {
$$self{"probA"}
}->[$i]
do {
$$self{"probA"}
}->[$i] eq "a"
Truth table100%3/3
A and B
A= do {
$$self{"probA"}
}->[$i]B= do {
$$self{"probA"}
}->[$i] eq "a"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | ${$self->{probA}}[$i]='10'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 7 | ▶ | if (${$self->{probC}}[$i] and ${$self->{probC}}[$i] eq 'a') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
do {
$$self{"probC"}
}->[$i] and do {
$$self{"probC"}
}->[$i] eq "a"
MC/DC100%2/2
do {
$$self{"probC"}
}->[$i] and do {
$$self{"probC"}
}->[$i] eq "a"
do {
$$self{"probC"}
}->[$i]
do {
$$self{"probC"}
}->[$i] eq "a"
Truth table100%3/3
A and B
A= do {
$$self{"probC"}
}->[$i]B= do {
$$self{"probC"}
}->[$i] eq "a"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | ${$self->{probC}}[$i]='10'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 7 | ▶ | if (${$self->{probG}}[$i] and ${$self->{probG}}[$i] eq 'a') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
do {
$$self{"probG"}
}->[$i] and do {
$$self{"probG"}
}->[$i] eq "a"
MC/DC0%0/2
do {
$$self{"probG"}
}->[$i] and do {
$$self{"probG"}
}->[$i] eq "a"
do {
$$self{"probG"}
}->[$i]
do {
$$self{"probG"}
}->[$i] eq "a"
Truth table66%2/3
A and B
A= do {
$$self{"probG"}
}->[$i]B= do {
$$self{"probG"}
}->[$i] eq "a"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ${$self->{probG}}[$i]='10'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 7 | ▶ | if (${$self->{probT}}[$i] and ${$self->{probT}}[$i] eq 'a') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
do {
$$self{"probT"}
}->[$i] and do {
$$self{"probT"}
}->[$i] eq "a"
MC/DC0%0/2
do {
$$self{"probT"}
}->[$i] and do {
$$self{"probT"}
}->[$i] eq "a"
do {
$$self{"probT"}
}->[$i]
do {
$$self{"probT"}
}->[$i] eq "a"
Truth table66%2/3
A and B
A= do {
$$self{"probT"}
}->[$i]B= do {
$$self{"probT"}
}->[$i] eq "a"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ${$self->{probT}}[$i]='10'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # Check for position with 0 for all bases, throw exception if so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 11 | ▶ | for (my $i=0;$i <= $#{$self->{probA}}; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 242 | ▶ | if ((${$self->{probA}}[$i] + ${$self->{probC}}[$i] + ${$self->{probG}}[$i] + ${$self->{probT}}[$i]) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $self->throw("Position meaningless-all frequencies are 0"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # apply pseudo-count correction to all values - this will result in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # very bad frequencies if the input is already frequences and a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # correction value as large as 1 is used! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 242 | ▶ | if ($self->{correction}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ${$self->{probA}}[$i] += $self->{correction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ${$self->{probC}}[$i] += $self->{correction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ${$self->{probG}}[$i] += $self->{correction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ${$self->{probT}}[$i] += $self->{correction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # (re)calculate frequencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 242 | my $div= ${$self->{probA}}[$i] + ${$self->{probC}}[$i] + ${$self->{probG}}[$i] + ${$self->{probT}}[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 242 | ${$self->{probA}}[$i]=${$self->{probA}}[$i]/$div; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 242 | ${$self->{probC}}[$i]=${$self->{probC}}[$i]/$div; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 242 | ${$self->{probG}}[$i]=${$self->{probG}}[$i]/$div; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 242 | ${$self->{probT}}[$i]=${$self->{probT}}[$i]/$div; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # Calculate the logs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 11 | ▶ | if ((!defined($self->{logA})) && ($input{model})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $self->{"logA"} and $input{"model"}
MC/DC0%0/2
not defined $self->{"logA"} and $input{"model"}
not defined $self->{"logA"}
$input{"model"}
Truth table66%2/3
not(A) and B
A= not defined $self->{"logA"}B= $input{"model"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $self->calc_weight($input{model}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # Make consensus, throw if any one of the vectors is shorter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 11 | $self->_calculate_consensus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 11 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | =head2 _calculate_consensus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | Title : _calculate_consensus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | Function: Internal stuff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 11 | ▶ | sub _calculate_consensus { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_calculate_consensus: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 11 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 11 | my ($lc,$lt,$lg)=($#{$self->{probC}},$#{$self->{probT}},$#{$self->{probG}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 11 | my $len=$#{$self->{probA}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 11 | ▶ | $self->throw("Probability matrix is damaged for C: $len vs $lc") if ($len != $lc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 11 | ▶ | $self->throw("Probability matrix is damaged for T: $len vs $lt") if ($len != $lt); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 11 | ▶ | $self->throw("Probability matrix is damaged for G: $len vs $lg") if ($len != $lg); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 11 | ▶ | for (my $i=0; $i<$len+1; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | #*** IUPACp values not actually used (eg. by next_pos) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 242 | (${$self->{IUPAC}}[$i],${$self->{IUPACp}}[$i])=_to_IUPAC(${$self->{probA}}[$i], ${$self->{probC}}[$i], ${$self->{probG}}[$i], ${$self->{probT}}[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 242 | (${$self->{seq}}[$i], ${$self->{seqp}}[$i]) = _to_cons(${$self->{probA}}[$i], ${$self->{probC}}[$i], ${$self->{probG}}[$i], ${$self->{probT}}[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 11 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | =head2 calc_weight | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | Title : calc_weight | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | Usage : $obj->calc_weight({A=>0.2562, C=>0.2438, G=>0.2432, T=>0.2568}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | Function: Recalculates the PSM (or weights) based on the PFM (the frequency | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | matrix) and user supplied background model. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | Throws : if no model is supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | Returns : n/a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | Args : reference to a hash with background frequencies for A,C,G and T | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | sub calc_weight { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calc_weight: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my ($self, $model) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my %model; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $model{probA}=$model->{A}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $model{probC}=$model->{C}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $model{probG}=$model->{G}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $model{probT}=$model->{T}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | foreach my $let (qw(probA probC probG probT)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my @str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | $self->throw('You did not provide valid model\n') unless (($model{$let}>0) && ($model{$let}<1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$model{$let} > 0 and $model{$let} < 1
MC/DC0%0/2
$model{$let} > 0 and $model{$let} < 1
$model{$let} > 0
$model{$let} < 1
Truth table0%0/3
A and B
A= $model{$let} > 0B= $model{$let} < 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | foreach my $f (@{$self->{$let}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my $w=log($f)-log($model{$let}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | push @str,$w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my $llet=$let; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $llet=~s/prob/log/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | $self->{$llet}=\@str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | =head2 next_pos | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | Title : next_pos | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | Function: Retrieves the next position features: frequencies for A,C,G,T, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | main letter (as in consensus) and the probabilty for this letter to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | occur at this position and the current position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | Returns : hash (pA,pC,pG,pT,logA,logC,logG,logT,base,prob,rel) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | Args : none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 79 | ▶ | sub next_pos { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_pos: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 79 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 79 | ▶ | $self->throw("instance method called on class") unless ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 79 | my $len=@{$self->{seq}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 79 | my $pos=$self->{_position}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # End reached? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 79 | ▶ | if ($pos<$len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 76 | my $pA=${$self->{probA}}[$pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 76 | my $pC=${$self->{probC}}[$pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 76 | my $pG=${$self->{probG}}[$pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 76 | my $pT=${$self->{probT}}[$pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 76 | my $lA=${$self->{logA}}[$pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 76 | my $lC=${$self->{logC}}[$pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 76 | my $lG=${$self->{logG}}[$pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 76 | my $lT=${$self->{logT}}[$pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 76 | my $base=${$self->{seq}}[$pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 76 | my $prob=${$self->{seqp}}[$pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 76 | $self->{_position}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 76 | my %seq=(pA=>$pA,pT=>$pT,pC=>$pC,pG=>$pG, lA=>$lA,lT=>$lT,lC=>$lC,lG=>$lG,base=>$base,rel=>$pos, prob=>$prob); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 76 | return %seq; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 3 | else {$self->{_position}=0; return;} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | =head2 curpos | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | Title : curpos | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | Function: Gets/sets the current position. Converts to 0 if argument is minus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | and to width if greater than width | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | Returns : integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | Args : integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 2 | ▶ | sub curpos { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
curpos: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 2 | my $prev = $self->{_position}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | if (@_) { $self->{_position} = shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 2 | return $prev; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | =head2 e_val | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | Title : e_val | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | Function: Gets/sets the e-value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | Returns : real number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | Args : none to get, real number to set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 3 | ▶ | sub e_val { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
e_val: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 3 | my $prev = $self->{e_val}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | ▶ | if (@_) { $self->{e_val} = shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 3 | return $prev; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | =head2 IC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | Title : IC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | Function: Get/set the Information Content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | Returns : real number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | Args : none to get, real number to set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | ▶ | sub IC { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IC: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | my $prev = $self->{IC}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | if (@_) { $self->{IC} = shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 1 | return $prev; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | =head2 accession_number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | Title : accession_number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | Function: Get/set the accession number, this will be unique id for the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | SiteMatrix object as well for any other object, inheriting from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | SiteMatrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | Returns : string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | Args : none to get, string to set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | sub accession_number { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accession_number: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my $prev = $self->{accession_number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | if (@_) { $self->{accession_number} = shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | return $prev; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | =head2 consensus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | Title : consensus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | Function: Returns the consensus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | Returns : string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | Args : (optional) threshold value 1 to 10, default 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | '5' means the returned characters had a 50% or higher presence at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | their position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 7 | ▶ | sub consensus { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consensus: called CC=4 SCAR=20.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 7 | my ($self, $thresh) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 7 | ▶ | if ($thresh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | my $len=$#{$self->{probA}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | for (my $i=0; $i<$len+1; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | (${$self->{seq}}[$i], ${$self->{seqp}}[$i]) = _to_cons(${$self->{probA}}[$i], ${$self->{probC}}[$i], ${$self->{probG}}[$i], ${$self->{probT}}[$i], $thresh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 7 | my $consensus=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 7 | foreach my $letter (@{$self->{seq}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 155 | $consensus .= $letter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 7 | return $consensus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | =head2 width | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | Title : width | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | Function: Returns the length of the sites in used to make this matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | Returns : int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | Args : none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 2 | ▶ | sub width { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
width: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 2 | my $width=@{$self->{probA}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 2 | return $width; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | =head2 sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | Title : sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | Function: Get/set the number of sites that were used to make this matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | Returns : int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | Args : none to get, int to set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | sub sites { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sites: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | if (@_) { $self->{sites} = shift } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | return $self->{sites} || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'sites'} || (return)
MC/DC0%0/1
$self->{'sites'} || (return)
$self->{'sites'}
Truth table0%0/2
A
A= $self->{'sites'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | =head2 IUPAC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | Title : IUPAC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | Function: Returns IUPAC compliant consensus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | Returns : string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | Args : optionally, also supply a whole number (int) of 1 or higher to set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | the significance level when considering the frequencies. 1 (the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | default) means a 0.05 significance level: frequencies lower than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0.05 will be ignored. 2 Means a 0.005 level, and so on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 5 | ▶ | sub IUPAC { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IUPAC: called CC=4 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 5 | my ($self, $thresh) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 5 | ▶ | if ($thresh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | my $len=$#{$self->{probA}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | for (my $i=0; $i<$len+1; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | (${$self->{IUPAC}}[$i],${$self->{IUPACp}}[$i])=_to_IUPAC(${$self->{probA}}[$i], ${$self->{probC}}[$i], ${$self->{probG}}[$i], ${$self->{probT}}[$i], $thresh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 5 | my $iu=$self->{IUPAC}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 5 | my $iupac=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 5 | foreach my $let (@{$iu}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 92 | $iupac .= $let; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 5 | return $iupac; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | =head2 _to_IUPAC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | Title : _to_IUPAC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | Function: Converts a single position to IUPAC compliant symbol. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | For rules see the implementation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | Returns : char, real number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | Args : real numbers for frequencies of A,C,G,T (positional) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | optionally, also supply a whole number (int) of 1 or higher to set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | the significance level when considering the frequencies. 1 (the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | default) means a 0.05 significance level: frequencies lower than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0.05 will be ignored. 2 Means a 0.005 level, and so on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 242 | ▶ | sub _to_IUPAC { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_to_IUPAC: called CC=16 SCAR=27.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 242 | my ($a, $c, $g, $t, $thresh) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 242 | ▶ | $thresh ||= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$thresh ||= 1
MC/DC0%0/1
$thresh ||= 1
$thresh
Truth table50%1/2
A
A= $thresh
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 242 | $thresh = int($thresh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 242 | $a = sprintf ("%.${thresh}f", $a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 242 | $c = sprintf ("%.${thresh}f", $c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 242 | $g = sprintf ("%.${thresh}f", $g); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 242 | $t = sprintf ("%.${thresh}f", $t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 242 | my $total = $a + $c + $g + $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 242 | ▶ | return 'A' if ($a == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 179 | ▶ | return 'G' if ($g == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 170 | ▶ | return 'C' if ($c == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 94 | ▶ | return 'T' if ($t == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 80 | my $r=$g+$a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 80 | ▶ | return 'R' if ($r == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 80 | my $y=$t+$c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 80 | ▶ | return 'Y' if ($y == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 74 | my $m=$a+$c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 74 | ▶ | return 'M' if ($m == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 54 | my $k=$g+$t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 54 | ▶ | return 'K' if ($k == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 43 | my $s=$g+$c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 43 | ▶ | return 'S' if ($s == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 37 | my $w=$a+$t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 37 | ▶ | return 'W' if ($w == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 18 | my $d=$r+$t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 18 | ▶ | return 'D' if ($d == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 15 | my $v=$r+$c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 15 | ▶ | return 'V' if ($v == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 8 | my $b=$y+$g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 8 | ▶ | return 'B' if ($b == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 6 | my $h=$y+$a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 6 | ▶ | return 'H' if ($h == $total); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 1 | return 'N'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | =head2 _to_cons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | Title : _to_cons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | Function: Converts a single position to simple consensus character and returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | its probability. For rules see the implementation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | Returns : char, real number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | Args : real numbers for A,C,G,T (positional), and optional 5th argument of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | threshold (as a number between 1 and 10, where 5 is default and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | means the returned character had a 50% or higher presence at this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | position) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 242 | ▶ | sub _to_cons { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_to_cons: called CC=25 SCAR=33.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 242 | my ($A, $C, $G, $T, $thresh) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 242 | ▶ | $thresh ||= 5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$thresh ||= 5
MC/DC0%0/1
$thresh ||= 5
$thresh
Truth table50%1/2
A
A= $thresh
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | # this multiplication by 10 is just to satisfy the thresh range of 1-10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 242 | my $a = $A * 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 242 | my $c = $C * 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 242 | my $g = $G * 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 242 | my $t = $T * 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 242 | ▶ | return 'N',10 if (($a<$thresh) && ($c<$thresh) && ($g<$thresh) && ($t<$thresh)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$a < $thresh and $c < $thresh and $g < $thresh and $t < $thresh
$a < $thresh and $c < $thresh and $g < $thresh
$a < $thresh and $c < $thresh
MC/DC100%4/4
$a < $thresh and $c < $thresh and $g < $thresh and $t < $thresh
$a < $thresh
$c < $thresh
$g < $thresh
$t < $thresh
Truth table100%5/5
A and B and C and D
A= $a < $threshB= $c < $threshC= $g < $threshD= $t < $thresh
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 223 | ▶ | return 'N',10 if (($a==$t) && ($a==$c) && ($a==$g)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$a == $t and $a == $c and $a == $g
$a == $t and $a == $c
MC/DC0%0/3
$a == $t and $a == $c and $a == $g
$a == $t
$a == $c
$a == $g
Truth table75%3/4
A and B and C
A= $a == $tB= $a == $cC= $a == $g
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | # threshold could be lower than 50%, so must check is not only over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # threshold, but also the highest frequency | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 223 | ▶ | return 'A',$a if (($a>=$thresh) && ($a>$t) && ($a>$c) && ($a>$g)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$a >= $thresh and $a > $t and $a > $c and $a > $g
$a >= $thresh and $a > $t and $a > $c
$a >= $thresh and $a > $t
MC/DC50%2/4
$a >= $thresh and $a > $t and $a > $c and $a > $g
$a >= $thresh
$a > $t
$a > $c
$a > $g
Truth table60%3/5
A and B and C and D
A= $a >= $threshB= $a > $tC= $a > $cD= $a > $g
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 134 | ▶ | return 'C',$c if (($c>=$thresh) && ($c>$t) && ($c>$a) && ($c>$g)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$c >= $thresh and $c > $t and $c > $a and $c > $g
$c >= $thresh and $c > $t and $c > $a
$c >= $thresh and $c > $t
MC/DC50%2/4
$c >= $thresh and $c > $t and $c > $a and $c > $g
$c >= $thresh
$c > $t
$c > $a
$c > $g
Truth table60%3/5
A and B and C and D
A= $c >= $threshB= $c > $tC= $c > $aD= $c > $g
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 42 | ▶ | return 'G',$g if (($g>=$thresh) && ($g>$t) && ($g>$c) && ($g>$a)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$g >= $thresh and $g > $t and $g > $c and $g > $a
$g >= $thresh and $g > $t and $g > $c
$g >= $thresh and $g > $t
MC/DC25%1/4
$g >= $thresh and $g > $t and $g > $c and $g > $a
$g >= $thresh
$g > $t
$g > $c
$g > $a
Truth table40%2/5
A and B and C and D
A= $g >= $threshB= $g > $tC= $g > $cD= $g > $a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 24 | ▶ | return 'T',$t if (($t>=$thresh) && ($t>$g) && ($t>$c) && ($t>$a)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$t >= $thresh and $t > $g and $t > $c and $t > $a
$t >= $thresh and $t > $g and $t > $c
$t >= $thresh and $t > $g
MC/DC50%2/4
$t >= $thresh and $t > $g and $t > $c and $t > $a
$t >= $thresh
$t > $g
$t > $c
$t > $a
Truth table60%3/5
A and B and C and D
A= $t >= $threshB= $t > $gC= $t > $cD= $t > $a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 2 | return 'N',10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | =head2 get_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | Title : get_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | Function: Returns given probability vector as a string. Useful if you want to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | store things in a rel database, where arrays are not first choice | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | Throws : If the argument is outside {A,C,G,T} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | Returns : string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | Args : character {A,C,G,T} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 1 | ▶ | sub get_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_string: called CC=7 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 1 | my $base=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 1 | my $string=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 1 | my @prob; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | BASE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 1 | ▶ | if ($base eq 'A') {@prob= @{$self->{probA}}; last BASE; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | if ($base eq 'C') {@prob= @{$self->{probC}}; last BASE; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | if ($base eq 'G') {@prob= @{$self->{probG}}; last BASE; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | if ($base eq 'T') {@prob= @{$self->{probT}}; last BASE; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | $self->throw ("No such base: $base!\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 1 | foreach my $prob (@prob) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 5 | my $corrected = $prob*10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 5 | my $next=sprintf("%.0f",$corrected); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 5 | ▶ | $next='a' if ($next eq '10'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 5 | $string .= $next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 1 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | =head2 get_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | Title : get_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | Function: Returns an array with frequencies for a specified base | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | Returns : array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | Args : char | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 3 | ▶ | sub get_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_array: called CC=5 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 3 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 3 | my $base=uc(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 3 | ▶ | return @{$self->{probA}} if ($base eq 'A'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | ▶ | return @{$self->{probC}} if ($base eq 'C'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | ▶ | return @{$self->{probG}} if ($base eq 'G'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | return @{$self->{probT}} if ($base eq 'T'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $self->throw("No such base: $base!\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | =head2 get_logs_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | Title : get_logs_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | Function: Returns an array with log_odds for a specified base | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | Returns : array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | Args : char | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 1 | ▶ | sub get_logs_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_logs_array: called CC=10 SCAR=41.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 1 | my $base=uc(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 1 | ▶ | return @{$self->{logA}} if (($base eq 'A') && ($self->{logA})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$base eq "A" and $self->{"logA"}
MC/DC0%0/2
$base eq "A" and $self->{"logA"}
$base eq "A"
$self->{"logA"}
Truth table33%1/3
A and B
A= $base eq "A"B= $self->{"logA"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | return @{$self->{logC}} if (($base eq 'C') && ($self->{logC})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$base eq "C" and $self->{"logC"}
MC/DC0%0/2
$base eq "C" and $self->{"logC"}
$base eq "C"
$self->{"logC"}
Truth table0%0/3
A and B
A= $base eq "C"B= $self->{"logC"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | return @{$self->{logG}} if (($base eq 'G') && ($self->{logG})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$base eq "G" and $self->{"logG"}
MC/DC0%0/2
$base eq "G" and $self->{"logG"}
$base eq "G"
$self->{"logG"}
Truth table0%0/3
A and B
A= $base eq "G"B= $self->{"logG"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | return @{$self->{logT}} if (($base eq 'T') && ($self->{logT})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$base eq "T" and $self->{"logT"}
MC/DC0%0/2
$base eq "T" and $self->{"logT"}
$base eq "T"
$self->{"logT"}
Truth table0%0/3
A and B
A= $base eq "T"B= $self->{"logT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | ▶ | $self->throw ("No such base: $base!\n") if (!grep(/$base/,qw(A C G T))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | =head2 id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | Title : id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | Function: Gets/sets the site id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | Returns : string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | Args : string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 12 | ▶ | sub id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 12 | my $prev = $self->{id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 12 | ▶ | if (@_) { $self->{id} = shift; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 12 | return $prev; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | =head2 regexp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | Title : regexp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | Function: Returns a regular expression which matches the IUPAC convention. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | N will match X, N, - and . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | Returns : string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | Args : none (works at the threshold last used for making the IUPAC string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 1 | ▶ | sub regexp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
regexp: called CC=16 SCAR=33.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 1 | my $regexp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 1 | foreach my $letter (@{$self->{IUPAC}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 5 | my $reg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | LETTER: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 5 | ▶ | if ($letter eq 'A') { $reg='[Aa]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 4 | ▶ | if ($letter eq 'C') { $reg='[Cc]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | if ($letter eq 'G') { $reg='[Gg]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | if ($letter eq 'T') { $reg='[Tt]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | if ($letter eq 'M') { $reg='[AaCcMm]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | if ($letter eq 'R') { $reg='[AaGgRr]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | if ($letter eq 'W') { $reg='[AaTtWw]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | if ($letter eq 'S') { $reg='[CcGgSs]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | if ($letter eq 'Y') { $reg='[CcTtYy]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | ▶ | if ($letter eq 'K') { $reg='[GgTtKk]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 3 | ▶ | if ($letter eq 'V') { $reg='[AaCcGgVv]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | ▶ | if ($letter eq 'H') { $reg='[AaCcTtHh]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 2 | ▶ | if ($letter eq 'D') { $reg='[AaGgTtDd]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 1 | ▶ | if ($letter eq 'B') { $reg='[CcGgTtBb]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | $reg='\S'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 5 | $regexp .= $reg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 1 | return $regexp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | =head2 regexp_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | Title : regexp_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | Function: Returns a regular expression which matches the IUPAC convention. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | N will match X, N, - and . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | Returns : array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | Args : none (works at the threshold last used for making the IUPAC string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | To do : I have separated regexp and regexp_array, but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | maybe they can be rewritten as one - just check what should be returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 1 | ▶ | sub regexp_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
regexp_array: called CC=16 SCAR=33.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 1 | my @regexp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 1 | foreach my $letter (@{$self->{IUPAC}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 5 | my $reg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | LETTER: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 5 | ▶ | if ($letter eq 'A') { $reg='[Aa]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 4 | ▶ | if ($letter eq 'C') { $reg='[Cc]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | ▶ | if ($letter eq 'G') { $reg='[Gg]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | if ($letter eq 'T') { $reg='[Tt]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | ▶ | if ($letter eq 'M') { $reg='[AaCcMm]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | ▶ | if ($letter eq 'R') { $reg='[AaGgRr]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | ▶ | if ($letter eq 'W') { $reg='[AaTtWw]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | if ($letter eq 'S') { $reg='[CcGgSs]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | ▶ | if ($letter eq 'Y') { $reg='[CcTtYy]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | if ($letter eq 'K') { $reg='[GgTtKk]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 3 | ▶ | if ($letter eq 'V') { $reg='[AaCcGgVv]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | ▶ | if ($letter eq 'H') { $reg='[AaCcTtHh]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 2 | ▶ | if ($letter eq 'D') { $reg='[AaGgTtDd]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 1 | ▶ | if ($letter eq 'B') { $reg='[CcGgTtBb]'; last LETTER; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | $reg='\S'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 5 | push @regexp,$reg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 1 | return @regexp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | =head2 _compress_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | Title : _compress_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | Function: Will compress an array of real signed numbers to a string (ie vector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | of bytes) -127 to +127 for bi-directional(signed) and 0..255 for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | unsigned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | Returns : String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | Args : array reference, followed by an max value and direction (optional, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | default 1-unsigned),1 unsigned, any other is signed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 3 | ▶ | sub _compress_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compress_array: called CC=12 SCAR=26.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 3 | my ($array,$lm,$direct)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 3 | my $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 3 | ▶ | return unless(($array) && ($lm)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$array and $lm
MC/DC0%0/2
$array and $lm
$array
$lm
Truth table33%1/3
A and B
A= $arrayB= $lm
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 3 | ▶ | $direct=1 unless ($direct); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 3 | ▶ | my $k1= ($direct==1) ? (255/$lm) : (127/$lm); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 3 | foreach my $c (@{$array}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 62 | ▶ | $c=$lm if ($c>$lm); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 62 | ▶ | $c=-$lm if (($c<-$lm) && ($direct !=1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$c < -$lm and $direct != 1
MC/DC0%0/2
$c < -$lm and $direct != 1
$c < -$lm
$direct != 1
Truth table33%1/3
A and B
A= $c < -$lmB= $direct != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 62 | ▶ | $c=0 if (($c<0) && ($direct ==1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$c < 0 and $direct == 1
MC/DC0%0/2
$c < 0 and $direct == 1
$c < 0
$direct == 1
Truth table66%2/3
A and B
A= $c < 0B= $direct == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 62 | my $byte=int($k1*$c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 62 | ▶ | $byte=127+$byte if ($direct !=1);#Clumsy, should be really shift the bits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 62 | my $char=chr($byte); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 62 | $str.=$char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 3 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | =head2 _uncompress_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | Title : _uncompress_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | Function: Will uncompress a string (vector of bytes) to create an array of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | real signed numbers (opposite to_compress_array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | Returns : string, followed by an max value and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | direction (optional, default 1-unsigned), 1 unsigned, any other is signed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | Args : array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 3 | ▶ | sub _uncompress_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uncompress_string: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 3 | my ($str,$lm,$direct)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 3 | my @array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 3 | ▶ | return unless(($str) && ($lm)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$str and $lm
MC/DC0%0/2
$str and $lm
$str
$lm
Truth table33%1/3
A and B
A= $strB= $lm
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 3 | ▶ | $direct=1 unless ($direct); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 3 | ▶ | my $k1= ($direct==1) ? (255/$lm) : (127/$lm); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 3 | foreach my $c (split(//,$str)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 62 | my $byte=ord($c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 62 | ▶ | $byte=$byte-127 if ($direct !=1);#Clumsy, should be really shift the bits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 62 | my $num=$byte/$k1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 62 | push @array,$num; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 3 | return @array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | =head2 get_compressed_freq | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | Title : get_compressed_freq | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | Function: A method to provide a compressed frequency vector. It uses one byte | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | to code the frequence for one of the probability vectors for one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | position. Useful for relational database. Improvement of the previous | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0..a coding. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | Example : my $strA=$self->get_compressed_freq('A'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | Returns : String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | Args : char | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 2 | ▶ | sub get_compressed_freq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_compressed_freq: called CC=9 SCAR=35.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 2 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 2 | my $base=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 2 | my $string=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 2 | my @prob; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | BASE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 2 | ▶ | if ($base eq 'A') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 2 | ▶ | @prob= @{$self->{probA}} unless (!defined($self->{probA})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 2 | last BASE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | ▶ | if ($base eq 'G') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | ▶ | @prob= @{$self->{probG}} unless (!defined($self->{probG})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | last BASE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | ▶ | if ($base eq 'C') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | ▶ | @prob= @{$self->{probC}} unless (!defined($self->{probC})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | last BASE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | if ($base eq 'T') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | @prob= @{$self->{probT}} unless (!defined($self->{probT})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | last BASE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | $self->throw ("No such base: $base!\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 2 | my $str= _compress_array(\@prob,1,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 2 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | =head2 get_compressed_logs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | Title : get_compressed_logs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | Function: A method to provide a compressed log-odd vector. It uses one byte to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | code the log value for one of the log-odds vectors for one position. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | Example : my $strA=$self->get_compressed_logs('A'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | Returns : String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | Args : char | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 1 | ▶ | sub get_compressed_logs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_compressed_logs: called CC=9 SCAR=35.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 1 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 1 | my $base=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 1 | my $string=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 1 | my @prob; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | BASE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 1 | ▶ | if ($base eq 'A') {@prob= @{$self->{logA}} unless (!defined($self->{logA})); last BASE; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | ▶ | if ($base eq 'C') {@prob= @{$self->{logC}} unless (!defined($self->{logC})); last BASE; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | if ($base eq 'G') {@prob= @{$self->{logG}} unless (!defined($self->{logG})); last BASE; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | ▶ | if ($base eq 'T') {@prob= @{$self->{logT}} unless (!defined($self->{logT})); last BASE; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | $self->throw ("No such base: $base!\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 1 | return _compress_array(\@prob,1000,2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | =head2 sequence_match_weight | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | Title : sequence_match_weight | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | Function: This method will calculate the score of a match, based on the PWM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | if such is associated with the matrix object. Returns undef if no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | PWM data is available. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | Throws : if the length of the sequence is different from the matrix width | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | Example : my $score=$matrix->sequence_match_weight('ACGGATAG'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | Returns : Floating point | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | Args : string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 1 | ▶ | sub sequence_match_weight { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sequence_match_weight: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 1 | my ($self,$seq)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 1 | ▶ | return unless ($self->{logA}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 1 | my $width=$self->width; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 1 | ▶ | $self->throw ("I can calculate the score only for sequence which are exactly my size for $seq, my width is $width\n") unless (length($seq)==@{$self->{logA}}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 1 | $seq = uc($seq); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 1 | my @seq=split(//,$seq); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 1 | my $score = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 1 | my $i=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 1 | foreach my $pos (@seq) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 25 | my $tv = 'log'.$pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 25 | ▶ | $self->warn("Position ".($i+1)." of input sequence has unknown (ambiguity?) character '$pos': scores will be wrong") unless defined $self->{$tv}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 25 | ▶ | $score += defined $self->{$tv} ? $self->{$tv}->[$i] : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 25 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 1 | return $score; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | =head2 get_all_vectors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | Title : get_all_vectors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | Function: returns all possible sequence vectors to satisfy the PFM under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | a given threshold | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | Throws : If threshold outside of 0..1 (no sense to do that) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | Example : my @vectors=$self->get_all_vectors(4); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | Returns : Array of strings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | Args : (optional) floating | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | ▶ | sub get_all_vectors { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_vectors: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | my $thresh=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | ▶ | $self->throw("Out of range. Threshold should be >0 and 1<.\n") if (($thresh<0) || ($thresh>1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$thresh < 0 or $thresh > 1
MC/DC0%0/2
$thresh < 0 or $thresh > 1
$thresh < 0
$thresh > 1
Truth table0%0/3
A or B
A= $thresh < 0B= $thresh > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | my @seq=split(//,$self->consensus($thresh*10)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my @perm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | for my $i (0..@{$self->{probA}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | ▶ | push @{$perm[$i]},'A' if ($self->{probA}->[$i]>$thresh); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ▶ | push @{$perm[$i]},'C' if ($self->{probC}->[$i]>$thresh); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | ▶ | push @{$perm[$i]},'G' if ($self->{probG}->[$i]>$thresh); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | ▶ | push @{$perm[$i]},'T' if ($self->{probT}->[$i]>$thresh); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | ▶ | push @{$perm[$i]},'N' if ($seq[$i] eq 'N'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | my $fpos=shift @perm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | my @strings=@$fpos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | foreach my $pos (@perm) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | my @newstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | foreach my $let (@$pos) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | foreach my $string (@strings) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | my $newstring = $string . $let; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | push @newstr,$newstring; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | @strings=@newstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | return @strings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||