2 # BioPerl module for Bio::SeqIO::PIR
4 # Cared for by Aaron Mackey <amackey@virginia.edu>
6 # Copyright Aaron Mackey
8 # You may distribute this module under the same terms as perl itself
11 # October 18, 1999 Largely rewritten by Lincoln Stein
13 # POD documentation - main docs before the code
17 Bio::SeqIO::pir - PIR sequence input/output stream
21 Do not use this module directly. Use it via the Bio::SeqIO class.
25 This object can transform Bio::Seq objects to and from fasta flat
32 User feedback is an integral part of the evolution of this
33 and other Bioperl modules. Send your comments and suggestions preferably
34 to one of the Bioperl mailing lists.
35 Your participation is much appreciated.
37 vsns-bcd-perl@lists.uni-bielefeld.de - General discussion
38 vsns-bcd-perl-guts@lists.uni-bielefeld.de - Technically-oriented discussion
39 http://bio.perl.org/MailList.html - About the mailing lists
43 Report bugs to the Bioperl bug tracking system to help us keep track
44 the bugs and their resolution.
45 Bug reports can be submitted via email or the web:
47 bioperl-bugs@bio.perl.org
48 http://bio.perl.org/bioperl-bugs/
52 Aaron Mackey <amackey@virginia.edu>
53 Lincoln Stein <lstein@cshl.org>
57 The rest of the documentation details each of the object
58 methods. Internal methods are usually preceded with a _
62 # Let the code begin...
64 package Bio
::SeqIO
::pir
;
69 @ISA = qw(Bio::SeqIO);
74 Usage : $seq = $stream->next_seq()
75 Function: returns the next sequence in the stream
76 Returns : Bio::Seq object
83 my ($self,@args) = @_;
84 my ($seq,$line,$name,$sfs,$desc);
86 return unless $line = $self->_readline;
87 $self->throw("PIR stream read attempted without leading '>P1;' [ $line ]")
88 unless $line =~ /^>(?:P|F)1;(\S+)\s*(\|.*)?\s*$/;
92 chomp($desc = $self->_readline);
94 my $junk = $self->_readline; # throw away everything to first empty line
95 my $seq = $self->_readline; # everything else is the sequence
97 $seq = Bio
::Seq
->new(-seq
=> $seq,
100 -names
=> defined $sfs ?
{ 'sfnum' => [ split(/\s*\|?\s+/, $sfs) ] } : undef );
107 Usage : $stream->write_seq(@seq)
108 Function: writes the $seq object into the stream
109 Returns : 1 for success and 0 for error
110 Args : Bio::Seq object
116 my ($self, @seq) = @_;
118 my $str = $seq->seq();
119 $str =~ s/(.{10})/$1 /g;
120 $str =~ s/(.{66})/$1\n/g;
121 return unless $self->_print(">P1;", $seq->id(),
122 (%{$seq->names()}->{'sfnum'} ?
" |" .
123 join(' ', @
{%{$seq->names()}->{'sfnum'}}) : '' ),
124 "\n", $seq->desc(), "\n",
125 ">P1;", $seq->id(),"\n",