Bio::G...ealign(3pm)

πŸ“¦
version 2.56 Β· 5 versions
, in ubuntu questing

✨ 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]) β€” the new() 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 β€” default 1 β€” award one point for an exact match πŸ’―
    • mismatch β€” default -1 β€” penalize one point for a mismatch 😬
    • wildcard_match β€” default 0 β€” no penalty for a match to a wildcard (e.g. "n") πŸƒ
    • gap β€” default -1 β€” penalize one point to create a gap πŸ’€
    • gap_extend β€” default 0 β€” 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 as undef. 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]) β€” 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 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