File Coverage

blib/lib/Ace/Sequence/Transcript.pm
Criterion Covered Total %
statement 35 54 64.8
branch 7 20 35.0
condition n/a
subroutine 10 15 66.7
pod 4 8 50.0
total 56 97 57.7


line stmt bran cond sub pod time code
1             package Ace::Sequence::Transcript;
2              
3 1     1   16 use strict;
  1         18  
  1         22  
4 1     1   17 use Ace;
  1         8  
  1         21  
5 1     1   16 use Ace::Sequence::Feature;
  1         10  
  1         20  
6 1     1   16 use vars '$AUTOLOAD';
  1         9  
  1         19  
7             use overload
8 1         58   '""' => 'asString',
9 1     1   17   ;
  1         9  
10              
11             # for compatibility with the Ace::Graphics::Glyph::segments glyph, and
12             # with Bioperl SeqFeatureI:
13             *sub_SeqFeature = *merged_segments = *segments = \&exons;
14              
15             # autoload delegates everything to the Sequence feature
16             sub AUTOLOAD {
17 24     24   854   my($pack,$func_name) = $AUTOLOAD=~/(.+)::([^:]+)$/;
18 24         224   my $self = shift;
19 24         349   $self->{base}->$func_name(@_);
20             }
21              
22 0     0   0 sub DESTROY { }
23              
24             sub new {
25 11     11 0 117   my $class = shift;
26 11         88   my $args = shift;
27 11         169   bless $args,$class;
28 11         130   return $args;
29              
30             # for documentation only
31             # my %args = @_;
32             # my $introns = $args{intron};
33             # my $exons = $args{exon};
34             # my $sequence = $args{base}; # this is the Ace::Sequence::Feature object
35             # return bless {base => $sequence,
36             # intron => $introns,
37             # exon => $exons,
38             # cds => $cds,},$class;
39              
40             }
41              
42 0     0 0 0 sub smapped { 1; }
43              
44             sub asString {
45 2     2 0 96   shift->{base}->info;
46             }
47              
48             sub type {
49 0     0 0 0   return 'Transcript';
50             }
51              
52             sub relative {
53 6     6 1 153   my $self = shift;
54 6         57   my $d = $self->{relative};
55 6 100       65   $self->{relative} = shift if @_;
56 6         69   $d;
57             }
58              
59             sub introns {
60 0     0 1 0   my $self = shift;
61 0 0       0   return $self->{intron} ? @{$self->{intron}} : () unless $self->relative;
  0 0       0  
62             # otherwise, we have to handle relative coordinates
63 0         0   my $base = $self->{base};
64 0         0   my @e = map {Ace::Sequence->new(-refseq=>$base,-seq=>$_)} @{$self->{intron}};
  0         0  
  0         0  
65 0 0       0   return $self->strand < 0 ? reverse @e : @e;
66             }
67              
68             sub exons {
69 4     4 1 79   my $self = shift;
70 4 50       43   return $self->{exon} ? @{$self->{exon}} : () unless $self->relative;
  2 100       37  
71             # otherwise, we have to handle relative coordinates
72 2         20   my $base = $self->{base};
73 2         18   my @e = map {Ace::Sequence->new(-refseq=>$base,-seq=>$_)} @{$self->{exon}};
  16         252  
  2         22  
74 2 100       34   return $self->strand < 0 ? reverse @e : @e;
75             }
76              
77             sub cds {
78 0     0 1     my $self = shift;
79 0 0           return $self->{cds} ? @{$self->{cds}} : () unless $self->relative;
  0 0          
80             # otherwise, we have to handle relative coordinates
81 0             my $base = $self->{base};
82 0             my @e = map {Ace::Sequence->new(-refseq=>$base,-seq=>$_)} @{$self->{cds}};
  0            
  0            
83 0 0           return $self->strand < 0 ? reverse @e : @e;
84             }
85              
86             1;
87              
88             __END__
89            
90             =head1 NAME
91            
92             Ace::Sequence::Transcript - Simple "Gene" Object
93            
94             =head1 SYNOPSIS
95            
96             # open database connection and get an Ace::Object sequence
97             use Ace::Sequence;
98            
99             # get a megabase from the middle of chromosome I
100             $seq = Ace::Sequence->new(-name => 'CHROMOSOME_I,
101             -db => $db,
102             -offset => 3_000_000,
103             -length => 1_000_000);
104            
105             # get all the transcripts
106             @genes = $seq->transcripts;
107            
108             # get the exons from the first one
109             @exons = $genes[0]->exons;
110            
111             # get the introns
112             @introns = $genes[0]->introns
113            
114             # get the CDSs (NOT IMPLEMENTED YET!)
115             @cds = $genes[0]->cds;
116            
117             =head1 DESCRIPTION
118            
119             Ace::Sequence::Gene is a subclass of Ace::Sequence::Feature. It
120             inherits all the methods of Ace::Sequence::Feature, but adds the
121             ability to retrieve the annotated introns and exons of the gene.
122            
123             =head1 OBJECT CREATION
124            
125             You will not ordinarily create an I<Ace::Sequence::Gene> object
126             directly. Instead, objects will be created in response to a
127             transcripts() call to an I<Ace::Sequence> object.
128            
129             =head1 OBJECT METHODS
130            
131             Most methods are inherited from I<Ace::Sequence::Feature>. The
132             following methods are also supported:
133            
134             =over 4
135            
136             =item exons()
137            
138             @exons = $gene->exons;
139            
140             Return a list of Ace::Sequence::Feature objects corresponding to
141             annotated exons.
142            
143             =item introns()
144            
145             @introns = $gene->introns;
146            
147             Return a list of Ace::Sequence::Feature objects corresponding to
148             annotated introns.
149            
150             =item cds()
151            
152             @cds = $gene->cds;
153            
154             Return a list of Ace::Sequence::Feature objects corresponding to
155             coding sequence. THIS IS NOT YET IMPLEMENTED.
156            
157             =item relative()
158            
159             $relative = $gene->relative;
160             $gene->relative(1);
161            
162             This turns on and off relative coordinates. By default, the exons and
163             intron features will be returned in the coordinate system used by the
164             gene. If relative() is set to a true value, then coordinates will be
165             expressed as relative to the start of the gene. The first exon will
166             (usually) be 1.
167            
168             =head1 SEE ALSO
169            
170             L<Ace>, L<Ace::Object>, L<Ace::Sequence>,L<Ace::Sequence::Homol>,
171             L<Ace::Sequence::Feature>, L<Ace::Sequence::FeatureList>, L<GFF>
172            
173             =head1 AUTHOR
174            
175             Lincoln Stein <lstein@cshl.org> with extensive help from Jean
176             Thierry-Mieg <mieg@kaa.crbm.cnrs-mop.fr>
177            
178             Copyright (c) 1999, Lincoln D. Stein
179            
180             This library is free software; you can redistribute it and/or modify
181             it under the same terms as Perl itself. See DISCLAIMER.txt for
182             disclaimers of warranty.
183            
184             =cut
185            
186