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.
24 Please email comments or questions to the
public Ensembl
25 developers list at <http:
27 Questions may also be sent to the Ensembl help desk at
35 themselves hits to other sequence features.
49 -hseqname =>
'ALUSX10.1',
50 -analysis => $analysis
53 my $hit_start = $feat->
hstart();
54 my $hit_end = $feat->hend();
55 my $hit_strand = $feat->hstrand();
56 my $analysis = $feat->analysis();
60 A sequence feature
object where the feature is itself a feature on
61 another sequence - e.g. a blast hit where residues 1-40 of a protein
62 sequence SW:HBA_HUMAN has hit to bases 100 - 220 on a genomic sequence
63 HS120G22. The genomic sequence coordinates are represented by the
64 start, end, strand attributes
while the protein (hit) coordinates are
65 represented by the hstart, hend, hstrand attributes.
67 $clone = $slice_adpator->fetch_by_region(
'clone',
'HS120G22' );
79 -hseqname =>
'SW:HBA_HUMAN',
80 -species =>
'Homo sapiens',
81 -hspecies =>
'Homo sapiens'
88 package Bio::EnsEMBL::FeaturePair;
101 Arg [HSTART] :
int - The start of the hit region (optional)
102 Arg [HEND] :
int - The end of the hit region (optional)
103 Arg [HSTRAND] : (0,1,-1) - The strand of the hit region (optional)
104 Arg [PERCENT_ID]:
float - The precentage identity of the hit (optional)
105 Arg [SCORE] :
float - The score of the hit (optional)
106 Arg [HSEQNAME] :
string - The name of the hit sequence (optional)
107 Arg [P_VALUE] :
float - The pvalue or evalue (optional)
108 Arg [SPECIES] :
string - The species the query sequence is from (optional)
109 Arg [HSPECIES] :
string - The species the hit sequence is from (optional)
110 Arg [COVERAGE] :
string - The % of the query that
this feature pair covers
111 Arg [HCOVERAGE] :
string - The % of the target
this this feature pair covers
112 Arg [EXTRA_DATA]: HashRef - Additional data, specified as name, value attribute pairs (optional)
123 -hseqname =>
'ALUSX10.1',
124 -analysis => $analysis);
127 Exceptions :
throw if start > end
128 throw if invalid strand is provided
137 my $class = ref($caller) || $caller;
139 my $self = $class->SUPER::new(@_);
141 my ($hstart, $hend, $hstrand, $percent_id, $score, $species, $hspecies, $p_value, $hseqname, $f1, $f2, $coverage, $hcoverage, $group_id, $level_id, $external_db_id, $extra_data, $external_db_name, $external_display_db_name, $hdescription) = rearrange([
'HSTART',
'HEND',
'HSTRAND',
'PERCENT_ID',
'SCORE',
'SPECIES',
'HSPECIES',
'P_VALUE',
'HSEQNAME',
'FEATURE1',
'FEATURE2',
'COVERAGE',
'HCOVERAGE',
'GROUP_ID',
'LEVEL_ID',
'EXTERNAL_DB_ID',
'EXTRA_DATA',
'DBNAME',
'DB_DISPLAY_NAME',
'HDESCRIPTION'], @_);
143 if (defined($hstart) && defined($hend) && ($hend < $hstart)) {
144 throw(
'HSTART must be less than or equal to HEND');
147 if (defined($hstrand) && $hstrand != 1 && $hstrand != -1 && $hstrand != 0) {
148 throw(
'HSTRAND must be one of (0,1,-1)');
151 $self->{
'hstart'} = $hstart;
152 $self->{
'hend'} = $hend;
153 $self->{
'hstrand'} = $hstrand;
154 $self->{
'score'} = $score;
155 $self->{
'percent_id'} = $percent_id;
156 $self->{
'species'} = $species;
157 $self->{
'hspecies'} = $hspecies;
158 $self->{
'hseqname'} = $hseqname;
159 $self->{
'coverage'} = $coverage;
160 $self->{
'hcoverage'} = $hcoverage;
161 $self->{
'p_value'} = $p_value;
162 $self->{
'group_id'} = $group_id;
163 $self->{
'level_id'} = $level_id;
164 $self->{
'external_db_id'} = $external_db_id;
165 $self->{
'extra_data'} = $extra_data;
166 $self->{
'dbname'} = $external_db_name;
167 $self->{
'db_display_name'} = $external_display_db_name;
168 $self->{
'hdescription'} = $hdescription;
176 Arg [1] :
string $hseqname (optional)
177 Example : $hseqname = $fp->hseqname();
178 Description: Getter/Setter
for the name of the hit sequence
188 $self->{
'hseqname'} = shift
if (@_);
189 return $self->{hseqname};
194 Arg [1] :
string $hstart (optional)
195 Example : $hstart = $fp->hstart();
196 Description: Getter/Setter
for the start coordinate on the hit sequence
206 $self->{
'hstart'} = shift
if (@_);
207 return $self->{
'hstart'};
212 Arg [1] :
string $hend (optional)
213 Example : $hend = $fp->hend();
214 Description: Getter/Setter
for the end coordinate on the hit sequence
224 $self->{
'hend'} = shift
if (@_);
225 return $self->{
'hend'};
230 Arg [1] :
int $hstrand (optional)
231 Example : $hstrand = $fp->hstrand
232 Description: Getter/Setter
for the orientation of the hit on the hit sequence
245 if (defined($hstrand) && $hstrand != 1 && $hstrand != 0 && $hstrand != -1) {
246 throw(
'hstrand must be one of (-1,0,1)');
248 $self->{
'hstrand'} = $hstrand;
251 return $self->{
'hstrand'};
258 Description: Getter/Setter
for the Slice that is associated with
this
259 hit feature. The slice represents the underlying sequence that
this
260 feature is on. Note that
this method call is analagous to the
261 old SeqFeature methods contig(), entire_seq(), attach_seq(),
264 Exceptions : thrown
if an invalid argument is passed
275 if (defined($sl) && (!ref($sl) || !($sl->isa(
'Bio::EnsEMBL::Slice')))) {
276 throw(
'slice argument must be a Bio::EnsEMBL::Slice');
279 $self->{
'hslice'} = $sl;
282 return $self->{
'hslice'};
285 =head2 hseq_region_name
288 Example : print $feature->hseq_region_name();
289 Description: Gets the name of the hseq_region which
this feature is on.
290 Returns undef
if this Feature is not on a hslice.
291 Returntype :
string or undef
298 sub hseq_region_name {
300 my $slice = $self->{
'hslice'};
305 =head2 hseq_region_strand
308 Example : print $feature->hseq_region_strand();
309 Description: Returns the strand of the hseq_region which
this feature is on
310 (i.e. feature_strand * slice_strand)
311 Returns undef
if this Feature is not on a hslice.
312 Returntype : 1,0,-1 or undef
319 sub hseq_region_strand {
321 my $slice = $self->{
'hslice'};
323 return ($slice) ? $slice->strand()*$self->{
'hstrand'} : undef;
326 =head2 hseq_region_start
329 Example : print $feature->hseq_region_start();
330 Description: Convenience method which returns the absolute start of
this
331 feature on the hseq_region, as opposed to the relative (hslice)
334 Returns undef
if this feature is not on a hslice.
335 Returntype :
int or undef
342 sub hseq_region_start {
344 my $slice = $self->{
'hslice'};
346 return undef
if (!$slice);
348 if ($slice->strand == 1) {
349 return undef
if (!defined($self->{
'hstart'}));
350 return $slice->start() + $self->{
'hstart'} - 1;
352 return undef
if (!defined($self->{
'hend'}));
353 return $slice->end() - $self->{
'hend'} + 1;
357 =head2 hseq_region_end
360 Example : print $feature->hseq_region_end();
361 Description: Convenience method which returns the absolute end of
this
362 feature on the hseq_region, as opposed to the relative (hslice)
365 Returns undef
if this feature is not on a hslice.
366 Returntype :
int or undef
373 sub hseq_region_end {
375 my $slice = $self->{
'hslice'};
377 return undef
if (!$slice);
379 if ($slice->strand == 1) {
380 return undef
if (!defined($self->{
'hend'}));
381 return $slice->start() + $self->{
'hend'} - 1;
383 return undef
if (!defined($self->{
'hstart'}));
384 return $slice->end() - $self->{
'hstart'} + 1;
390 Arg [1] :
float $score (optional)
391 Example : $score = $fp->score();
392 Description: Getter/Setter
for the score of
this feature pair
402 $self->{
'score'} = shift
if (@_);
403 return $self->{
'score'};
408 Arg [1] :
float $percent_id (optional)
409 Example : $percent_id = $fp->percent_id();
410 Description: Getter/Setter
for the percentage identity of
this feature pair
420 $self->{
'percent_id'} = shift
if (@_);
421 return $self->{
'percent_id'};
426 Arg [1] :
string $genus_species_name (optional)
427 e.g. Homo_sapiens or Mus_musculus
428 Example : $species = $fp->species();
429 Description: get/set on the species of feature1
439 $self->{
'species'} = shift
if (@_);
440 return $self->{
'species'};
445 Arg [1] :
string $genus_species_name (optional)
446 e.g. Homo_sapiens or Mus_musculus
447 Example : $hspecies = $fp->hspecies
448 Description: get/set on the species of feature2
458 $self->{
'hspecies'} = shift
if (@_);
459 return $self->{
'hspecies'};
464 Arg [1] : number (percentage) $coverage (optional)
465 Example : $cov = $fp->coverage();
466 Description: Getter/Setter
for the % of the query covered by the feature
476 $self->{
'coverage'} = shift
if (@_);
477 return $self->{
'coverage'};
482 Arg [1] : number (percentage) $hcoverage (optional)
483 Example : $hcov = $fp->hcoverage();
484 Description: Getter/Setter
for the % of the target covered by the feature
494 $self->{
'hcoverage'} = shift
if (@_);
495 return $self->{
'hcoverage'};
498 =head2 external_db_id
500 Arg [1] :
int $external_db_id (optional)
501 Example : $ex_db = $fp->external_db_id();
502 Description: Getter/Setter
for the external_db_id taregt source database feature
512 $self->{
'external_db_id'} = shift
if (@_);
513 return $self->{
'external_db_id'};
518 Arg [1] :
string $external_db_name (optional)
519 Example : $ex_db_name = $fp->dbname();
520 Description: Getter/Setter
for the external_db_name attribute, name of external database
530 $self->{
'dbname'} = shift
if (@_);
531 return $self->{
'dbname'};
534 =head2 db_display_name
536 Arg [1] :
string $db_display_name (optional)
537 Example : $ex_db_display_name = $fp->db_display_name();
538 Description: Getter/Setter
for the db_display_name attribute
539 The preferred display name
for the external database.
547 sub db_display_name {
549 $self->{
'db_display_name'} = shift
if (@_);
550 return $self->{
'db_display_name'};
555 Arg [1] :
float $p_value (optional)
556 Example : $eval = $fp->p_value
557 Description: Getter Setter
for the evalue / pvalue of
this feature
567 $self->{
'p_value'} = shift
if (@_);
568 return $self->{
'p_value'};
573 Arg [1] : String (optional)
574 Example : $des = $fp->hdescription()
575 Description: Getter Setter
for optional description of
this feature
585 $self->{
'hdescription'} = shift
if (@_);
586 return $self->{
'hdescription'};
592 Example : print $fp->display_id();
593 Description: This method returns a
string that is considered to be
594 the
'display' identifier. For feature pairs
this is the
595 hseqname
if it is available otherwise it is an empty
string.
598 Caller : web drawing code
605 return $self->{
'hseqname'} ||
'';
608 =head2 identical_matches
610 Arg [1] :
int $identical_matches (optional)
612 Description: get/set on the number of identical matches
620 sub identical_matches {
621 my ($self, $arg) = @_;
624 return $self->{
'_identical_matches'} = $arg;
626 return $self->{
'_identical_matches'};
629 =head2 positive_matches
631 Arg [1] :
int $positive_matches (optional)
633 Description: get/set on the number of positive matches
641 sub positive_matches {
642 my ($self, $arg) = @_;
645 return $self->{
'_positive_matches'} = $arg;
647 return $self->{
'_positive_matches'};
652 Arg [1] :
int $group_id
654 Description: get/set
for attribute group_id
663 my ($self, $arg) = @_;
666 $self->{
'group_id'} = $arg;
668 return $self->{
'group_id'};
673 Arg [1] :
int $level_id
675 Description: get/set
for attribute level_id
684 my ($self, $arg) = @_;
687 $self->{
'level_id'} = $arg;
689 return $self->{
'level_id'};
696 Example : $feature->
invert();
697 Description: This method is used to swap the hit and query sides of
this
698 feature in place. A
new slice may optionally provided which
699 this feature will be placed on. If no slice is provided the
700 feature slice will be set to undef.
703 Caller : pipeline (BlastMiniGenewise)
708 my ($self, $slice) = @_;
710 if (!defined $slice && defined $self->hslice) {
711 $slice = $self->hslice;
714 my $hstart = $self->{
'hstart'};
715 my $hend = $self->{
'hend'};
716 my $hstrand = $self->{
'hstrand'};
717 my $hspecies = $self->{
'hspecies'};
718 my $hseqname = $self->{
'hseqname'};
719 my $hdescription = $self->{
'hdescription'};
721 my $start = $self->{
'start'};
722 my $end = $self->{
'end'};
723 my $strand = $self->{
'strand'};
724 my $species = $self->{
'species'};
725 my $seqname = $self->seqname();
727 $self->{
'start'} = $hstart;
728 $self->{
'end'} = $hend;
729 $self->{
'strand'} = $hstrand;
730 $self->{
'species'} = $hspecies;
731 $self->{
'seqname'} = $hseqname
if (defined($hseqname));
733 $self->{
'hstart'} = $start;
734 $self->{
'hend'} = $end;
735 $self->{
'hstrand'} = $strand;
736 $self->{
'hseqname'} = $seqname;
737 $self->{
'hspecies'} = $species;
739 $self->{
'hdescription'} = $hdescription;
741 $self->{
'hslice'} = $self->
slice;
742 $self->{
'slice'} = $slice;
748 $self->{
'extra_data'} = shift
if (@_);
749 return $self->{
'extra_data'};
754 $self->{
'extra_data'}->{
'type'} = shift
if (@_);
755 if (exists $self->{
'extra_data'}) {
756 return $self->{
'extra_data'}->{
'type'};