SeqReader/FastaRecord.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 10 totaltotal 0.0% 0 / 65 CC 7 SCAR 23.0
CC
7
Cov
0%
new
20.0
desc
6.0
display_id
6.0
CRAP 10.0
1 #! /usr/bin/perl
2  
3 package Bio::SeqReader::FastaRecord;
4  
5 sub desc;
6 sub display_id;
7 sub new;
8 sub reset;
9 sub seq;
10  
11 =head1 NAME
12  
13 Bio::SeqReader::FastaRecord - Class providing methods for representing identifier,
14 description, and sequence information in FASTA records.
15  
16 =head1 SYNOPSIS
17  
18 use Bio::SeqReader::FastaRecord;
19  
20 =head1 EXAMPLES
21  
22 my $so = new Bio::SeqReader::FastaRecord();
23 $so->seq( 'ACGTACGT' );
24 print $so->seq(); # => ACGTACGT
25  
26 =head1 DESCRIPTION
27  
28 Class representing a sequence in FASTA format. Display id, description, and sequence
29 text are accessed by the object's getter-setter methods.
30  
31 =head1 CLASS METHODS
32  
33 Bio::SeqReader::FastaRecord provides no class methods.
34  
35 =head1 INSTANCE METHODS
36  
37 Bio::SeqReader::FastaRecord provides the following instance methods.
38  
39 =cut
40  
41 use strict;
42  
43 =over 12
44  
45 =item B<new()>
46  
47 Returns a new Bio::SeqReader::FastaRecord object.
48  
49 # Void constructor
50 my $so = new Bio::SeqReader::FastaRecord();
51  
52 # Constructor with initial values
53 my $so = new Bio::SeqReader::FastaRecord(
54 display_id => 'R_12345',
55 description => 'Predicted kinase gene',
56 seqtext => 'ACGTACGT',
57 );
58  
59 =back
60  
61 =cut
62  
63 sub new {
64 my ( $class, %parms ) = @_;
65  
66 my $self = {};
67 bless( $self, $class );
68  
69 $self->reset();
70 $self->seq( $parms{ seqtext } ) if exists $parms{ seqtext };
71 $self->display_id( $parms{ display_id } ) if exists $parms{ display_id };
72 $self->desc( $parms{ description } ) if exists $parms{ description };
73  
74 return $self;
75 }
76  
77 =over 12
78  
79 =item B<desc()>
80  
81 Getter-setter for the description text of a Bio::SeqReader::FastaRecord object.
82  
83 $so->desc( 'R_12345 read info ...' );
84 print $so->desc(); # => R_12345 read info
85  
86 =back
87  
88 =cut
89  
90 sub desc {
91 my $self = shift;
92  
93 if ( @_ ) {
94 $self->{ _DESCRIPTION } = shift;
95 $self->{ _DESCRIPTION } =~ s/^\s+//g;
96 $self->{ _DESCRIPTION } =~ s/\s+$//g;
97 }
98  
99 return $self->{ _DESCRIPTION };
100 }
101  
102  
103 =over 12
104  
105 =item B<display_id()>
106  
107 Getter-setter for the display id of a Bio::SeqReader::FastaRecord object.
108  
109 $so->display_id( 'R_12345 read info ...' );
110 print $so->display_id(); # => R_12345 read info
111  
112 =back
113  
114 =cut
115  
116 sub display_id {
117 my $self = shift;
118  
119 if ( @_ ) {
120 $self->{ _DISPLAY_ID } = shift;
121 $self->{ _DISPLAY_ID } =~ s/^\s+//g;
122 $self->{ _DISPLAY_ID } =~ s/\s+$//g;
123 }
124  
125 return $self->{ _DISPLAY_ID };
126 }
127  
128 =over 12
129  
130 =item B<reset()>
131  
132 Reset a Bio::SeqReader::FastaRecord object.
133  
134 =back
135  
136 =cut
137  
138 sub reset {
139 my $self = shift;
140  
141 $self->{ _DESCRIPTION } = '';
142 $self->{ _DISPLAY_ID } = '';
143 $self->{ _SEQTEXT } = '';
144 }
145  
146 =over 12
147  
148 =item B<seq()>
149  
150 Getter-setter for the sequence text from a Bio::SeqReader::FastaRecord object.
151  
152 $so->seq( 'ACGTACGT' );
153 print $so->seq(); # => ACGTACGT
154  
155 =back
156  
157 =cut
158  
159 sub seq {
160 my $self = shift;
161  
162 if ( @_ ) {
163 $self->{ _SEQTEXT } = shift;
164 $self->{ _SEQTEXT } =~ s/[\000-\037\s]+//g;
165 }
166  
167 return $self->{ _SEQTEXT };
168 }
169  
170 1;
171  
172 =head1 EXTERNAL DEPENDENCIES
173  
174 Perl core.
175  
176 =head1 BUGS
177  
178 None reported yet, but let me know.
179  
180 =head1 SEE ALSO
181  
182 Bio::SeqReader::Fasta, Bio::SeqReader.
183  
184 =head1 AUTHOR
185  
186 John A. Crow E<lt>jac_at_cpan_dot_orgE<gt>
187  
188 =head1 COPYRIGHT AND LICENSE
189  
190 This library is free software; you can redistribute it and/or modify
191 it under the same terms as Perl itself, either Perl version 5.10.0 or,
192 at your option, any later version of Perl 5 you may have available.
193  
194 Copyright (C) 2012 by John A. Crow
195 Copyright (C) 2012 by National Center for Genome Resources
196  
197  
198 =cut
199