bump alpha to test ODBA-related bug fix
[bioperl-live.git] / Bio / DB / Flat / BDB / fasta.pm
blob06a2d07042c595a30e3e679358c7ad0fe4e77203
2 # $Id$
4 # BioPerl module for Bio::DB::Flat::BDB
6 # Please direct questions and support issues to <bioperl-l@bioperl.org>
8 # Cared for by Lincoln Stein <lstein@cshl.org>
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::DB::Flat::BDB::fasta - fasta adaptor for Open-bio standard BDB-indexed flat file
18 =head1 SYNOPSIS
20 See Bio::DB::Flat.
22 =head1 DESCRIPTION
24 This module allows fasta files to be stored in Berkeley DB flat files
25 using the Open-Bio standard BDB-indexed flat file scheme. You should
26 not be using this directly, but instead use it via Bio::DB::Flat.
28 =head1 FEEDBACK
30 =head2 Mailing Lists
32 User feedback is an integral part of the evolution of this and other
33 Bioperl modules. Send your comments and suggestions preferably to one
34 of the Bioperl mailing lists. Your participation is much appreciated.
36 bioperl-l@bioperl.org - General discussion
37 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
39 =head2 Support
41 Please direct usage questions or support issues to the mailing list:
43 I<bioperl-l@bioperl.org>
45 rather than to the module maintainer directly. Many experienced and
46 reponsive experts will be able look at the problem and quickly
47 address it. Please include a thorough description of the problem
48 with code and data examples if at all possible.
50 =head2 Reporting Bugs
52 Report bugs to the Bioperl bug tracking system to help us keep track
53 the bugs and their resolution. Bug reports can be submitted via the
54 web:
56 http://bugzilla.open-bio.org/
58 =head1 SEE ALSO
60 L<Bio::DB::Flat>,
62 =head1 AUTHOR - Lincoln Stein
64 Email - lstein@cshl.org
66 =cut
68 package Bio::DB::Flat::BDB::fasta;
70 use strict;
72 use base qw(Bio::DB::Flat::BDB);
74 sub default_file_format { "fasta" }
76 sub seq_to_ids {
77 my $self = shift;
78 my $seq = shift;
79 my %ids;
80 $ids{$self->primary_namespace} = $seq->primary_id;
81 \%ids;
84 sub parse_one_record {
85 my $self = shift;
86 my $fh = shift;
88 # fasta parses by changing $/ to '\n>', need to adjust accordingly
89 my $adj = ( $^O =~ /mswin/i ) ? -2 : -1;
90 my $parser =
91 $self->{cached_parsers}{fileno($fh)}
92 ||= Bio::SeqIO->new(-fh=>$fh,-format=>$self->default_file_format);
93 my $seq = $parser->next_seq or return;
94 $self->{flat_alphabet} ||= $seq->alphabet;
95 my $ids = $self->seq_to_ids($seq);
96 return ($ids, $adj);