~ubuntu-branches/ubuntu/hoary/bioperl/hoary

« back to all changes in this revision

Viewing changes to Bio/SeqIO/pln.pm

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2004-04-18 14:24:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040418142411-gr92uexquw4w8liq
Tags: 1.4-1
* New upstream release
* Examples and working code are installed by default to usr/bin,
  this has been moved to usr/share/doc/bioperl/bin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: pln.pm,v 1.7 2002/10/22 07:38:42 lapp Exp $
 
2
# BioPerl module for Bio::SeqIO::pln
 
3
#
 
4
# Cared for by Aaron Mackey <amackey@virginia.edu>
 
5
#
 
6
# Copyright Aaron Mackey
 
7
#
 
8
# You may distribute this module under the same terms as perl itself
 
9
 
 
10
# POD documentation - main docs before the code
 
11
 
 
12
=head1 NAME
 
13
 
 
14
Bio::SeqIO::pln - pln trace sequence input/output stream
 
15
 
 
16
=head1 SYNOPSIS
 
17
 
 
18
Do not use this module directly.  Use it via the Bio::SeqIO class.
 
19
 
 
20
=head1 DESCRIPTION
 
21
 
 
22
This object can transform Bio::Seq objects to and from pln trace
 
23
files.
 
24
 
 
25
=head1 FEEDBACK
 
26
 
 
27
=head2 Mailing Lists
 
28
 
 
29
User feedback is an integral part of the evolution of this and other
 
30
Bioperl modules. Send your comments and suggestions preferably to one
 
31
of the Bioperl mailing lists.  Your participation is much appreciated.
 
32
 
 
33
  bioperl-l@bioperl.org            - General discussion
 
34
  http://bioperl.org/MailList.shtml - About the mailing lists
 
35
 
 
36
=head2 Reporting Bugs
 
37
 
 
38
Report bugs to the Bioperl bug tracking system to help us keep track
 
39
 the bugs and their resolution.
 
40
 Bug reports can be submitted via email or the web:
 
41
 
 
42
  bioperl-bugs@bio.perl.org
 
43
  http://bugzilla.bioperl.org/
 
44
 
 
45
=head1 AUTHORS - Aaron Mackey
 
46
 
 
47
Email: amackey@virginia.edu
 
48
 
 
49
=head1 APPENDIX
 
50
 
 
51
The rest of the documentation details each of the object
 
52
methods. Internal methods are usually preceded with a _
 
53
 
 
54
=cut
 
55
 
 
56
# Let the code begin...
 
57
 
 
58
package Bio::SeqIO::pln;
 
59
use vars qw(@ISA $READ_AVAIL);
 
60
use strict;
 
61
# Object preamble - inherits from Bio::Root::Object
 
62
 
 
63
use Bio::SeqIO;
 
64
use Bio::Seq::SeqFactory;
 
65
 
 
66
push @ISA, qw( Bio::SeqIO );
 
67
 
 
68
sub BEGIN {
 
69
    eval { require Bio::SeqIO::staden::read; };
 
70
    if ($@) {
 
71
        $READ_AVAIL = 0;
 
72
    } else {
 
73
        push @ISA, "Bio::SeqIO::staden::read";
 
74
        $READ_AVAIL = 1;
 
75
    }
 
76
}
 
77
 
 
78
sub _initialize {
 
79
  my($self,@args) = @_;
 
80
  $self->SUPER::_initialize(@args);  
 
81
  if( ! defined $self->sequence_factory ) {
 
82
      $self->sequence_factory(new Bio::Seq::SeqFactory(-verbose => $self->verbose(), -type => 'Bio::Seq'));      
 
83
  }
 
84
  unless ($READ_AVAIL) {
 
85
      Bio::Root::Root->throw( -class => 'Bio::Root::SystemException',
 
86
                              -text  => "Bio::SeqIO::staden::read is not available; make sure the bioperl-ext package has been installed successfully!"
 
87
                            );
 
88
  }
 
89
}
 
90
 
 
91
=head2 next_seq
 
92
 
 
93
 Title   : next_seq
 
94
 Usage   : $seq = $stream->next_seq()
 
95
 Function: returns the next sequence in the stream
 
96
 Returns : Bio::SeqWithQuality object
 
97
 Args    : NONE
 
98
 
 
99
=cut
 
100
 
 
101
sub next_seq {
 
102
 
 
103
    my ($self) = @_;
 
104
 
 
105
    my ($seq, $id, $desc, $qual) = $self->read_trace($self->_fh, 'pln');
 
106
 
 
107
    # create the seq object
 
108
    $seq = $self->sequence_factory->create(-seq        => $seq,
 
109
                                           -id         => $id,
 
110
                                           -primary_id => $id,
 
111
                                           -desc       => $desc,
 
112
                                           -alphabet   => 'DNA',
 
113
                                           -qual       => $qual
 
114
                                           );
 
115
    return $seq;
 
116
}
 
117
 
 
118
=head2 write_seq
 
119
 
 
120
 Title   : write_seq
 
121
 Usage   : $stream->write_seq(@seq)
 
122
 Function: writes the $seq object into the stream
 
123
 Returns : 1 for success and 0 for error
 
124
 Args    : Bio::Seq object
 
125
 
 
126
 
 
127
=cut
 
128
 
 
129
sub write_seq {
 
130
    my ($self,@seq) = @_;
 
131
 
 
132
    my $fh = $self->_fh;
 
133
    foreach my $seq (@seq) {
 
134
        $self->write_trace($fh, $seq, 'pln');
 
135
    }
 
136
 
 
137
    $self->flush if $self->_flush_on_write && defined $self->_fh;
 
138
    return 1;
 
139
}
 
140
 
 
141
1;