lib/TIGR/FASTA/Record.pm

filter: Statementstmt 17.4% 18 / 103 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 54 MC/DCmcdc 0.0% 0 / 26 Subroutinesub 26.6% 4 / 15 Podpod 100% 11 / 11 totaltotal 13.6% 33 / 241 CC 35 SCAR 38.5
CC
35
Cov
10%
subSequence
110.0
reverseComplement
56.0
reverseComplementData
56.0
CRAP 47.1
« script/convert_hmmscan_to_htab.pl ↑ Summary lib/TIGR/FASTA/Grammar.pm »
1 # $Id: FASTArecord.pm,v 1.1 2004/04/28 15:03:43 aphillip Exp $
2  
3 package TIGR::FASTA::Record;
4 {
5  
6 =head1 NAME
7  
8 TIGR::FASTA::Record - TIGR::FASTA::Record class describing FASTA records
9  
10 =head1 SYNOPSIS
11  
12 use TIGR::FASTA::Record;
13 my $obj_instance = new TIGR::FASTA::Record ($record_header,
14 $record_data);
15  
16 =head1 DESCRIPTION
17  
18 This module provides an object definition for a FASTA record. It verifies
19 data entry on creation, and returns information queried on the record.
20  
21 =cut
22  
23 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 require 5.006_00;
25 }
26  
27 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶ use TIGR::FASTA::Grammar ':public';
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 ▶ use TIGR::FASTA::Grammar ':private';
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 ## external variables
32  
33 1 my $OUTPUT_LINE_LENGTH_REF = \$TIGR::FASTA::Grammar::OUTPUT_LINE_LENGTH;
34 1 my $UNBOUND_FASTA_SEPARATOR = $TIGR::FASTA::Grammar::UNBOUND_FASTA_SEPARATOR;
35
36 ## internal variables and identifiers
37  
38 1 our $REVISION = (qw$Revision: 1.1 $)[-1];
39 1 our $VERSION = '1.2';
40 1 our $VERSION_STRING = "$VERSION (Build $REVISION)";
41 1 our @DEPEND = ();
42  
43 ## prototypes
44  
45 sub new($$);
46 sub equals($);
47 sub getHeader();
48 sub getIdentifier();
49 sub getData();
50 sub size();
51 sub toString();
52 sub reverseComplement($);
53 sub reverseComplementData();
54 sub subSequence($;$);
55 sub unGap();
56  
57 ## implementation
58  
59 =over
60  
61 =item $obj_instance = new TIGR::FASTA::Record ($header, $data_rec);
62  
63 This method returns a new instance of a TIGR::FASTA::Record object. It takes
64 a record header, C<$header>, and the record data, C<$data_rec> as parameters.
65 The record header may optionally contain the leading header character, a
66 C<<gt>> symbol. Both parameters are parsed. A new object instance is
67 returned on success. If parsing fails or a record cannot be created, this
68 method returns undefined.
69  
70 =cut
71  
72  
73 0 ▶ sub new($$) {
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
74 0 my $pkg = shift;
75 0 my $header = shift;
76 0 my $data_rec = shift;
77 0 my $self = undef;
78 0 my $identifier = undef;
79  
80 0 ▶ if ( ( defined ($header) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $header and $header =~ s/^($UNBOUND_FASTA_SEPARATOR){0,1}(.*)/$UNBOUND_FASTA_SEPARATOR$2/ and defined $data_rec and defined($identifier = &_headerToIdentifier($header)) and &isValidFASTAdata($data_rec) != 0) 0 0 0
Condition0%0/12
defined $header and $header =~ s/^($UNBOUND_FASTA_SEPARATOR){0,1}(.*)/$UNBOUND_FASTA_SEPARATOR$2/ and defined $data_rec and defined($identifier = &_headerToIdentifier($header)) and &isValidFASTAdata($data_rec) != 0
!ll&&!rl&&r
000
defined $header and $header =~ s/^($UNBOUND_FASTA_SEPARATOR){0,1}(.*)/$UNBOUND_FASTA_SEPARATOR$2/ and defined $data_rec and defined($identifier = &_headerToIdentifier($header))
!ll&&!rl&&r
000
defined $header and $header =~ s/^($UNBOUND_FASTA_SEPARATOR){0,1}(.*)/$UNBOUND_FASTA_SEPARATOR$2/ and defined $data_rec
!ll&&!rl&&r
000
defined $header and $header =~ s/^($UNBOUND_FASTA_SEPARATOR){0,1}(.*)/$UNBOUND_FASTA_SEPARATOR$2/
!ll&&!rl&&r
000
MC/DC0%0/5
defined $header and $header =~ s/^($UNBOUND_FASTA_SEPARATOR){0,1}(.*)/$UNBOUND_FASTA_SEPARATOR$2/ and defined $data_rec and defined($identifier = &_headerToIdentifier($header)) and &isValidFASTAdata($data_rec) != 0
defined $header $header =~ s/^($UNBOUND_FASTA_SEPARATOR){0,1}(.*)/$UNBOUND_FASTA_SEPARATOR$2/ defined $data_rec defined($identifier = &_headerToIdentifier($header)) &isValidFASTAdata($data_rec) != 0
Truth table0%0/6
A and B and C and D and E
A= defined $headerB= $header =~ s/^($UNBOUND_FASTA_SEPARATOR){0,1}(.*)/$UNBOUND_FASTA_SEPARATOR$2/C= defined $data_recD= defined($identifier = &_headerToIdentifier($header))E= &isValidFASTAdata($data_rec) != 0
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
81 ( $header =~ s[^($UNBOUND_FASTA_SEPARATOR){0,1}(.*)] # accept no
82 [$UNBOUND_FASTA_SEPARATOR$2] ) && # separator
83 ( defined ($data_rec) ) &&
84 ( defined($identifier = _headerToIdentifier($header)) ) &&
85 #
86 # parsable id.
87 ( isValidFASTAdata($data_rec) != 0 ) ) { # valid data?
88 0 $self = {};
89 0 bless $self, $pkg;
90  
91 0 chomp($header);
92 0 chomp($data_rec);
93  
94 0 $self->{header} = $header;
95 0 $self->{identifier} = $identifier;
96 0 $self->{data_rec} = $data_rec;
97 0 $self->{rec_size} = length($data_rec); # compute size
98 }
99 0 return $self;
100 }
101  
102  
103 =item $result = $obj_instance->equals($fasta_obj);
104  
105 This method takes a I<TIGR::FASTA::Record> object as a parameter. It compares
106 the passed object with the calling object's internal structures to test for
107 equality. If the two objects are equal, this method returns true (1).
108 Otherwise, this method returns false (undefined).
109  
110 =cut
111  
112  
113 0 ▶ sub equals($) {
Subroutine equals: not called CC=3 SCAR=24.8
Pod documented
114 0 my $self = shift;
115 0 my $other_obj = shift;
116 0 my $return_val = undef;
117  
118 0 ▶ if ( ( defined ($other_obj) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $other_obj and $self->toString eq $other_obj->toString) { } 0 0 0
Condition0%0/3
defined $other_obj and $self->toString eq $other_obj->toString
!ll&&!rl&&r
000
MC/DC0%0/2
defined $other_obj and $self->toString eq $other_obj->toString
defined $other_obj $self->toString eq $other_obj->toString
Truth table0%0/3
A and B
A= defined $other_objB= $self->toString eq $other_obj->toString
ABresult
0X0
100
111
119 ( $self->toString() eq $other_obj->toString() )
120 ) {
121 0 $return_val = 1;
122 }
123 else {
124 0 $return_val = undef;
125 }
126  
127 0 return $return_val;
128 }
129  
130  
131 =item $identifier = $obj_instance->getHeader();
132  
133 This method returns the header string for the record.
134  
135 =cut
136  
137  
138 0 ▶ sub getHeader() {
Subroutine getHeader: not called CC=2 SCAR=17.9
Pod documented
139 0 my $self = shift;
140 0 my $header = $self->{header}; # should always be defined
141 0 ▶ if (! isValidFASTAheader($header) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&isValidFASTAheader($header)) 0 0 0
142 # need to prepend an $UNBOUND_FASTA_SEPARATOR
143 0 $header = $UNBOUND_FASTA_SEPARATOR . $header;
144 }
145 0 return $header;
146 }
147  
148  
149 =item $identifier = $obj_instance->getIdentifier();
150  
151 This method returns the identifier string for the record.
152  
153 =cut
154  
155  
156 0 ▶ sub getIdentifier() {
Subroutine getIdentifier: not called CC=1 SCAR=6.9
Pod documented
157 0 my $self = shift;
158 0 return $self->{identifier}; # should always be defined
159 }
160  
161  
162 =item $data_contents = $obj_instance->getData();
163  
164 This method returns the data contents of the record as an
165 uninterrupted string.
166  
167 =cut
168  
169  
170 0 ▶ sub getData() {
Subroutine getData: not called CC=1 SCAR=6.9
Pod documented
171 0 my $self = shift;
172 0 return $self->{data_rec}; # should always be defined
173 }
174  
175  
176 =item $size_of_rec = $obj_instance->size();
177  
178 This method returns the size of the data string contained by the
179 record.
180  
181 =cut
182  
183  
184 0 ▶ sub size() {
Subroutine size: not called CC=1 SCAR=6.9
Pod documented
185 0 my $self = shift;
186 0 return $self->{rec_size}; # should always be defined
187 }
188  
189  
190 =item $str_rep = $obj_instance->toString();
191  
192 This method returns a string representation of the FASTA record.
193 This string representation conforms to the TIGR definition of a
194 FASTA record.
195  
196 =cut
197  
198  
199 0 ▶ sub toString() {
Subroutine toString: not called CC=3 SCAR=24.8
Pod documented
200 0 my $self = shift;
201 0 my $data_copy = $self->{data_rec};
202 0 my $str_rep = $self->getHeader() . "\n";
203 0 my $seg = undef;
204 0 my @segments = ();
205 0 my $last_seg = undef;
206 0 my $skip = undef;
207  
208 0 ▶ while((defined($seg = substr $data_copy, 0,
Branch: 1 branch
BranchTrueFalseTotal
if (defined($seg = substr($data_copy, 0, $$OUTPUT_LINE_LENGTH_REF, '')) and $seg ne "") 0 0 0
Condition0%0/3
defined($seg = substr($data_copy, 0, $$OUTPUT_LINE_LENGTH_REF, '')) and $seg ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined($seg = substr($data_copy, 0, $$OUTPUT_LINE_LENGTH_REF, '')) and $seg ne ""
defined($seg = substr($data_copy, 0, $$OUTPUT_LINE_LENGTH_REF, '')) $seg ne ""
Truth table0%0/3
A and B
A= defined($seg = substr($data_copy, 0, $$OUTPUT_LINE_LENGTH_REF, ''))B= $seg ne ""
ABresult
0X0
100
111
209 $$OUTPUT_LINE_LENGTH_REF,'')) && ($seg ne '')) {
210 0 $str_rep .= $seg . "\n";
211 }
212 0 return $str_rep;
213 }
214  
215 =item $rev_compl_str = $obj_instance->reverseComplement($NA_strand);
216  
217 This method takes in a string which represents a Nucleotide strand and
218 returns the reverse complement of the strand. If the string does not
219 represent a Nucleotide strand or is undefined, the method returns undefined.
220 When an empty string is passed into the method, we get an empty string on
221 return.
222  
223 =cut
224  
225
226 0 ▶ sub reverseComplement($) {
Subroutine reverseComplement: not called CC=7 SCAR=40.3
Pod documented
227 0 my $self = shift;
228 0 my $NA_strand = shift;
229 0 my $error_condition = 1;
230 0 my $rev_compl_str = undef;
231 0 my $validData = 0;
232
233 0 ▶ if((defined ($NA_strand)) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $NA_strand and $validData = &_isNucleotideData($NA_strand) and $validData == 1) { } 0 0 0
Condition0%0/6
defined $NA_strand and $validData = &_isNucleotideData($NA_strand) and $validData == 1
!ll&&!rl&&r
000
defined $NA_strand and $validData = &_isNucleotideData($NA_strand)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $NA_strand and $validData = &_isNucleotideData($NA_strand) and $validData == 1
defined $NA_strand $validData = &_isNucleotideData($NA_strand) $validData == 1
Truth table0%0/4
A and B and C
A= defined $NA_strandB= $validData = &_isNucleotideData($NA_strand)C= $validData == 1
ABCresult
0XX0
10X0
1100
1111
234 ($validData = _isNucleotideData($NA_strand)) && ($validData == 1)) {
235
236 0 $rev_compl_str = '';
237 # taking the complement of the sequence
238 0 ▶ if(!defined( $NA_strand =~ tr/AaCcTtGgUuMmRrWwSsYyKkVvHhDdBbXxNn.-/TtGgAaCcAaKkYyWwSsRrMmBbDdHhVvXxNn.-/)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $NA_strand =~ tr/\-.A-DGHKMNR-Ya-dghkmnr-y/\-.TVGHCDMKNYSAABWXRtvghcdmknysaabwxr/) { } 0 0 0
elsif (not defined($rev_compl_str = reverse($NA_strand))) { } 0 0 0
239 0 $error_condition = undef;
240 }
241 # taking the reverse of the complemented sequence
242 elsif(!defined($rev_compl_str = reverse($NA_strand))) {
243 0 $error_condition = undef;
244 }
245 }
246 else {
247 0 $error_condition = undef;
248 }
249 0 ▶ return ( defined ( $error_condition ) ) ? $rev_compl_str : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $error_condition ? : 0 0 0
250 }
251  
252  
253 =item $rev_compl_str = $obj_instance->reverseComplementData();
254  
255 This method returns the reverse complement of the FASTA record data. If the
256 FASTA record data does not represent a Nucleotide strand or is undefined, the
257 method returns undefined.
258  
259 =cut
260  
261  
262 0 ▶ sub reverseComplementData() {
Subroutine reverseComplementData: not called CC=7 SCAR=40.3
Pod documented
263 0 my $self = shift;
264 0 my $NA_strand = $self->{data_rec};
265 0 my $error_condition = 1;
266 0 my $rev_compl_str = undef;
267 0 my $validData = 0;
268
269 0 ▶ if((defined ($NA_strand)) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $NA_strand and $validData = &_isNucleotideData($NA_strand) and $validData == 1) { } 0 0 0
Condition0%0/6
defined $NA_strand and $validData = &_isNucleotideData($NA_strand) and $validData == 1
!ll&&!rl&&r
000
defined $NA_strand and $validData = &_isNucleotideData($NA_strand)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $NA_strand and $validData = &_isNucleotideData($NA_strand) and $validData == 1
defined $NA_strand $validData = &_isNucleotideData($NA_strand) $validData == 1
Truth table0%0/4
A and B and C
A= defined $NA_strandB= $validData = &_isNucleotideData($NA_strand)C= $validData == 1
ABCresult
0XX0
10X0
1100
1111
270 ($validData = _isNucleotideData($NA_strand)) && ($validData == 1)) {
271
272 0 $rev_compl_str = '';
273 # taking the complement of the sequence
274 0 ▶ if(!defined( $NA_strand =~ tr/AaCcTtGgUuMmRrWwSsYyKkVvHhDdBbXxNn.-/TtGgAaCcAaKkYyWwSsRrMmBbDdHhVvXxNn.-/)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $NA_strand =~ tr/\-.A-DGHKMNR-Ya-dghkmnr-y/\-.TVGHCDMKNYSAABWXRtvghcdmknysaabwxr/) { } 0 0 0
elsif (not defined($rev_compl_str = reverse($NA_strand))) { } 0 0 0
275 0 $error_condition = undef;
276 }
277 # taking the reverse of the complemented sequence
278 elsif(!defined($rev_compl_str = reverse($NA_strand))) {
279 0 $error_condition = undef;
280 }
281 }
282 else {
283 0 $error_condition = undef;
284 }
285 0 ▶ return ( defined ( $error_condition ) ) ? $rev_compl_str : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $error_condition ? : 0 0 0
286 }
287  
288  
289 =item $data_substr = $obj_instance->subSequence($startpos, $length);
290  
291 This method behaves like substr(). This method takes in two numbers $startpos
292 and $length and returns a substring of the record data. The $startpos for the
293 first base in the data is 0. The $length is optional. The substring is
294 extracted starting at $startpos characters from the front of the data string.
295 If $startpos is negative, the substring starts that far from the end of the
296 string instead. If $length is omitted, everything to the end of the string is
297 returned. If $length is negative, the length is calculated to leave that many
298 characters off the end of the string. Otherwise, $length indicates the length
299 of the substring to extract. If $startpos is undefined the function returns
300 undefined. If either $startpos or $length are greater than the data length, the
301 method returns undefined
302  
303 =cut
304  
305
306 0 ▶ sub subSequence($;$) {
Subroutine subSequence: not called CC=10 SCAR=47.0
Pod documented
307 0 my $self = shift;
308 0 my ($startpos, $length) = @_;
309 0 my $data_str = $self->getData();
310 0 my $data_substr = undef;
311 0 my $strlen = length($data_str);
312
313 0 ▶ if((defined ($data_str)) && (defined ($startpos)) &&
Branch: 2 branches
BranchTrueFalseTotal
if (defined $data_str and defined $startpos and defined $length and abs $startpos < $strlen and abs $length <= $strlen) { } 0 0 0
elsif (defined $data_str and defined $startpos and not defined $length and abs $startpos < $strlen) { } 0 0 0
Condition0%0/12
defined $data_str and defined $startpos and defined $length and abs $startpos < $strlen and abs $length <= $strlen
!ll&&!rl&&r
000
defined $data_str and defined $startpos and defined $length and abs $startpos < $strlen
!ll&&!rl&&r
000
defined $data_str and defined $startpos and defined $length
!ll&&!rl&&r
000
defined $data_str and defined $startpos
!ll&&!rl&&r
000
MC/DC0%0/5
defined $data_str and defined $startpos and defined $length and abs $startpos < $strlen and abs $length <= $strlen
defined $data_str defined $startpos defined $length abs $startpos < $strlen abs $length <= $strlen
Truth table0%0/6
A and B and C and D and E
A= defined $data_strB= defined $startposC= defined $lengthD= abs $startpos < $strlenE= abs $length <= $strlen
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
314 (defined ($length)) && (abs($startpos) < $strlen) &&
315 (abs($length) <= $strlen)) {
316 #both parameters are specified
317 0 $data_substr = substr($data_str, $startpos, $length);
318 }
319 ▶ elsif((defined ($data_str)) && (defined ($startpos)) &&
Condition0%0/9
defined $data_str and defined $startpos and not defined $length and abs $startpos < $strlen
!ll&&!rl&&r
000
defined $data_str and defined $startpos and not defined $length
!ll&&!rl&&r
000
defined $data_str and defined $startpos
!ll&&!rl&&r
000
MC/DC0%0/4
defined $data_str and defined $startpos and not defined $length and abs $startpos < $strlen
defined $data_str defined $startpos not defined $length abs $startpos < $strlen
Truth table0%0/5
A and B and not(C) and D
A= defined $data_strB= defined $startposC= not defined $lengthD= abs $startpos < $strlen
ABCDresult
0XXX0
10XX0
110X0
11100
11111
320 (!defined ($length)) && (abs($startpos) < $strlen) ) {
321 #only one parameter is specified.
322 0 $data_substr = substr($data_str, $startpos);
323 }
324 else {
325 #either $data_str is undefined or $startpos is undefined so do
326 #nothing.
327 }
328 0 return $data_substr;
329 }
330  
331 =item $result = $obj_instance->unGap();
332  
333 This method removes all the gaps('-' characters) from the record data. The
334 record size is changed after the gaps are removed. The method returns 1 on
335 success and undefined otherwise.
336  
337 =cut
338  
339
340 0 ▶ sub unGap() {
Subroutine unGap: not called CC=4 SCAR=30.0
Pod documented
341 0 my $self = shift;
342 0 my $data_str = $self->getData();
343 0 my $result = 1;
344 0 ▶ if((defined ($data_str)) && ($data_str =~ /[-]+/)) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $data_str and $data_str =~ /[-]+/) { } 0 0 0
elsif (not defined $data_str) { } 0 0 0
Condition0%0/3
defined $data_str and $data_str =~ /[-]+/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $data_str and $data_str =~ /[-]+/
defined $data_str $data_str =~ /[-]+/
Truth table0%0/3
A and B
A= defined $data_strB= $data_str =~ /[-]+/
ABresult
0X0
100
111
345 #removing the gaps in the data.
346 0 $data_str =~ s/[-]+//g;
347 0 $self->{data_rec} = $data_str;
348 0 $self->{rec_size} = length($data_str);
349
350 }
351 elsif(!defined ($data_str)) {
352 0 $result = undef;
353 }
354 0 return $result;
355 }
356  
357 =back
358  
359  
360  
361 =head1 USAGE
362  
363 To use this module, load it using the C<use> function. The object must
364 be initialized with a header and a data string. An example follows.
365 Please refer to the C<TIGR::FASTA::Reader> package usage for more examples.
366  
367 #!/usr/local/bin/perl -w
368  
369 use strict;
370 use TIGR::FASTA::Record;
371  
372 MAIN:
373 {
374  
375 # set up a simple example without using the leading carot.
376 my $header1 = "ORF00001 The first ORF in the series";
377 my $data1 =
378 "MEEISTPEGGVLVPISIETEVKRAYIDYSMSVIVSRALPDVRDGLKPVHRRILYAMEEKG" .
379 "LRFSGPTRKCAKIVGDVLGSFHPHGDASVYDALVRLGQDFSLRYPVIHPQGNFGTIGGDP" .
380 "PAAYRYTEAKMARIAESMVEDIKKETVSFVPNFDDSDVEPTVLPGRFPFLLANGSSGIAV" .
381 "GMTTNMPPHNLREIAAAISAYIENPNLSIQELCDCINGPDFPTGGIIFGKNGIRQSYETG" .
382 "RGKIVVRARFTIETDSKGRDTIIFTEVPYQVNTTMLVMRIGELARAKVIEGIANVNDETS" .
383 "DRTGLRIVVELKKGTPAQVVLNHLFAKTPLQSSFNVINLALVEGRPRMLTLKDLVRYFVE" .
384 "HRVDVVTRRAHFELRKAQERIHLVRALIRALDAIDKIITLIRHSQNTELAKQRLREQFDF" .
385 "DNVQAQAIVDMQMKRLTGLEVESLRTELKDLTELISSLEELLTSPQKVLGVVKKETRDIA" .
386 "DMFGDDRRTDIVSNEIEYLDVEDFIQKEEMVILISHLGYIKRVPVSAYRNQNRGGKGSSS" .
387 "ANLAAHDFISQIFTASTHDYVMFVTSRGRAYWLKVYGIPESGRANRGSHIKSLLMVATDE" .
388 "EITAIVSLREFSNKSYVFMATARGVVKKVTTDNFVNAKTRGIIALKLSGGDTLVSAVLVQ" .
389 "DEDEVMLITRQGKALRMSGREVREMGRNSSGVIGIKLTSEDLVAGVLRVSEQRKVLIMTE" .
390 "NGYGKRVSFSEFSVHGRGTAGQKIYTQTDRKGAIIGALAVLDTDECMCITGQGKTIRVDV" .
391 "CAISVLGRGAQGVRVLDIEPSDLVVGLSCVMQG";
392  
393 my $fasta_record = new TIGR::FASTA::Record $header1, $data1;
394 if ( defined ( $fasta_record ) ) {
395 print STDOUT "Sequence " . $fasta_record->getIdentifier() . " is " .
396 $fasta_record->size() . " residues.\n";
397 print STDOUT $fasta_record->toString();
398 }
399 else {
400 die "Invalid FASTA record 1";
401 }
402
403 # but this header is also valid.
404 my $header2 = ">ORF00001 The first ORF in the series";
405 my $data2 =
406 "MEEISTPEGGVLVPISIETEVKRAYIDYSMSVIVSRALPDVRDGLKPVHRRILYAMEEKG" .
407 "LRFSGPTRKCAKIVGDVLGSFHPHGDASVYDALVRLGQDFSLRYPVIHPQGNFGTIGGDP" .
408 "PAAYRYTEAKMARIAESMVEDIKKETVSFVPNFDDSDVEPTVLPGRFPFLLANGSSGIAV" .
409 "GMTTNMPPHNLREIAAAISAYIENPNLSIQELCDCINGPDFPTGGIIFGKNGIRQSYETG" .
410 "RGKIVVRARFTIETDSKGRDTIIFTEVPYQVNTTMLVMRIGELARAKVIEGIANVNDETS" .
411 "DRTGLRIVVELKKGTPAQVVLNHLFAKTPLQSSFNVINLALVEGRPRMLTLKDLVRYFVE" .
412 "HRVDVVTRRAHFELRKAQERIHLVRALIRALDAIDKIITLIRHSQNTELAKQRLREQFDF" .
413 "DNVQAQAIVDMQMKRLTGLEVESLRTELKDLTELISSLEELLTSPQKVLGVVKKETRDIA" .
414 "DMFGDDRRTDIVSNEIEYLDVEDFIQKEEMVILISHLGYIKRVPVSAYRNQNRGGKGSSS" .
415 "ANLAAHDFISQIFTASTHDYVMFVTSRGRAYWLKVYGIPESGRANRGSHIKSLLMVATDE" .
416 "EITAIVSLREFSNKSYVFMATARGVVKKVTTDNFVNAKTRGIIALKLSGGDTLVSAVLVQ" .
417 "DEDEVMLITRQGKALRMSGREVREMGRNSSGVIGIKLTSEDLVAGVLRVSEQRKVLIMTE" .
418 "NGYGKRVSFSEFSVHGRGTAGQKIYTQTDRKGAIIGALAVLDTDECMCITGQGKTIRVDV" .
419 "CAISVLGRGAQGVRVLDIEPSDLVVGLSCVMQG";
420  
421 my $fasta_record2 = new TIGR::FASTA::Record $header2, $data2;
422 if ( defined ( $fasta_record2 ) ) {
423 print STDOUT "Sequence " . $fasta_record2->getIdentifier() . " is " .
424 $fasta_record2->size() . " residues.\n";
425 print STDOUT $fasta_record2->toString();
426 }
427 else {
428 die "Invalid FASTA record 2";
429 }
430  
431 # this entry fails; note the 'J' in the second line of data (8th char.)
432 my $header3 = "ORF00001 The first ORF in the series";
433 my $data3 =
434 "MEEISTPEGGVLVPISIETEVKRAYIDYSMSVIVSRALPDVRDGLKPVHRRILYAMEEKG" .
435 "LRFSGPTJKCAKIVGDVLGSFHPHGDASVYDALVRLGQDFSLRYPVIHPQGNFGTIGGDP" .
436 "PAAYRYTEAKMARIAESMVEDIKKETVSFVPNFDDSDVEPTVLPGRFPFLLANGSSGIAV" .
437 "GMTTNMPPHNLREIAAAISAYIENPNLSIQELCDCINGPDFPTGGIIFGKNGIRQSYETG" .
438 "RGKIVVRARFTIETDSKGRDTIIFTEVPYQVNTTMLVMRIGELARAKVIEGIANVNDETS" .
439 "DRTGLRIVVELKKGTPAQVVLNHLFAKTPLQSSFNVINLALVEGRPRMLTLKDLVRYFVE" .
440 "HRVDVVTRRAHFELRKAQERIHLVRALIRALDAIDKIITLIRHSQNTELAKQRLREQFDF" .
441 "DNVQAQAIVDMQMKRLTGLEVESLRTELKDLTELISSLEELLTSPQKVLGVVKKETRDIA" .
442 "DMFGDDRRTDIVSNEIEYLDVEDFIQKEEMVILISHLGYIKRVPVSAYRNQNRGGKGSSS" .
443 "ANLAAHDFISQIFTASTHDYVMFVTSRGRAYWLKVYGIPESGRANRGSHIKSLLMVATDE" .
444 "EITAIVSLREFSNKSYVFMATARGVVKKVTTDNFVNAKTRGIIALKLSGGDTLVSAVLVQ" .
445 "DEDEVMLITRQGKALRMSGREVREMGRNSSGVIGIKLTSEDLVAGVLRVSEQRKVLIMTE" .
446 "NGYGKRVSFSEFSVHGRGTAGQKIYTQTDRKGAIIGALAVLDTDECMCITGQGKTIRVDV" .
447 "CAISVLGRGAQGVRVLDIEPSDLVVGLSCVMQG";
448  
449 my $fasta_record3 = new TIGR::FASTA::Record $header3, $data3;
450 if ( defined ( $fasta_record3 ) ) {
451 print STDOUT "Sequence " . $fasta_record3->getIdentifier() . " is " .
452 $fasta_record3->size() . " residues.\n";
453 print STDOUT $fasta_record3->toString();
454 }
455 else {
456 die "Invalid FASTA record 3";
457 }
458 }
459  
460 =cut
461  
462 }
463  
464 1 1;
« script/convert_hmmscan_to_htab.pl ↑ Summary lib/TIGR/FASTA/Grammar.pm »