4 Bio::Matrix::PSM::PsmHeader - PSM mast parser implementation
8 # See Bio::Matrix::PSM::IO for detailed documentation on how to use
13 Parser for mast. This driver unlike meme or transfac for example is
14 dedicated more to PSM sequence matches
20 User feedback is an integral part of the evolution of this and other
21 Bioperl modules. Send your comments and suggestions preferably to one
22 of the Bioperl mailing lists. Your participation is much appreciated.
24 bioperl-l@bioperl.org - General discussion
25 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
29 Please direct usage questions or support issues to the mailing list:
31 I<bioperl-l@bioperl.org>
33 rather than to the module maintainer directly. Many experienced and
34 reponsive experts will be able look at the problem and quickly
35 address it. Please include a thorough description of the problem
36 with code and data examples if at all possible.
40 Report bugs to the Bioperl bug tracking system to help us keep track
41 the bugs and their resolution. Bug reports can be submitted via the
44 https://github.com/bioperl/bioperl-live/issues
46 =head1 AUTHOR - Stefan Kirov
55 # Let the code begin...
56 package Bio
::Matrix
::PSM
::PsmHeader
;
58 use Bio
::Matrix
::PSM
::InstanceSite
;
61 use base
qw(Bio::Root::Root Bio::Matrix::PSM::PsmHeaderI);
63 #These define what structures within the
64 @Bio::Matrix
::PSM
::PsmHeader
::MASTHEADER
=qw(html version release seq hid
65 length instances unstructured);
66 @Bio::Matrix
::PSM
::PsmHeader
::MEMEHEADER
=qw(html version release hid weight length unstructured);
67 @Bio::Matrix
::PSM
::PsmHeader
::TRANSFACHEADER
=qw(unstructured version release);
68 @Bio::Matrix
::PSM
::PsmHeader
::PSIBLASTHEADER
=qw(seq width ic);
69 @Bio::Matrix
::PSM
::PsmHeader
::ALLHEADER
=qw(header release type version html
70 release weight length id
71 seq instances unstructured);
76 Usage : my $header= Bio::Matrix::PSM::PsmHeader->new(-seq=>\%seq,
79 -instances=>\%instances,
82 Function: Creates a new Bio::Matrix::PSM::PsmHeader object
85 Returns : Bio::Matrix::PSM::PsmHeader object
93 my $self = $class->SUPER::new
(@args);
97 #parse version/release info here from the unstructured array
102 $self->{_type
} = $type;
103 my $dat=join(" ",grep(/version|release/i,@
{$self->{unstructured
}}));
104 if ($dat && ($dat=~/version\b/i)) {
105 $self->{version
}=substr($dat,$+[0]+1);
106 $self->{version
}=~s/\s.+[^\d\.\:\/]//g
;
107 $self->{version
}=~s/^\D//;
109 if ($dat && ($dat=~/release\b/i)) {
110 my $rel=substr($dat,$+[0]+1);
111 $rel=~s/[^\d\.\:\/\-]//g
;
113 if ($rel=~/\d\d:\d\d:\d\d/) { #Reformat if time is available too
114 my $time=substr($rel,$-[0]+1);
115 my $dat= substr($rel,0,$-[0]);
116 $self->{release
}="$dat $time";
118 else { $self->{release
}=$rel; }
126 Usage : my %seq= $header->seq();
127 Function: Returns the sequence data as a hash, indexed by a sequence ID (motif id or accession number)
128 In case the input data is a motif it would return the consenus seq for each of them (mast).
139 return () unless ($self->_check('seq'));
140 return %{$self->{seq
}};
146 Usage : my @hid= $header->hid();
147 Function: Returns array with the motif ids
158 return unless ($self->_check('hid'));
159 my @header=@
{$self->{hid
}};
166 Usage : my %length= $header->length();
167 Function: Returns the length of the input sequence or motifs as a hash, indexed
168 by a sequence ID (motif id or accession number)
179 return unless ($self->_check('length'));
180 return $self->{length};
186 Usage : my %instances= $header->instances();
187 Function: Returns the info about the input data, contained in the header
198 return unless ($self->_check('instances'));
199 return %{$self->{instances
}};
205 Usage : my %weights= $header->weight();
206 Function: Returns the weights of the input sequence as a hash, indexed
218 return () unless ($self->_check('weight'));
219 return %{$self->{weight
}};
226 Usage : my @unstructured= $header->unstuctured();
227 Function: Returns the unstructured data in the header as an array, one line per
228 array element, all control symbols are removed with \W
239 return @
{$self->{unstructured
}};
245 Usage : my $version= $header->version;
246 Function: Returns the version of the file being parsed if such exists
257 return $self->{version
};
263 Usage : my $release= $header->release;
264 Function: Returns the release of the file being parsed if such exists
275 return $self->{release
};
281 Usage : if ($self->_check('weights') { #do something} else {return 0;}
282 Function: Checks if the method called is aplicable to the file format
292 my ($self,$method) = @_;
293 my $type= $self->{'_type'};
294 if ($type eq 'meme') {
295 return 0 unless (grep(/$method/,
296 @Bio::Matrix
::PSM
::PsmHeader
::MEMEHEADER
));
297 } elsif ($type eq 'mast') {
298 return 0 unless (grep(/$method/,
299 @Bio::Matrix
::PSM
::PsmHeader
::MASTHEADER
));
300 } elsif ($type eq 'transfac') {
301 return 0 unless (grep(/$method/,
302 @Bio::Matrix
::PSM
::PsmHeader
::TRANSFACHEADER
));
303 } elsif ($type eq 'psiblast') {
304 return 0 unless (grep(/$method/,
305 @Bio::Matrix
::PSM
::PsmHeader
::PSIBLASTHEADER
));