t/AlignIO/AlignIO.t: fix number of tests in plan (fixup c523e6bed866)
[bioperl-live.git] / Bio / LiveSeq / DNA.pm
blob2fea1b463bbf754d00de3bca9b0bd13ab9d4fc38
2 # bioperl module for Bio::LiveSeq::DNA
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Joseph Insana <insana@ebi.ac.uk> <jinsana@gmx.net>
8 # Copyright Joseph Insana
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::LiveSeq::DNA - DNA object for LiveSeq
18 =head1 SYNOPSIS
20 # documentation needed
22 =head1 DESCRIPTION
24 This holds the DNA sequence (or the RNA in the case of cDNA entries)
25 and is accessed by exons, genes, transcripts... objects
27 =head1 AUTHOR - Joseph A.L. Insana
29 Email: Insana@ebi.ac.uk, jinsana@gmx.net
31 =head1 APPENDIX
33 The rest of the documentation details each of the object
34 methods. Internal methods are usually preceded with a _
36 =cut
38 # Let the code begin...
40 package Bio::LiveSeq::DNA;
42 use strict;
43 use base qw(Bio::LiveSeq::SeqI);
45 =head2 new
47 Title : new
48 Usage : $dna = Bio::LiveSeq::DNA->new(-seq => "atcgaccaatggacctca",
49 -offset => 3 );
51 Function: generates a new Bio::LiveSeq::DNA
52 Returns : reference to a new object of class DNA
53 Errorcode -1
54 Args : a string
55 AND an optional offset to create nucleotide labels (default is 1, i.e.
56 starting the count of labels from "1") -> do not bother using it ->
57 it could be used by alternative loaders !EMBL format
58 NOTE : strand of DNA is set to 1 by default
60 =cut
62 sub new {
63 my ($thing, %args) = @_;
64 my $class = ref($thing) || $thing;
65 my (%empty,$obj);
67 if ($args{-seq}) {
68 $obj = $thing->string2chain($args{-seq},$args{-offset}); # inherited from ChainI
69 $obj = bless $obj, $class;
70 } else {
71 $obj=\%empty;
72 $obj = bless $obj, $class;
73 $obj->throw("$class not initialized properly");
76 $obj->{'alphabet'}='dna'; # set alphabet default
77 $obj->{'strand'}=1; # set strand default = 1
78 $obj->{'seq'}=$obj; # set seq field to itself
80 return $obj;
83 # START method
84 # it has to be redefined here because default from SeqI accesses field "start"
85 sub start {
86 my $self = shift;
87 return $self->{'begin'}; # the chain's start is called begin
90 # it is overridden to provide faster output
91 sub length {
92 my $self=shift;
93 return $self->chain_length();
96 # it is overridden to provide MUCH faster output
97 sub valid {
98 my $self=shift(@_);
99 return $self->label_exists(@_);