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

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

πŸ’– NAME πŸ’–

Bio::Graphics::Browser2::PadAlignment β€” the icon that inserts pads into a multiple alignment. Yes bestie, it literally pads. That's the whole job. πŸŽ€


✨ VERSION (CVS-info) ✨

$RCSfile: PadAlignment.pm,v $
$Revision$
$Author: lstein $
$Date: 2008-09-09 20:53:36 $

🌸 SYNOPSIS 🌸

Okay so here's the whole vibe, copy-paste ready:

use Bio::Graphics::Browser2::PadAlignment;

my @dnas = (
            dna1 =>'FFFFgatcGATCgatcGATCgatcGATCgatcGBATCgatcGATCatcGATCgatcGATCgatcGATCgatcGATgatcGATCgatcNNNNGATC',
            dna2 =>'FFgatcGATCGATCgatcNNGATCgatcGATCgatcGATCgatcGATCgatcGATCtcGATBCgatcGATCatcGATCgatcNNNNGATCFFFF',
            dna3 =>'FFFFgatcGATCgatcGATCgatcGATCgatcBBBGATCgatcGATCatcGATCBgatcGATCgatcGATCgatcGATgatcGATCgatcNNNNGATCFF',
            dna4 =>'ZZFFFFgatcGATCgatcGATCgatcGATCgatc',
            dna5 =>'ATBGGATtcttttttt',
          );

#                   target  st  en  tst ten
my @alignments = ([ 'dna2', 4,  11,  2, 9      ],
                  [ 'dna2', 16, 23,  10, 17    ],
                  [ 'dna2', 24, 32,  20, 28    ],
                  [ 'dna2', 34, 44,  29, 39    ],
                  [ 'dna2', 45, 59,  41, 55    ],
                  [ 'dna2', 62, 66,  56, 60    ],
                  [ 'dna2', 67, 74,  62, 69    ],
                  [ 'dna2', 76, 86,  71, 81    ],
                  [ 'dna2', 91, 94,  86, 89    ],

                  [ 'dna3',  4,  31, 4, 31    ],
                  [ 'dna3',  33, 33, 34, 34    ],
                  [ 'dna3',  34, 51, 36, 53    ],
                  [ 'dna3',  52, 86, 55, 89    ],
                  [ 'dna3',  91, 94, 94, 97    ],

                  [ 'dna4',  0,  31, 2,  33    ],

                  [ 'dna5',  17, 18, 0, 1    ],
                  [ 'dna5',  41, 43, 4,   6    ],
                  [ 'dna5',  85, 86, 7,   8    ],
                 );

my $align = Bio::Graphics::Browser2::PadAlignment->new(\@dnas,\@alignments);

my @padded = $align->padded_sequences;
print join "\n",@padded,"\n";
# ..FFFFgatcGATCgatcGATCgatc--GATCgatcG-B-ATCgatcGATC-atcGATC-gatcGATCgatcGAT-CgatcGATgatcGATCgatcNNNNGATC....
# ....FFgatcGATC----GATCgatcNNGATCgatcG---ATCgatcGATCgatcGATC-gatcGATC--tcGATBCgatcGATCatcGATCgatcNNNNGATCFFFF
# ..FFFFgatcGATCgatcGATCgatc--GATCgatcBBBGATCgatcGATC-atcGATCBgatcGATCgatcGAT-CgatcGATgatcGATCgatcNNNNGATCFF..
# ZZFFFFgatcGATCgatcGATCgatc--GATCgatc........................................................................
# ...................AT-----------------BG-------GAT--------------------------------------------tcttttttt.....

my $pretty = $align->alignment;
print $pretty,"\n";
# dna1   1 ..FFFFgatc GATCgatcGA TCgatc--GA TCgatcG-B- ATCgatcGAT C-atcGATC- gatcGATCga tcGAT-Cgat
# dna2   1 ....FFgatc GATC----GA TCgatcNNGA TCgatcG--- ATCgatcGAT CgatcGATC- gatcGATC-- tcGATBCgat
# dna3   1 ..FFFFgatc GATCgatcGA TCgatc--GA TCgatcBBBG ATCgatcGAT C-atcGATCB gatcGATCga tcGAT-Cgat
# dna4   1 ZZFFFFgatc GATCgatcGA TCgatc--GA TCgatc.... .......... .......... .......... ..........
# dna5   1 .......... .........A T--------- ---------- -----BGGAT ---------- ---------- ----------

# dna1  72 cGATgatcGA TCgatcNNNN GATC....
# dna2  67 cGATCatcGA TCgatcNNNN GATCFFFF
# dna3  75 cGATgatcGA TCgatcNNNN GATCFF..
# dna4  35 .......... .......... ........
# dna5   8 ---------- ----tctttt ttt.....

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so real talk: this is a utility module for pretty-printing the exact type of alignment that comes out of gbrowse β€” the kind of multiple alignment where every target is aligned to a reference genome and there are no explicit pads or other spaces in there at all. It's giving "raw data, but make it fashion." πŸ’…

For speed and ease of use, the module does not use form Bio::SeqI objects β€” it works with raw strings and alignment data structures instead. That might change tho. Lowkey TBD. πŸ™ˆ

Bestie. Listen. This module does not perform multiple alignments! It merely pretty-prints them! Do not come for it for something it never promised. 😭

πŸ’œ METHODS πŸ’œ

This section describes the methods used by this class. Slay, let's go.


$aligner = Bio::Graphics::Browser2::PadAlignment->new(\@sequences,\@alignments)

Create a new aligner, periodt. The two arguments are \@sequences, an array ref to the list of sequences to be aligned, and \@alignments, an array ref describing how the sequences are to be aligned. Two args, both array refs, no notes. ✨

\@sequences should have the following structure:

[ name1 => $sequence1,
  name2 => $sequence2,
  name3 => $sequence3 ]

The sequences will be displayed in top to bottom order in the order provided. The first sequence in the list is special because it is the reference sequence. All alignments are relative to it. Main character energy, honestly. πŸ‘‘

\@alignments should have the following structure:

[ [ target1, $start1, $end1, $tstart1, $tend1 ],
  [ target1, $start2, $end2, $tstart2, $tend2 ],
  ...
 ]

Each element of @alignments is an arrayref with five elements. Let's break it down bestie:

  1. The first element is the name of the target sequence, which must be one of the named sequences given in @sequences.
  2. The second and third elements are the start and stop position of the aligned target segment relative to the reference sequence, "name1" in the example given above.
  3. The fourth and fifth elements are the start and stop position of the aligned target segment in the coordinate space of the target.

Example:

@dnas = ('dna1' => 'ccccccaaaaaatttt',
         'dna2' => 'aaaaaa');
@alignment = ( ['dna2', 6, 11, 0, 5 ]);

Positions 0 to 5 of "dna2" align to positions 6-11 of "dna1". There it is. That's the mapping. 🫢

Heads up: sequence positions are zero based. This may change. (Classic. It's giving "we'll see." πŸ’€)

@lines = $aligner->padded_sequences

This inserts pads into the sequences and returns them as a list of strings in the order specified in new(). In a scalar context</>, this method will return a hashref in which the keys are the sequence names and the values are their padded strings. Two moods, one method. 🌈


$map = $aligner->gap_map

This returns an arrayref indicating the position of each base in the gapped reference sequence. The indexes are base positions, and the element values are their positions in the reference sequence as returned by padded_sequences().

Ngl, the gap map only provides coordinate mapping for the reference sequence. For an alternative implementation that provides gap maps for each of the targets (at the cost of speed and memory efficiency) see the section after __END__ in the source file for this module. So if you want the deluxe version, it's in there, it's just not free. 😌

$align_string = $aligner->alignment(\%origins [,\%options])

This method returns a pretty-printed string of the aligned sequences. Obsessed. πŸ’–

You may provide a hashref of sequence origins in order to control the numbers printed next to each line of the alignment. The keys of the %origins hashref are the names of the sequences, and the values are the coordinate to be assigned to the first base of the sequence. Use a negative number if you wish to indicate that the sequence has been reverse complemented (the negative number should indicate the coordinate of the first base in the provided sequence). Yes, negative = reverse complemented, write that down. πŸ“

An optional second argument, if present, contains a hash reference to a set of option=>value pairs. Three options are recognized:

  • show_mismatches 0|1 β€” if true, highlight mismatches in pink
  • show_matches 0|1 β€” if true, highlight matches in yellow
  • color_code_proteins 0|1 β€” if true, highlight amino acids thus:
    • Acidic amino acids in red
    • Basic amino acids in blue
    • Hydrophobic amino acids in <grey>grey</grey>
  • Polar amino acids in yellow
  • flip 0|1 β€” if true, reverse complement the whole alignment
Wait, that's four options in a list that says "three." Not me noticing that. πŸ™ˆ Anyway, every single one of them is listed, bestie. Nothing skipped. We keep the facts, always. πŸ’―

πŸŽ€ SEE ALSO πŸŽ€

  • Bio::Graphics::Panel
  • Bio::Graphics::Glyph
  • Bio::Graphics::Feature
  • Bio::Graphics::FeatureFile
  • Bio::Graphics::Browser
  • Bio::Graphics::Browser2::Plugin

Go read them. They're iconic too. πŸ‘‘


⭐ AUTHOR ⭐

Lincoln Stein <lstein@cshl.org>.

Copyright (c) 2002 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. (Yeah, warranty disclaimers, we love a legally-necessary moment. πŸ’…)


okay that's the whole page bestie!! You just read the manual page for Bio::G...ignment(3pm) β€” that's Bio::Graphics::Browser2::PadAlignment if we're being formal β€” from perl v5.40.0, dated 2024-10-20. Thanks for sticking around, you ate that. πŸ¦‹πŸŒΈβœ¨

πŸ“¦ where this page comes from