[Bio] / FigKernelPackages / FullLocation.pm Repository: Repository Listing Bio

# Diff of /FigKernelPackages/FullLocation.pm

revision 1.2, Wed Jul 27 19:43:33 2005 UTC revision 1.3, Sat Jul 30 23:53:16 2005 UTC
# Line 539  Line 539
539      return \$retVal;      return \$retVal;
540  }  }
541
543
544    C<< my \$loc->ExtremeCodon(\$dir); >>
545
546    Return the most extreme codon in the specified direction. This is not always the most
547    extreme location, since the distance to the appropriate edge of the location must be
548    a multiple of 3.
549
550    =over 4
551
552    =item dir
553
554    C<first> to get the codon moving away from the beginning of the location, C<last>
555    to get the codon moving away from the end of the location.
556
557    =item RETURN
558
559    Returns the edge location of the desired codon.
560
561    =back
562
563    =cut
564
565    sub ExtremeCodon {
566        # Get the parameters.
567        my (\$self, \$dir) = @_;
568        my \$fig = \$self->{fig};
569        # The first task is to determine the starting point and direction for the
570        # search. We start by converting the direction to the same format as the
571        # location direction.
572        my \$parity = (\$dir eq 'first' ? '-' : '+');
573        # If we're moving in the opposite direction as the location, we're going to
574        # go toward the beginning of the contig; otherwise, we're going toward the
575        # end.
576        my (\$multiplier, \$endPoint);
577        if (\$parity ne \$self->Dir) {
578            (\$multiplier, \$endPoint) = (-3, 1);
579        } else {
580            (\$multiplier, \$endPoint) = (3, \$fig->contig_ln(\$self->{genomeID}, \$self->Contig));
581        }
582        # Now we need the start point, which is determined by direction of this method.
583        my \$beginPoint = (\$parity eq '-' ? \$self->PrevPoint : \$self->NextPoint);
584        # Compute the number of positions to move and add it to the begin point.
585        my \$retVal = int((\$endPoint - \$beginPoint) / \$multiplier) * \$multiplier +
586                     \$beginPoint;
587        # Return the codon found.
588        return \$retVal;
589    }
590