alignment

package
v0.0.0-...-25502c3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2012 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package alignment handles aligned sequences stored as columns.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QSeq

type QSeq struct {
	ID         string
	Desc       string
	Loc        string
	SubIDs     []string
	S          [][]alphabet.QLetter
	Consensify protein.Consensifyer
	Threshold  alphabet.Qphred // Threshold for returning valid letter.
	LowQFilter seq.Filter      // How to represent below threshold letter.
	Stringify  seq.Stringify
	Meta       interface{} // No operation implicitly copies or changes the contents of Meta.
	// contains filtered or unexported fields
}

Aligned protein with quality scores.

func NewQSeq

func NewQSeq(id string, subids []string, ql [][]alphabet.QLetter, alpha alphabet.Peptide, encode alphabet.Encoding, cons protein.Consensifyer) (*QSeq, error)
Example
qm, err := NewQSeq("example alignment",
	[]string{"seq 1", "seq 2", "seq 3"},
	[][]alphabet.QLetter{
		{{'A', 40}, {'A', 40}, {'A', 40}},
		{{'C', 40}, {'C', 40}, {'C', 40}},
		{{'G', 40}, {'G', 40}, {'G', 40}},
		{{'C', 40}, {'G', 40}, {'A', 40}},
		{{'T', 40}, {'T', 40}, {'T', 40}},
		{{'G', 40}, {'G', 40}, {'G', 40}},
		{{'A', 40}, {'A', 40}, {'A', 40}},
		{{'C', 40}, {'C', 40}, {'C', 40}},
		{{'T', 40}, {'C', 40}, {'G', 40}},
		{{'T', 40}, {'T', 40}, {'T', 40}},
		{{'G', 40}, {'G', 40}, {'G', 40}},
		{{'G', 40}, {'G', 40}, {'G', 40}},
		{{'T', 40}, {'C', 40}, {'C', 40}},
		{{'G', 40}, {'G', 40}, {'G', 40}},
		{{'C', 40}, {'C', 40}, {'C', 40}},
		{{'A', 40}, {'G', 40}, {'T', 40}},
		{{'C', 40}, {'C', 40}, {'C', 40}},
		{{'G', 40}, {'A', 40}, {'A', 40}},
		{{'T', 40}, {'T', 40}, {'T', 40}},
	},
	alphabet.Protein,
	alphabet.Sanger,
	protein.QConsensify)
if err != nil {
	panic(err)
}

qaligned(qm)
Output:

ACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCAT
ACGATGACGTGGCGCTCAT

acgxtgacxtggcgcxcat

func (*QSeq) Add

func (self *QSeq) Add(n ...protein.Sequence) (err error)

Add sequences n to Alignment. Sequences in n must align start and end with the receiving alignment. Additional sequence will be clipped.

Example
fmt.Printf("%v %v\n", qm.Count(), qm)
qm.Add(protein.NewQSeq("example DNA",
	[]alphabet.QLetter{{'a', 40}, {'c', 39}, {'g', 40}, {'C', 38}, {'t', 35}, {'g', 20}},
	alphabet.Protein, alphabet.Sanger))
fmt.Printf("%v %v\n", qm.Count(), qm)
Output:

3 acgxtgacxtggcgcxcat
4 acgctgacxtggcgcxcat

func (*QSeq) Alphabet

func (self *QSeq) Alphabet() alphabet.Alphabet

func (*QSeq) AppendColumns

func (self *QSeq) AppendColumns(a ...[]alphabet.QLetter) (err error)

Append each byte of each a to the appropriate sequence in the reciever.

func (*QSeq) AppendEach

func (self *QSeq) AppendEach(a [][]alphabet.QLetter) (err error)

Append each []byte in a to the appropriate sequence in the reciever.

func (*QSeq) At

func (self *QSeq) At(pos seq.Position) alphabet.QLetter

func (*QSeq) Circular

func (self *QSeq) Circular(c bool)

func (*QSeq) Column

func (self *QSeq) Column(pos int, _ bool) (c []alphabet.Letter)

func (*QSeq) ColumnQL

func (self *QSeq) ColumnQL(pos int, _ bool) []alphabet.QLetter

func (*QSeq) Compose

func (self *QSeq) Compose(f feat.FeatureSet) (err error)

func (*QSeq) Consensus

func (self *QSeq) Consensus(_ bool) (qs *protein.QSeq)

func (*QSeq) Copy

func (self *QSeq) Copy() seq.Sequence
Example
qn = qm.Copy().(*QSeq)
qn.Set(seq.Position{Pos: 3, Ind: 2}, alphabet.QLetter{L: 't', Q: 40})
qaligned(qm)
fmt.Println()
qaligned(qn)
Output:

ACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCAT
ACGATGACGTGGCGCTCAT
acgCtg-------------

acgctgacxtggcgcxcat

ACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCAT
ACGtTGACGTGGCGCTCAT
acgCtg-------------

acgctgacxtggcgcxcat

func (*QSeq) Count

func (self *QSeq) Count() int
Example
fmt.Println(qm.Count())
Output:

4

func (*QSeq) Description

func (self *QSeq) Description() *string

Description returns a pointer to the Desc string of the sequence.

func (*QSeq) EAt

func (self *QSeq) EAt(pos seq.Position) float64

func (*QSeq) Encoding

func (self *QSeq) Encoding() alphabet.Encoding

func (*QSeq) End

func (self *QSeq) End() int

func (*QSeq) Extract

func (self *QSeq) Extract(i int) protein.Sequence

func (*QSeq) IsCircular

func (self *QSeq) IsCircular() bool

func (*QSeq) Join

func (self *QSeq) Join(p *QSeq, where int) (err error)
Example
qaligned(qn)
qn.Join(qm, seq.End)
fmt.Println()
qaligned(qn)
Output:

ACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCAT
ACGtTGACGTGGCGCTCAT
acgCtg-------------

acgctgacxtggcgcxcat

ACGCTGACTTGGTGCACGTACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCATACGGTGACCTGGCGCGCAT
ACGtTGACGTGGCGCTCATACGATGACGTGGCGCTCAT
acgCtg-------------acgCtg-------------

acgctgacxtggcgcxcatacgctgacxtggcgcxcat

func (*QSeq) Len

func (self *QSeq) Len() int

func (*QSeq) Location

func (self *QSeq) Location() *string

Location returns a pointer to the Loc string of the sequence.

func (*QSeq) Name

func (self *QSeq) Name() *string

Name returns a pointer to the ID string of the sequence.

func (*QSeq) Offset

func (self *QSeq) Offset(o int)

func (*QSeq) Protein

func (self *QSeq) Protein()

Required to satisfy protein.Sequence interface.

func (*QSeq) QDecode

func (self *QSeq) QDecode(l byte) alphabet.Qphred

func (*QSeq) QEncode

func (self *QSeq) QEncode(pos seq.Position) byte

func (*QSeq) Raw

func (self *QSeq) Raw() interface{}

Raw returns a pointer to the underlying [][]alphabet.QLetter slice.

func (*QSeq) Reverse

func (self *QSeq) Reverse()
Example
qaligned(qm)
fmt.Println()
qm.Reverse()
qaligned(qm)
Output:

ACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCAT
ACGATGACGTGGCGCTCAT
acgCtg-------------

acgctgacxtggcgcxcat

TGCACGTGGTTCAGTCGCA
TACGCGCGGTCCAGTGGCA
TACTCGCGGTGCAGTAGCA
-------------gtCgca

tacxcgcggtxcagtcgca

func (*QSeq) Set

func (self *QSeq) Set(pos seq.Position, l alphabet.QLetter)

func (*QSeq) SetE

func (self *QSeq) SetE(pos seq.Position, l float64)

func (*QSeq) SetEncoding

func (self *QSeq) SetEncoding(e alphabet.Encoding)

Set the quality encoding type to e.

func (*QSeq) Start

func (self *QSeq) Start() int

func (*QSeq) Stitch

func (self *QSeq) Stitch(f feat.FeatureSet) (err error)
Example
f := feat.FeatureSet{
	&feat.Feature{Start: -1, End: 4},
	&feat.Feature{Start: 30, End: 38},
}
qaligned(qn)
fmt.Println()
err := qn.Stitch(f)
if err != nil {
	fmt.Println(err)
} else {
	qaligned(qn)
}
Output:

ACGCTGACTTGGTGCACGTACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCATACGGTGACCTGGCGCGCAT
ACGtTGACGTGGCGCTCATACGATGACGTGGCGCTCAT
acgCtg-------------acgCtg-------------

acgctgacxtggcgcxcatacgctgacxtggcgcxcat

ACGCGTGCACGT
ACGGGCGCGCAT
ACGtGCGCTCAT
acgC--------

acgcgcgcxcat

func (*QSeq) String

func (self *QSeq) String() string

func (*QSeq) Subseq

func (self *QSeq) Subseq(start int, end int) (sub seq.Sequence, err error)

Return a subsequence from start to end, wrapping if the sequence is circular.

func (*QSeq) Truncate

func (self *QSeq) Truncate(start int, end int) (err error)
Example
qaligned(qm)
qm.Truncate(4, 12)
fmt.Println()
qaligned(qm)
Output:

TGCACGTGGTTCAGTCGCA
TACGCGCGGTCCAGTGGCA
TACTCGCGGTGCAGTAGCA
-------------gtCgca

tacxcgcggtxcagtcgca

CGTGGTTC
CGCGGTCC
CGCGGTGC
--------

cgcggtxc

type Seq

type Seq struct {
	ID         string
	Desc       string
	Loc        string
	SubIDs     []string
	S          [][]alphabet.Letter
	Consensify protein.Consensifyer
	Stringify  seq.Stringify
	Meta       interface{} // No operation implicitly copies or changes the contents of Meta.
	// contains filtered or unexported fields
}

Alignment protein sequence.

func NewSeq

func NewSeq(id string, subids []string, b [][]alphabet.Letter, alpha alphabet.Peptide, cons protein.Consensifyer) (*Seq, error)
Example
m, err := NewSeq("example alignment",
	[]string{"seq 1", "seq 2", "seq 3"},
	[][]alphabet.Letter{
		[]alphabet.Letter("AAA"),
		[]alphabet.Letter("CCC"),
		[]alphabet.Letter("GGG"),
		[]alphabet.Letter("CGA"),
		[]alphabet.Letter("TTT"),
		[]alphabet.Letter("GGG"),
		[]alphabet.Letter("AAA"),
		[]alphabet.Letter("CCC"),
		[]alphabet.Letter("TCG"),
		[]alphabet.Letter("TTT"),
		[]alphabet.Letter("GGG"),
		[]alphabet.Letter("GGG"),
		[]alphabet.Letter("TCC"),
		[]alphabet.Letter("GGG"),
		[]alphabet.Letter("CCC"),
		[]alphabet.Letter("AGT"),
		[]alphabet.Letter("CCC"),
		[]alphabet.Letter("GAA"),
		[]alphabet.Letter("TTT"),
	},
	alphabet.Protein,
	protein.Consensify)
if err != nil {
	panic(err)
}

aligned(m)
Output:

ACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCAT
ACGATGACGTGGCGCTCAT

acgxtgacxtggcgcxcat

func (*Seq) Add

func (self *Seq) Add(n ...protein.Sequence) (err error)

Add sequences n to Seq. Sequences in n must align start and end with the receiving alignment. Additional sequence will be clipped.

Example
fmt.Printf("%v %v\n", m.Count(), m)
m.Add(protein.NewQSeq("example Protein",
	[]alphabet.QLetter{{'a', 40}, {'c', 39}, {'g', 40}, {'C', 38}, {'t', 35}, {'g', 20}},
	alphabet.Protein, alphabet.Sanger))
fmt.Printf("%v %v\n", m.Count(), m)
Output:

3 acgxtgacxtggcgcxcat
4 acgctgacxtggcgcxcat

func (*Seq) Alphabet

func (self *Seq) Alphabet() alphabet.Alphabet

func (*Seq) AppendColumns

func (self *Seq) AppendColumns(a ...[]alphabet.QLetter) (err error)

Append each byte of each a to the appropriate sequence in the reciever.

func (*Seq) AppendEach

func (self *Seq) AppendEach(a [][]alphabet.QLetter) (err error)

Append each []byte in a to the appropriate sequence in the reciever.

func (*Seq) At

func (self *Seq) At(pos seq.Position) alphabet.QLetter

func (*Seq) Circular

func (self *Seq) Circular(c bool)

func (*Seq) Column

func (self *Seq) Column(pos int, _ bool) (c []alphabet.Letter)

func (*Seq) ColumnQL

func (self *Seq) ColumnQL(pos int, _ bool) (c []alphabet.QLetter)

func (*Seq) Compose

func (self *Seq) Compose(f feat.FeatureSet) (err error)

func (*Seq) Consensus

func (self *Seq) Consensus(_ bool) (qs *protein.QSeq)

func (*Seq) Copy

func (self *Seq) Copy() seq.Sequence
Example
n = m.Copy().(*Seq)
n.Set(seq.Position{Pos: 3, Ind: 2}, alphabet.QLetter{L: 't'})
aligned(m)
fmt.Println()
aligned(n)
Output:

ACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCAT
ACGATGACGTGGCGCTCAT
acgCtg-------------

acgctgacxtggcgcxcat

ACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCAT
ACGtTGACGTGGCGCTCAT
acgCtg-------------

acgctgacxtggcgcxcat

func (*Seq) Count

func (self *Seq) Count() int
Example
fmt.Println(m.Count())
Output:

4

func (*Seq) Description

func (self *Seq) Description() *string

Description returns a pointer to the Desc string of the sequence.

func (*Seq) End

func (self *Seq) End() int

func (*Seq) Extract

func (self *Seq) Extract(i int) protein.Sequence

func (*Seq) IsCircular

func (self *Seq) IsCircular() bool

func (*Seq) Join

func (self *Seq) Join(p *Seq, where int) (err error)
Example
aligned(n)
n.Join(m, seq.End)
fmt.Println()
aligned(n)
Output:

ACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCAT
ACGtTGACGTGGCGCTCAT
acgCtg-------------

acgctgacxtggcgcxcat

ACGCTGACTTGGTGCACGTACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCATACGGTGACCTGGCGCGCAT
ACGtTGACGTGGCGCTCATACGATGACGTGGCGCTCAT
acgCtg-------------acgCtg-------------

acgctgacxtggcgcxcatacgctgacxtggcgcxcat

func (*Seq) Len

func (self *Seq) Len() int

func (*Seq) Location

func (self *Seq) Location() *string

Location returns a pointer to the Loc string of the sequence.

func (*Seq) Name

func (self *Seq) Name() *string

Name returns a pointer to the ID string of the sequence.

func (*Seq) Offset

func (self *Seq) Offset(o int)

func (*Seq) Protein

func (self *Seq) Protein()

Required to satisfy protein.Sequence interface.

func (*Seq) Raw

func (self *Seq) Raw() interface{}

Raw returns a pointer to the underlying [][]byte slice.

func (*Seq) Reverse

func (self *Seq) Reverse()
Example
aligned(m)
fmt.Println()
m.Reverse()
aligned(m)
Output:

ACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCAT
ACGATGACGTGGCGCTCAT
acgCtg-------------

acgctgacxtggcgcxcat

TGCACGTGGTTCAGTCGCA
TACGCGCGGTCCAGTGGCA
TACTCGCGGTGCAGTAGCA
-------------gtCgca

tacxcgcggtxcagtcgca

func (*Seq) Set

func (self *Seq) Set(pos seq.Position, l alphabet.QLetter)

func (*Seq) Start

func (self *Seq) Start() int

func (*Seq) Stitch

func (self *Seq) Stitch(f feat.FeatureSet) (err error)
Example
f := feat.FeatureSet{
	&feat.Feature{Start: -1, End: 4},
	&feat.Feature{Start: 30, End: 38},
}
aligned(n)
fmt.Println()
err := n.Stitch(f)
if err != nil {
	fmt.Println(err)
} else {
	aligned(n)
}
Output:

ACGCTGACTTGGTGCACGTACGCTGACTTGGTGCACGT
ACGGTGACCTGGCGCGCATACGGTGACCTGGCGCGCAT
ACGtTGACGTGGCGCTCATACGATGACGTGGCGCTCAT
acgCtg-------------acgCtg-------------

acgctgacxtggcgcxcatacgctgacxtggcgcxcat

ACGCGTGCACGT
ACGGGCGCGCAT
ACGtGCGCTCAT
acgC--------

acgcgcgcxcat

func (*Seq) String

func (self *Seq) String() string

func (*Seq) Subseq

func (self *Seq) Subseq(start int, end int) (sub seq.Sequence, err error)

Return a subsequence from start to end, wrapping if the sequence is circular.

func (*Seq) Truncate

func (self *Seq) Truncate(start int, end int) (err error)
Example
aligned(m)
m.Truncate(4, 12)
fmt.Println()
aligned(m)
Output:

TGCACGTGGTTCAGTCGCA
TACGCGCGGTCCAGTGGCA
TACTCGCGGTGCAGTAGCA
-------------gtCgca

tacxcgcggtxcagtcgca

CGTGGTTC
CGCGGTCC
CGCGGTGC
--------

cgcggtxc

Jump to

Keyboard shortcuts

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