t/AlignIO/AlignIO.t: fix number of tests in plan (fixup c523e6bed866)
[bioperl-live.git] / Bio / SeqIO / exp.pm
blob6630f69c3f619e9f850727d591509e099a515c43
1 # BioPerl module for Bio::SeqIO::exp
3 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 # Cared for by Aaron Mackey <amackey@virginia.edu>
7 # Copyright Aaron Mackey
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
13 =head1 NAME
15 Bio::SeqIO::exp - exp trace sequence input/output stream
17 =head1 SYNOPSIS
19 Do not use this module directly. Use it via the Bio::SeqIO class.
21 =head1 DESCRIPTION
23 This object can transform Bio::Seq objects to and from exp trace
24 files.
26 =head1 FEEDBACK
28 =head2 Mailing Lists
30 User feedback is an integral part of the evolution of this and other
31 Bioperl modules. Send your comments and suggestions preferably to one
32 of the Bioperl mailing lists. Your participation is much appreciated.
34 bioperl-l@bioperl.org - General discussion
35 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
37 =head2 Support
39 Please direct usage questions or support issues to the mailing list:
41 I<bioperl-l@bioperl.org>
43 rather than to the module maintainer directly. Many experienced and
44 reponsive experts will be able look at the problem and quickly
45 address it. Please include a thorough description of the problem
46 with code and data examples if at all possible.
48 =head2 Reporting Bugs
50 Report bugs to the Bioperl bug tracking system to help us keep track
51 the bugs and their resolution. Bug reports can be submitted via the
52 web:
54 https://github.com/bioperl/bioperl-live/issues
56 =head1 AUTHORS - Aaron Mackey
58 Email: amackey@virginia.edu
60 =head1 APPENDIX
62 The rest of the documentation details each of the object
63 methods. Internal methods are usually preceded with a _
65 =cut
67 # Let the code begin...
69 package Bio::SeqIO::exp;
70 use vars qw(@ISA $READ_AVAIL);
71 use strict;
73 use Bio::SeqIO;
74 use Bio::Seq::SeqFactory;
76 push @ISA, qw( Bio::SeqIO );
78 sub BEGIN {
79 eval { require Bio::SeqIO::staden::read; };
80 if ($@) {
81 $READ_AVAIL = 0;
82 } else {
83 push @ISA, "Bio::SeqIO::staden::read";
84 $READ_AVAIL = 1;
88 sub _initialize {
89 my($self,@args) = @_;
90 $self->SUPER::_initialize(@args);
91 if( ! defined $self->sequence_factory ) {
92 $self->sequence_factory(Bio::Seq::SeqFactory->new(-verbose => $self->verbose(), -type => 'Bio::Seq::Quality'));
94 unless ($READ_AVAIL) {
95 Bio::Root::Root->throw( -class => 'Bio::Root::SystemException',
96 -text => "Bio::SeqIO::staden::read is not available; make sure the bioperl-ext package has been installed successfully!"
101 =head2 next_seq
103 Title : next_seq
104 Usage : $seq = $stream->next_seq()
105 Function: returns the next sequence in the stream
106 Returns : Bio::Seq::Quality object
107 Args : NONE
109 =cut
111 sub next_seq {
113 my ($self) = @_;
115 my ($seq, $id, $desc, $qual) = $self->read_trace($self->_fh, 'exp');
117 # create the seq object
118 $seq = $self->sequence_factory->create(-seq => $seq,
119 -id => $id,
120 -primary_id => $id,
121 -desc => $desc,
122 -alphabet => 'DNA',
123 -qual => $qual
125 return $seq;
128 =head2 write_seq
130 Title : write_seq
131 Usage : $stream->write_seq(@seq)
132 Function: writes the $seq object into the stream
133 Returns : 1 for success and 0 for error
134 Args : Bio::Seq object
137 =cut
139 sub write_seq {
140 my ($self,@seq) = @_;
142 my $fh = $self->_fh;
143 foreach my $seq (@seq) {
144 $self->write_trace($fh, $seq, 'exp');
147 $self->flush if $self->_flush_on_write && defined $self->_fh;
148 return 1;