sequtils

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: BSD-3-Clause Imports: 5 Imported by: 19

Documentation

Overview

Package sequtils provides generic functions for manipulation of biogo/seq/... types.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compose

func Compose(dst, src Sliceable, fs feat.Set) error

Compose produces a composition of src defined by the features in fs. The subparts of the composition may be out of order and if features in fs specify orientation may be reversed or reverse complemented depending on the src - if src is a SliceReverser and its alphabet is a Complementor the segment will be reverse complemented, if the alphabte is not a Complementor these segments will only be reversed. If src is not a SliceREverser and a reverse segment is specified an error is returned. Composing a circular sequence returns a linear sequence.

func Join

func Join(dst, src Joinable, where int) error

Join joins a and be with the target location of b specified by where. The offset of dst will be updated if src is prepended. Join will panic if dst and src do not hold the same concrete Slice type. Circular sequences cannot be joined.

Example
var s1, s2 *offSlice

s1 = stringToOffSlice("agctgtgctga")
s2 = stringToOffSlice("CGTGCAGTCATGAGTGA")
fmt.Printf("%s %s\n", s1, s2)
Join(s1, s2, seq.Start)
fmt.Printf("%s\n", s1)

s1 = stringToOffSlice("agctgtgctga")
s2 = stringToOffSlice("CGTGCAGTCATGAGTGA")
Join(s1, s2, seq.End)
fmt.Printf("%s\n", s1)
Output:

agctgtgctga 0 CGTGCAGTCATGAGTGA 0
CGTGCAGTCATGAGTGAagctgtgctga -17
agctgtgctgaCGTGCAGTCATGAGTGA 0

func Stitch

func Stitch(dst, src Sliceable, fs feat.Set) error

Stitch produces a subsequence of src defined by fs and places the the result in dst. The subsequences are guaranteed to be in order and non-overlapping even if not provided as such. Stitching a circular sequence returns a linear sequence.

Example
s := stringToConformRangeOffSlice("aAGTATAAgtcagtgcagtgtctggcagTGCTCGTGCgtagtgaagtagGGTTAGTTTa")
f := fs{
	fe{s: 1, e: 8},
	fe{s: 28, e: 37},
	fe{s: 49, e: len(s.slice) - 1},
}
fmt.Printf("%s\n", s)
if err := Stitch(s, s, f); err == nil {
	fmt.Printf("%s\n", s)
}
Output:

aAGTATAAgtcagtgcagtgtctggcagTGCTCGTGCgtagtgaagtagGGTTAGTTTa
AGTATAATGCTCGTGCGGTTAGTTT

func Trim

func Trim(q QualityFeature, limit float64) (start, end int)

Trim uses the modified-Mott trimming function to determine the start and end positions of good sequence. http://www.phrap.org/phredphrap/phred.html

func Truncate

func Truncate(dst, src Sliceable, start, end int) error

Truncate performs a truncation on src from start to end and places the result in dst. The conformation of dst is set to linear and the offset is set to start. If dst and src are not equal, a copy of the truncation is allocated. Only circular sequences can be truncated with start > end.

Example (A)
s := stringToConformRangeOffSlice("ACGCTGACTTGGTGCACGT")
s.conf = feat.Linear
fmt.Printf("%s\n", s)
if err := Truncate(s, s, 5, 12); err == nil {
	fmt.Printf("%s\n", s)
}
Output:

ACGCTGACTTGGTGCACGT
GACTTGG
Example (B)
var (
	src = stringToConformRangeOffSlice("ACGCTGACTTGGTGCACGT")
	dst = &conformRangeOffSlice{}
)
src.conf = feat.Circular
fmt.Printf("%s Conformation = %v\n", src, src.Conformation())
if err := Truncate(dst, src, 12, 5); err == nil {
	fmt.Printf("%s\n", dst)
} else {
	fmt.Println("Error:", err)
}

src.conf = feat.Linear
fmt.Printf("%s Conformation = %v\n", src, src.Conformation())
if err := Truncate(dst, src, 12, 5); err == nil {
	fmt.Printf("%s\n", dst)
} else {
	fmt.Println("Error:", err)
}
Output:

ACGCTGACTTGGTGCACGT Conformation = circular
TGCACGTACGCT
ACGCTGACTTGGTGCACGT Conformation = linear
Error: sequtils: start position greater than end position for linear sequence

Types

type Joinable

type Joinable interface {
	SetOffset(int) error
	Slice() alphabet.Slice
	SetSlice(alphabet.Slice)
}

A Joinable can be joined to another of the same concrete type using the Join function.

type QualityFeature

type QualityFeature interface {
	feat.Feature
	EAt(int) float64
}

A QualityFeature describes a segment of sequence quality information. EAt() called with column values within Start() and End() is expected to return valid error probabilities for the zero'th row position.

type SliceReverser

type SliceReverser interface {
	Sliceable
	New() seq.Sequence
	Alphabet() alphabet.Alphabet
	SetAlphabet(alphabet.Alphabet) error
	RevComp()
	Reverse()
}

type Sliceable

type Sliceable interface {
	Start() int
	End() int
	SetOffset(int) error
	Slice() alphabet.Slice
	SetSlice(alphabet.Slice)
}

A Sliceable can be truncated, stitched and composed.

Jump to

Keyboard shortcuts

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