1 #---------------------------------------------------------
5 Bio::Matrix::PSM::IO::psiblast - PSM psiblast parser
9 See Bio::Matrix::PSM::IO for documentation
13 Parser for ASCII matrices from PSI-BLAST (blastpgp program in
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 - James Thompson
48 Email tex@biosysadmin.com
55 # Let the code begin...
56 package Bio
::Matrix
::PSM
::IO
::psiblast
;
57 use Bio
::Matrix
::PSM
::Psm
;
58 use Bio
::Matrix
::PSM
::ProtMatrix
;
61 use base
qw(Bio::Matrix::PSM::PsmHeader Bio::Matrix::PSM::IO);
63 # define the order in which amino acids are listed in the psiblast matrix file
64 our @ordered_alphabet = qw
/A R N D C Q E G H I L K M F P S T W Y V/;
69 Usage : my $psmIO = Bio::Matrix::PSM::IO->new(-format=>'psiblast',
71 Function: Associates a file with the appropriate parser
75 Returns : Bio::Matrix::PSM::ProtMatrix->new(@args);
83 my $self = $class->SUPER::new
(@args);
84 my ($file) = $self->_rearrange(['FILE'], @args);
85 $self->_initialize_io(@args) || warn "Did you intend to use STDIN?"; # Read only for now
88 $self->{_ordered_alphabet
} = \
@ordered_alphabet;
95 Usage : my $psm = $psmIO->next_psm();
96 Function: Reads the next PSM from the input file, associated with this object
98 Returns : Bio::Matrix::PSM::ProtPsm object
107 return if ($self->{_end
});
110 my @ordered_alphabet = @
{$self->{_ordered_alphabet
}};
112 while ( defined( $line = $self->_readline) ) {
113 # remove leading and trailing whitespace
118 if ( $line =~ /^(\d+)\s+(\w{1})/ ) { # match reference aa and position number
119 my @elements = split /\s+/, $line;
121 my $position = shift @elements;
122 my $letter = shift @elements;
124 my $ratio = pop @elements;
125 my $ic = pop @elements;
127 # put the next 20 elements into the correct array in %args
128 for ( 0 .. 19 ) { push @
{$args{'l'.$ordered_alphabet[$_]}}, shift @elements; }
129 for ( 0 .. 19 ) { push @
{$args{'p'.$ordered_alphabet[$_]}}, shift @elements; }
131 push @
{$args{'ic'}}, $ic;
135 $self->{_end
} = 1; # psiblast matrix files currently only hold one PSM per file
137 my $psm = Bio
::Matrix
::PSM
::ProtMatrix
->new( %args );