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";
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
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:
perl Makefile.PL DO_XS=1
- $aligner =
- 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
- $end = $aligner->end
- Return the end of the aligned region, in source sequence
- $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
For example, this alignment:
corresponds to this arrayref:
- ($top,$middle,$bottom) = $aligner->pads
- Returns the alignment as three padded strings indicating
the top, middle and bottom lines of a pretty-printed representation.
print join "\n",$aligner->pads;
Will produce this output:
No functions are exported by default, but the following two methods can be
- ($top,$middle,$bottom) = align($source,$target
- 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
- 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
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
- $segs_arrayref =
- 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 <firstname.lastname@example.org>.
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.