This module allows you to read DNA position scoring matrices and/or
their respective sequence matches from a file.
There are two header methods, one belonging to
Bio::Matrix::PSM::IO::driver and the other to
Bio::Matrix::PSM::Psm. They provide general information about the file
(driver) and for the current PSM result (Psm) respectively. Psm header
method always returns the same thing, but some values in the hash
might be empty, depending on the file you are parsing. You will get
undef in this case (no exceptions are thrown).
Please note that the file header data (commenatries, version, input
data, configuration, etc.) might be obtained through
Bio::Matrix::PSM::PsmHeader methods. Some methods are driver specific
(meme, transfac, etc.): meme: weight mast: seq, instances
If called when you parse a different file type you will get undef. For
example:
my $psmIO= Bio::Matrix::PSM::IO->new(file=>$file, format=>'transfac');
my %seq=$psmIO->seq;
will return an empty hash. To see all methods and how to use them go
to Bio::Matrix::PSM::PsmHeaderI.
See also Bio::Matrix::PSM::PsmI for details on using and manipulating
the parsed data.
The only way to write PFM/PWM is through masta module (something like fasta for
DNA matrices). You can see an example by reading Bio::Matrix::PSM::IO::masta
documentation.
sub new
{ my($caller,@args) = @_;
my $class = ref($caller) || $caller;
my $self;
if( $class =~ /Bio::Matrix::PSM::IO(\S+)/ ) {
$self = $class->SUPER::new(@args);
$self->_initialize(@args);
return $self;
} else {
my %param = @args;
@param{ map { lc $_ } keys %param } = values %param; my $format = $param{'-format'} ||
$class->_guess_format( $param{'-file'} || $ARGV[0] ) ||
'scoring';
$class->throw("$format format unrecognized or an argument error occured\n.") if (!grep(/$format/,@Bio::Matrix::PSM::IO::PSMFORMATS));
$format = "\L$format";
return unless( $class->_load_format_module($format) );
return "Bio::Matrix::PSM::IO::$format"->new(@args);
}} |
sub _load_format_module
{ my ($self,$format) = @_;
my $module = "Bio::Matrix::PSM::IO::" . $format;
my $ok;
eval {
$ok = $self->_load_module($module);
};
if ( $@ ) {
print STDERR <<END; $self: $format cannot be found Exception $@ For more information about the Matrix::PSM::IO system please see the Matrix::PSM::IO docs. This includes ways of checking for formats at compile time, not run time END ;
}
return $ok;} |
Bio::Matrix::PSM::PsmI, Bio::Matrix::PSM::PsmHeaderI, Bio::Matrix::PSM::IO::masta
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to one
of the Bioperl mailing lists. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists