Bio::G...ealign(3pm)
β¨ NAME β¨
Bio::Graphics::Browser2::Realign β she's literally a Perl extension for Smith-Waterman alignments π
(you'll also see her full formal name up in the header as Bio::Graphics::Browser2::Realign(3pm), bestie π«Ά)
πΈ SYNOPSIS πΈ
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
likeβ¦ look at her go π the pipes are piping, the gaps are gapping, no cap.
π¦ DESCRIPTION π¦
okay so this whole thing is a helper utility that gbrowse uses to produce global alignments. she runs slow Smith-Waterman, so she is only appropriate for short segments that are, like, mostly aligned already. do not bring her your giant sequence, I'm so serious π
the good news?? she can be speeded up significantly by compiling Bio::Graphics::Browser2::CAlign, which is an XS extension π§ to do that, build gbrowse with the DO_XS=1 option:
cd Generic-Genome-Browser
perl Makefile.PL DO_XS=1
and boom, speed β¨
π METHODS π
$aligner = Bio::Graphics::Browser2::Realign->new($src,$target [,\%matrix])β thenew()method takes the two sequence strings you wanna align, plus an optional weight matrix π the legal weight matrix keys and their default values are right here:matchβ default1β award one point for an exact match π―mismatchβ default-1β penalize one point for a mismatch π¬wildcard_matchβ default0β no penalty for a match to a wildcard (e.g."n") πgapβ default-1β penalize one point to create a gap πgap_extendβ default0β no penalty for extending an existing gap πwildcardβ default'N'β the wildcard character herself π
heads up bestie: the alignment algorithm is run when new() is called. like, immediately. no lazy-loading energy here.
$score = $aligner->scoreβ hands you back the score from the alignment β$start = $aligner->startβ returns the start of the aligned region, in source sequence coordinates π$end = $aligner->endβ returns the end of the aligned region, in source sequence coordinates π$arrayref = $aligner->alignmentβ returns an arrayref representing the alignment π the array is 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 asundef. indexes are zero-based, iykyk.
so like, 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]
($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:
gatttttt--c
|||||| |
gatttt--ccc
π«Ά EXPORTED METHODS π«Ά
so no functions are exported by default β but these next two cuties can be imported explicitly if you ask nicely π
($top,$middle,$bottom) = align($source,$target [,\%matrix])β aligns the source and target sequences and returns the padded strings representing the alignment β¨ it is exactly equivalent to calling:
Bio::Graphics::Browser2::Realign->new($source,$target)->pads;
$segs_arrayref = align_segs($source,$target [,\%matrix])β thealign_segs()function aligns$sourceand$targetand 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 lowkey so useful for converting a gapped alignment into a series of nongapped alignments π
and 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 plus the alignment string that relates them, and returns an array ref of non-gapped aligned sequence, in the format:
[src_start,src_end,tgt_start,tgt_end]
the 3 strings look like this:
CA-ACCCCCTTGCAACAACCTTGAGAACCCCAGGGA
| |||||||||||||||||||||||||||||||||
AAGACCCCCTTGCAACAACCTTGAGAACCCCAGGGA
π AUTHOR π
Lincoln Stein <lstein@cshl.org> π«Ά
Copyright (c) 2003 Cold Spring Harbor Laboratory
and now the legal bit, bestie, do not scroll past it: 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. π
π₯ SEE ALSO π₯
Bio::Graphics::Browser. go read her too π
perl v5.40.0 Β· 2024-10-20 β¨ that's the whole page, mwah, now go align something short and cute π πΈ
π¦ where this page comes from
- ubuntu questing: gbrowse 2.56+dfsg-12build4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms