Provided by: gbrowse_2.56+dfsg-3build1_all bug


       Bio::Graphics::Browser2::Realign - Perl extension for Smith-Waterman alignments


         use Bio::Graphics::Browser2::Realign 'align';
         my ($top,$middle,$bottom) = align('gattttttc','gattttccc');
         print join "\n",$top,$middle,$bottom,"\n";

         # produces:
         ||||||    |


       This is a helper utility used by gbrowse to produce global alignments.  It uses slow
       Smith-Waterman, so is only appropriate for short segments that are mostly aligned already.

       It can be speeded up significantly by compiling Bio::Graphics::Browser2::CAlign, an XS
       extension.  To do this, build gbrowse with the DO_XS=1 option:

         cd Generic-Genome-Browser
         perl Makefile.PL DO_XS=1

       $aligner = Bio::Graphics::Browser2::Realign->new($src,$target [,\%matrix])
           The new() method takes two the two sequence strings to be aligned and an optional
           weight matrix.  Legal weight matrix keys and their default values are shown here:

              Key name       Default       Description
              --------       -------       -----------

              match            1           Award one point for an exact match.
              mismatch        -1           Penalize one point for a mismatch.
              wildcard_match   0           No penalty for a match to a wildcard (e.g. "n").
              gap             -1           Penalize one point to create a gap.
              gap_extend       0           No penalty for extending an existing gap.
              wildcard         'N'         The wildcard character.

           The alignment algorithm is run when new() is called.

       $score = $aligner->score
           Return the score from the alignment.

       $start = $aligner->start
           Return the start of the aligned region, in source sequence coordinates.

       $end = $aligner->end
           Return the end of the aligned region, in source sequence coordinates.

       $arrayref = $aligner->alignment
           Return an arrayref representing the alignment.  The array will be exactly as long as
           the source sequence.  Its indexes correspond to positions on the source sequence, and
           its values correspond to positions on the target sequence.  An unaligned base is
           indicated as undef.  Indexes are zero-based.

           For example, this alignment:

             ||||||    |

           corresponds to this arrayref:

              index    value
              0[g]    0[g]
              1[a]    1[a]
              2[t]    2[t]
              3[t]    3[t]
              4[t]    4[t]
              5[t]    5[t]
              6[t]    undef
              7[t]    undef
              8[c]    8[c]

       ($top,$middle,$bottom) = $aligner->pads
           Returns the alignment as three padded strings indicating the top, middle and bottom
           lines of a pretty-printed representation.

           For example:

             print join "\n",$aligner->pads;

           Will produce this output:

             ||||||    |

       No functions are exported by default, but the following two methods can be imported

       ($top,$middle,$bottom) = align($source,$target [,\%matrix])
           Align the source and target sequences and return the padded strings representing the
           alignment.  It is exactly equivalent to calling:


       $segs_arrayref = align_segs($source,$target [,\%matrix])
           The align_segs() function aligns $source and $target and returns an array of non-
           gapped segments.  Each element of the array corresponds to a contiguous nongapped
           alignment in the format [src_start,src_end,tgt_start,tgt_end].

           This is useful for converting a gapped alignment into a series of nongapped

           In a list context this function will return a list of non-gapped segments.

       $segs_arrayref = Bio::Graphics::Browser2::Realign->pads_to_segments($seq1,$pads,$seq2)
           This class method takes two padded sequence strings and the alignment string that
           relates them and returns an array ref of non-gapped aligned sequence in the format:


           The 3 strings look like this CA-ACCCCCTTGCAACAACCTTGAGAACCCCAGGGA
                                        | |||||||||||||||||||||||||||||||||


       Lincoln Stein <>.

       Copyright (c) 2003 Cold Spring Harbor Laboratory

       This library is free software; you can redistribute it and/or modify it under the same
       terms as Perl itself.  See DISCLAIMER.txt for disclaimers of warranty.