nw

package
v0.0.0-...-7b6cf24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2012 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Needleman-Wunsch sequence alignment package

Index

Examples

Constants

This section is empty.

Variables

View Source
var LookUpN, LookUpR, LookUpP util.CTL

Default character table lookups.

Functions

This section is empty.

Types

type Aligner

type Aligner struct {
	Matrix  [][]int
	GapChar byte
	LookUp  util.CTL
}

Needleman-Wunsch aligner type. Matrix is a square scoring matrix with the last column and last row specifying gap penalties. GapChar is the character used to fill gaps. LookUp is used to translate sequance values into positions in the scoring matrix. Currently gap opening is not considered.

func (*Aligner) Align

func (self *Aligner) Align(reference, query *seq.Seq) (aln seq.Alignment, err error)

Method to align two sequences using the Smith-Waterman algorithm. Returns an alignment or an error if the scoring matrix is not square.

Example
nwsa := &seq.Seq{Seq: []byte("AGACTAGTTA")}
nwsb := &seq.Seq{Seq: []byte("GACAGACG")}

//  	 A	 C	 G	 T	 -
// A	10	-3	-1	-4	-5
// C	-3	 9	-5	 0	-5
// G	-1	-5	 7	-3	-5
// T	-4	 0	-3	 8	-5
// -	-5	-5	-5	-5	 0
nwm := [][]int{
	{10, -3, -1, -4, -5},
	{-3, 9, -5, 0, -5},
	{-1, -5, 7, -3, -5},
	{-4, 0, -3, 8, -5},
	{-4, -4, -4, -4, 0},
}

needle := &Aligner{Matrix: nwm, LookUp: LookUpN, GapChar: '-'}
if nwa, err := needle.Align(nwsa, nwsb); err == nil {
	fmt.Printf("%s\n%s\n", nwa[0].Seq, nwa[1].Seq)
}
Output:
AGACTAGTTA
-GAC-AGACG

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL