changes all issue tracking in preparation for switch to github issues
[bioperl-live.git] / Bio / SeqIO / abi.pm
blobc66b167abfca2f6c0c9403a592566d2056178f79
1 # BioPerl module for Bio::SeqIO::abi
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::abi - abi 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 abi trace
24 files. To optionally read the trace graph data (which can be used
25 to draw chromatographs, for instance), set the optional
26 '-get_trace_data' flag or the get_trace_data method to a value
27 evaluating to TRUE.
29 =head1 FEEDBACK
31 =head2 Mailing Lists
33 User feedback is an integral part of the evolution of this and other
34 Bioperl modules. Send your comments and suggestions preferably to one
35 of the Bioperl mailing lists. Your participation is much appreciated.
37 bioperl-l@bioperl.org - General discussion
38 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
40 =head2 Support
42 Please direct usage questions or support issues to the mailing list:
44 I<bioperl-l@bioperl.org>
46 rather than to the module maintainer directly. Many experienced and
47 reponsive experts will be able look at the problem and quickly
48 address it. Please include a thorough description of the problem
49 with code and data examples if at all possible.
51 =head2 Reporting Bugs
53 Report bugs to the Bioperl bug tracking system to help us keep track
54 the bugs and their resolution.
55 Bug reports can be submitted via the web:
57 https://github.com/bioperl/bioperl-live/issues
59 =head1 AUTHORS - Aaron Mackey
61 Email: amackey@virginia.edu
63 =head1 APPENDIX
65 The rest of the documentation details each of the object
66 methods. Internal methods are usually preceded with a _
68 =cut
70 # Let the code begin...
72 package Bio::SeqIO::abi;
73 use vars qw(@ISA $READ_AVAIL);
74 use strict;
76 use Bio::SeqIO;
77 use Bio::Seq::SeqFactory;
79 push @ISA, qw( Bio::SeqIO );
81 sub BEGIN {
82 eval { require Bio::SeqIO::staden::read; };
83 if ($@) {
84 $READ_AVAIL = 0;
85 } else {
86 push @ISA, "Bio::SeqIO::staden::read";
87 $READ_AVAIL = 1;
91 sub _initialize {
92 my($self,@args) = @_;
93 $self->SUPER::_initialize(@args);
94 my ($get_trace) = $self->_rearrange([qw(get_trace_data)],@args);
95 $get_trace && $self->get_trace_data(1);
96 if( ! defined $self->sequence_factory ) {
97 $self->sequence_factory(Bio::Seq::SeqFactory->new(-verbose => $self->verbose(), -type => 'Bio::Seq::Quality'));
99 unless ($READ_AVAIL) {
100 Bio::Root::Root->throw( -class => 'Bio::Root::SystemException',
101 -text => "Bio::SeqIO::staden::read is not available; make sure the bioperl-ext package has been installed successfully!"
106 =head2 next_seq
108 Title : next_seq
109 Usage : $seq = $stream->next_seq()
110 Function: returns the next sequence in the stream
111 Returns : Bio::Seq::Quality object
112 Args : NONE
114 =cut
116 sub next_seq {
118 my ($self) = @_;
120 my ($seq, $id, $desc, $qual) = $self->read_trace($self->_fh, 'abi');
122 # create the seq object
123 my ($base_locs, $a_trace, $c_trace, $g_trace, $t_trace, $points, $max_height);
124 if ($self->get_trace_data) {
125 ($base_locs, $a_trace, $c_trace, $g_trace, $t_trace, $points, $max_height) = $self->read_trace_with_graph($self->_fh, 'abi');
126 } else {
127 $base_locs = [];
130 # create the seq object
131 $seq = $self->sequence_factory->create(-seq => $seq,
132 -id => $id,
133 -primary_id => $id,
134 -desc => $desc,
135 -alphabet => 'DNA',
136 -qual => $qual,
137 -trace => join (" ", @{$base_locs}),
138 -trace_data => { a_trace => $a_trace,
139 c_trace => $c_trace,
140 g_trace => $g_trace,
141 t_trace => $t_trace,
142 max_height => $max_height,
143 num_points => $points }
145 return $seq;
148 =head2 write_seq
150 Title : write_seq
151 Usage : $stream->write_seq(@seq)
152 Function: writes the $seq object into the stream
153 Returns : 1 for success and 0 for error
154 Args : Bio::Seq object
157 =cut
159 sub write_seq {
160 my ($self,@seq) = @_;
162 my $fh = $self->_fh;
163 foreach my $seq (@seq) {
164 $self->write_trace($fh, $seq, 'abi');
167 $self->flush if $self->_flush_on_write && defined $self->_fh;
168 return 1;
171 =head2 get_trace_data
173 Title : get_trace_data
174 Usage : $stream->get_trace_data(1)
175 Function: set boolean flag to retrieve the trace data (possibly for
176 output)
177 Returns : bool value, TRUE = retrieve trace data (default FALSE)
178 Args : bool value
180 =cut
182 sub get_trace_data {
183 my ($self, $val) = @_;
184 $self->{_get_trace_data} = $val ? 1 : 0 if (defined $val);
185 $self->{_get_trace_data};