Bio::Tools::CodonTable and Bio::Tools::IUPAC: prepare with dzil.
[bioperl-live.git] / lib / Bio / Seq / LargeSeq.pm
blob702f90dfb67a186c19428fe0d7ec7220e6fa8d65
2 # BioPerl module for Bio::Seq::LargeSeq
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Ewan Birney, Jason Stajich
8 # Copyright Ewan Birney, Jason Stajich
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::Seq::LargeSeq - SeqI compliant object that stores sequence as
17 files in /tmp
19 =head1 SYNOPSIS
21 # normal primary seq usage
23 =head1 DESCRIPTION
25 This object stores a sequence as a series of files in a temporary
26 directory. The aim is to allow someone the ability to store very large
27 sequences (eg, E<gt> 100MBases) in a file system without running out
28 of memory (eg, on a 64 MB real memory machine!).
30 Of course, to actually make use of this functionality, the programs
31 which use this object B<must> not call $primary_seq-E<gt>seq otherwise
32 the entire sequence will come out into memory and probably paste your
33 machine. However, calls $primary_seq-E<gt>subseq(10,100) will cause
34 only 90 characters to be brought into real memory.
36 =head1 FEEDBACK
38 =head2 Mailing Lists
40 User feedback is an integral part of the evolution of this and other
41 Bioperl modules. Send your comments and suggestions preferably to one
42 of the Bioperl mailing lists. Your participation is much appreciated.
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
47 =head2 Support
49 Please direct usage questions or support issues to the mailing list:
51 I<bioperl-l@bioperl.org>
53 rather than to the module maintainer directly. Many experienced and
54 reponsive experts will be able look at the problem and quickly
55 address it. Please include a thorough description of the problem
56 with code and data examples if at all possible.
58 =head2 Reporting Bugs
60 Report bugs to the Bioperl bug tracking system to help us keep track
61 the bugs and their resolution. Bug reports can be submitted via the
62 web:
64 https://github.com/bioperl/bioperl-live/issues
66 =head1 AUTHOR - Ewan Birney
68 Email birney@ebi.ac.uk
70 =head1 APPENDIX
72 The rest of the documentation details each of the object
73 methods. Internal methods are usually preceded with a _
75 =cut
78 # Let the code begin...
81 package Bio::Seq::LargeSeq;
83 use vars qw($AUTOLOAD);
84 use strict;
86 # Object preamble
88 use Bio::Seq::LargePrimarySeq;
90 use base qw(Bio::Seq Bio::Seq::LargeSeqI);
93 sub new {
94 my ($class, @args) = @_;
95 my $self = $class->SUPER::new(@args);
97 my ($pseq) = $self->_rearrange([qw(PRIMARYSEQ)], @args);
99 if( ! defined $pseq ) {
100 $pseq = Bio::Seq::LargePrimarySeq->new(@args);
102 $self->primary_seq($pseq);
104 return $self;
108 =head2 trunc
110 Title : trunc
111 Usage : $subseq = $myseq->trunc(10,100);
112 Function: Provides a truncation of a sequence,
114 Example :
115 Returns : a fresh Bio::SeqI object
116 Args :
118 =cut
120 sub trunc {
121 my ($self, $s, $e) = @_;
122 return new Bio::Seq::LargeSeq
123 ('-display_id' => $self->display_id,
124 '-accession_number' => $self->accession_number,
125 '-desc' => $self->desc,
126 '-alphabet' => $self->alphabet,
127 -primaryseq => $self->primary_seq->trunc($s,$e));
130 =head2 Bio::Seq::LargePrimarySeq methods
132 =cut
134 =head2 add_sequence_as_string
136 Title : add_sequence_as_string
137 Usage : $seq->add_sequence_as_string("CATGAT");
138 Function: Appends additional residues to an existing LargePrimarySeq object.
139 This allows one to build up a large sequence without storing
140 entire object in memory.
141 Returns : Current length of sequence
142 Args : string to append
144 =cut
146 sub add_sequence_as_string {
147 my ($self,$str) = @_;
148 return $self->primary_seq->add_sequence_as_string($str);