File Coverage

Bio/LiveSeq/DNA.pm
Criterion Covered Total %
statement 20 25 80.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 5 6 83.3
pod 4 4 100.0
total 31 40 77.5


line stmt bran cond sub pod time code
1             #
2             # bioperl module for Bio::LiveSeq::DNA
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Joseph Insana
7             #
8             # Copyright Joseph Insana
9             #
10             # You may distribute this module under the same terms as perl itself
11             #
12             # POD documentation - main docs before the code
13              
14             =head1 NAME
15              
16             Bio::LiveSeq::DNA - DNA object for LiveSeq
17              
18             =head1 SYNOPSIS
19              
20             # documentation needed
21              
22             =head1 DESCRIPTION
23              
24             This holds the DNA sequence (or the RNA in the case of cDNA entries)
25             and is accessed by exons, genes, transcripts... objects
26              
27             =head1 AUTHOR - Joseph A.L. Insana
28              
29             Email: Insana@ebi.ac.uk, jinsana@gmx.net
30              
31             =head1 APPENDIX
32              
33             The rest of the documentation details each of the object
34             methods. Internal methods are usually preceded with a _
35              
36             =cut
37              
38             # Let the code begin...
39              
40             package Bio::LiveSeq::DNA;
41              
42 2     2   10 use strict;
  2         3  
  2         55  
43 2     2   11 use base qw(Bio::LiveSeq::SeqI);
  2         4  
  2         621  
44              
45             =head2 new
46              
47             Title : new
48             Usage : $dna = Bio::LiveSeq::DNA->new(-seq => "atcgaccaatggacctca",
49             -offset => 3 );
50              
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
59              
60             =cut
61              
62             sub new {
63 6     6 1 23 my ($thing, %args) = @_;
64 6   33     25 my $class = ref($thing) || $thing;
65 6         9 my (%empty,$obj);
66              
67 6 50       18 if ($args{-seq}) {
68 6         47 $obj = $thing->string2chain($args{-seq},$args{-offset}); # inherited from ChainI
69 6         35 $obj = bless $obj, $class;
70             } else {
71 0         0 $obj=\%empty;
72 0         0 $obj = bless $obj, $class;
73 0         0 $obj->throw("$class not initialized properly");
74             }
75              
76 6         46 $obj->{'alphabet'}='dna'; # set alphabet default
77 6         16 $obj->{'strand'}=1; # set strand default = 1
78 6         15 $obj->{'seq'}=$obj; # set seq field to itself
79              
80 6         35 return $obj;
81             }
82              
83             # START method
84             # it has to be redefined here because default from SeqI accesses field "start"
85             sub start {
86 21     21 1 45 my $self = shift;
87 21         79 return $self->{'begin'}; # the chain's start is called begin
88             }
89              
90             # it is overridden to provide faster output
91             sub length {
92 0     0 1 0 my $self=shift;
93 0         0 return $self->chain_length();
94             }
95              
96             # it is overridden to provide MUCH faster output
97             sub valid {
98 3594     3594 1 3838 my $self=shift(@_);
99 3594         5350 return $self->label_exists(@_);
100             }
101              
102             1;