sync w/ main trunk
[bioperl-live.git] / Bio / LiveSeq / DNA.pm
blobd081182136a7e40d158a3e22c207964aed58f49a
1 # $Id$
3 # bioperl module for Bio::LiveSeq::DNA
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Joseph Insana <insana@ebi.ac.uk> <jinsana@gmx.net>
9 # Copyright Joseph Insana
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
15 =head1 NAME
17 Bio::LiveSeq::DNA - DNA object for LiveSeq
19 =head1 SYNOPSIS
21 # documentation needed
23 =head1 DESCRIPTION
25 This holds the DNA sequence (or the RNA in the case of cDNA entries)
26 and is accessed by exons, genes, transcripts... objects
28 =head1 AUTHOR - Joseph A.L. Insana
30 Email: Insana@ebi.ac.uk, jinsana@gmx.net
32 =head1 APPENDIX
34 The rest of the documentation details each of the object
35 methods. Internal methods are usually preceded with a _
37 =cut
39 # Let the code begin...
41 package Bio::LiveSeq::DNA;
43 use strict;
44 use base qw(Bio::LiveSeq::SeqI);
46 =head2 new
48 Title : new
49 Usage : $dna = Bio::LiveSeq::DNA->new(-seq => "atcgaccaatggacctca",
50 -offset => 3 );
52 Function: generates a new Bio::LiveSeq::DNA
53 Returns : reference to a new object of class DNA
54 Errorcode -1
55 Args : a string
56 AND an optional offset to create nucleotide labels (default is 1, i.e.
57 starting the count of labels from "1") -> do not bother using it ->
58 it could be used by alternative loaders !EMBL format
59 NOTE : strand of DNA is set to 1 by default
61 =cut
63 sub new {
64 my ($thing, %args) = @_;
65 my $class = ref($thing) || $thing;
66 my (%empty,$obj);
68 if ($args{-seq}) {
69 $obj = $thing->string2chain($args{-seq},$args{-offset}); # inherited from ChainI
70 $obj = bless $obj, $class;
71 } else {
72 $obj=\%empty;
73 $obj = bless $obj, $class;
74 $obj->throw("$class not initialized properly");
77 $obj->{'alphabet'}='dna'; # set alphabet default
78 $obj->{'strand'}=1; # set strand default = 1
79 $obj->{'seq'}=$obj; # set seq field to itself
81 return $obj;
84 # START method
85 # it has to be redefined here because default from SeqI accesses field "start"
86 sub start {
87 my $self = shift;
88 return $self->{'begin'}; # the chain's start is called begin
91 # it is overridden to provide faster output
92 sub length {
93 my $self=shift;
94 return $self->chain_length();
97 # it is overridden to provide MUCH faster output
98 sub valid {
99 my $self=shift(@_);
100 return $self->label_exists(@_);