Lincoln D. Stein > GBrowse-2.55 > Bio::Graphics::Browser2::Realign

Download:
GBrowse-2.55.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  6
Open  1
View/Report Bugs
Source  

NAME ^

Bio::Graphics::Browser2::Realign - Perl extension for Smith-Waterman alignments

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

DESCRIPTION ^

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

METHODS

$aligner = Bio::Graphics::Browser2::Realign->new($src,$target [,\%matrix])

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 coordinates.

$end = $aligner->end

Return the end of the aligned region, in source sequence coordinates.

$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 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]
($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

No functions are exported by default, but the following two methods can be imported explicitly.

($top,$middle,$bottom) = align($source,$target [,\%matrix])

Align the source and target sequences and return 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 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.

$segs_arrayref = Bio::Graphics::Browser2::Realign->pads_to_segments($seq1,$pads,$seq2)

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:

  [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

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.

syntax highlighting: