FAST/Bio/SeqIO/lasergene.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 73 CC 9 SCAR 40.0
CC
9
Cov
0%
next_seq
90.0
write_seq
2.0
BEGIN
2.0
CRAP 54.8
1 #-----------------------------------------5~------------------------------------
2 # PACKAGE : FAST::Bio::SeqIO::lasergene
3 # AUTHOR : Malcolm Cook <mec@stowers-institute.org>
4 # CREATED : Feb 16 1999
5 #
6 # _History_
7 #
8 # This code is based on the FAST::Bio::SeqIO::raw module with
9 # the necessary minor tweaks necessary to get it to read (only)
10 # Lasergene formatted sequences
11 #
12 # Cleaned up by Torsten Seemann June 2006
13  
14 # POD documentation - main docs before the code
15  
16 =head1 NAME
17  
18 FAST::Bio::SeqIO::lasergene - Lasergene sequence file input/output stream
19  
20 =head1 SYNOPSIS
21  
22 Do not use this module directly. Use it via the L<FAST::Bio::SeqIO> class.
23  
24 =head1 DESCRIPTION
25  
26 This object can product FAST::Bio::Seq::RichSeq objects from Lasergene sequence files.
27  
28 IT DOES NOT PARSE ANY ATTIBUTE VALUE PAIRS IN THE HEADER OF THE LASERGENE FORMATTED FILE.
29  
30 IT DOES NOT WRITE THESE FILES EITHER.
31  
32 =head1 REFERENCES
33  
34 https://www.dnastar.com/products/lasergene.php
35  
36 =head1 FEEDBACK
37  
38 =head2 Mailing Lists
39  
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.
43  
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
46  
47 =head2 Support
48  
49 Please direct usage questions or support issues to the mailing list:
50  
51 I<bioperl-l@bioperl.org>
52  
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.
57  
58 =head2 Reporting Bugs
59  
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
62 the web:
63  
64 https://redmine.open-bio.org/projects/bioperl/
65  
66 =head1 AUTHORS
67  
68 Torsten Seemann - torsten.seemann AT infotech.monash.edu.au
69 Malcolm Cook - mec AT stowers-institute.org
70  
71 =head1 APPENDIX
72  
73 The rest of the documentation details each of the object methods.
74 Internal methods are usually preceded with a _
75  
76 =cut
77  
78  
79 # Let the code begin...
80  
81 package FAST::Bio::SeqIO::lasergene;
82  
83 use strict;
84  
85 use base qw(FAST::Bio::SeqIO);
86  
87 =head2 next_seq
88  
89 Title : next_seq
90 Usage : $seq = $stream->next_seq()
91 Function: returns the next sequence in the stream
92 Returns : FAST::Bio::Seq object
93 Args : none
94  
95 =cut
96  
97 use FAST::Bio::Seq;
98 use FAST::Bio::Annotation::Collection;
99 use FAST::Bio::Annotation::Comment;
100  
101 sub next_seq {
102 my ($self) = @_;
103  
104 my $state = 0;
105 my @comment;
106 my @sequence;
107  
108 while (my $line = $self->_readline) {
109 $state = 1 if $state == 0;
110 chomp $line;
111 next if $line =~ m/^\s*$/; # skip blank lines
112  
113 if ($line eq '^^') { # end of a comment or sequence
114 $state++;
115 last if $state > 2; # we have comment and sequence so exit
116 }
117 elsif ($state == 1) { # another piece of comment
118 push @comment, $line;
119 }
120 elsif ($state == 2) { # another piece of sequence
121 push @sequence, $line
122 }
123 else {
124 $self->throw("unreachable state reached, probable bug!");
125 }
126 }
127  
128 # return quietly if there was nothing in the file
129 return if $state == 0;
130  
131 # ensure we read some comment and some sequence
132 if ($state < 2) {
133 $self->throw("unexpected end of file");
134 }
135  
136 my $sequence = join('', @sequence);
137 # print STDERR "SEQ=[[$sequence]]\n";
138 $sequence or $self->throw("empty sequence in lasergene file");
139 my $seq = FAST::Bio::Seq->new(-seq => $sequence);
140  
141 my $comment = join('; ', @comment);
142 # print STDERR "COM=[[$comment]]\n";
143 my $anno = FAST::Bio::Annotation::Collection->new;
144 $anno->add_Annotation('comment', FAST::Bio::Annotation::Comment->new(-text => $comment) );
145 $seq->annotation($anno);
146  
147 return $seq;
148 }
149  
150 =head2 write_seq (NOT IMPLEMENTED)
151  
152 Title : write_seq
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 FAST::Bio::PrimarySeqI objects
157  
158 =cut
159  
160 sub write_seq {
161 my ($self, @seq) = @_;
162 $self->throw("write_seq() is not implemented for the lasergene format.");
163 }
164  
165  
166 1;
167