/usr/share/perl5/Bio/SeqFeature/FeaturePair.pm is in libbio-perl-perl 1.6.924-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | #
# BioPerl module for Bio::SeqFeature::FeaturePair
#
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Cared for by Ewan Birney <birney@sanger.ac.uk>
#
# Copyright Ewan Birney
#
# You may distribute this module under the same terms as perl itself
# POD documentation - main docs before the code
=head1 NAME
Bio::SeqFeature::FeaturePair - hold pair feature information e.g. blast hits
=head1 SYNOPSIS
my $feat = Bio::SeqFeature::FeaturePair->new(
-feature1 => $f1,
-feature2 => $f2,
);
# Bio::SeqFeatureI methods can be used
my $start = $feat->start;
my $end = $feat->end;
# Bio::FeaturePair methods can be used
my $hstart = $feat->hstart;
my $hend = $feat->hend;
my $feature1 = $feat->feature1; # returns feature1 object
=head1 DESCRIPTION
A sequence feature object where the feature is itself a feature on
another sequence - e.g. a blast hit where residues 1-40 of a protein
sequence SW:HBA_HUMAN has hit to bases 100 - 220 on a genomic sequence
HS120G22. The genomic sequence coordinates are used to create one
sequence feature $f1 and the protein coordinates are used to create
feature $f2. A FeaturePair object can then be made
my $fp = Bio::SeqFeature::FeaturePair->new(
-feature1 => $f1, # genomic
-feature2 => $f2, # protein
);
This object can be used as a standard Bio::SeqFeatureI in which case
my $gstart = $fp->start # returns start coord on feature1 - genomic seq.
my $gend = $fp->end # returns end coord on feature1.
In general standard Bio::SeqFeatureI method calls return information
in feature1.
Data in the feature 2 object are generally obtained using the standard
methods prefixed by h (for hit!)
my $pstart = $fp->hstart # returns start coord on feature2 = protein seq.
my $pend = $fp->hend # returns end coord on feature2.
If you wish to swap feature1 and feature2 around :
$feat->invert
so...
$feat->start # etc. returns data in $feature2 object
No sub_SeqFeatures or tags can be stored in this object directly. Any
features or tags are expected to be stored in the contained objects
feature1, and feature2.
=head1 CONTACT
Ewan Birney E<lt>birney@sanger.ac.ukE<gt>
=head1 APPENDIX
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _
=cut
# Let the code begin...
package Bio::SeqFeature::FeaturePair;
use vars qw($AUTOLOAD);
use strict;
use Bio::SeqFeatureI;
use Bio::Factory::ObjectFactory;
use base qw(Bio::SeqFeature::Generic);
=head2 new
Title : new
Usage :
Function: Constructor for this module. Accepts the following parameters:
-feature1 Bio::SeqFeatureI-compliant object
-feature2 Bio::SeqFeatureI-compliant object
-feature_factory Bio::Factory::ObjectFactoryI compliant
object to be used when feature1 and/or feature2
are accessed without explicitly set before. This
is mostly useful for derived classes who want to
set their preferred class for feature objects.
Example :
Returns :
Args : see above
=cut
sub new {
my ($class, @args) = @_;
#
# We've got a certain problem here that somewhat relates to chicken and
# eggs. The problem is, we override a lot of SeqFeatureI methods here
# to delegate them to either feature1 or feature2. If we pass along
# those attributes right away, we need feature1 or feature2 or the feature
# factory in place, or there is no way around the dreaded default, which
# is ugly too (as it necessitates subsequent copying if you wanted a
# different feature object class).
#
# So I decided to go with the lesser of two evils here: we need to assume
# here that we can set all attributes through set_attributes(), which we
# assume is no different from setting them through the constructor. This
# gives us a window to set the feature objects and the factory, such that
# any derived class doesn't have to worry about this any more.
#
# I'm happy to hear a better solution, but I think this one isn't so bad.
#
my $self = $class->SUPER::new();
my ($feature1,$feature2,$featfact) =
$self->_rearrange([qw( FEATURE1
FEATURE2
FEATURE_FACTORY )],@args);
$self->_register_for_cleanup(\&cleanup_fp);
# initialize the feature object factory if not provided
if(! $featfact) {
$featfact = Bio::Factory::ObjectFactory->new(
-type => "Bio::SeqFeature::Generic",
-interface => "Bio::SeqFeatureI"
);
}
$self->feature_factory($featfact);
# Store the features in the object
$feature1 && $self->feature1($feature1);
$feature2 && $self->feature2($feature2);
# OK. Now we're setup to store all the attributes, and they'll go right
# away into the right objects.
$self->set_attributes(@args);
# done - we hope
return $self;
}
=head2 feature1
Title : feature1
Usage : $f = $featpair->feature1
$featpair->feature1($feature)
Function: Get/set for the query feature
Returns : Bio::SeqFeatureI
Args : Bio::SeqFeatureI
=cut
sub feature1 {
my ($self,$arg) = @_;
if ( defined($arg) || !defined $self->{'feature1'} ) {
$self->throw("internal error: feature factory not set!")
unless $self->feature_factory;
$arg = $self->feature_factory->create_object() unless( defined $arg);
$self->throw("Argument [$arg] must be a Bio::SeqFeatureI")
unless (ref($arg) && $arg->isa("Bio::SeqFeatureI"));
$self->{'feature1'} = $arg;
}
return $self->{'feature1'};
}
=head2 feature2
Title : feature2
Usage : $f = $featpair->feature2
$featpair->feature2($feature)
Function: Get/set for the hit feature
Returns : Bio::SeqFeatureI
Args : Bio::SeqFeatureI
=cut
sub feature2 {
my ($self,$arg) = @_;
if ( defined($arg) || ! defined $self->{'feature2'}) {
$self->throw("internal error: feature factory not set!")
unless $self->feature_factory;
$arg = $self->feature_factory->create_object() unless( defined $arg);
$self->throw("Argument [$arg] must be a Bio::SeqFeatureI")
unless (ref($arg) && $arg->isa("Bio::SeqFeatureI"));
$self->{'feature2'} = $arg;
}
return $self->{'feature2'};
}
=head2 start
Title : start
Usage : $start = $featpair->start
$featpair->start(20)
Function: Get/set on the start coordinate of feature1
Returns : integer
Args : [optional] beginning of feature
=cut
sub start {
return shift->feature1->start(@_);
}
=head2 end
Title : end
Usage : $end = $featpair->end
$featpair->end($end)
Function: get/set on the end coordinate of feature1
Returns : integer
Args : [optional] ending point of feature
=cut
sub end {
return shift->feature1->end(@_);
}
=head2 strand
Title : strand
Usage : $strand = $feat->strand()
$feat->strand($strand)
Function: get/set on strand information, being 1,-1 or 0
Returns : -1,1 or 0
Args : [optional] strand information to set
=cut
sub strand {
return shift->feature1->strand(@_);
}
=head2 location
Title : location
Usage : $location = $featpair->location
$featpair->location($location)
Function: Get/set location object (using feature1)
Returns : Bio::LocationI object
Args : [optional] LocationI to store
=cut
sub location {
return shift->feature1->location(@_);
}
=head2 score
Title : score
Usage : $score = $feat->score()
$feat->score($score)
Function: get/set on score information
Returns : float
Args : none if get, the new value if set
=cut
sub score {
return shift->feature1->score(@_);
}
=head2 frame
Title : frame
Usage : $frame = $feat->frame()
$feat->frame($frame)
Function: get/set on frame information
Returns : 0,1,2
Args : none if get, the new value if set
=cut
sub frame {
return shift->feature1->frame(@_);
}
=head2 primary_tag
Title : primary_tag
Usage : $ptag = $featpair->primary_tag
Function: get/set on the primary_tag of feature1
Returns : 0,1,2
Args : none if get, the new value if set
=cut
sub primary_tag {
return shift->feature1->primary_tag(@_);
}
=head2 source_tag
Title : source_tag
Usage : $tag = $feat->source_tag()
$feat->source_tag('genscan');
Function: Returns the source tag for a feature,
eg, 'genscan'
Returns : a string
Args : none
=cut
sub source_tag {
return shift->feature1->source_tag(@_);
}
=head2 seqname
Title : seqname
Usage : $obj->seq_id($newval)
Function: There are many cases when you make a feature that you
do know the sequence name, but do not know its actual
sequence. This is an attribute such that you can store
the seqname.
This attribute should *not* be used in GFF dumping, as
that should come from the collection in which the seq
feature was found.
Returns : value of seqname
Args : newvalue (optional)
=cut
sub seq_id {
return shift->feature1->seq_id(@_);
}
=head2 hseqname
Title : hseqname
Usage : $featpair->hseqname($newval)
Function: Get/set method for the name of
feature2.
Returns : value of $feature2->seq_id
Args : newvalue (optional)
=cut
sub hseq_id {
return shift->feature2->seq_id(@_);
}
=head2 hstart
Title : hstart
Usage : $start = $featpair->hstart
$featpair->hstart(20)
Function: Get/set on the start coordinate of feature2
Returns : integer
Args : none
=cut
sub hstart {
return shift->feature2->start(@_);
}
=head2 hend
Title : hend
Usage : $end = $featpair->hend
$featpair->hend($end)
Function: get/set on the end coordinate of feature2
Returns : integer
Args : none
=cut
sub hend {
return shift->feature2->end(@_);
}
=head2 hstrand
Title : hstrand
Usage : $strand = $feat->strand()
$feat->strand($strand)
Function: get/set on strand information, being 1,-1 or 0
Returns : -1,1 or 0
Args : none
=cut
sub hstrand {
return shift->feature2->strand(@_);
}
=head2 hscore
Title : hscore
Usage : $score = $feat->score()
$feat->score($score)
Function: get/set on score information
Returns : float
Args : none if get, the new value if set
=cut
sub hscore {
return shift->feature2->score(@_);
}
=head2 hframe
Title : hframe
Usage : $frame = $feat->frame()
$feat->frame($frame)
Function: get/set on frame information
Returns : 0,1,2
Args : none if get, the new value if set
=cut
sub hframe {
return shift->feature2->frame(@_);
}
=head2 hprimary_tag
Title : hprimary_tag
Usage : $ptag = $featpair->hprimary_tag
Function: Get/set on the primary_tag of feature2
Returns : 0,1,2
Args : none if get, the new value if set
=cut
sub hprimary_tag {
return shift->feature2->primary_tag(@_);
}
=head2 hsource_tag
Title : hsource_tag
Usage : $tag = $feat->hsource_tag()
$feat->source_tag('genscan');
Function: Returns the source tag for a feature,
eg, 'genscan'
Returns : a string
Args : none
=cut
sub hsource_tag {
return shift->feature2->source_tag(@_);
}
=head2 invert
Title : invert
Usage : $tag = $feat->invert
Function: Swaps feature1 and feature2 around
Returns : Nothing
Args : none
=cut
sub invert {
my ($self) = @_;
my $tmp = $self->feature1;
$self->feature1($self->feature2);
$self->feature2($tmp);
return 1;
}
=head2 feature_factory
Title : feature_factory
Usage : $obj->feature_factory($newval)
Function: Get/set the feature object factory for this feature pair.
The feature object factory will be used to create a feature
object if feature1() or feature2() is called in get mode
without having been set before.
The default is an instance of Bio::Factory::ObjectFactory
and hence allows the type to be changed dynamically at any
time.
Example :
Returns : The feature object factory in use (a
Bio::Factory::ObjectFactoryI compliant object)
Args : on set, a Bio::Factory::ObjectFactoryI compliant object
=cut
sub feature_factory {
my $self = shift;
return $self->{'feature_factory'} = shift if @_;
return $self->{'feature_factory'};
}
#################################################################
# aliases for backwards compatibility #
#################################################################
# seqname() is already aliased in Generic.pm, and we overwrite seq_id
sub hseqname {
my $self = shift;
$self->warn("SeqFeatureI::seqname() is deprecated. Please use seq_id() instead.");
return $self->hseq_id(@_);
}
sub cleanup_fp {
my $self = shift;
$self->{'feature1'} = $self->{'feature2'} = undef;
}
1;
|