File Coverage

lib/Sanger/CGP/Vagrent/TranscriptSource/AbstractTranscriptSource.pm
Criterion Covered Total %
branch 0 6 0.0
subroutine 10 13 76.9
pod 4 4 100.0
total 14 23 60.8


line bran sub pod code
1       package Sanger::CGP::Vagrent::TranscriptSource::AbstractTranscriptSource;
2        
3       ##########LICENCE##########
4       # Copyright (c) 2014 Genome Research Ltd.
5       #
6       # Author: Cancer Genome Project cgpit@sanger.ac.uk
7       #
8       # This file is part of VAGrENT.
9       #
10       # VAGrENT is free software: you can redistribute it and/or modify it under
11       # the terms of the GNU Affero General Public License as published by the Free
12       # Software Foundation; either version 3 of the License, or (at your option) any
13       # later version.
14       #
15       # This program is distributed in the hope that it will be useful, but WITHOUT
16       # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17       # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18       # details.
19       #
20       # You should have received a copy of the GNU Affero General Public License
21       # along with this program. If not, see <http://www.gnu.org/licenses/>.
22       ##########LICENCE##########
23        
24        
25   4   use strict;
26        
27   4   use Log::Log4perl;
28   4   use Carp;
29   4   use Attribute::Abstract;
30   4   use Data::Dumper;
31   4   use Sanger::CGP::Vagrent qw($VERSION);
32       my $log = Log::Log4perl->get_logger(__PACKAGE__);
33        
34       1;
35        
36       sub new {
37   862 1 my $proto = shift;
38       my $class = ref($proto) || $proto;
39       my $self = {};
40       bless($self, $class);
41       $self->_init(@_);
42       return $self;
43       }
44        
45   4   sub _init: Abstract;
46        
47   4   sub getTranscripts: Abstract;
48        
49       sub setDumpRegion {
50   0 1 my ($self,$gr) = @_;
51 0     unless(defined($gr) && $gr->isa('Sanger::CGP::Vagrent::Data::AbstractGenomicPosition')){
52       croak("Did not recieve a Sanger::CGP::Vagrent::Data::AbstractGenomicPosition object");
53       }
54       $self->{_dumpInfo} = undef;
55       $self->{_dumpInfo}->{_region} = $gr;
56       return;
57       }
58        
59       sub getDumpRegion {
60   0 1 my $self = shift;
61 0     if(defined $self->{_dumpInfo} && defined $self->{_dumpInfo}->{_region}){
62       return $self->{_dumpInfo}->{_region};
63       }
64       return undef;
65       }
66        
67       sub isDumpRegionACompleteSequence {
68   0 1 my $self = shift;
69 0     if(defined $self->{_dumpInfo} && defined $self->{_dumpInfo}->{_fullSeq}){
70       return $self->{_dumpInfo}->{_fullSeq};
71       }
72       return undef;
73       }
74        
75   4   sub getTranscriptsForNextGeneInDumpRegion: Abstract;
76        
77       __END__
78        
79       =head1 NAME
80        
81       Sanger::CGP::Vagrent::TranscriptSource::AbstractTranscriptSource - Abstract base class for Transcript sources
82        
83       =head1 DESCRIPTION
84        
85       This is a base utility class all TranscriptSources should inherit from, its little more than an interface with the vast majority of the functionality being implemented in the sub class.
86        
87       Sub classes must implement a getTranscripts method and an internal _init method.
88        
89       =head1 METHODS
90        
91       =head2 Constructor
92        
93       =head3 new
94        
95       =over
96        
97       =item Usage :
98        
99       my $source = Sanger::CGP::Vagrent::TranscriptSource::AbstractTranscriptSourceSubClass->new();
100        
101       =item Function :
102        
103       Builds a new Sanger::CGP::Vagrent::TranscriptSource::AbstractTranscriptSource inheriting object
104        
105       =item Returns :
106        
107       Sanger::CGP::Vagrent::TranscriptSource::AbstractTranscriptSource object initialized with parameter values
108        
109       =item Params :
110        
111       Hash of parameter values, the actual keys/values required depend on the sub class.
112        
113       =back
114        
115       =head2 Attributes
116        
117       =head3 setDumpRegion
118        
119       =over
120        
121       =item Usage :
122        
123       $source->setDumpRegion($genomicPosition);
124        
125       =item Function :
126        
127       Sets the L<GenomicRegion|Sanger::CGP::Vagrent::Data::AbstractGenomicPosition> to seed Transcript/Gene set retrieval
128        
129       =item Returns :
130        
131       Nothing
132        
133       =item Params :
134        
135       Any L<Sanger::CGP::Vagrent::Data::AbstractGenomicPosition|Sanger::CGP::Vagrent::Data::AbstractGenomicPosition> implementing object
136        
137       =back
138        
139       =head3 getDumpRegion
140        
141       =over
142        
143       =item Usage :
144        
145       my $region = $source->getDumpRegion();
146        
147       =item Function :
148        
149       Gets the L<GenomicRegion|Sanger::CGP::Vagrent::Data::AbstractGenomicPosition> used to seed Transcript/Gene set retrieval
150        
151       =item Returns :
152        
153       A L<Sanger::CGP::Vagrent::Data::AbstractGenomicPosition|Sanger::CGP::Vagrent::Data::AbstractGenomicPosition> implementing object or undef
154        
155       =back
156        
157       =head2 Functions
158        
159       =head3 isDumpRegionACompleteSequence
160        
161       =over
162        
163       =item Usage :
164        
165       if($source->isDumpRegionACompleteSequence()){
166       ......
167       }
168        
169       =item Function :
170        
171       Returns boolean status for the current dump region being a complete sequence (eg. a whole chromosome/contig). The value behind this is populated by getTranscriptsForNextGeneInDumpRegion method when processing the specified gene region
172        
173       =item Returns :
174        
175       A Boolean, 1 if it is a complete sequence, 0 if is isn't or undef if it doesn't know
176        
177       =back
178        
179       =head2 Abstract
180        
181       =head3 getTranscripts
182        
183       =over
184        
185       =item Usage :
186        
187       my @transList = $source->getTranscripts($genomicPosition);
188        
189       =item Function :
190        
191       Abstract function, must be overridden by a subclass. Retrieves a list of L<Transcripts|Sanger::CGP::Vagrent::Data::Transcript> objects overlapping the specified L<GenomicPosition|Sanger::CGP::Vagrent::Data::AbstractGenomicPosition>
192        
193       =item Returns :
194        
195       An array of L<Sanger::CGP::Vagrent::Data::Transcript|Sanger::CGP::Vagrent::Data::Transcript> objects
196        
197       =item Params :
198        
199       Any L<Sanger::CGP::Vagrent::Data::AbstractGenomicPosition|Sanger::CGP::Vagrent::Data::AbstractGenomicPosition> implementing object
200        
201       =back
202        
203       =head3 getTranscriptsForNextGeneInDumpRegion
204        
205       =over
206        
207       =item Usage :
208        
209       while (my @transList = $source->getTranscriptsForNextGeneInDumpRegion()){
210       ....
211       }
212        
213       =item Function :
214        
215       Abstract function, must be overridden by a subclass. Retrieves a list of L<Transcripts|Sanger::CGP::Vagrent::Data::Transcript> objects belonging to the next gene inside the previously specified L<GenomicRegion|Sanger::CGP::Vagrent::Data::AbstractGenomicPosition>
216        
217       =item Returns :
218        
219       An array of L<Sanger::CGP::Vagrent::Data::Transcript|Sanger::CGP::Vagrent::Data::Transcript> objects
220        
221       =item Params :
222        
223       None
224        
225       =back
226        
227       =head3 _init
228        
229       =over
230        
231       =item Usage :
232        
233       $self->_init(@params);
234        
235       =item Function :
236        
237       Abstract internal function, must be overridden by a subclass. This method is used to handle constructor parameters, its called by new.
238        
239       =item Returns :
240        
241       None
242        
243       =item Params :
244        
245       The flattened array of key/value pairs passed in from new.
246        
247       =back