50
50
systems when these sort of objects are used. Some mapping now occurs to deal
51
51
with HSP data, however it can probably be integrated in better and most methods
52
52
do not implement it correctly yet. Also, several PrimarySeqI methods (subseq(),
53
trunc(), etc.) do not behave as expected and must be used with care.
53
trunc(), etc.) do not behave as expected and must be used with care. Due to this,
54
LocatableSeq functionality is to be refactored in a future BioPerl release.
55
However, for alignment functionality it works adequately for the time being.
55
Due to this, LocatableSeq functionality is to be refactored in a future BioPerl
56
release. However, for alignment functionality it works adequately for the time
57
If you do not need alignment functionality, L<Bio::SeqfeatureI>-implementing
58
modules may be a suitable alternative to L<Bio::LocatableSeq>. For example,
59
L<Bio::SeqFeature::Generic> and L<Bio::SeqFeature::Lite> provide methods to
60
attach a sequence to a specific region of a parent sequence and to set other
436
449
unless $resnumber =~ /^\d+$/ and $resnumber > 0;
438
451
if ($resnumber >= $self->start() and $resnumber <= $self->end()) {
442
my $current_residue = $self->start - 1;
443
my $seq = $self->seq;
444
my $strand = $self->strand || 0;
447
# @chunks = reverse $seq =~ m/[^\.\-]+|[\.\-]+/go;
448
@chunks = reverse $seq =~ m/[$RESIDUE_SYMBOLS]+|[$GAP_SYMBOLS]+/go;
450
$current_column = (CORE::length $seq) + 1;
453
# @chunks = $seq =~ m/[^\.\-]+|[\.\-]+/go;
454
@chunks = $seq =~ m/[$RESIDUE_SYMBOLS]+|[$GAP_SYMBOLS]+/go;
459
while (my $chunk = shift @chunks) {
460
# if ($chunk =~ m|^[\.\-]|o) {
461
if ($chunk =~ m|^[$GAP_SYMBOLS]|o) {
462
$current_column += $column_incr * CORE::length($chunk);
465
if ($current_residue + CORE::length($chunk) < $resnumber) {
466
$current_column += $column_incr * CORE::length($chunk);
467
$current_residue += CORE::length($chunk);
471
$current_column -= $resnumber - $current_residue;
474
$current_column += $resnumber - $current_residue;
476
return $current_column;
455
my $current_residue = $self->start - 1;
456
my $seq = $self->seq;
457
my $strand = $self->strand || 0;
460
#@chunks = reverse $seq =~ m/[^\.\-]+|[\.\-]+/go;
461
@chunks = reverse $seq =~ m/[$RESIDUE_SYMBOLS]+|[$GAP_SYMBOLS]+/go;
463
$current_column = (CORE::length $seq) + 1;
466
#@chunks = $seq =~ m/[^\.\-]+|[\.\-]+/go;
467
@chunks = $seq =~ m/[$RESIDUE_SYMBOLS]+|[$GAP_SYMBOLS]+/go;
472
while (my $chunk = shift @chunks) {
473
#if ($chunk =~ m|^[\.\-]|o) {
474
if ($chunk =~ m|^[$GAP_SYMBOLS]|o) {
475
$current_column += $column_incr * CORE::length($chunk);
478
if ($current_residue + CORE::length($chunk) < $resnumber) {
479
$current_column += $column_incr * CORE::length($chunk);
480
$current_residue += CORE::length($chunk);
484
$current_column -= $resnumber - $current_residue;
487
$current_column += $resnumber - $current_residue;
489
return $current_column;
482
495
$self->throw("Could not find residue number $resnumber");
486
500
=head2 location_from_column
488
502
Title : location_from_column
624
638
=head2 validate_seq
626
640
Title : validate_seq
627
Usage : if(! $seq->validate_seq($seq_str) ) {
641
Usage : if(! $seqobj->validate_seq($seq_str) ) {
628
642
print "sequence $seq_str is not valid for an object of
629
alphabet ",$seq->alphabet, "\n";
631
Function: Validates a given sequence string. A validating sequence string
632
must be accepted by seq(). A string that does not validate will
633
lead to an exception if passed to seq().
635
The implementation provided here does not take alphabet() into
636
account. Allowed are all letters (A-Z), numbers [0-9]
637
and common symbols used for gaps, stop codons, unknown residues,
638
and frameshifts, including '-','.','*','?','=',and '~'.
641
Returns : 1 if the supplied sequence string is valid for the object, and
643
Args : The sequence string to be validated.
643
alphabet ",$seqobj->alphabet, "\n";
645
Function: Test that the given sequence is valid, i.e. contains only valid
646
characters. The allowed characters are all letters (A-Z) and '-','.',
647
'*','?','=' and '~'. Spaces are not valid. Note that this
648
implementation does not take alphabet() into account.
649
Returns : 1 if the supplied sequence string is valid, 0 otherwise.
650
Args : - Sequence string to be validated
651
- Boolean to throw an error if the sequence is invalid
647
655
sub validate_seq {
648
my ($self,$seqstr) = @_;
649
if( ! defined $seqstr ){ $seqstr = $self->seq(); }
650
return 0 unless( defined $seqstr);
652
if((CORE::length($seqstr) > 0) &&
653
($seqstr !~ /^([$MATCHPATTERN]+)$/)) {
654
$self->warn("seq doesn't validate with [$MATCHPATTERN], mismatch is " .
655
join(",",($seqstr =~ /([^$MATCHPATTERN]+)/g)));
656
my ($self, $seqstr, $throw) = @_;
657
$seqstr = '' if not defined $seqstr;
658
$throw = 0 if not defined $throw ; # 0 for backward compatiblity
659
if ( (CORE::length $seqstr > 0 ) &&
660
($seqstr !~ /^([$MATCHPATTERN]+)$/) ) {
662
$self->throw("Failed validation of sequence '".(defined($self->id) ||
663
'[unidentified sequence]')."'. Invalid characters were: " .
664
join('',($seqstr =~ /([^$MATCHPATTERN]+)/g)));
661
672
################## DEPRECATED METHODS ##################
682
$self->deprecated(-warn_version => 1.0069,
683
-throw_version => 1.0075,
684
-message => 'Use of method no_gaps() is deprecated, use num_gaps() instead');
694
$self->deprecated( -warn_version => 1.0069,
695
-throw_version => 1.0075,
696
-message => 'Use of method no_gaps() is deprecated, use num_gaps() instead' );
697
return $self->num_gaps(@_);
688
701
=head2 no_sequences
690
703
Title : no_sequences
699
712
sub no_sequences {
701
$self->deprecated(-warn_version => 1.0069,
702
-throw_version => 1.0075,
703
-message => 'Use of method no_sequences() is deprecated, use num_sequences() instead');
704
$self->num_sequences(@_);
714
$self->deprecated( -warn_version => 1.0069,
715
-throw_version => 1.0075,
716
-message => 'Use of method no_sequences() is deprecated, use num_sequences() instead' );
717
return $self->num_sequences(@_);