1 #-----------------------------------------5~------------------------------------
2 # PACKAGE : Bio::SeqIO::lasergene
3 # AUTHOR : Malcolm Cook <mec@stowers-institute.org>
4 # CREATED : Feb 16 1999
8 # This code is based on the Bio::SeqIO::raw module with
9 # the necessary minor tweaks necessary to get it to read (only)
10 # Lasergene formatted sequences
12 # Cleaned up by Torsten Seemann June 2006
14 # POD documentation - main docs before the code
18 Bio::SeqIO::lasergene - Lasergene sequence file input/output stream
22 Do not use this module directly. Use it via the L<Bio::SeqIO> class.
26 This object can product Bio::Seq::RichSeq objects from Lasergene sequence files.
28 IT DOES NOT PARSE ANY ATTIBUTE VALUE PAIRS IN THE HEADER OF THE LASERGENE FORMATTED FILE.
30 IT DOES NOT WRITE THESE FILES EITHER.
34 https://www.dnastar.com/products/lasergene.php
40 User feedback is an integral part of the evolution of this and other
41 Bioperl modules. Send your comments and suggestions preferably to one
42 of the Bioperl mailing lists. Your participation is much appreciated.
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
49 Please direct usage questions or support issues to the mailing list:
51 I<bioperl-l@bioperl.org>
53 rather than to the module maintainer directly. Many experienced and
54 reponsive experts will be able look at the problem and quickly
55 address it. Please include a thorough description of the problem
56 with code and data examples if at all possible.
60 Report bugs to the Bioperl bug tracking system to help us keep track
61 of the bugs and their resolution. Bug reports can be submitted via
64 https://github.com/bioperl/bioperl-live/issues
68 Torsten Seemann - torsten.seemann AT infotech.monash.edu.au
69 Malcolm Cook - mec AT stowers-institute.org
73 The rest of the documentation details each of the object methods.
74 Internal methods are usually preceded with a _
79 # Let the code begin...
81 package Bio
::SeqIO
::lasergene
;
85 use base
qw(Bio::SeqIO);
90 Usage : $seq = $stream->next_seq()
91 Function: returns the next sequence in the stream
92 Returns : Bio::Seq object
98 use Bio
::Annotation
::Collection
;
99 use Bio
::Annotation
::Comment
;
108 while (my $line = $self->_readline) {
109 $state = 1 if $state == 0;
111 next if $line =~ m/^\s*$/; # skip blank lines
113 if ($line eq '^^') { # end of a comment or sequence
115 last if $state > 2; # we have comment and sequence so exit
117 elsif ($state == 1) { # another piece of comment
118 push @comment, $line;
120 elsif ($state == 2) { # another piece of sequence
121 push @sequence, $line
124 $self->throw("unreachable state reached, probable bug!");
128 # return quietly if there was nothing in the file
129 return if $state == 0;
131 # ensure we read some comment and some sequence
133 $self->throw("unexpected end of file");
136 my $sequence = join('', @sequence);
137 # print STDERR "SEQ=[[$sequence]]\n";
138 $sequence or $self->throw("empty sequence in lasergene file");
139 my $seq = Bio
::Seq
->new(-seq
=> $sequence);
141 my $comment = join('; ', @comment);
142 # print STDERR "COM=[[$comment]]\n";
143 my $anno = Bio
::Annotation
::Collection
->new;
144 $anno->add_Annotation('comment', Bio
::Annotation
::Comment
->new(-text
=> $comment) );
145 $seq->annotation($anno);
150 =head2 write_seq (NOT IMPLEMENTED)
153 Usage : $stream->write_seq($seq)
154 Function: writes the $seq object into the stream
155 Returns : 1 for success and 0 for error
156 Args : Array of Bio::PrimarySeqI objects
161 my ($self, @seq) = @_;
162 $self->throw("write_seq() is not implemented for the lasergene format.");