0
|
1 #
|
|
2 # $Id: fasta.pm,v 1.3 2002/10/22 07:38:31 lapp Exp $
|
|
3 #
|
|
4 # BioPerl module for Bio::DB::Flat::BDB
|
|
5 #
|
|
6 # Cared for by Lincoln Stein <lstein@cshl.org>
|
|
7 #
|
|
8 # You may distribute this module under the same terms as perl itself
|
|
9
|
|
10 # POD documentation - main docs before the code
|
|
11
|
|
12 =head1 NAME
|
|
13
|
|
14 Bio::DB::Flat::BDB::fasta - fasta adaptor for Open-bio standard BDB-indexed flat file
|
|
15
|
|
16 =head1 SYNOPSIS
|
|
17
|
|
18 See Bio::DB::Flat.
|
|
19
|
|
20 =head1 DESCRIPTION
|
|
21
|
|
22 This module allows fasta files to be stored in Berkeley DB flat files
|
|
23 using the Open-Bio standard BDB-indexed flat file scheme. You should
|
|
24 not be using this directly, but instead use it via Bio::DB::Flat.
|
|
25
|
|
26 =head1 FEEDBACK
|
|
27
|
|
28 =head2 Mailing Lists
|
|
29
|
|
30 User feedback is an integral part of the evolution of this and other
|
|
31 Bioperl modules. Send your comments and suggestions preferably to one
|
|
32 of the Bioperl mailing lists. Your participation is much appreciated.
|
|
33
|
|
34 bioperl-l@bioperl.org - General discussion
|
|
35 http://bioperl.org/MailList.shtml - About the mailing lists
|
|
36
|
|
37 =head2 Reporting Bugs
|
|
38
|
|
39 Report bugs to the Bioperl bug tracking system to help us keep track
|
|
40 the bugs and their resolution. Bug reports can be submitted via
|
|
41 email or the web:
|
|
42
|
|
43 bioperl-bugs@bio.perl.org
|
|
44 http://bugzilla.bioperl.org/
|
|
45
|
|
46 =head1 SEE ALSO
|
|
47
|
|
48 L<Bio::DB::Flat>,
|
|
49
|
|
50 =head1 AUTHOR - Lincoln Stein
|
|
51
|
|
52 Email - lstein@cshl.org
|
|
53
|
|
54 =cut
|
|
55
|
|
56 package Bio::DB::Flat::BDB::fasta;
|
|
57
|
|
58 use strict;
|
|
59 use Bio::DB::Flat::BDB;
|
|
60 use vars '@ISA';
|
|
61
|
|
62 @ISA = qw(Bio::DB::Flat::BDB);
|
|
63
|
|
64 sub parse_one_record {
|
|
65 my $self = shift;
|
|
66 my $fh = shift;
|
|
67
|
|
68 undef $self->{fasta_stored_id} if exists $self->{fasta_stored_fh}
|
|
69 && $fh ne $self->{fasta_stored_fh} ;
|
|
70 $self->{fasta_stored_fh} = $fh;
|
|
71
|
|
72 while (<$fh>) { # don't try this at home
|
|
73 if (/^>(\S+)/) {
|
|
74 my $id = $self->{fasta_stored_id};
|
|
75 $self->{fasta_stored_id} = $1;
|
|
76 next unless defined $id;
|
|
77 return ($id,-length($_));
|
|
78 }
|
|
79 }
|
|
80 # we get here at the end of the file
|
|
81 return $self->{fasta_stored_id};
|
|
82 }
|
|
83
|
|
84 sub default_file_format { "fasta" }
|
|
85
|
|
86 1;
|