| 1 | |||||||||||||||||||||||||||||
| 2 | =head1 NAME | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | Bio::Matrix::PSM::IO::mast - PSM mast parser implementation | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | See Bio::Matrix::PSM::IO for detailed documentation on how to | ||||||||||||||||||||||||||||
| 9 | use PSM parsers | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | Parser for mast. This driver unlike meme or transfac for example is | ||||||||||||||||||||||||||||
| 14 | dedicated more to PSM sequence matches, than to PSM themselves. | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 TO DO | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | Section III should be parsed too, otherwise no real sequence is | ||||||||||||||||||||||||||||
| 19 | available, so we supply 'NNNNN....' as a seq which is not right. | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =head1 FEEDBACK | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =head2 Mailing Lists | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | User feedback is an integral part of the evolution of this | ||||||||||||||||||||||||||||
| 26 | and other Bioperl modules. Send your comments and suggestions preferably | ||||||||||||||||||||||||||||
| 27 | to one of the Bioperl mailing lists. Your participation is much appreciated. | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||
| 30 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =head2 Support | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||
| 39 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||
| 40 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||
| 41 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||
| 46 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||
| 47 | web: | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head1 AUTHOR - Stefan Kirov | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | Email skirov@utk.edu | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head1 APPENDIX | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | The rest of the documentation details each of the object | ||||||||||||||||||||||||||||
| 58 | methods. Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =cut | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | # Let the code begin... | ||||||||||||||||||||||||||||
| 63 | package Bio::Matrix::PSM::IO::mast; | ||||||||||||||||||||||||||||
| 64 | 2 | $Bio::Matrix::PSM::IO::mast::VERSION = '1.7.8'; | |||||||||||||||||||||||||||
| 65 | 2 | ▶ | use Bio::Matrix::PSM::InstanceSite; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 66 | 2 | ▶ | use Bio::Matrix::PSM::Psm; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 67 | 2 | ▶ | use Bio::Root::Root; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 2 | ▶ | use base qw(Bio::Matrix::PSM::PsmHeader Bio::Matrix::PSM::IO); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head2 new | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | Title : new | ||||||||||||||||||||||||||||
| 75 | Usage : my $psmIO = Bio::Matrix::PSM::IO->new(-format=>'mast', | ||||||||||||||||||||||||||||
| 76 | -file=>$file); | ||||||||||||||||||||||||||||
| 77 | Function: Associates a file with the appropriate parser | ||||||||||||||||||||||||||||
| 78 | Throws : Throws if the file passed is in HTML format or if | ||||||||||||||||||||||||||||
| 79 | some criteria for the file | ||||||||||||||||||||||||||||
| 80 | format are not met. | ||||||||||||||||||||||||||||
| 81 | Example : | ||||||||||||||||||||||||||||
| 82 | Returns : psm object, associated with a file with matrix file | ||||||||||||||||||||||||||||
| 83 | Args : hash | ||||||||||||||||||||||||||||
| 84 | return : "Bio::Matrix::PSM::$format"->new(@args); | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=20 SCAR=30.2
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | 2 | my($class, @args)=@_; | |||||||||||||||||||||||||||
| 91 | 2 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||
| 92 | 2 | my (%instances,@header,$n); | |||||||||||||||||||||||||||
| 93 | 2 | my ($file)=$self->_rearrange(['FILE'], @args); | |||||||||||||||||||||||||||
| 94 | 2 | $self->{file} = $file; | |||||||||||||||||||||||||||
| 95 | 2 | $self->{_factor}=1; | |||||||||||||||||||||||||||
| 96 | 2 | ▶ | $self->_initialize_io(@args) || warn "Did you intend to use STDIN?"; #Read only for now | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 2 | $self->{_end}=0; | |||||||||||||||||||||||||||
| 98 | 2 | undef $self->{hid}; | |||||||||||||||||||||||||||
| 99 | 2 | ▶ | return $self if ($file=~/^>/);#Just writing | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 2 | my $buf=$self->_readline; | |||||||||||||||||||||||||||
| 101 | 2 | ▶ | $self->throw('Cannot parse HTML format yet') if ($buf =~/^<HTML>/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | # this should probably be moved to its own function | ||||||||||||||||||||||||||||
| 103 | 2 | ▶ | while ( defined($buf=$self->_readline)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 90 | chomp($buf); | |||||||||||||||||||||||||||
| 105 | 90 | ▶ | if ($buf=~/DATABASE AND MOTIFS/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 2 | ▶ | while ($buf=$self->_readline) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 16 | ▶ | if ($buf=~/DATABASE/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 2 | $buf=~s/^[\s\t]+//; | |||||||||||||||||||||||||||
| 109 | 2 | chomp $buf; | |||||||||||||||||||||||||||
| 110 | 2 | ($n,$self->{_dbname},$self->{_dbtype})=split(/\s/,$buf); | |||||||||||||||||||||||||||
| 111 | 2 | $self->{_dbtype}=~s/[\(\)]//g; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | 16 | ▶ | if ($buf=~/MOTIFS/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 2 | $buf=~s/^[\s\t]+//; | |||||||||||||||||||||||||||
| 115 | 2 | chomp $buf; | |||||||||||||||||||||||||||
| 116 | 2 | ($n,$self->{_mrsc},$self->{_msrctype})=split(/\s/,$buf); | |||||||||||||||||||||||||||
| 117 | 2 | $self->{_msrctype}=~s/[\(\)]//g; | |||||||||||||||||||||||||||
| 118 | 2 | last; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | 2 | ▶ | if ($self->{_msrctype} ne $self->{_dbtype}) {#Assume we have protein motifs, nuc DB (not handling opp.) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 1 | $self->{_factor}=3; | |||||||||||||||||||||||||||
| 123 | 1 | $self->{_mixquery}=1; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | 90 | ▶ | if ($buf=~m/MOTIF WIDTH BEST POSSIBLE MATCH/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 2 | $self->_readline; | |||||||||||||||||||||||||||
| 128 | 2 | ▶ | while (defined($buf=$self->_readline)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 10 | ▶ | last if ($buf!~/\w/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 8 | $buf=~s/\t+//g; | |||||||||||||||||||||||||||
| 131 | 8 | $buf=~s/^\s+//g; | |||||||||||||||||||||||||||
| 132 | 8 | my ($id,$width,$seq)=split(/\s+/,$buf); | |||||||||||||||||||||||||||
| 133 | 8 | push @{$self->{hid}},$id; | |||||||||||||||||||||||||||
| 134 | 8 | $self->{length}->{$id}=$width; | |||||||||||||||||||||||||||
| 135 | 8 | $self->{seq}->{$id}=$seq; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 2 | next; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | 88 | ▶ | if ($buf=~m/section i:/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 2 | $self->_readline; | |||||||||||||||||||||||||||
| 141 | 2 | $self->_readline; | |||||||||||||||||||||||||||
| 142 | 2 | $self->_readline; | |||||||||||||||||||||||||||
| 143 | 2 | %instances=_get_genes($self); | |||||||||||||||||||||||||||
| 144 | 2 | $self->{instances}=\%instances; | |||||||||||||||||||||||||||
| 145 | 2 | ▶ | if (!(%instances)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | $self->warn ("Your MAST analysis did not find any matches satisfying the current threshold.\nSee MAST documentation for more information.\n"); | |||||||||||||||||||||||||||
| 147 | 0 | return $self; #The header might be useful so we return the object, not undef | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | 2 | next; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | 86 | ▶ | if ($buf=~m/section ii:/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 2 | $self->_readline; | |||||||||||||||||||||||||||
| 153 | 2 | $self->_readline; | |||||||||||||||||||||||||||
| 154 | 2 | $self->_readline; | |||||||||||||||||||||||||||
| 155 | 2 | last; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | 84 | $buf=~s/[\t+\s+]/ /g; | |||||||||||||||||||||||||||
| 158 | 84 | ▶ | push @header,$buf unless (($buf=~/\*{10,}/)||($buf!~/\w/)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$buf =~ /\*{10,}/ or not $buf =~ /\w/
MC/DC100%2/2
$buf =~ /\*{10,}/ or not $buf =~ /\w/
$buf =~ /\*{10,}/
not $buf =~ /\w/
Truth table100%3/3
A or not(B)
A= $buf =~ /\*{10,}/B= not $buf =~ /\w/
| |||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | 2 | ▶ | $self->throw('Could not read Section I, probably wrong format, make sure it is not HTML, giving up...') if !(%instances); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 2 | ▶ | $self->warn( "This file might be an unreadable version, proceed with caution!\n") if (!grep(/\s+MAST\s+version\s+3/,@header)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 2 | $self->{unstructured} = \@header; | |||||||||||||||||||||||||||
| 164 | 2 | $self->_initialize; | |||||||||||||||||||||||||||
| 165 | 2 | return $self; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | # Get the file header and put store it as a hash, which later we'll use to create | ||||||||||||||||||||||||||||
| 170 | # the header for each Psm. See Bio::Matrix::PSM::PsmI for header function. | ||||||||||||||||||||||||||||
| 171 | 2 | ▶ | sub _get_genes { | ||||||||||||||||||||||||||
|
Subroutine
_get_genes: called CC=5 SCAR=16.5
| |||||||||||||||||||||||||||||
| 172 | 2 | my $self=shift; | |||||||||||||||||||||||||||
| 173 | 2 | my %llid; | |||||||||||||||||||||||||||
| 174 | 2 | my $ok=0; | |||||||||||||||||||||||||||
| 175 | 2 | my $i=0; | |||||||||||||||||||||||||||
| 176 | 2 | my %instances; | |||||||||||||||||||||||||||
| 177 | 2 | ▶ | while (my $line=$self->_readline) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 108 | ▶ | last if ($line=~/^[\s\t*]/); # Well, ids can be nearly anything...??? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 106 | chomp($line); | |||||||||||||||||||||||||||
| 180 | 106 | $i++; | |||||||||||||||||||||||||||
| 181 | 106 | ▶ | next if ($line eq ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 106 | $line=~s/\s+/,/g; | |||||||||||||||||||||||||||
| 183 | 106 | my ($id,$key,$eval,$len)=split(/,/,$line); | |||||||||||||||||||||||||||
| 184 | 106 | ▶ | unless ($len) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | 0 | warn "Malformed data found: $line\n"; | |||||||||||||||||||||||||||
| 186 | 0 | next; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | 106 | $instances{$id}=Bio::Matrix::PSM::InstanceSite->new(-id=>$id, | |||||||||||||||||||||||||||
| 189 | -desc=>$key, | ||||||||||||||||||||||||||||
| 190 | -score=>$eval, | ||||||||||||||||||||||||||||
| 191 | -width=>$len, | ||||||||||||||||||||||||||||
| 192 | -seq=>'ACGT'); | ||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | 2 | return %instances; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | =head2 next_psm | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | Title : next_psm | ||||||||||||||||||||||||||||
| 201 | Usage : my $psm=$psmIO->next_psm(); | ||||||||||||||||||||||||||||
| 202 | Function: Reads the next PSM from the input file, associated with this object | ||||||||||||||||||||||||||||
| 203 | Throws : Throws if there ara format violations in the input file (checking is not | ||||||||||||||||||||||||||||
| 204 | very strict with all drivers). | ||||||||||||||||||||||||||||
| 205 | Example : | ||||||||||||||||||||||||||||
| 206 | Returns : Bio::Matrix::PSM::Psm object | ||||||||||||||||||||||||||||
| 207 | Args : none | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | =cut | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 2 | ▶ | sub next_psm { | ||||||||||||||||||||||||||
|
Subroutine
next_psm: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||
| 213 | 2 | my $self=shift; | |||||||||||||||||||||||||||
| 214 | 2 | ▶ | return if ($self->{_end}==1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 2 | my (@lmotifsm,%index,$eval,$scheme,$sid); | |||||||||||||||||||||||||||
| 216 | 2 | %index= %{$self->{length}}; | |||||||||||||||||||||||||||
| 217 | 2 | my (@instances,%instances); | |||||||||||||||||||||||||||
| 218 | 2 | my $line=$self->_readline; | |||||||||||||||||||||||||||
| 219 | 2 | $line=~s/[\t\n]//; | |||||||||||||||||||||||||||
| 220 | 2 | ▶ | if ($line =~ /\*{10,}/) { #Endo of Section II if we do only section II | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | 0 | $self->{_end}=1; | |||||||||||||||||||||||||||
| 222 | 0 | return ; | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | 2 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | 36 | ▶ | if ($line!~/^\s/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 2 | ($sid,$eval,$scheme)=split(/\s+/,$line,3); | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | else | ||||||||||||||||||||||||||||
| 229 | 34 | { $scheme .=$line; } | |||||||||||||||||||||||||||
| 230 | 36 | $line=$self->_readline; | |||||||||||||||||||||||||||
| 231 | 36 | $line=~s/[\t\n]//; | |||||||||||||||||||||||||||
| 232 | } until ($line!~/^\s/); | ||||||||||||||||||||||||||||
| 233 | 2 | my $pos=1; | |||||||||||||||||||||||||||
| 234 | 2 | $scheme=~s/\s+//g; | |||||||||||||||||||||||||||
| 235 | 2 | $scheme=~s/\n//g; | |||||||||||||||||||||||||||
| 236 | 2 | my @motifs=split(/_/,$scheme); | |||||||||||||||||||||||||||
| 237 | 2 | ▶ | while (@motifs) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 184 | my $next=shift(@motifs); | |||||||||||||||||||||||||||
| 239 | 184 | ▶ | if (!($next=~/\D/)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | 93 | ▶ | last if (!@motifs); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 91 | $pos+=$next; | |||||||||||||||||||||||||||
| 242 | 91 | next; | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | 91 | my $id=$next; | |||||||||||||||||||||||||||
| 245 | 91 | ▶ | my $score= $id=~m/\[/ ? 'strong' : 'weak' ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 91 | my $frame; | |||||||||||||||||||||||||||
| 247 | 91 | ▶ | my $strand = $id =~ m/\-\d/ ? -1 : 1 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 91 | ▶ | if ($self->{_mixquery}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 87 | ▶ | $frame = 0 if $id =~ m/\d+a/ ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 87 | ▶ | $frame = 1 if $id =~ m/\d+b/ ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | 87 | ▶ | $frame = 2 if $id =~ m/\d+c/ ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | 91 | $id=~s/\D+//g; | |||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 91 | my @s; | |||||||||||||||||||||||||||
| 256 | 91 | my $width=$index{$id}; | |||||||||||||||||||||||||||
| 257 | #We don't know the sequence, but we know the length | ||||||||||||||||||||||||||||
| 258 | 91 | my $seq='N' x ($width*$self->{_factor}); #Future version will have to parse Section tree nad get the real seq | |||||||||||||||||||||||||||
| 259 | 91 | my $instance=Bio::Matrix::PSM::InstanceSite->new | |||||||||||||||||||||||||||
| 260 | ( -id=>"$id\@$sid", | ||||||||||||||||||||||||||||
| 261 | -mid=>$id, | ||||||||||||||||||||||||||||
| 262 | -accession_number=>$sid, | ||||||||||||||||||||||||||||
| 263 | -desc=>"Motif $id occurrance in $sid", | ||||||||||||||||||||||||||||
| 264 | -score=>$score, | ||||||||||||||||||||||||||||
| 265 | -seq=>$seq, | ||||||||||||||||||||||||||||
| 266 | -alphabet => 'dna', | ||||||||||||||||||||||||||||
| 267 | -start=>$pos, | ||||||||||||||||||||||||||||
| 268 | -strand=>$strand); | ||||||||||||||||||||||||||||
| 269 | 91 | ▶ | $instance->frame($frame) if ($self->{_mixquery}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | 91 | push @instances,$instance; | |||||||||||||||||||||||||||
| 271 | 91 | $pos+=$index{$id}*$self->{_factor}; | |||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | 2 | my $psm= Bio::Matrix::PSM::Psm->new(-instances=> \@instances, | |||||||||||||||||||||||||||
| 274 | -e_val => $eval, | ||||||||||||||||||||||||||||
| 275 | -id => $sid); | ||||||||||||||||||||||||||||
| 276 | 2 | $self->_pushback($line); | |||||||||||||||||||||||||||
| 277 | 2 | return $psm; | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | =head2 write_psm | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | Title : write_psm | ||||||||||||||||||||||||||||
| 284 | Usage : #Get SiteMatrix object somehow (see Bio::Matrix::PSM::SiteMatrix) | ||||||||||||||||||||||||||||
| 285 | my $matrix=$psmin->next_matrix; | ||||||||||||||||||||||||||||
| 286 | #Create the stream | ||||||||||||||||||||||||||||
| 287 | my $psmio=new(-file=>">psms.mast",-format=>'mast'); | ||||||||||||||||||||||||||||
| 288 | $psmio->write_psm($matrix); | ||||||||||||||||||||||||||||
| 289 | #Will warn if only PFM data is contained in $matrix, recalculate the PWM | ||||||||||||||||||||||||||||
| 290 | #based on normal distribution (A=>0.25, C=>0.25, etc) | ||||||||||||||||||||||||||||
| 291 | Function: writes pwm in mast format | ||||||||||||||||||||||||||||
| 292 | Throws : | ||||||||||||||||||||||||||||
| 293 | Example : | ||||||||||||||||||||||||||||
| 294 | Args : SiteMatrix object | ||||||||||||||||||||||||||||
| 295 | Returns : | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | =cut | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 0 | ▶ | sub write_psm { | ||||||||||||||||||||||||||
|
Subroutine
write_psm: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 300 | 0 | my ($self,$matrix)=@_; | |||||||||||||||||||||||||||
| 301 | # my $idline=">". $matrix->id . "\n"; | ||||||||||||||||||||||||||||
| 302 | 0 | my $w=$matrix->width; | |||||||||||||||||||||||||||
| 303 | 0 | my $header="ALPHABET= ACGT\nlog-odds matrix: alength= 4 w= $w\n"; | |||||||||||||||||||||||||||
| 304 | 0 | $self->_print($header); | |||||||||||||||||||||||||||
| 305 | 0 | ▶ | unless ($matrix->get_logs_array('A')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | 0 | warn "No log-odds data, available, using normal distribution to recalculate the PWM"; | |||||||||||||||||||||||||||
| 307 | 0 | $matrix->calc_weight({A=>0.25, C=>0.25, G=>0.25,T=>0.25}); | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | 0 | ▶ | while (my %h=$matrix->next_pos) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | 0 | $self->_print (join("\t",$h{lA},$h{lC},$h{lG},$h{lT},"\n")); | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 2 | 1; | |||||||||||||||||||||||||||