File Coverage

Bio/LiveSeq/Range.pm
Criterion Covered Total %
statement 23 33 69.7
branch 6 12 50.0
condition 2 6 33.3
subroutine 3 3 100.0
pod 1 1 100.0
total 35 55 63.6


line stmt bran cond sub pod time code
1             #
2             # bioperl module for Bio::LiveSeq::Range
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::Range - Range abstract class for LiveSeq
17              
18             =head1 SYNOPSIS
19              
20             # documentation needed
21              
22             =head1 DESCRIPTION
23              
24             This is used as parent for exon and intron classes.
25              
26             =head1 AUTHOR - Joseph A.L. Insana
27              
28             Email: Insana@ebi.ac.uk, jinsana@gmx.net
29              
30             =head1 APPENDIX
31              
32             The rest of the documentation details each of the object
33             methods. Internal methods are usually preceded with a _
34              
35             =cut
36              
37             # Let the code begin...
38              
39             package Bio::LiveSeq::Range;
40 2     2   12 use strict;
  2         3  
  2         137  
41 2     2   8 use base qw(Bio::LiveSeq::SeqI);
  2         51  
  2         532  
42              
43             =head2 new
44              
45             Title : new
46             Usage : $range1 = Bio::LiveSeq::Range->new(-seq => $obj_ref,
47             -start => $beginlabel,
48             -end => $endlabel, -strand => 1);
49              
50             Function: generates a new Bio::LiveSeq::Range
51             Returns : reference to a new object of class Range
52             Errorcode -1
53             Args : two labels, an obj_ref and an integer
54             strand 1=forward strand, strand -1=reverse strand
55             if strand not specified, it defaults to 1
56             the -seq argument must point to the underlying DNA LiveSeq object
57              
58             =cut
59              
60             sub new {
61 64     64 1 240 my ($thing, %args) = @_;
62 64   33     198 my $class = ref($thing) || $thing;
63 64         76 my ($obj,%range);
64              
65 64         126 my ($seq,$start,$end,$strand)=($args{-seq},$args{-start},$args{-end},$args{-strand});
66              
67 64         93 $obj = \%range;
68 64         97 $obj = bless $obj, $class;
69              
70 64 50       144 unless ($seq->valid($start)) {
71 0         0 $obj->warn("$class not initialised because start label not valid");
72 0         0 return (-1);
73             }
74 64 50       121 unless ($seq->valid($end)) {
75 0         0 $obj->warn("$class not initialised because end label not valid");
76 0         0 return (-1);
77             }
78 64 50       120 unless (defined $strand) {
79 0         0 $strand = 1;
80             }
81 64 50 33     132 if (($strand != 1)&&($strand != -1)) {
82 0         0 $obj->warn("$class not initialised because strand identifier not valid. Use 1 (forward strand) or -1 (reverse strand).");
83 0         0 return (-1);
84             }
85 64 50       111 if ($start eq $end) {
86 0         0 $obj->warn("$class reports: start and end label are the same....");
87             } else {
88 64 50       153 unless ($seq->follows($start,$end,$strand)==1) {
89 0         0 $obj->warn("Fatal: end label $end doesn't follow start label $start for strand $strand!");
90 0         0 return (-1);
91             }
92             }
93             #if ($strand == 1) {
94             # unless ($seq->is_downstream($start,$end)==1) {
95             # croak "Fatal: end label not downstream of start label for forward strand!";
96             # }
97             #} else {
98             # unless ($seq->is_upstream($start,$end)==1) {
99             # croak "Fatal: end label not upstream of start label for reverse strand!";
100             # }
101             #}
102 64         270 $obj->{'seq'}=$seq;
103 64         130 $obj->{'start'}=$start;
104 64         100 $obj->{'end'}=$end;
105 64         109 $obj->{'strand'}=$strand;
106 64         256 return $obj;
107             }
108              
109             =head2 valid
110              
111             Title : valid
112             Usage : $boolean = $obj->valid($label)
113             Function: tests if a label exists AND is part of the object
114             Returns : boolean
115             Args : label
116              
117             =cut
118              
119             1;