/usr/share/perl5/Bio/Seq/QualI.pm is in libbio-perl-perl 1.7.2-2.
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 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | #
# BioPerl module for Bio::Seq::QualI
#
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Cared for by Chad Matsalla <bioinformatics@dieselwurks.com
#
# Copyright Chad Matsalla
#
# You may distribute this module under the same terms as perl itself
# POD documentation - main docs before the code
=head1 NAME
Bio::Seq::QualI - Interface definition for a Bio::Seq::Qual
=head1 SYNOPSIS
# get a Bio::Seq::Qual compliant object somehow
# to test this is a seq object
$obj->isa("Bio::Seq::QualI")
|| $obj->throw("$obj does not implement the Bio::Seq::QualI interface");
# accessors
$string = $obj->qual();
$substring = $obj->subqual(12,50);
$display = $obj->display_id(); # for human display
$id = $obj->primary_id(); # unique id for this object,
# implementation defined
$unique_key= $obj->accession_number();
# unique biological id
=head1 DESCRIPTION
This object defines an abstract interface to basic quality
information. PrimaryQual is an object just for the quality and its
name(s), nothing more. There is a pure perl implementation of this in
Bio::Seq::PrimaryQual. If you just want to use Bio::Seq::PrimaryQual
objects, then please read that module first. This module defines the
interface, and is of more interest to people who want to wrap their
own Perl Objects/RDBs/FileSystems etc in way that they "are" bioperl
quality objects, even though it is not using Perl to store the
sequence etc.
This interface defines what bioperl consideres necessary to "be" a
sequence of qualities, without providing an implementation of
this. (An implementation is provided in Bio::Seq::PrimaryQual). If you
want to provide a Bio::Seq::PrimaryQual 'compliant' object which in
fact wraps another object/database/out-of-perl experience, then this
is the correct thing to wrap, generally by providing a wrapper class
which would inherit from your object and this Bio::Seq::QualI
interface. The wrapper class then would have methods lists in the
"Implementation Specific Functions" which would provide these methods
for your object.
=head1 FEEDBACK
=head2 Mailing Lists
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to one
of the Bioperl mailing lists. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
=head2 Support
Please direct usage questions or support issues to the mailing list:
I<bioperl-l@bioperl.org>
rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
=head2 Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via the
web:
https://github.com/bioperl/bioperl-live/issues
=head1 AUTHOR - Chad Matsalla
This module is heavily based on Bio::Seq::PrimarySeq and is modeled after
or outright copies sections of it. Thanks Ewan!
Email bioinformatics@dieselwurks.com
=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::Seq::QualI;
use strict;
use Carp;
use base qw(Bio::Root::RootI);
=head1 Implementation Specific Functions
These functions are the ones that a specific implementation must
define.
=head2 qual()
Title : qual()
Usage : @quality_values = @{$obj->qual()};
Function: Returns the quality as a reference to an array containing the
quality values. The individual elements of the quality array are
not validated and can be any numeric value.
Returns : A reference to an array.
Status :
=cut
sub qual {
my ($self) = @_;
if( $self->can('throw') ) {
$self->throw("Bio::Seq::QualI definition of qual - implementing class did not provide this method");
} else {
confess("Bio::Seq::QualI definition of qual - implementing class did not provide this method");
}
}
=head2 subqual($start,$end)
Title : subqual($start,$end)
Usage : @subset_of_quality_values = @{$obj->subseq(10,40)};
Function: returns the quality values from $start to $end, where the
first value is 1 and the number is inclusive, ie 1-2 are the first
two bases of the sequence. Start cannot be larger than end but can
be equal.
Returns : A reference to an array.
Args : a start position and an end position
=cut
sub subqual {
my ($self) = @_;
if( $self->can('throw') ) {
$self->throw("Bio::Seq::QualI definition of subqual - implementing class did not provide this method");
} else {
confess("Bio::Seq::QualI definition of subqual - implementing class did not provide this method");
}
}
=head2 display_id()
Title : display_id()
Usage : $id_string = $obj->display_id() _or_
$id_string = $obj->display_id($new_display_id);
Function: Returns the display id, aka the common name of the Quality
object.
The semantics of this is that it is the most likely string to be
used as an identifier of the quality sequence, and likely to have
"human" readability. The id is equivalent to the ID field of the
GenBank/EMBL databanks and the id field of the Swissprot/sptrembl
database. In fasta format, the >(\S+) is presumed to be the id,
though some people overload the id to embed other information.
Bioperl does not use any embedded information in the ID field,
and people are encouraged to use other mechanisms (accession field
for example, or extending the sequence object) to solve this.
Notice that $seq->id() maps to this function, mainly for
legacy/convience issues
Returns : A string
Args : If an arg is provided, it will replace the existing display_id
in the object.
=cut
sub display_id {
my ($self) = @_;
if( $self->can('throw') ) {
$self->throw("Bio::Seq::QualI definition of id - implementing class did not provide this method");
} else {
confess("Bio::Seq::QualI definition of id - implementing class did not provide this method");
}
}
=head2 accession_number()
Title : accession_number()
Usage : $unique_biological_key = $obj->accession_number(); _or_
$unique_biological_key = $obj->accession_number($new_acc_num);
Function: Returns the unique biological id for a sequence, commonly
called the accession_number. For sequences from established
databases, the implementors should try to use the correct
accession number. Notice that primary_id() provides the unique id
for the implementation, allowing multiple objects to have the same
accession number in a particular implementation. For sequences
with no accession number, this method should return "unknown".
Returns : A string.
Args : If an arg is provided, it will replace the existing
accession_number in the object.
=cut
sub accession_number {
my ($self,@args) = @_;
if( $self->can('throw') ) {
$self->throw("Bio::Seq::QualI definition of seq - implementing class did not provide this method");
} else {
confess("Bio::Seq::QualI definition of seq - implementing class did not provide this method");
}
}
=head2 primary_id()
Title : primary_id()
Usage : $unique_implementation_key = $obj->primary_id(); _or_
$unique_implementation_key = $obj->primary_id($new_prim_id);
Function: Returns the unique id for this object in this implementation.
This allows implementations to manage their own object ids in a
way the implementation can control clients can expect one id to
map to one object. For sequences with no accession number, this
method should return a stringified memory location.
Returns : A string
Args : If an arg is provided, it will replace the existing
primary_id in the object.
=cut
sub primary_id {
my ($self,@args) = @_;
if( $self->can('throw') ) {
$self->throw("Bio::Seq::QualI definition of qual - implementing class did not provide this method");
} else {
confess("Bio::Seq::QualI definition of qual - implementing class did not provide this method");
}
}
=head2 can_call_new()
Title : can_call_new()
Usage : if( $obj->can_call_new ) {
$newobj = $obj->new( %param );
}
Function: can_call_new returns 1 or 0 depending on whether an
implementation allows new constructor to be called. If a new
constructor is allowed, then it should take the followed hashed
constructor list.
$myobject->new( -qual => $quality_as_string,
-display_id => $id,
-accession_number => $accession,
);
Example :
Returns : 1 or 0
Args :
=cut
sub can_call_new{
my ($self,@args) = @_;
# we default to 0 here
return 0;
}
=head2 qualat($position)
Title : qualat($position)
Usage : $quality = $obj->qualat(10);
Function: Return the quality value at the given location, where the
first value is 1 and the number is inclusive, ie 1-2 are the first
two bases of the sequence. Start cannot be larger than end but can
be equal.
Returns : A scalar.
Args : A position.
=cut
sub qualat {
my ($self,$value) = @_;
if( $self->can('warn') ) {
$self->warn("Bio::Seq::QualI definition of qualat - implementing class did not provide this method");
} else {
warn("Bio::Seq::QualI definition of qualat - implementing class did not provide this method");
}
return '';
}
=head1 Optional Implementation Functions
The following functions rely on the above functions. A implementing
class does not need to provide these functions, as they will be
provided by this class, but is free to override these functions.
All of revcom(), trunc(), and translate() create new sequence
objects. They will call new() on the class of the sequence object
instance passed as argument, unless can_call_new() returns FALSE. In
the latter case a Bio::PrimarySeq object will be created. Implementors
which really want to control how objects are created (eg, for object
persistence over a database, or objects in a CORBA framework), they
are encouraged to override these methods
=head2 revcom
Title : revcom
Usage : @rev = @{$qual->revcom()};
Function: Produces a new Bio::Seq::QualI implementing object which
is reversed from the original quality array.
The id is the same id as the original sequence, and the accession number
is also identical. If someone wants to track that this sequence has
been reversed, it needs to define its own extensions
To do an inplace edit of an object you can go:
$qual = $qual->revcom();
This of course, causes Perl to handle the garbage collection of the old
object, but it is roughly speaking as efficient as an inplace edit.
Returns : A new (fresh) Bio::Seq::PrimaryQualI object
Args : none
=cut
sub revcom{
my ($self) = @_;
# this is the cleanest way
my @qualities = @{$self->qual()};
my @reversed_qualities = reverse(@qualities);
my $seqclass;
if($self->can_call_new()) {
$seqclass = ref($self);
} else {
$seqclass = 'Bio::Seq::PrimaryQual';
# Wassat?
# $self->_attempt_to_load_Seq();
}
# the \@reverse_qualities thing works simply because I will it to work.
my $out = $seqclass->new( '-qual' => \@reversed_qualities,
'-display_id' => $self->display_id,
'-accession_number' => $self->accession_number,
'-desc' => $self->desc()
);
return $out;
}
=head2 trunc()
Title : trunc
Usage : $subseq = $myseq->trunc(10,100);
Function: Provides a truncation of a sequence,
Returns : a fresh Bio::Seq::QualI implementing object
Args : Two integers denoting first and last base of the sub-sequence.
=cut
sub trunc {
my ($self,$start,$end) = @_;
if( !$end ) {
if( $self->can('throw') ) {
$self->throw("trunc start,end");
} else {
confess("[$self] trunc start,end");
}
}
if( $end < $start ) {
if( $self->can('throw') ) {
$self->throw("$end is smaller than $start. if you want to truncated and reverse complement, you must call trunc followed by revcom. Sorry.");
} else {
confess("[$self] $end is smaller than $start. If you want to truncated and reverse complement, you must call trunc followed by revcom. Sorry.");
}
}
my $r_qual = $self->subqual($start,$end);
my $seqclass;
if($self->can_call_new()) {
$seqclass = ref($self);
} else {
$seqclass = 'Bio::Seq::PrimaryQual';
# wassat?
# $self->_attempt_to_load_Seq();
}
my $out = $seqclass->new( '-qual' => $r_qual,
'-display_id' => $self->display_id,
'-accession_number' => $self->accession_number,
'-desc' => $self->desc()
);
return $out;
}
=head2 translate()
Title : translate()
Usage : $protein_seq_obj = $dna_seq_obj->translate
#if full CDS expected:
$protein_seq_obj = $cds_seq_obj->translate(undef,undef,undef,undef,1);
Function: Completely useless in this interface.
Returns : Nothing.
Args : Nothing.
=cut
sub translate {
return 0;
}
=head2 id()
Title : id()
Usage : $id = $qual->id()
Function: ID of the quality. This should normally be (and actually is in
the implementation provided here) just a synonym for display_id().
Example :
Returns : A string.
Args :
=cut
sub id {
my ($self)= @_;
return $self->display_id();
}
=head2 length()
Title : length()
Usage : $length = $qual->length();
Function: Return the length of the array holding the quality values.
Under most circumstances, this should match the number of quality
values but no validation is done when the PrimaryQual object is
constructed and non-digits could be put into this array. Is this a
bug? Just enough rope...
Returns : A scalar (the number of elements in the quality array).
Args : None.
=cut
sub length {
my ($self)= @_;
if( $self->can('throw') ) {
$self->throw("Bio::Seq::QualI definition of length - implementing class did not provide this method");
} else {
confess("Bio::Seq::QualI definition of length - implementing class did not provide this method");
}
}
=head2 desc()
Title : desc()
Usage : $qual->desc($newval);
$description = $seq->desc();
Function: Get/set description text for a qual object
Example :
Returns : value of desc
Args : newvalue (optional)
=cut
sub desc {
my ($self,$value) = @_;
if( $self->can('warn') ) {
$self->warn("Bio::Seq::QualI definition of desc - implementing class did not provide this method");
} else {
warn("Bio::Seq::QualI definition of desc - implementing class did not provide this method");
}
return '';
}
# These methods are here for backward compatibility with the old, 0.5
# Seq objects. They all throw warnings that someone is using a
# deprecated method, and may eventually be removed completely from
# this object. However, they are important to ease the transition from
# the old system.
=head1 Private functions
These are some private functions for the PrimarySeqI interface. You do not
need to implement these functions
=head2 _attempt_to_load_Seq
Title : _attempt_to_load_Seq
Usage :
Function:
Example :
Returns :
Args :
=cut
sub _attempt_to_load_Seq{
my ($self) = @_;
if( $main::{'Bio::Seq::PrimaryQual'} ) {
return 1;
} else {
eval {
require Bio::Seq::PrimaryQual;
};
if( $@ ) {
if( $self->can('throw') ) {
$self->throw("Bio::Seq::PrimaryQual could not be loaded for $self\nThis indicates that you are using Bio::Seq::PrimaryQualI without Bio::Seq::PrimaryQual loaded and without providing a complete solution\nThe most likely problem is that there has been a misconfiguration of the bioperl environment\nActual exception\n\n$@\n");
} else {
confess("Bio::Seq::PrimarySeq could not be loaded for $self\nThis indicates that you are usnig Bio::Seq::PrimaryQualI without Bio::Seq::PrimaryQual loaded and without providing a complete solution\nThe most likely problem is that there has been a misconfiguration of the bioperl environment\nActual exception\n\n$@\n");
}
return 0;
}
return 1;
}
}
=head2 qualtype()
Title : qualtype()
Usage : if( $obj->qualtype eq 'phd' ) { /Do Something/ }
Function: At this time, this function is not used for
Bio::Seq::PrimaryQual objects. In fact, now it is a month later and
I just completed the Bio::Seq::SeqWithQuality object and this is
definitely deprecated.
Returns : Nothing. (not implemented)
Args : none
Status : Virtual
=cut
sub qualtype {
my ($self,@args) = @_;
if( $self->can('throw') ) {
# $self->throw("Bio::Seq::QualI definition of qual - implementing class did not provide this method");
$self->throw("qualtypetype is not used with quality objects.");
} else {
# confess("Bio::Seq::QualI definition of qual - implementing class did not provide this method");
confess("qualtype is not used with quality objects.");
}
}
1;
|