~ubuntu-branches/ubuntu/oneiric/bioperl/oneiric

« back to all changes in this revision

Viewing changes to Bio/DB/Fasta.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2007-09-21 22:52:22 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070921225222-tt20m2yy6ycuy2d8
Tags: 1.5.2.102-1
* Developer release.
* Upgraded source package to debhelper 5 and standards-version 3.7.2.
* Added libmodule-build-perl and libtest-harness-perl to
  build-depends-indep.
* Disabled automatic CRAN download.
* Using quilt instead of .diff.gz to manage modifications.
* Updated Recommends list for the binary package.
* Moved the "production-quality" scripts to /usr/bin/.
* New maintainer: Debian-Med packaging team mailing list.
* New uploaders: Charles Plessy and Steffen Moeller.
* Updated Depends, Recommends and Suggests.
* Imported in Debian-Med's SVN repository on Alioth.
* Executing the regression tests during package building.
* Moved the Homepage: field out from the package's description.
* Updated watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: Fasta.pm,v 1.44.4.3 2006/10/02 23:10:14 sendu Exp $
 
2
#
 
3
# BioPerl module for Bio::DB::Fasta
 
4
#
 
5
# You may distribute this module under the same terms as perl itself
 
6
#
 
7
 
 
8
# POD documentation - main docs before the code
 
9
 
1
10
=head1 NAME
2
11
 
3
12
Bio::DB::Fasta -- Fast indexed access to a directory of fasta files
10
19
  my $db      = Bio::DB::Fasta->new('/path/to/fasta/files');
11
20
 
12
21
  # simple access (for those without Bioperl)
13
 
  my $seq     = $db->seq('CHROMOSOME_I',4_000_000 => 4_100_000);
14
 
  my $revseq  = $db->seq('CHROMOSOME_I',4_100_000 => 4_000_000);
 
22
  my $seq      = $db->seq('CHROMOSOME_I',4_000_000 => 4_100_000);
 
23
  my $revseq   = $db->seq('CHROMOSOME_I',4_100_000 => 4_000_000);
15
24
  my @ids     = $db->ids;
16
 
  my $length  = $db->length('CHROMOSOME_I');
 
25
  my $length   = $db->length('CHROMOSOME_I');
17
26
  my $alphabet = $db->alphabet('CHROMOSOME_I');
18
 
  my $header  = $db->header('CHROMOSOME_I');
 
27
  my $header   = $db->header('CHROMOSOME_I');
19
28
 
20
29
  # Bioperl-style access
21
30
  my $db      = Bio::DB::Fasta->new('/path/to/fasta/files');
27
36
  # (etc)
28
37
 
29
38
  # Bio::SeqIO-style access
30
 
  my $stream  = Bio::DB::Fasta->new('/path/to/fasta/files')->get_PrimarySeq_stream;
 
39
  my $stream  = Bio::DB::Fasta->new('/path/to/files')->get_PrimarySeq_stream;
31
40
  while (my $seq = $stream->next_seq) {
32
41
    # Bio::PrimarySeqI stuff
33
42
  }
51
60
When you initialize the module, you point it at a single fasta file or
52
61
a directory of multiple such files.  The first time it is run, the
53
62
module generates an index of the contents of the file or directory
54
 
using the AnyDBM module (Berkeley DB preferred, followed by GDBM_File,
 
63
using the AnyDBM module (Berkeley DB* preferred, followed by GDBM_File,
55
64
NDBM_File, and SDBM_File).  Thereafter it uses the index file to find
56
65
the file and offset for any requested sequence.  If one of the source
57
66
fasta files is updated, the module reindexes just that one file.  (You
61
70
 
62
71
The fasta files may contain any combination of nucleotide and protein
63
72
sequences; during indexing the module guesses the molecular type.
64
 
Entries may have any line length, and different line lengths are
65
 
allowed in the same file.  However, within a sequence entry, all lines
66
 
must be the same length except for the last.
 
73
Entries may have any line length up to 65,536 characters, and
 
74
different line lengths are allowed in the same file.  However, within
 
75
a sequence entry, all lines must be the same length except for the
 
76
last.
67
77
 
68
 
The module uses /^E<gt>(\S+)/ to extract each sequence's primary ID from
69
 
the Fasta header.  During indexing, you may pass a callback routine to
 
78
The module uses /^E<gt>(\S+)/ to extract the primary ID of each sequence 
 
79
from the Fasta header.  During indexing, you may pass a callback routine to
70
80
modify this primary ID.  For example, you may wish to extract a
71
81
portion of the gi|gb|abc|xyz nonsense that GenBank Fasta files use.
72
82
The original header line can be recovered later.
78
88
laptop. On the same system, average access time for any 200-mer within
79
89
the C. elegans genome was E<lt>0.02s.
80
90
 
 
91
*Berkeley DB can be obtained free from www.sleepycat.com. After it is 
 
92
installed you will need to install the BerkeleyDB Perl module.
 
93
 
81
94
=head1 DATABASE CREATION AND INDEXING
82
95
 
83
96
The two constructors for this class are new() and newFh().  The former
86
99
style to fetch sequence objects in a stream fashion.  There is also a
87
100
tied hash interface.
88
101
 
89
 
=over 4
 
102
=over 2
90
103
 
91
104
=item $db = Bio::DB::Fasta-E<gt>new($fasta_path [,%options])
92
105
 
105
118
 
106
119
 -glob         Glob expression to use    *.{fa,fasta,fast,FA,FASTA,FAST,dna}
107
120
               for searching for Fasta
108
 
               files in directories. 
 
121
                    files in directories. 
109
122
 
110
123
 -makeid       A code subroutine for     None
111
 
               transforming Fasta IDs.
112
 
 
113
 
 -maxopen      Maximum size of           32
114
 
               filehandle cache.
115
 
 
116
 
 -debug        Turn on status            0
117
 
               messages.
 
124
                    transforming Fasta IDs.
 
125
 
 
126
 -maxopen      Maximum size of               32
 
127
                    filehandle cache.
 
128
 
 
129
 -debug        Turn on status                   0
 
130
                    messages.
118
131
 
119
132
 -reindex      Force the index to be     0
120
133
               rebuilt.
140
153
=back
141
154
 
142
155
The -makeid option gives you a chance to modify sequence IDs during
143
 
indexing.  The option's value should be a code reference that will
 
156
indexing.  The option value should be a code reference that will
144
157
take a scalar argument and return a scalar result, like this:
145
158
 
146
159
  $db = Bio::DB::Fasta->new("file.fa",-makeid=>\&make_my_id);
147
160
 
148
161
  sub make_my_id {
149
162
    my $description_line = shift;
150
 
    # get a new id from the fasta header
151
 
    return $new_id;
 
163
    # get a different id from the fasta header, e.g.
 
164
         $description_line =~ /(\S+)$/;
 
165
    return $1;
152
166
  }
153
167
 
154
168
make_my_id() will be called with the full fasta id line (including the
167
181
 
168
182
The following object methods are provided.
169
183
 
170
 
=over 4
 
184
=over 10
171
185
 
172
186
=item $raw_seq = $db-E<gt>seq($id [,$start, $stop])
173
187
 
176
190
$stop is less than $start, then the reverse complement of the sequence
177
191
is returned (this violates Bio::Seq conventions).
178
192
 
179
 
For your convenience, subsequences can be indicated with this compound 
180
 
ID:
 
193
For your convenience, subsequences can be indicated with any of the
 
194
following compound IDs:
181
195
 
182
196
   $db->seq("$id:$start,$stop")
183
197
 
 
198
   $db->seq("$id:$start..$stop")
 
199
 
 
200
   $db->seq("$id:$start-$stop")
 
201
 
184
202
=item $length = $db-E<gt>length($id)
185
203
 
186
204
Return the length of the indicated sequence.
265
283
 
266
284
The tied hash interface is very straightforward
267
285
 
268
 
=over 4
 
286
=over 1
269
287
 
270
288
=item $obj = tie %db,'Bio::DB::Fasta','/path/to/fasta/files' [,@args]
271
289
 
313
331
    print "$id => ",tied(%db)->length($id),"\n";
314
332
 }
315
333
 
316
 
You may, in addition invoke Bio::DB::Fasta's FIRSTKEY and NEXTKEY tied
 
334
You may, in addition invoke Bio::DB::Fasta the FIRSTKEY and NEXTKEY tied
317
335
hash methods directly.
318
336
 
319
 
=over 4
 
337
=over 2
320
338
 
321
339
=item $id = $db-E<gt>FIRSTKEY
322
340
 
390
408
use AnyDBM_File;
391
409
use Fcntl;
392
410
use File::Basename qw(basename dirname);
393
 
use Bio::DB::SeqI;
394
 
use Bio::Root::Root;
395
 
use vars qw(@ISA);
396
411
 
397
 
@ISA = qw(Bio::DB::SeqI Bio::Root::Root);
 
412
use base qw(Bio::DB::SeqI Bio::Root::Root);
398
413
 
399
414
*seq = *sequence = \&subseq;
400
415
*ids = \&get_all_ids;
401
416
*get_seq_by_primary_id = *get_Seq_by_acc  = \&get_Seq_by_id;
402
417
 
403
418
use constant STRUCT =>'NNnnCa*';
 
419
use constant STRUCTBIG =>'QQnnCa*'; # 64-bit file offset and seq length
404
420
use constant DNA     => 1;
405
421
use constant RNA     => 2;
406
422
use constant PROTEIN => 3;
420
436
 
421
437
 -glob         Glob expression to use    *.{fa,fasta,fast,FA,FASTA,FAST}
422
438
               for searching for Fasta
423
 
               files in directories. 
 
439
                    files in directories. 
424
440
 
425
441
 -makeid       A code subroutine for     None
426
 
               transforming Fasta IDs.
427
 
 
428
 
 -maxopen      Maximum size of           32
429
 
               filehandle cache.
430
 
 
431
 
 -debug        Turn on status            0
432
 
               messages.
 
442
                    transforming Fasta IDs.
 
443
 
 
444
 -maxopen      Maximum size of               32
 
445
                    filehandle cache.
 
446
 
 
447
 -debug        Turn on status                   0
 
448
                    messages.
433
449
 
434
450
 -reindex      Force the index to be     0
435
451
               rebuilt.
447
463
  my %opts  = @_;
448
464
 
449
465
  my $self = bless { debug      => $opts{-debug},
450
 
                     makeid     => $opts{-makeid},
451
 
                     glob       => $opts{-glob}    || '*.{fa,fasta,FA,FASTA,fast,FAST,dna,fsa}',
452
 
                     maxopen    => $opts{-maxfh}   || 32,
453
 
                     dbmargs    => $opts{-dbmargs} || undef,
454
 
                     fhcache    => {},
455
 
                     cacheseq   => {},
456
 
                     curopen    => 0,
457
 
                     openseq    => 1,
458
 
                     dirname    => undef,
459
 
                     offsets    => undef,
 
466
          makeid     => $opts{-makeid},
 
467
          glob       => $opts{-glob} || '*.{fa,fasta,FA,FASTA,fast,FAST,dna,FNA,fna,FAA,faa,FSA,fsa}',
 
468
          maxopen    => $opts{-maxfh}   || 32,
 
469
          dbmargs    => $opts{-dbmargs} || undef,
 
470
          fhcache    => {},
 
471
          cacheseq   => {},
 
472
          curopen    => 0,
 
473
          openseq    => 1,
 
474
          dirname    => undef,
 
475
          offsets    => undef,
460
476
                   }, $class;
461
477
  my ($offsets,$dirname);
462
478
 
463
479
  if (-d $path) {
 
480
    # because Win32 glob() is broken with respect to long file names
 
481
    # that contain whitespace.
 
482
    $path = Win32::GetShortPathName($path)
 
483
      if $^O =~ /^MSWin/i && eval 'use Win32; 1';
464
484
    $offsets = $self->index_dir($path,$opts{-reindex});
465
485
    $dirname = $path;
466
486
  } elsif (-f _) {
499
519
  my %offsets;
500
520
  my $flags = $write ? O_CREAT|O_RDWR : O_RDONLY;
501
521
  my @dbmargs = $self->dbmargs;
502
 
  tie %offsets,'AnyDBM_File',$index,$flags,0644,@dbmargs or $self->throw( "Can't open cache file $index: $!");
 
522
  tie %offsets,'AnyDBM_File',$index,$flags,0644,@dbmargs 
 
523
         or $self->throw( "Can't open cache file $index: $!");
503
524
  return \%offsets;
504
525
}
505
526
 
 
527
sub _close_index {
 
528
  my $self = shift;
 
529
  my $index = shift;
 
530
  untie %$index;
 
531
}
 
532
 
506
533
=head2 index_dir
507
534
 
508
535
 Title   : index_dir
534
561
  for my $suffix('','.pag','.dir') {
535
562
    $indextime ||= (stat("${index}${suffix}"))[9];
536
563
  }
 
564
  $indextime ||= 0;  # prevent some uninit variable warnings
537
565
 
538
566
  # get the most recent modification time of any of the contents
539
567
  my $modtime = 0;
540
568
  my %modtime;
 
569
  $self->set_pack_method( @files );
541
570
  foreach (@files) {
542
571
    my $m = (stat($_))[9];
543
572
    $modtime{$_} = $m;
544
 
    $modtime = $m if $modtime < $m;
 
573
    $modtime = $m if defined $m && $modtime < $m;
545
574
  }
546
575
 
547
 
  my $reindex = $force_reindex || $indextime < $modtime;
548
 
  my $offsets = $self->_open_index($index,$reindex) or return;
549
 
  $self->{offsets} = $offsets;
 
576
  my $reindex      = $force_reindex || $indextime < $modtime;
 
577
  $self->{offsets} = $self->_open_index($index,$reindex) or return;
550
578
 
551
579
  # no indexing needed
552
 
  return $offsets unless $reindex;
 
580
  return $self->{offsets} unless $reindex;
553
581
 
554
582
  # otherwise reindex contents of changed files
555
583
  $self->{indexing} = $index;
556
584
  foreach (@files) {
557
585
    next if( defined $indextime && $modtime{$_} <= $indextime);
558
 
    $self->calculate_offsets($_,$offsets);
 
586
    $self->calculate_offsets($_,$self->{offsets});
559
587
  }
560
588
  delete $self->{indexing};
561
 
  return $self->{offsets};
 
589
 
 
590
  # we've been having troubles with corrupted index files on Windows systems,
 
591
  # so possibly closing and reopening will help
 
592
  $self->_close_index($self->{offsets});
 
593
 
 
594
  return $self->{offsets}  = $self->_open_index($index);
562
595
}
563
596
 
564
597
=head2 get_Seq_by_id
578
611
  return Bio::PrimarySeq::Fasta->new($self,$id);
579
612
}
580
613
 
 
614
=head2 set_pack_method
 
615
 
 
616
 Title   : set_pack_method
 
617
 Usage   : $db->set_pack_method( @files )
 
618
 Function: Determines whether data packing uses 32 or 64 bit integers
 
619
 Returns :
 
620
 Args    : one or more file paths
 
621
 
 
622
=cut
 
623
 
 
624
sub set_pack_method {
 
625
  my $self = shift;
 
626
  # Find the maximum file size:
 
627
  my ($maxsize) = sort { $b <=> $a } map { -s $_ } @_;
 
628
  my $fourGB    = (2 ** 32) - 1;
 
629
 
 
630
  if ($maxsize > $fourGB) {
 
631
      # At least one file exceeds 4Gb - we will need to use 64 bit ints
 
632
      $self->{packmeth}   = \&_packBig;
 
633
      $self->{unpackmeth} = \&_unpackBig;
 
634
  } else {
 
635
      $self->{packmeth}   = \&_pack;
 
636
      $self->{unpackmeth} = \&_unpack;
 
637
  }
 
638
}
 
639
 
581
640
=head2 index_file
582
641
 
583
642
 Title   : index_file
595
654
  my $file = shift;
596
655
  my $force_reindex = shift;
597
656
 
 
657
  $self->set_pack_method( $file );
598
658
  my $index = $self->index_name($file);
599
659
  # if caller has requested reindexing, then unlink the index
600
660
  unlink $index if $force_reindex;
623
683
 Returns : array
624
684
 Args    : none
625
685
 
626
 
 
627
686
=cut
628
687
 
629
688
sub dbmargs {
671
730
  my $base = $self->path2fileno(basename($file));
672
731
 
673
732
  my $fh = IO::File->new($file) or $self->throw( "Can't open $file: $!");
 
733
  binmode $fh;
674
734
  warn "indexing $file\n" if $self->{debug};
675
 
  my ($offset,$id,$linelength,$type,$firstline,$count,$termination_length,%offsets);
 
735
  my ($offset,$id,$linelength,$type,$firstline,$count,$termination_length,$seq_lines,$last_line,%offsets);
676
736
  while (<$fh>) {               # don't try this at home
677
737
    $termination_length ||= /\r\n$/ ? 2 : 1;  # account for crlf-terminated Windows files
678
738
    if (/^>(\S+)/) {
680
740
        if $self->{debug} && (++$count%1000) == 0;
681
741
      my $pos = tell($fh);
682
742
      if ($id) {
683
 
        my $seqlength    = $pos - $offset - length($_) - 1;
684
 
        $seqlength      -= $termination_length * int($seqlength/$linelength);
685
 
        $offsets->{$id}  = $self->_pack($offset,$seqlength,
 
743
        my $seqlength    = $pos - $offset - length($_);
 
744
        $seqlength      -= $termination_length * $seq_lines;
 
745
        $offsets->{$id}  = &{$self->{packmeth}}($offset,$seqlength,
686
746
                                        $linelength,$firstline,
687
747
                                        $type,$base);
688
748
      }
689
749
      $id = ref($self->{makeid}) eq 'CODE' ? $self->{makeid}->($_) : $1;
690
750
      ($offset,$firstline,$linelength) = ($pos,length($_),0);
 
751
      $self->_check_linelength($linelength);
 
752
      $seq_lines = 0;
691
753
    } else {
692
754
      $linelength ||= length($_);
693
755
      $type       ||= $self->_type($_);
694
 
    }
695
 
    }
 
756
      $seq_lines++;
 
757
    }
 
758
    $last_line = $_;
 
759
  }
 
760
 
 
761
  $self->_check_linelength($linelength);
696
762
  # deal with last entry
697
763
  if ($id) {
698
764
    my $pos = tell($fh);
699
 
    my $seqlength   = $pos - $offset  - 1;
 
765
    my $seqlength   = $pos - $offset;
700
766
 
701
767
    if ($linelength == 0) { # yet another pesky empty chr_random.fa file
702
768
      $seqlength = 0;
703
769
    } else {
704
 
      $seqlength -= $termination_length * int($seqlength/$linelength);
 
770
      if ($last_line !~ /\s$/) {
 
771
        $seq_lines--;
 
772
      }
 
773
      $seqlength -= $termination_length * $seq_lines;
705
774
    };
706
 
    $offsets->{$id} = $self->_pack($offset,$seqlength,
 
775
    $offsets->{$id} = &{$self->{packmeth}}($offset,$seqlength,
707
776
                                   $linelength,$firstline,
708
777
                                   $type,$base);
709
 
  }
 
778
}
710
779
  $offsets->{__termination_length} = $termination_length;
711
780
  return \%offsets;
712
781
}
727
796
  my $self = shift;
728
797
  my $id   = shift;
729
798
  my $offset = $self->{offsets}{$id} or return;
730
 
  ($self->_unpack($offset))[0];
 
799
  (&{$self->{unpackmeth}}($offset))[0];
731
800
}
732
801
 
733
802
sub length {
734
803
  my $self = shift;
735
804
  my $id   = shift;
736
805
  my $offset = $self->{offsets}{$id} or return;
737
 
  ($self->_unpack($offset))[1];
 
806
  (&{$self->{unpackmeth}}($offset))[1];
738
807
}
739
808
 
740
809
sub linelen {
741
810
  my $self = shift;
742
811
  my $id   = shift;
743
812
  my $offset = $self->{offsets}{$id} or return;
744
 
  ($self->_unpack($offset))[2];
 
813
  (&{$self->{unpackmeth}}($offset))[2];
745
814
}
746
815
 
747
816
sub headerlen {
748
817
  my $self = shift;
749
818
  my $id   = shift;
750
819
  my $offset = $self->{offsets}{$id} or return;
751
 
  ($self->_unpack($offset))[3];
 
820
  (&{$self->{unpackmeth}}($offset))[3];
752
821
}
753
822
 
754
823
sub alphabet {
755
824
  my $self = shift;
756
825
  my $id   = shift;
757
826
  my $offset = $self->{offsets}{$id} or return;
758
 
  my $type = ($self->_unpack($offset))[4];
 
827
  my $type = (&{$self->{unpackmeth}}($offset))[4];
759
828
  return $type == DNA ? 'dna'
760
829
         : $type == RNA ? 'rna'
761
830
         : 'protein';
775
844
  my $self = shift;
776
845
  my $id   = shift;
777
846
  my $offset = $self->{offsets}{$id} or return;
778
 
  $self->fileno2path(($self->_unpack($offset))[5]);
 
847
  $self->fileno2path((&{$self->{unpackmeth}}($offset))[5]);
779
848
}
780
849
 
781
850
sub fileno2path {
794
863
  return $self->{offsets}{"__path_$path"}
795
864
}
796
865
 
 
866
sub _check_linelength {
 
867
  my $self       = shift;
 
868
  my $linelength = shift;
 
869
  return unless defined $linelength;
 
870
  $self->throw("Each line of the fasta file must be less than 65,536 characters.  Line $. is $linelength chars.")       if $linelength > 65535.
 
871
 
 
872
}
 
873
 
797
874
=head2 subseq
798
875
 
799
876
 Title   : subseq
806
883
 
807
884
sub subseq {
808
885
  my ($self,$id,$start,$stop) = @_;
809
 
  if ($id =~ /^(.+):([\d_]+)[,-]([\d_]+)$/) {
 
886
  if ($id =~ /^(.+):([\d_]+)(?:,|-|\.\.)([\d_]+)$/) {
810
887
    ($id,$start,$stop) = ($1,$2,$3);
811
888
    $start =~ s/_//g;
812
889
    $stop =~ s/_//g;
815
892
  $stop  ||= $self->length($id);
816
893
 
817
894
  my $reversed;
818
 
  if ($start > $stop) {
 
895
  if (defined $stop && $start > $stop) {
819
896
    ($start,$stop) = ($stop,$start);
820
897
    $reversed++;
821
898
  }
848
925
  my $self = shift;
849
926
  my $id   = shift;
850
927
  my ($offset,$seqlength,$linelength,$firstline,$type,$file) 
851
 
    = $self->_unpack($self->{offsets}{$id}) or return;
 
928
    = &{$self->{unpackmeth}}($self->{offsets}{$id}) or return;
852
929
  $offset -= $firstline;
853
930
  my $data;
854
931
  my $fh = $self->fh($id) or return;
863
940
  my $self = shift;
864
941
  my $id   = shift;
865
942
  my $a    = shift()-1;
866
 
  my ($offset,$seqlength,$linelength,$firstline,$type,$file) = $self->_unpack($self->{offsets}{$id});
 
943
  my ($offset,$seqlength,$linelength,$firstline,$type,$file) = &{$self->{unpackmeth}}($self->{offsets}{$id});
867
944
  $a = 0            if $a < 0;
868
945
  $a = $seqlength-1 if $a >= $seqlength;
869
946
  my $tl = $self->{offsets}{__termination_length};
881
958
      for (@lru) { delete $self->{fhcache}{$_} }
882
959
    }
883
960
    $self->{fhcache}{$path} = IO::File->new($path) or return;
 
961
    binmode $self->{fhcache}{$path};
884
962
    $self->{curopen}++;
885
963
  }
886
964
  $self->{cacheseq}{$path}++;
888
966
}
889
967
 
890
968
sub _pack {
891
 
  shift;
892
969
  pack STRUCT,@_;
893
970
}
894
971
 
 
972
sub _packBig {
 
973
  pack STRUCTBIG,@_;
 
974
}
 
975
 
895
976
sub _unpack {
896
 
  shift;
897
977
  unpack STRUCT,shift;
898
978
}
899
979
 
 
980
sub _unpackBig {
 
981
  unpack STRUCTBIG,shift;
 
982
}
 
983
 
900
984
sub _type {
901
985
  shift;
902
986
  local $_ = shift;
914
998
 Returns : 
915
999
 Args    :
916
1000
 
917
 
 
918
1001
=cut
919
1002
 
920
1003
sub get_PrimarySeq_stream {
959
1042
package Bio::PrimarySeq::Fasta;
960
1043
use overload '""' => 'display_id';
961
1044
 
962
 
use vars '@ISA';
963
 
eval {
964
 
  require Bio::PrimarySeqI;
965
 
  require Bio::Root::Root;
966
 
} && (@ISA = ('Bio::Root::Root','Bio::PrimarySeqI'));
 
1045
use base qw(Bio::Root::Root Bio::PrimarySeqI);
967
1046
 
968
1047
sub new {
969
1048
  my $class = shift;
1002
1081
        
1003
1082
}
1004
1083
 
 
1084
sub is_circular {
 
1085
  my $self = shift;
 
1086
  return $self->{is_circular};
 
1087
}
 
1088
 
1005
1089
sub display_id {
1006
1090
  my $self = shift;
1007
1091
  return $self->{id};
1036
1120
 
1037
1121
sub description  { 
1038
1122
    my $self = shift;
1039
 
    return '';
 
1123
    my $header = $self->{'db'}->header($self->{id});
 
1124
    # remove the id from the header
 
1125
    return (split(/\s+/,$header,2))[2];
1040
1126
}
1041
1127
 
1042
1128
*desc = \&description;
1045
1131
# stream-based access to the database
1046
1132
#
1047
1133
package Bio::DB::Fasta::Stream;
1048
 
use Tie::Handle;
1049
 
use vars qw(@ISA);
1050
 
@ISA = qw(Tie::Handle);
1051
 
eval {
1052
 
  require Bio::DB::SeqI;
1053
 
} && (push @ISA,'Bio::DB::SeqI');
 
1134
use base qw(Tie::Handle Bio::DB::SeqI);
1054
1135
 
1055
1136
 
1056
1137
sub new {