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: gatttttt--c |||||| | gatttt--ccc
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
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.
Return the score from the alignment.
Return the start of the aligned region, in source sequence coordinates.
Return the end of the aligned region, in source sequence coordinates.
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:
gatttttt--c |||||| | gatttt--ccc
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]
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:
gatttttt--c |||||| | gatttt--ccc
No functions are exported by default, but the following two methods can be imported explicitly.
Align the source and target sequences and return the padded strings representing the alignment. It is exactly equivalent to calling:
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 alignments.
In a list context this function will return a list of non-gapped segments.
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 | ||||||||||||||||||||||||||||||||| AAGACCCCCTTGCAACAACCTTGAGAACCCCAGGGA
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.