| 1 | #--------------------------------------------------------- | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Bio::Matrix::PSM::IO::psiblast - PSM psiblast parser | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | See Bio::Matrix::PSM::IO for documentation | ||||||||||
| 10 | |||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||
| 12 | |||||||||||
| 13 | Parser for ASCII matrices from PSI-BLAST (blastpgp program in | ||||||||||
| 14 | BLAST distribution). | ||||||||||
| 15 | |||||||||||
| 16 | =head1 FEEDBACK | ||||||||||
| 17 | |||||||||||
| 18 | =head2 Mailing Lists | ||||||||||
| 19 | |||||||||||
| 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. | ||||||||||
| 23 | |||||||||||
| 24 | bioperl-l@bioperl.org - General discussion | ||||||||||
| 25 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||
| 26 | |||||||||||
| 27 | =head2 Support | ||||||||||
| 28 | |||||||||||
| 29 | Please direct usage questions or support issues to the mailing list: | ||||||||||
| 30 | |||||||||||
| 31 | I<bioperl-l@bioperl.org> | ||||||||||
| 32 | |||||||||||
| 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. | ||||||||||
| 37 | |||||||||||
| 38 | =head2 Reporting Bugs | ||||||||||
| 39 | |||||||||||
| 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 | ||||||||||
| 42 | web: | ||||||||||
| 43 | |||||||||||
| 44 | https://github.com/bioperl/bioperl-live/issues | ||||||||||
| 45 | |||||||||||
| 46 | =head1 AUTHOR - James Thompson | ||||||||||
| 47 | |||||||||||
| 48 | Email tex@biosysadmin.com | ||||||||||
| 49 | |||||||||||
| 50 | =head1 APPENDIX | ||||||||||
| 51 | |||||||||||
| 52 | =cut | ||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | # Let the code begin... | ||||||||||
| 56 | package Bio::Matrix::PSM::IO::psiblast; | ||||||||||
| 57 | 2 | $Bio::Matrix::PSM::IO::psiblast::VERSION = '1.7.8'; | |||||||||
| 58 | 2 | ▶ | use Bio::Matrix::PSM::Psm; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 59 | 2 | ▶ | use Bio::Matrix::PSM::ProtMatrix; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 60 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 61 | |||||||||||
| 62 | 2 | ▶ | use base qw(Bio::Matrix::PSM::PsmHeader Bio::Matrix::PSM::IO); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 63 | |||||||||||
| 64 | # define the order in which amino acids are listed in the psiblast matrix file | ||||||||||
| 65 | 2 | our @ordered_alphabet = qw/A R N D C Q E G H I L K M F P S T W Y V/; | |||||||||
| 66 | |||||||||||
| 67 | =head2 new | ||||||||||
| 68 | |||||||||||
| 69 | Title : new | ||||||||||
| 70 | Usage : my $psmIO = Bio::Matrix::PSM::IO->new(-format=>'psiblast', | ||||||||||
| 71 | -file=>$file); | ||||||||||
| 72 | Function: Associates a file with the appropriate parser | ||||||||||
| 73 | Throws : | ||||||||||
| 74 | Example : | ||||||||||
| 75 | Args : | ||||||||||
| 76 | Returns : Bio::Matrix::PSM::ProtMatrix->new(@args); | ||||||||||
| 77 | |||||||||||
| 78 | =cut | ||||||||||
| 79 | |||||||||||
| 80 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 81 | 1 | my ($class,@args)=@_; | |||||||||
| 82 | 1 | my $line; | |||||||||
| 83 | |||||||||||
| 84 | 1 | my $self = $class->SUPER::new(@args); | |||||||||
| 85 | 1 | my ($file) = $self->_rearrange(['FILE'], @args); | |||||||||
| 86 | 1 | ▶ | $self->_initialize_io(@args) || warn "Did you intend to use STDIN?"; # Read only for now | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | 1 | $self->_initialize; | |||||||||
| 88 | |||||||||||
| 89 | 1 | $self->{_ordered_alphabet} = \@ordered_alphabet; | |||||||||
| 90 | 1 | return $self; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | =head2 next_psm | ||||||||||
| 94 | |||||||||||
| 95 | Title : next_psm | ||||||||||
| 96 | Usage : my $psm = $psmIO->next_psm(); | ||||||||||
| 97 | Function: Reads the next PSM from the input file, associated with this object | ||||||||||
| 98 | Throws : None | ||||||||||
| 99 | Returns : Bio::Matrix::PSM::ProtPsm object | ||||||||||
| 100 | Args : none | ||||||||||
| 101 | |||||||||||
| 102 | =cut | ||||||||||
| 103 | |||||||||||
| 104 | 1 | ▶ | sub next_psm { | ||||||||
|
Subroutine
next_psm: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||
| 105 | 1 | my $self = shift; | |||||||||
| 106 | 1 | my $line; | |||||||||
| 107 | |||||||||||
| 108 | 1 | ▶ | return if ($self->{_end}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 109 | |||||||||||
| 110 | 1 | my %args; | |||||||||
| 111 | 1 | my @ordered_alphabet = @{$self->{_ordered_alphabet}}; | |||||||||
| 112 | |||||||||||
| 113 | 1 | ▶ | while ( defined( $line = $self->_readline) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 114 | # remove leading and trailing whitespace | ||||||||||
| 115 | 516 | chomp $line; | |||||||||
| 116 | 516 | $line =~ s/^\s+//g; | |||||||||
| 117 | 516 | $line =~ s/\s+$//g; | |||||||||
| 118 | |||||||||||
| 119 | 516 | ▶ | if ( $line =~ /^(\d+)\s+(\w{1})/ ) { # match reference aa and position number | ||||||||
|
Branch: 1 branch
| |||||||||||
| 120 | 507 | my @elements = split /\s+/, $line; | |||||||||
| 121 | |||||||||||
| 122 | 507 | my $position = shift @elements; | |||||||||
| 123 | 507 | my $letter = shift @elements; | |||||||||
| 124 | |||||||||||
| 125 | 507 | my $ratio = pop @elements; | |||||||||
| 126 | 507 | my $ic = pop @elements; | |||||||||
| 127 | |||||||||||
| 128 | # put the next 20 elements into the correct array in %args | ||||||||||
| 129 | 507 | for ( 0 .. 19 ) { push @{$args{'l'.$ordered_alphabet[$_]}}, shift @elements; } | |||||||||
| 130 | 507 | for ( 0 .. 19 ) { push @{$args{'p'.$ordered_alphabet[$_]}}, shift @elements; } | |||||||||
| 131 | |||||||||||
| 132 | 507 | push @{$args{'ic'}}, $ic; | |||||||||
| 133 | } | ||||||||||
| 134 | } | ||||||||||
| 135 | |||||||||||
| 136 | 1 | $self->{_end} = 1; # psiblast matrix files currently only hold one PSM per file | |||||||||
| 137 | |||||||||||
| 138 | 1 | my $psm = Bio::Matrix::PSM::ProtMatrix->new( %args ); | |||||||||
| 139 | 1 | return $psm; | |||||||||
| 140 | } | ||||||||||
| 141 | |||||||||||
| 142 | 1 | ▶ | sub DESTROY { | ||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||
| 143 | 1 | my $self=shift; | |||||||||
| 144 | 1 | $self->close; | |||||||||
| 145 | } | ||||||||||
| 146 | |||||||||||
| 147 | 2 | 1; | |||||||||