| 1 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::SeqIO::PIR | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # Copyright Aaron Mackey | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # _history | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # October 18, 1999 Largely rewritten by Lincoln Stein | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | Bio::SeqIO::pir - PIR sequence input/output stream | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | Do not use this module directly. Use it via the Bio::SeqIO class. | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | This object can transform Bio::Seq objects to and from pir flat | ||||||||||||||||||||||||||||||||||||||||||
| 26 | file databases. | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | Note: This does not completely preserve the PIR format - quality | ||||||||||||||||||||||||||||||||||||||||||
| 29 | information about sequence is currently discarded since bioperl | ||||||||||||||||||||||||||||||||||||||||||
| 30 | does not have a mechanism for handling these encodings in sequence | ||||||||||||||||||||||||||||||||||||||||||
| 31 | data. | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||||||||||||
| 38 | Bioperl modules. Send your comments and suggestions preferably to one | ||||||||||||||||||||||||||||||||||||||||||
| 39 | of the Bioperl mailing lists. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||||||||||
| 42 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | =head2 Support | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||||||||||||
| 51 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||||||||||||
| 52 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||||||||||||
| 53 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||||||||||||
| 58 | the bugs and their resolution. | ||||||||||||||||||||||||||||||||||||||||||
| 59 | Bug reports can be submitted via the web: | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | Aaron Mackey E<lt>amackey@virginia.eduE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 66 | Lincoln Stein E<lt>lstein@cshl.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 67 | Jason Stajich E<lt>jason@bioperl.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | The rest of the documentation details each of the object | ||||||||||||||||||||||||||||||||||||||||||
| 72 | methods. Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | # Let the code begin... | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | package Bio::SeqIO::pir; | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | $Bio::SeqIO::pir::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | ▶ | use Bio::Seq::SeqFactory; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | ▶ | use base qw(Bio::SeqIO); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 3 | our %VALID_TYPE = map {$_ => 1} qw(P1 F1 DL DC RL RC XX); | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | ▶ | sub _initialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 5 | my($self,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 5 | $self->SUPER::_initialize(@args); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 5 | ▶ | if( ! defined $self->sequence_factory ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | $self->sequence_factory(Bio::Seq::SeqFactory->new | |||||||||||||||||||||||||||||||||||||||||
| 93 | (-verbose => $self->verbose(), | ||||||||||||||||||||||||||||||||||||||||||
| 94 | -type => 'Bio::Seq')); | ||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | =head2 next_seq | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | Title : next_seq | ||||||||||||||||||||||||||||||||||||||||||
| 101 | Usage : $seq = $stream->next_seq() | ||||||||||||||||||||||||||||||||||||||||||
| 102 | Function: returns the next sequence in the stream | ||||||||||||||||||||||||||||||||||||||||||
| 103 | Returns : Bio::Seq object | ||||||||||||||||||||||||||||||||||||||||||
| 104 | Args : NONE | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 12 | ▶ | sub next_seq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_seq: called CC=7 SCAR=21.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 12 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 12 | local $/ = "\n>"; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 12 | ▶ | return unless my $line = $self->_readline; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 11 | ▶ | if ( $line eq '>' ) { # handle the very first one having no comment | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | return unless $line = $self->_readline; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 11 | ▶ | my ( $top, $desc, $seq ) = ( $line =~ /^(.+?)\n(.*?)\n([^>]*)/s ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | or $self->throw("Cannot parse entry PIR entry [$line]"); | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 11 | my ( $type, $id ); | |||||||||||||||||||||||||||||||||||||||||
| 119 | 11 | ▶ | if ( $top =~ /^>?(\S{2});(\S+)\s*$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 11 | ( $type, $id ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||
| 121 | 11 | ▶ | if ( ! exists $VALID_TYPE{$type} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $self->throw( | |||||||||||||||||||||||||||||||||||||||||
| 123 | "PIR stream read attempted without proper two-letter sequence code [ $type ]" | ||||||||||||||||||||||||||||||||||||||||||
| 124 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $self->throw("Line does not match PIR format [ $line ]"); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | # P - indicates complete protein | ||||||||||||||||||||||||||||||||||||||||||
| 131 | # F - indicates protein fragment | ||||||||||||||||||||||||||||||||||||||||||
| 132 | # not sure how to stuff these into a Bio object | ||||||||||||||||||||||||||||||||||||||||||
| 133 | # suitable for writing out. | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 11 | $seq =~ s/\*//g; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 11 | $seq =~ s/[\(\)\.\/\=\,]//g; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 11 | $seq =~ s/\s+//g; # get rid of whitespace | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 11 | my ($alphabet) = ('protein'); | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | # TODO - not processing SFS data | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 11 | return $self->sequence_factory->create( | |||||||||||||||||||||||||||||||||||||||||
| 142 | -seq => $seq, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | -primary_id => $id, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | -id => $id, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | -desc => $desc, | ||||||||||||||||||||||||||||||||||||||||||
| 146 | -alphabet => $alphabet | ||||||||||||||||||||||||||||||||||||||||||
| 147 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | =head2 write_seq | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | Title : write_seq | ||||||||||||||||||||||||||||||||||||||||||
| 153 | Usage : $stream->write_seq(@seq) | ||||||||||||||||||||||||||||||||||||||||||
| 154 | Function: writes the $seq object into the stream | ||||||||||||||||||||||||||||||||||||||||||
| 155 | Returns : 1 for success and 0 for error | ||||||||||||||||||||||||||||||||||||||||||
| 156 | Args : Array of Bio::PrimarySeqI objects | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | sub write_seq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_seq: called CC=9 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | my ($self, @seq) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | for my $seq (@seq) { | |||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | ▶ | $self->throw("Did not provide a valid Bio::PrimarySeqI object") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $seq and ref $seq and $seq->isa("Bio::PrimarySeqI")
defined $seq and ref $seq
MC/DC0%0/3
defined $seq and ref $seq and $seq->isa("Bio::PrimarySeqI")
defined $seq
ref $seq
$seq->isa("Bio::PrimarySeqI")
Truth table25%1/4
A and B and C
A= defined $seqB= ref $seqC= $seq->isa("Bio::PrimarySeqI")
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | unless defined $seq && ref($seq) && $seq->isa('Bio::PrimarySeqI'); | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | ▶ | $self->warn("No whitespace allowed in PIR ID [". $seq->display_id. "]") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | if $seq->display_id =~ /\s/; | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | my $str = $seq->seq(); | |||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | ▶ | return unless $self->_print(">P1;".$seq->id(), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | "\n", $seq->desc(), "\n", | ||||||||||||||||||||||||||||||||||||||||||
| 173 | $str, "*\n"); | ||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | ▶ | $self->flush if $self->_flush_on_write && defined $self->_fh; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_flush_on_write and defined $self->_fh
MC/DC0%0/2
$self->_flush_on_write and defined $self->_fh
$self->_flush_on_write
defined $self->_fh
Truth table33%1/3
A and B
A= $self->_flush_on_writeB= defined $self->_fh
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||