sync w/ main trunk
[bioperl-live.git] / Bio / SeqIO / exp.pm
blob9358c388479e6a6ea4978a8df7e39b16ccb45b65
1 # $Id$
2 # BioPerl module for Bio::SeqIO::exp
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Aaron Mackey <amackey@virginia.edu>
8 # Copyright Aaron Mackey
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::SeqIO::exp - exp trace sequence input/output stream
18 =head1 SYNOPSIS
20 Do not use this module directly. Use it via the Bio::SeqIO class.
22 =head1 DESCRIPTION
24 This object can transform Bio::Seq objects to and from exp trace
25 files.
27 =head1 FEEDBACK
29 =head2 Mailing Lists
31 User feedback is an integral part of the evolution of this and other
32 Bioperl modules. Send your comments and suggestions preferably to one
33 of the Bioperl mailing lists. Your participation is much appreciated.
35 bioperl-l@bioperl.org - General discussion
36 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
38 =head2 Support
40 Please direct usage questions or support issues to the mailing list:
42 L<bioperl-l@bioperl.org>
44 rather than to the module maintainer directly. Many experienced and
45 reponsive experts will be able look at the problem and quickly
46 address it. Please include a thorough description of the problem
47 with code and data examples if at all possible.
49 =head2 Reporting Bugs
51 Report bugs to the Bioperl bug tracking system to help us keep track
52 the bugs and their resolution. Bug reports can be submitted via the
53 web:
55 http://bugzilla.open-bio.org/
57 =head1 AUTHORS - Aaron Mackey
59 Email: amackey@virginia.edu
61 =head1 APPENDIX
63 The rest of the documentation details each of the object
64 methods. Internal methods are usually preceded with a _
66 =cut
68 # Let the code begin...
70 package Bio::SeqIO::exp;
71 use vars qw(@ISA $READ_AVAIL);
72 use strict;
74 use Bio::SeqIO;
75 use Bio::Seq::SeqFactory;
77 push @ISA, qw( Bio::SeqIO );
79 sub BEGIN {
80 eval { require Bio::SeqIO::staden::read; };
81 if ($@) {
82 $READ_AVAIL = 0;
83 } else {
84 push @ISA, "Bio::SeqIO::staden::read";
85 $READ_AVAIL = 1;
89 sub _initialize {
90 my($self,@args) = @_;
91 $self->SUPER::_initialize(@args);
92 if( ! defined $self->sequence_factory ) {
93 $self->sequence_factory(Bio::Seq::SeqFactory->new(-verbose => $self->verbose(), -type => 'Bio::Seq::Quality'));
95 unless ($READ_AVAIL) {
96 Bio::Root::Root->throw( -class => 'Bio::Root::SystemException',
97 -text => "Bio::SeqIO::staden::read is not available; make sure the bioperl-ext package has been installed successfully!"
102 =head2 next_seq
104 Title : next_seq
105 Usage : $seq = $stream->next_seq()
106 Function: returns the next sequence in the stream
107 Returns : Bio::Seq::Quality object
108 Args : NONE
110 =cut
112 sub next_seq {
114 my ($self) = @_;
116 my ($seq, $id, $desc, $qual) = $self->read_trace($self->_fh, 'exp');
118 # create the seq object
119 $seq = $self->sequence_factory->create(-seq => $seq,
120 -id => $id,
121 -primary_id => $id,
122 -desc => $desc,
123 -alphabet => 'DNA',
124 -qual => $qual
126 return $seq;
129 =head2 write_seq
131 Title : write_seq
132 Usage : $stream->write_seq(@seq)
133 Function: writes the $seq object into the stream
134 Returns : 1 for success and 0 for error
135 Args : Bio::Seq object
138 =cut
140 sub write_seq {
141 my ($self,@seq) = @_;
143 my $fh = $self->_fh;
144 foreach my $seq (@seq) {
145 $self->write_trace($fh, $seq, 'exp');
148 $self->flush if $self->_flush_on_write && defined $self->_fh;
149 return 1;