~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to Bio/Index/AbstractSeq.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: AbstractSeq.pm,v 1.16 2002/10/22 07:38:33 lapp Exp $
 
1
# $Id: AbstractSeq.pm,v 1.24.4.3 2006/11/27 15:46:48 sendu Exp $
2
2
#
3
 
# BioPerl module for Bio::DB::AbstractSeq
 
3
# BioPerl module for Bio::Index::AbstractSeq
4
4
#
5
5
# Cared for by Ewan Birney <birney@ebi.ac.uk>
6
6
#
12
12
 
13
13
=head1 NAME
14
14
 
15
 
Bio::Index::AbstractSeq - Base class for AbstractSeq s 
 
15
Bio::Index::AbstractSeq - base class for AbstractSeq
16
16
 
17
17
=head1 SYNOPSIS
18
18
 
19
19
  # Make a new sequence file indexing package
20
20
 
21
21
  package MyShinyNewIndexer;
22
 
  use Bio::Index::AbstractSeq;
23
22
 
24
 
  @ISA = ('Bio::Index::AbstractSeq');
 
23
  use base qw(Bio::Index::AbstractSeq);
25
24
 
26
25
  # Now provide the necessary methods...
27
26
 
28
27
=head1 DESCRIPTION
29
28
 
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 
 
31
interface.
34
32
 
35
33
=head1 FEEDBACK
36
34
 
37
35
=head2 Mailing Lists
38
36
 
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.
43
41
 
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
46
44
 
47
45
=head2 Reporting Bugs
48
46
 
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
 
49
web:
52
50
 
53
 
  bioperl-bugs@bio.perl.org
54
 
  http://bugzilla.bioperl.org/
 
51
  http://bugzilla.open-bio.org/
55
52
 
56
53
=head1 AUTHOR - Ewan Birney
57
54
 
58
55
Email birney@ebi.ac.uk
59
56
 
60
 
Describe contact details here
61
 
 
62
57
=head1 APPENDIX
63
58
 
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 _
65
61
 
66
62
=head1 SEE ALSO
67
63
 
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>
72
67
 
73
68
=cut
74
69
 
75
70
# Let's begin the code ...
76
71
 
77
 
 
78
72
package Bio::Index::AbstractSeq;
79
 
use vars qw(@ISA);
80
73
use strict;
81
74
 
82
75
use Bio::SeqIO::MultiFile;
83
 
use Bio::Index::Abstract;
84
 
use Bio::DB::SeqI;
85
 
 
86
 
 
87
 
@ISA = qw(Bio::Index::Abstract Bio::DB::SeqI);
 
76
 
 
77
use base qw(Bio::Index::Abstract Bio::DB::SeqI);
88
78
 
89
79
sub new {
90
 
    my ($class, @args) = @_;
91
 
    my $self = $class->SUPER::new(@args);
 
80
        my ($class, @args) = @_;
 
81
        my $self = $class->SUPER::new(@args);
92
82
    
93
 
    $self->{'_seqio_cache'} = [];
94
 
    return $self;
 
83
        $self->{'_seqio_cache'} = [];
 
84
        return $self;
95
85
}
96
86
 
97
87
=head2 _file_format
105
95
 Returns : 
106
96
 Args    :
107
97
 
108
 
 
109
98
=cut
110
99
 
111
100
sub _file_format {
127
116
=cut
128
117
 
129
118
sub fetch {
130
 
    my( $self, $id ) = @_;
131
 
    my $db = $self->db();
132
 
    my $seq;
 
119
        my( $self, $id ) = @_;
 
120
        my $db = $self->db();
 
121
        my $seq;
133
122
 
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 );
136
125
        
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();
140
129
 
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);
144
133
        
145
 
        $seq = $seqio->next_seq();
146
 
    }
147
 
 
148
 
    # we essentially assumme that the primary_id for the database
149
 
    # is the display_id
150
 
    $seq->primary_id($seq->display_id()) if( defined $seq && ref($seq) &&
151
 
                                             $seq->isa('Bio::PrimarySeqI') );
152
 
 
153
 
    return $seq;
 
134
                $seq = $seqio->next_seq();      
 
135
        }
 
136
 
 
137
        # we essentially assumme that the primary_id for the database
 
138
        # is the display_id
 
139
        if (ref($seq) && $seq->isa('Bio::PrimarySeqI') &&
 
140
                 $seq->primary_id =~ /^\D+$/) {
 
141
                $seq->primary_id( $seq->display_id() );
 
142
        }
 
143
        return $seq;
154
144
}
155
145
 
156
146
=head2 _get_SeqIO_object