3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
42 -hit_start => $tstart,
44 -hit_strand => $tstrand,
45 -ditag_id => $ditag_id,
46 -ditag_side => $ditag_side,
47 -ditag_pair_id => $ditag_pair_id,
48 -cigar_line => $cigar_line,
49 -analysis => $analysis,
54 Represents a mapped ditag
object in the
EnsEMBL database. These are
55 the original tags separated into start (
"L") and end ("R") parts if
56 applicable, successfully aligned to the genome. Two DitagFeatures
57 usually relate to one parent
Ditag. Alternatively there are CAGE tags
58 e.g. which only have a 5\'tag ("F").
71 use
Bio::
EnsEMBL::Utils::Exception qw( throw );
72 use
Bio::
EnsEMBL::Utils::Argument qw( rearrange );
78 Arg [1] : (optional)
int dbID
79 Arg [2] : (optional)
Bio::
EnsEMBL::DitagFeatureAdaptor $adaptor
85 Arg [8] :
int hit_start
87 Arg [10] :
int hit_strand
88 Arg [11] :
int ditag_id
89 Arg [12] :
string ditag_side
90 Arg [13] : (optional) sring cigar_line
91 Arg [14] : (optional)
int ditag_pair_id
92 Arg [15] : (optional)
int tag_count, only used for imported mappings where
93 identical positions where collapsed into into one feature.
95 Arg [16] : (optional) ditag
object
98 (-dbID => 123, -adaptor => $adaptor, ...);
107 my ($caller, @args) = @_;
108 my ( $dbID, $adaptor, $start, $end, $strand, $slice, $analysis, $hit_start, $hit_end,
109 $hit_strand, $ditag_id, $ditag_side, $cigar_line, $ditag_pair_id, $tag_count, $ditag ) =
110 rearrange( [
'dbid',
'adaptor' ,
'start',
'end',
'strand',
'slice',
'analysis',
'hit_start',
111 'hit_end',
'hit_strand',
'ditag_id',
'ditag_side',
'cigar_line',
'ditag_pair_id' ,
'tag_count',
'ditag'],
113 my $class = ref($caller) || $caller;
116 if(!ref($analysis) || !$analysis->isa(
'Bio::EnsEMBL::Analysis')) {
117 throw(
'-ANALYSIS argument must be a Bio::EnsEMBL::Analysis not '.
121 if(defined($strand)) {
122 if(!($strand =~ /^-?\d$/) or !($strand == 1) && !($strand == -1) && !($strand == 0)) {
123 throw(
'-STRAND argument must be 1, -1, or 0');
126 if(defined($hit_strand)) {
127 if(!($hit_strand == 1) && !($hit_strand == -1) && !($hit_strand == 0)) {
128 throw(
'-HIT_STRAND argument must be 1, -1, or 0 not '.$hit_strand);
131 if(defined($start) && defined($end)) {
132 if($end+1 < $start) {
133 throw(
'Start must be less than or equal to end+1.');
137 throw(
'Need start and end location.');
139 if(!(defined($hit_start) && defined($hit_end))) {
140 throw(
'Need hit start and hit end location.');
142 if(!defined($tag_count) or (!$tag_count =~ /^[\d]+$/)){
146 my $self = bless( {
'dbID' => $dbID,
147 'analysis' => $analysis,
152 'hit_start' => $hit_start,
153 'hit_end' => $hit_end,
154 'hit_strand' => $hit_strand,
155 'ditag_id' => $ditag_id,
156 'ditag_pair_id' => $ditag_pair_id,
157 'ditag_side' => $ditag_side,
158 'cigar_line' => $cigar_line,
159 'tag_count' => $tag_count,
163 $self->adaptor($adaptor);
170 Arg [1] : (optional) ditag
object
171 Description: Get/Set the ditag
object of
this DitagFeature
183 $self->{
'ditag'} = shift;
184 } elsif(!$self->{
'ditag'}) {
185 if($self->{
'ditag_id'}) {
187 my $ditag_adaptor = $self->analysis->
adaptor->
db->get_DitagAdaptor;
188 $self->{
'ditag'} = $ditag_adaptor->fetch_by_dbID($self->ditag_id);
191 throw "Could not get Ditag for DitagFeature ".$self->dbID;
195 return($self->{
'ditag'});
199 =head2 get_ditag_location
202 Description: Get the start and end location (and strand ) of the start-end pair
203 this DitagFeature belongs to.
204 If it is not a paired ditag, these will be identical
205 to DitagFeature->start() & DitagFeature->end().
206 Please note that the returned start/end are min/max locations.
207 Returntype : int (start, end, strand)
208 Exceptions :
throws if the 2 features of a pair are found on different strands
209 or
if the second one cannot be found.
215 sub get_ditag_location {
218 my ($start, $end, $strand);
219 if($self->ditag_side eq
"F"){
220 $start = $self->start;
224 my ($ditag_a, $ditag_b, $more);
226 ($ditag_a, $ditag_b, $more) = @{$self->adaptor->fetch_all_by_ditagID($self->ditag_id,
227 $self->ditag_pair_id,
228 $self->analysis->dbID)};
230 if($@ or !defined($ditag_a) or !defined($ditag_b)){
231 throw(
"Cannot find 2nd tag of pair (".$self->dbID.
", ".$self->ditag_id.
", ".
232 $self->ditag_pair_id.
", ".$self->analysis->dbID.
")\n".$@);
236 # throw("More than two DitagFeatures were returned for ".$self->dbID.", ".$self->ditag_id
237 # .", ".$self->ditag_pair_id);
240 ($ditag_a->start < $ditag_b->start) ? ($start = $ditag_a->start) : ($start = $ditag_b->start);
241 ($ditag_a->end > $ditag_b->end) ? ($end = $ditag_a->end) : ($end = $ditag_b->end);
242 if($ditag_a->strand != $ditag_b->strand){
243 throw(
'the strands of the two ditagFeatures are different! '.$ditag_a->strand.
'/'.$ditag_b->strand);
248 return($start, $end, $self->strand);
254 Arg [1] : (optional) value
255 Description: Getter/Setter
for the ditag_id
268 $self->{
'ditag_id'} = shift;
271 return $self->{
'ditag_id'};
276 Arg [1] : (optional) value
277 Description: Getter/Setter
for the slice
279 Returntype : slice
object
290 $self->{
'slice'} = shift;
293 return $self->{
'slice'};
298 Arg [1] : (optional) value
299 Description: Getter/Setter
for the ditag_pair_id
311 $self->{
'ditag_pair_id'} = shift;
314 return $self->{
'ditag_pair_id'};
319 Arg [1] : (optional) value
320 Description: Getter/Setter
for the ditag_side
333 $self->{
'ditag_side'} = shift;
336 return $self->{
'ditag_side'};
341 Arg [1] : (optional) value
342 Description: Getter/Setter
for the hit_start
355 $self->{
'hit_start'} = shift;
358 return $self->{
'hit_start'};
363 Arg [1] : (optional) value
364 Description: Getter/Setter
for the hit_end
377 $self->{
'hit_end'} = shift;
380 return $self->{
'hit_end'};
385 Arg [1] : (optional) value
386 Description: Getter/Setter
for the hit_strand
399 $self->{
'hit_strand'} = shift;
402 return $self->{
'hit_strand'};
407 Arg [1] : (optional) value
408 Description: Getter/Setter
for the cigar_line
421 $self->{
'cigar_line'} = shift;
424 return $self->{
'cigar_line'};
429 Arg [1] : (optional) value
430 Description: Getter/Setter
for the start
443 $self->{
'start'} = shift;
446 return $self->{
'start'};
451 Arg [1] : (optional) value
452 Description: Getter/Setter
for the end
454 Returntype :
int or
string
465 $self->{
'end'} = shift;
468 return $self->{
'end'};
473 Arg [1] : (optional) value
474 Description: Getter/Setter
for the strand
487 $self->{
'strand'} = shift;
490 return $self->{
'strand'};
495 Arg [1] : (optional) value
496 Description: Getter/Setter
for the dbID
509 $self->{
'dbID'} = shift;
512 return $self->{
'dbID'};
517 Arg [1] : (optional) value
518 Description: Getter/Setter
for the sequence
530 $self->{
'sequence'} = $self->adaptor->sequence($self->dbID());
532 return $self->{
'sequence'};
538 Arg [1] : (optional) value
539 Description: Getter/Setter
for the tag_count
552 $self->{
'tag_count'} = shift;
555 return $self->{
'tag_count'};