15
Bio::Index::AbstractSeq - Base class for AbstractSeq s
15
Bio::Index::AbstractSeq - base class for AbstractSeq
19
19
# Make a new sequence file indexing package
21
21
package MyShinyNewIndexer;
22
use Bio::Index::AbstractSeq;
24
@ISA = ('Bio::Index::AbstractSeq');
23
use base qw(Bio::Index::AbstractSeq);
26
25
# Now provide the necessary methods...
30
Provides a common base class for multiple
31
sequence files built using the
32
Bio::Index::Abstract system, and provides a
33
Bio::DB::SeqI interface.
29
Provides a common base class for multiple sequence files built using
30
the Bio::Index::Abstract system, and provides a Bio::DB::SeqI
37
35
=head2 Mailing Lists
39
37
User feedback is an integral part of the evolution of this
40
and other Bioperl modules. Send your comments and suggestions preferably
41
to one of the Bioperl mailing lists.
38
and other Bioperl modules. Send your comments and suggestions
39
preferably to one of the Bioperl mailing lists.
42
40
Your participation is much appreciated.
44
bioperl-l@bioperl.org - General discussion
45
http://bioperl.org/MailList.shtml - About the mailing lists
42
bioperl-l@bioperl.org - General discussion
43
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
47
45
=head2 Reporting Bugs
49
47
Report bugs to the Bioperl bug tracking system to help us keep track
50
the bugs and their resolution.
51
Bug reports can be submitted via email or the web:
48
the bugs and their resolution. Bug reports can be submitted via the
53
bioperl-bugs@bio.perl.org
54
http://bugzilla.bioperl.org/
51
http://bugzilla.open-bio.org/
56
53
=head1 AUTHOR - Ewan Birney
58
55
Email birney@ebi.ac.uk
60
Describe contact details here
64
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
59
The rest of the documentation details each of the object methods.
60
Internal methods are usually preceded with a _
68
Bio::Index::Abstract - Module which
69
Bio::Index::AbstractSeq inherits off, which
70
provides dbm indexing for flat files (which are
71
not necessarily sequence files).
64
L<Bio::Index::Abstract>, which provides dbm indexing for flat files of
65
any type, containing sequence or not. L<Bio::Index::AbstractSeq> inherits
66
from L<Bio::Index::Abstract>
75
70
# Let's begin the code ...
78
72
package Bio::Index::AbstractSeq;
82
75
use Bio::SeqIO::MultiFile;
83
use Bio::Index::Abstract;
87
@ISA = qw(Bio::Index::Abstract Bio::DB::SeqI);
77
use base qw(Bio::Index::Abstract Bio::DB::SeqI);
90
my ($class, @args) = @_;
91
my $self = $class->SUPER::new(@args);
80
my ($class, @args) = @_;
81
my $self = $class->SUPER::new(@args);
93
$self->{'_seqio_cache'} = [];
83
$self->{'_seqio_cache'} = [];
97
87
=head2 _file_format
130
my( $self, $id ) = @_;
131
my $db = $self->db();
119
my( $self, $id ) = @_;
120
my $db = $self->db();
134
if (my $rec = $db->{ $id }) {
135
my ($file, $begin) = $self->unpack_record( $rec );
123
if (my $rec = $db->{ $id }) {
124
my ($file, $begin) = $self->unpack_record( $rec );
137
# Get the (possibly cached) SeqIO object
138
my $seqio = $self->_get_SeqIO_object( $file );
139
my $fh = $seqio->_fh();
126
# Get the (possibly cached) SeqIO object
127
my $seqio = $self->_get_SeqIO_object( $file );
128
my $fh = $seqio->_fh();
141
# move to start of record
142
$begin-- if( $^O =~ /mswin/i); # workaround for Win DB_File bug
143
seek($fh, $begin, 0);
130
# move to start of record
131
# $begin-- if( $^O =~ /mswin/i); # workaround for Win DB_File bug
132
seek($fh, $begin, 0);
145
$seq = $seqio->next_seq();
148
# we essentially assumme that the primary_id for the database
150
$seq->primary_id($seq->display_id()) if( defined $seq && ref($seq) &&
151
$seq->isa('Bio::PrimarySeqI') );
134
$seq = $seqio->next_seq();
137
# we essentially assumme that the primary_id for the database
139
if (ref($seq) && $seq->isa('Bio::PrimarySeqI') &&
140
$seq->primary_id =~ /^\D+$/) {
141
$seq->primary_id( $seq->display_id() );
156
146
=head2 _get_SeqIO_object