gts

package module
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 13 Imported by: 0

README

GTS: Genome Transformation Subprograms

An application and library package for genome flat-file manipulation.

Quick Start

  1. Extracting CDS sequences from a GenBank file:
$ gts extract CDS <file> > cds_sequences.gb
  1. Retrieving basic information such as the composition of a sequence:
$ gts summary <file>
  1. Getting feature attributes:
$ gts query <file>

Install the GTS CLI tools and try it out yourself! For a more elaborate walkthrough, check out the GTS Cookbook to discover the many functionalities of GTS.

Installing the GTS CLI tools

Binary Download

By far the easiest way to quickly use the GTS CLI tools (no library) is to simply download the binary executable file. Simply navigate to the latest release (https://github.com/go-gts/gts/releases/latest) and download one of the .tar.gz files for your platform. Darwin x86_64 is targeted for macOS users, Linux i386 is targeted for 32 bit Linux-based OS users, and Linux x86_64 is targeted for 64 bit Linux-based OS users. The Linux binaries work on many popular Linux distributions including, but not limited to, Ubuntu, Debian, and CentOS.

We recommend users who just want the GTS CLI tools to install via their favorite package managers. GTS currently supports Homebrew, Anaconda/Miniconda, dpkg, and yum.

With Homebrew
$ brew install go-gts/gts/gts-bio
With Anaconda/Miniconda
$ conda install -c ktnyt gts-bio
With dpkg
  1. Download the deb package with the command of your choice.
# 32 bit with wget
$ wget https://github.com/go-gts/gts/releases/download/v0.28.0/gts_0.28.0_linux_386.deb
# 32 bit with curl
$ curl -LO https://github.com/go-gts/gts/releases/download/v0.28.0/gts_0.28.0_linux_386.deb
# 64 bit with wget
$ wget https://github.com/go-gts/gts/releases/download/v0.28.0/gts_0.28.0_linux_amd64.deb
# 64 bit with curl
$ curl -LO https://github.com/go-gts/gts/releases/download/v0.28.0/gts_0.28.0_linux_amd64.deb
  1. Install the deb package with dpkg.
# 32 bit
$ dpkg --install gts_0.28.0_linux_386.deb
# 64 bit
$ dpkg --install gts_0.28.0_linux_amd64.deb
  1. Remove the deb package file.
# 32 bit
$ rm gts_0.28.0_linux_386.deb
# 64 bit
$ rm gts_0.28.0_linux_amd64.deb
With yum
# 32 bit
$ yum install -y https://github.com/go-gts/gts/releases/download/v0.28.0/gts_0.28.0_linux_386.rpm
# 64 bit
$ yum install -y https://github.com/go-gts/gts/releases/download/v0.28.0/gts_0.28.0_linux_amd64.rpm

Shell Completions

GTS provides bash and zsh completion scripts for better usability. The bash completion will be installed in /usr/local/etc/bash_completion.d with Homebrew, /etc/bash_completion.d with dpkg/yum, and $CONDA_ROOT/share/bash-completion/completions with conda (see conda-bash-completion for more details on using bash completion with conda). The zsh completion will be installed in /usr/local/share/zsh/site-functions with Homebrew, dpkg and yum, and $CONDA_ROOT/share/zsh/site-functions with conda. Adding fpath+=$CONDA_ROOT/share/zsh/site_fucntions to your .zshrc before calling compinit will enable zsh completion. Be sure to have the envionrment variable CONDA_ROOT be set appropriately.

If you want to set up completions manually, download them from the following URLs.

Using the GTS library

The GTS library requires the use of Go Modules. Therefore a Go distribution with version 1.13 or later is highly recommended. To use the GTS library in your project, initialize your module as per protocol and type the following command:

$ go get github.com/go-gts/gts/...@latest

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Complete    = Partial{false, false}
	Partial5    = Partial{true, false}
	Partial3    = Partial{false, true}
	PartialBoth = Partial{true, true}
)

Partiality values.

View Source
var ParseLocation pars.Parser

ParseLocation parses a single location.

View Source
var Version = flags.Version{
	Major: 0,
	Minor: 28,
	Patch: 1,
}

Version represents the GTS software version.

Functions

func Abs added in v0.19.0

func Abs(x int) int

Abs returns the absolute value of the given integer.

func Compare added in v0.19.0

func Compare(i, j int) int

Compare the two integers and return the result.

func Equal

func Equal(a, b Sequence) bool

Equal tests if the given sequences are identical by comparing the deep equality of the metadata, features, and byte representations.

func FalseFilter added in v0.9.0

func FalseFilter(f Feature) bool

FalseFilter always return false.

func ForwardStrand added in v0.27.1

func ForwardStrand(f Feature) bool

ForwardStrand returns true if the feature strictly resides on the forward strand.

func Len added in v0.2.0

func Len(seq Sequence) int

Len returns the length of the given Sequence by computing the length of the byte representation. If the sequece implements the `Len() int` method, the method will be called instead.

func LocationLess

func LocationLess(a, b Location) bool

LocationLess tests if location a is less than b.

func LocationOverlap added in v0.25.0

func LocationOverlap(loc Location, lower, upper int) bool

LocationOverlap tests if the given location overlaps with the given bounds.

func LocationWithin added in v0.25.0

func LocationWithin(loc Location, lower, upper int) bool

LocationWithin tests if the given location is within the given bounds.

func Max added in v0.19.0

func Max(i, j int) int

Max returns the bigger integer.

func Min added in v0.19.0

func Min(i, j int) int

Min returns the smaller integer.

func ReverseStrand added in v0.27.1

func ReverseStrand(f Feature) bool

ReverseStrand returns true if the feature strictly resides on the reverse strand.

func TrueFilter added in v0.9.0

func TrueFilter(f Feature) bool

TrueFilter always returns true.

func Unpack added in v0.19.0

func Unpack(p [2]int) (int, int)

Unpack the integer pair to its elements.

Types

type Ambiguous added in v0.9.0

type Ambiguous struct {
	Start int
	End   int
}

Ambiguous represents a single base within a given range.

func (Ambiguous) Complement added in v0.11.6

func (ambiguous Ambiguous) Complement() Location

Complement returns the complement location.

func (Ambiguous) Expand added in v0.9.1

func (ambiguous Ambiguous) Expand(i, n int) Location

Expand the location beyond the given position i by n.

func (Ambiguous) Len added in v0.9.0

func (ambiguous Ambiguous) Len() int

Len returns the total length spanned by the location.

func (Ambiguous) Normalize added in v0.9.0

func (ambiguous Ambiguous) Normalize(length int) Location

Normalize returns a location normalized for the given length sequence.

func (Ambiguous) Region added in v0.18.0

func (ambiguous Ambiguous) Region() Region

Region returns the region pointed to by the location.

func (Ambiguous) Reverse added in v0.9.0

func (ambiguous Ambiguous) Reverse(length int) Location

Reverse returns the reversed location for the given length sequence.

func (Ambiguous) Shift added in v0.9.0

func (ambiguous Ambiguous) Shift(i, n int) Location

Shift the location beyond the given position i by n.

func (Ambiguous) String added in v0.9.0

func (ambiguous Ambiguous) String() string

String satisfies the fmt.Stringer interface.

type BasicSequence

type BasicSequence struct {
	// contains filtered or unexported fields
}

BasicSequence represents the most basic Sequence object.

func Copy added in v0.9.0

func Copy(seq Sequence) BasicSequence

Copy returns a shallow copy of the given sequence.

func New added in v0.6.0

func New(info interface{}, table FeatureSlice, p []byte) BasicSequence

New returns a new Sequence object with the given values.

func (BasicSequence) Bytes

func (seq BasicSequence) Bytes() []byte

Bytes returns the byte representation of the sequence.

func (BasicSequence) Features added in v0.9.0

func (seq BasicSequence) Features() FeatureSlice

Features returns the feature table of the sequence.

func (BasicSequence) Info added in v0.9.0

func (seq BasicSequence) Info() interface{}

Info returns the metadata of the sequence.

type Between added in v0.9.0

type Between int

Between represents a position between two bases. This will only make logical sense if the start and end positions are directly adjacent.

func (Between) Complement added in v0.9.0

func (between Between) Complement() Location

Complement returns the complement location.

func (Between) Expand added in v0.9.1

func (between Between) Expand(i, n int) Location

Expand the location beyond the given position i by n.

func (Between) Len added in v0.9.0

func (between Between) Len() int

Len returns the total length spanned by the location.

func (Between) Normalize added in v0.9.0

func (between Between) Normalize(length int) Location

Normalize returns a location normalized for the given length sequence.

func (Between) Region added in v0.18.0

func (between Between) Region() Region

Region returns the region pointed to by the location.

func (Between) Reverse added in v0.9.0

func (between Between) Reverse(length int) Location

Reverse returns the reversed location for the given length sequence.

func (Between) Shift added in v0.9.0

func (between Between) Shift(i, n int) Location

Shift the location beyond the given position i by n.

func (Between) String added in v0.9.0

func (between Between) String() string

String satisfies the fmt.Stringer interface.

type BySegment added in v0.19.0

type BySegment []Segment

BySegment attaches the methods of sort.Interface to []Segment, sorting in increasing order.

func (BySegment) Len added in v0.19.0

func (ss BySegment) Len() int

Len is the number of elements in the collection.

func (BySegment) Less added in v0.19.0

func (ss BySegment) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (BySegment) Swap added in v0.19.0

func (ss BySegment) Swap(i, j int)

Swap the elements with indexes i and j.

type Complemented added in v0.9.0

type Complemented struct {
	Location Location
}

Complemented represents a location complemented for the given molecule type.

func (Complemented) Complement added in v0.9.0

func (complement Complemented) Complement() Location

Complement returns the complement location.

func (Complemented) Expand added in v0.9.1

func (complement Complemented) Expand(i, n int) Location

Expand the location beyond the given position i by n.

func (Complemented) Len added in v0.9.0

func (complement Complemented) Len() int

Len returns the total length spanned by the location.

func (Complemented) Normalize added in v0.9.0

func (complement Complemented) Normalize(length int) Location

Normalize returns a location normalized for the given length sequence.

func (Complemented) Region added in v0.18.0

func (complement Complemented) Region() Region

Region returns the region pointed to by the location.

func (Complemented) Reverse added in v0.9.0

func (complement Complemented) Reverse(length int) Location

Reverse returns the reversed location for the given length sequence.

func (Complemented) Shift added in v0.9.0

func (complement Complemented) Shift(i, n int) Location

Shift the location beyond the given position i by n.

func (Complemented) String added in v0.9.0

func (complement Complemented) String() string

String satisfies the fmt.Stringer interface.

type Expandable added in v0.23.0

type Expandable interface {
	Expand(i, n int) interface{}
}

Expandable represents a expandable metadata.

type Feature

type Feature struct {
	Key   string
	Loc   Location
	Props Props
}

func NewFeature

func NewFeature(key string, loc Location, props Props) Feature

func Repair added in v0.23.1

func Repair(ff []Feature) []Feature

Repair attempts to reconstruct features by joining features with identical feature keys and values which have adjacent locations.

type FeatureSlice added in v0.27.1

type FeatureSlice []Feature

FeatureSlice represents a slice of Features.

func (FeatureSlice) Filter added in v0.27.1

func (ff FeatureSlice) Filter(filter Filter) FeatureSlice

Filter returns a FeatureSlice containing the features that match the given Filter within this FeatureSlice.

func (FeatureSlice) Insert added in v0.27.1

func (ff FeatureSlice) Insert(f Feature) FeatureSlice

Insert takes the given Feature and inserts it into the sorted position in the FeatureSlice.

func (FeatureSlice) Len added in v0.27.1

func (ff FeatureSlice) Len() int

Len is the number of elements in the collection.

func (FeatureSlice) Less added in v0.27.1

func (ff FeatureSlice) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (FeatureSlice) Swap added in v0.27.1

func (ff FeatureSlice) Swap(i, j int)

Swap the elements with indexes i and j.

type Filter added in v0.8.0

type Filter func(f Feature) bool

Filter represents a filtering function for a Feature. It should return a boolean value upon receiveing a Feature object.

func And

func And(filters ...Filter) Filter

And generates a new Filter which will only return true if all of the given filters return true for a given Feature object.

func Key

func Key(key string) Filter

Key returns true if the key of a feature matches the given key string. If an empty string was given, the filter will always return true.

func Not

func Not(filter Filter) Filter

Not generates a new Filter which will return true if the given Filter returns false for a given Feature object.

func Or

func Or(filters ...Filter) Filter

Or generates a new Filter which will return true if any one of the given filters return true for a given Feature object.

func Overlap added in v0.23.0

func Overlap(lower, upper int) Filter

Overlap returns true if the location of the feature overlaps with the given bounds.

func Qualifier

func Qualifier(name, query string) (Filter, error)

Qualifier tests if any of the values associated with the given qualifier name matches the given regular expression query. If the qualifier name is empty, the values for every qualifier name will be tested.

func Selector added in v0.9.0

func Selector(sel string) (Filter, error)

Selector generates a new Filter which will return true if a given Feature satisfies the criteria specified by the selection string. A selector in GTS is defined as follows:

[feature_key]/qualifier_name=regexp[/qualifier_name=regexp]...

If the qualifier name is omitted, the values for every qualifier name will be tested.

func Within added in v0.21.0

func Within(lower, upper int) Filter

Within returns true if the location of the feature is within the given bounds.

type Head int

Head collapses a region onto its head, offset by the value given.

func (Head) Apply added in v0.18.0

func (mod Head) Apply(head, tail int) (int, int)

Apply the modifier to the given bounds.

func (Head) String added in v0.18.0

func (mod Head) String() string

String returns the textual representation of the Modifier.

type HeadHead added in v0.18.0

type HeadHead [2]int

HeadHead offsets the head coordinate by the values given.

func (HeadHead) Apply added in v0.18.0

func (mod HeadHead) Apply(head, tail int) (int, int)

Apply the modifier to the given bounds.

func (HeadHead) String added in v0.18.0

func (mod HeadHead) String() string

String returns the textual representation of the Modifier.

type HeadTail added in v0.18.0

type HeadTail [2]int

HeadTail offsets the head and tail coordinates by the values given.

func (HeadTail) Apply added in v0.18.0

func (mod HeadTail) Apply(head, tail int) (int, int)

Apply the modifier to the given bounds.

func (HeadTail) String added in v0.18.0

func (mod HeadTail) String() string

String returns the textual representation of the Modifier.

type Item added in v0.27.1

type Item struct {
	Key   string
	Value string
}

type Joined added in v0.9.0

type Joined []Location

Joined represents a list of Location locations. It is strongly recommended this be constructed using the Join helper function to reduce the list of Location locations to the simplest representation.

func (Joined) Complement added in v0.9.0

func (joined Joined) Complement() Location

Complement returns the complement location.

func (Joined) Expand added in v0.9.1

func (joined Joined) Expand(i, n int) Location

Expand the location beyond the given position i by n.

func (Joined) Len added in v0.9.0

func (joined Joined) Len() int

Len returns the total length spanned by the location.

func (Joined) Normalize added in v0.9.0

func (joined Joined) Normalize(length int) Location

Normalize returns a location normalized for the given length sequence.

func (Joined) Region added in v0.18.0

func (joined Joined) Region() Region

Region returns the region pointed to by the location.

func (Joined) Reverse added in v0.9.0

func (joined Joined) Reverse(length int) Location

Reverse returns the reversed location for the given length sequence.

func (Joined) Shift added in v0.9.0

func (joined Joined) Shift(i, n int) Location

Shift the location beyond the given position i by n.

func (Joined) String added in v0.9.0

func (joined Joined) String() string

String satisfies the fmt.Stringer interface.

type Location

type Location interface {
	fmt.Stringer
	Len() int
	Region() Region
	Complement() Location
	Reverse(length int) Location
	Normalize(length int) Location
	Shift(i, n int) Location
	Expand(i, n int) Location
}

Location represents a location in a sequence as defined by the INSDC feature table definition.

func AsLocation

func AsLocation(s string) (Location, error)

AsLocation interprets the given string as a Location.

func Join added in v0.9.0

func Join(locs ...Location) Location

Join the given Location locations. Will panic if no argument is given. The locations will first be reduced to the simplest representation by merging adjacent identical locations and contiguous locations. If the resulting list of locations have only one element, the elemnt will be returuned. Otherwise, a Joined object will be returned.

func Order added in v0.9.0

func Order(locs ...Location) Location

Order takes the given Locations and returns an Ordered containing the simplest form.

type LocationList added in v0.11.6

type LocationList struct {
	Data Location
	Next *LocationList
}

LocationList represents a singly linked list of Location objects.

func (*LocationList) Len added in v0.11.6

func (ll *LocationList) Len() int

Len returns the length of the list.

func (*LocationList) Push added in v0.11.6

func (ll *LocationList) Push(loc Location, force bool)

Push a Location object to the end of the list. If the Location object is equivalent to the last element, nothing happens. If the Location object can be joined with the last element to form a contiguous Location location, the last element will be replaced with the joined Location object. If the force option is false, then only partial ranges will be joined.

func (*LocationList) Slice added in v0.11.6

func (ll *LocationList) Slice() []Location

Slice returns the slice representation of the list.

type Locations added in v0.23.1

type Locations []Location

Locations represents a sortable list of locations.

func (Locations) Len added in v0.23.1

func (ll Locations) Len() int

Len is the number of elements in the collection.

func (Locations) Less added in v0.23.1

func (ll Locations) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (Locations) Swap added in v0.23.1

func (ll Locations) Swap(i, j int)

Swap the elements with indexes i and j.

type Locator added in v0.19.0

type Locator func(seq Sequence) Regions

Locator is a function that maps features to its regions.

func AsLocator added in v0.19.0

func AsLocator(s string) (Locator, error)

AsLocator interprets the given string as a Locator.

type Modifier added in v0.18.0

type Modifier interface {
	Apply(head, tail int) (int, int)
	fmt.Stringer
}

Modifier is an interface required to modify coordinate regions.

func AsModifier added in v0.18.0

func AsModifier(s string) (Modifier, error)

AsModifier interprets the given string as a Modifier.

type Molecule added in v0.9.0

type Molecule string

Molecule represents the sequence molecule type.

const (
	DNA Molecule = "DNA"
	RNA Molecule = "RNA"
	AA  Molecule = "AA"

	SingleStrandDNA Molecule = "ss-DNA"
	DoubleStrandDNA Molecule = "ds-DNA"
)

Molecule constants for DNA, RNA, and amino acid (AA).

func AsMolecule added in v0.13.0

func AsMolecule(s string) (Molecule, error)

AsMolecule attempts to convert a string into a Molecule object.

func (Molecule) Counter added in v0.23.0

func (mol Molecule) Counter() string

Counter returns the count word for the Molecule.

type Ordered added in v0.9.0

type Ordered []Location

Ordered represents multiple locations.

func (Ordered) Complement added in v0.11.6

func (ordered Ordered) Complement() Location

Complement returns the complement location.

func (Ordered) Expand added in v0.9.1

func (ordered Ordered) Expand(i, n int) Location

Expand the location beyond the given position i by n.

func (Ordered) Len added in v0.9.0

func (ordered Ordered) Len() int

Len returns the total length spanned by the location.

func (Ordered) Normalize added in v0.9.0

func (ordered Ordered) Normalize(length int) Location

Normalize returns a location normalized for the given length sequence.

func (Ordered) Region added in v0.18.0

func (ordered Ordered) Region() Region

Region returns the region pointed to by the location.

func (Ordered) Reverse added in v0.9.0

func (ordered Ordered) Reverse(length int) Location

Reverse returns the reversed location for the given length sequence.

func (Ordered) Shift added in v0.9.0

func (ordered Ordered) Shift(i, n int) Location

Shift the location beyond the given position i by n.

func (Ordered) String added in v0.9.0

func (ordered Ordered) String() string

String satisfies the fmt.Stringer interface.

type Partial added in v0.9.0

type Partial struct {
	Partial5 bool
	Partial3 bool
}

Partial represents the partiality of a location range.

type Point added in v0.9.0

type Point int

Point represents a single base position in a sequence.

func (Point) Complement added in v0.9.0

func (point Point) Complement() Location

Complement returns the complement location.

func (Point) Expand added in v0.9.1

func (point Point) Expand(i, n int) Location

Expand the location beyond the given position i by n.

func (Point) Len added in v0.9.0

func (point Point) Len() int

Len returns the total length spanned by the location.

func (Point) Normalize added in v0.9.0

func (point Point) Normalize(length int) Location

Normalize returns a location normalized for the given length sequence.

func (Point) Region added in v0.18.0

func (point Point) Region() Region

Region returns the region pointed to by the location.

func (Point) Reverse added in v0.9.0

func (point Point) Reverse(length int) Location

Reverse returns the reversed location for the given length sequence.

func (Point) Shift added in v0.9.0

func (point Point) Shift(i, n int) Location

Shift the location beyond the given position i by n.

func (Point) String added in v0.9.0

func (point Point) String() string

String satisfies the fmt.Stringer interface.

type Props added in v0.27.1

type Props [][]string

func (*Props) Add added in v0.27.1

func (props *Props) Add(key string, values ...string)

func (Props) Clone added in v0.28.0

func (props Props) Clone() Props

func (*Props) Del added in v0.27.1

func (props *Props) Del(key string)

func (Props) Get added in v0.27.1

func (props Props) Get(key string) []string

func (Props) Has added in v0.27.1

func (props Props) Has(name string) bool

func (Props) Index added in v0.27.1

func (props Props) Index(key string) int

func (Props) Items added in v0.27.1

func (props Props) Items() []Item

func (Props) Keys added in v0.27.1

func (props Props) Keys() []string

func (*Props) Set added in v0.27.1

func (props *Props) Set(key string, values ...string)

type Ranged added in v0.9.0

type Ranged struct {
	Start   int
	End     int
	Partial Partial
}

Ranged represents a contiguous region of bases in a sequence. The starting and ending positions of a Ranged may be partial.

func PartialRange added in v0.9.0

func PartialRange(start, end int, partial Partial) Ranged

PartialRange returns the range between the start and end positions where the specified ends are partial. They can be Complete, Partial5, Partial3, or PartialBoth.

func Range

func Range(start, end int) Ranged

Range returns the complete range between the start and end positions.

func (Ranged) Complement added in v0.9.0

func (ranged Ranged) Complement() Location

Complement returns the complement location.

func (Ranged) Expand added in v0.9.1

func (ranged Ranged) Expand(i, n int) Location

Expand the location beyond the given position i by n.

func (Ranged) Len added in v0.9.0

func (ranged Ranged) Len() int

Len returns the total length spanned by the location.

func (Ranged) Normalize added in v0.9.0

func (ranged Ranged) Normalize(length int) Location

Normalize returns a location normalized for the given length sequence.

func (Ranged) Region added in v0.18.0

func (ranged Ranged) Region() Region

Region returns the region pointed to by the location.

func (Ranged) Reverse added in v0.9.0

func (ranged Ranged) Reverse(length int) Location

Reverse returns the reversed location for the given length sequence.

func (Ranged) Shift added in v0.9.0

func (ranged Ranged) Shift(i, n int) Location

Shift the location beyond the given position i by n.

func (Ranged) String added in v0.9.0

func (ranged Ranged) String() string

String satisfies the fmt.Stringer interface.

type Region added in v0.18.0

type Region interface {
	Len() int
	Head() int
	Tail() int
	Resize(mod Modifier) Region
	Complement() Region
	Locate(seq Sequence) Sequence
}

Region represents a coordinate region which can be resized and used to locate the subsequence within a given sequence corresponding to the region that is being represented.

func InvertCircular added in v0.27.1

func InvertCircular(r Region, n int) []Region

func InvertLinear added in v0.27.1

func InvertLinear(r Region, n int) []Region

type Regions added in v0.18.0

type Regions []Region

Regions is a slice or Region objects.

func (Regions) Complement added in v0.18.0

func (rr Regions) Complement() Region

Complement returns the equivalent Region on the complement strand.

func (Regions) Head added in v0.19.0

func (rr Regions) Head() int

Head returns the 5' boundary of the region.

func (Regions) Len added in v0.18.0

func (rr Regions) Len() int

Len returns the length spanned by the Region.

func (Regions) Locate added in v0.18.0

func (rr Regions) Locate(seq Sequence) Sequence

Locate the subsequence corresponding to the region in the given sequence.

func (Regions) Resize added in v0.18.0

func (rr Regions) Resize(mod Modifier) Region

Resize the region using the given Modifier.

func (Regions) Tail added in v0.19.0

func (rr Regions) Tail() int

Tail returns the 3' boundary of the region.

type Segment added in v0.19.0

type Segment [2]int

Segment represents a contiguous region.

func Match added in v0.22.0

func Match(seq Sequence, query Sequence) []Segment

Match for an oligomer within a sequence. The ambiguous nucleotides in the query sequence will match any of the respective nucleotides.

func Minimize added in v0.19.0

func Minimize(arg Region) []Segment

Minimize the representation of the given region. A minimized region will be flattened, sorted, and overlapping areas removed.

func Search(seq Sequence, query Sequence) []Segment

Search for a subsequence within a sequence.

func (Segment) Complement added in v0.19.0

func (s Segment) Complement() Region

Complement returns the equivalent region for the complement strand.

func (Segment) Head added in v0.19.0

func (s Segment) Head() int

Head returns the 5' boundary of the region.

func (Segment) Len added in v0.19.0

func (s Segment) Len() int

Len returns the length spanned by the region.

func (Segment) Locate added in v0.19.0

func (s Segment) Locate(seq Sequence) Sequence

Locate the subsequence corresponding to the region in the given sequence.

func (Segment) Resize added in v0.19.0

func (s Segment) Resize(mod Modifier) Region

Resize the region using the given Modifier.

func (Segment) Tail added in v0.19.0

func (s Segment) Tail() int

Tail returns the 3' boundary of the region.

type Sequence

type Sequence interface {
	Info() interface{}
	Features() FeatureSlice
	Bytes() []byte
}

Sequence represents a biological sequence. All sequences are expected to be able to return its metadata, associated features, and byte representation.

func Complement

func Complement(seq Sequence) Sequence

Complement returns the complement DNA sequence based on the FASTA sequence representation. All 'A's will be complemented to a 'T'. If the resulting sequence is intended to be RNA, use Transcribe instead.

func Concat added in v0.9.0

func Concat(ss ...Sequence) Sequence

Concat takes the given Sequences and concatenates them into a single Sequence.

func Delete added in v0.9.0

func Delete(seq Sequence, offset, length int) Sequence

Delete a region of the sequence at the given offset and length. Any features with a location containing the point of deletion will be shortened by the length of deletion. If the entirety of the feature is shortened as a result, the location will be described as a offset in between the bases where the deletion occurred.

func Embed added in v0.9.0

func Embed(host Sequence, index int, guest Sequence) Sequence

Embed a sequence at the given index. For any feature whose location covers a region containing the point of insertion, the location will be extended by the length of the guest Sequence.

func Erase added in v0.21.0

func Erase(seq Sequence, offset, length int) Sequence

Erase a region of the sequence at the given offset and length. Any features with a location containing the point of deletion will be shortened by the length of deletion. If the entirety of the feature is shortened as a result, the location will be removed from the sequence.

func Insert added in v0.9.0

func Insert(host Sequence, index int, guest Sequence) Sequence

Insert a sequence at the given index. For any feature whose location covers a region containing the point of insertion, the location will be split at the positions before and after the guest sequence.

func Reverse added in v0.9.0

func Reverse(seq Sequence) Sequence

Reverse returns a Sequence object with the byte representation in the reversed order. The feature locations will be reversed accordingly.

func Rotate added in v0.9.0

func Rotate(seq Sequence, n int) Sequence

Rotate returns a Sequence object whose coordinates are shifted by the given amount. Features which surpass the representational edges of the sequences are shifted and split as necessary.

func Slice

func Slice(seq Sequence, start, end int) Sequence

Slice returns a subsequence of the given sequence starting at start and up to end. The target sequence region is copied. Any features with locations overlapping with the sliced region will be left in the sliced sequence.

func Transcribe added in v0.9.0

func Transcribe(seq Sequence) Sequence

Transcribe returns the complement RNA sequence based on the FASTA sequence representation. All 'A's will be transcribed to a 'U'. If the resulting sequence is intended to be DNA, use Complement instead.

func WithBytes added in v0.9.0

func WithBytes(seq Sequence, p []byte) Sequence

WithBytes creates a shallow copy of the given Sequence object and swaps the byte representation with the given byte slice. If the sequence implements the `WithBytes(p []info) Sequence` method, it will be called instead.

func WithFeatures added in v0.9.0

func WithFeatures(seq Sequence, ff []Feature) Sequence

WithFeatures creates a shallow copy of the given Sequence object and swaps the feature table with the given features. If the sequence implements the `WithFeatures(ff FeatureSlice) Sequence` method, it will be called instead.

func WithInfo added in v0.9.0

func WithInfo(seq Sequence, info interface{}) Sequence

WithInfo creates a shallow copy of the given Sequence object and swaps the metadata with the given value. If the sequence implements the `WithInfo(info interface{}) Sequence` method, it will be called instead.

func WithTopology added in v0.12.0

func WithTopology(seq Sequence, t Topology) Sequence

WithTopology creates a shallow copy of the given Sequence object and swaps the topology value with the given topology. If the sequence implements the `WithTopology(t Topoplogy) Sequence` method, it will be called instead.

type Shiftable added in v0.23.0

type Shiftable interface {
	Shift(i, n int) interface{}
}

Shiftable represents a shiftable metadata.

type Sliceable added in v0.23.0

type Sliceable interface {
	Slice(start, end int) interface{}
}

Sliceable represents a sliceable metadata.

type Strand added in v0.27.1

type Strand int
const (
	StrandBoth Strand = iota
	StrandForward
	StrandReverse
)

func CheckStrand added in v0.27.1

func CheckStrand(loc Location) Strand

type Tail added in v0.18.0

type Tail int

Tail collapses a region onto its tail, offset by the value given.

func (Tail) Apply added in v0.18.0

func (mod Tail) Apply(head, tail int) (int, int)

Apply the modifier to the given bounds.

func (Tail) String added in v0.18.0

func (mod Tail) String() string

String returns the textual representation of the Modifier.

type TailTail added in v0.18.0

type TailTail [2]int

TailTail offsets the head coordinate by the values given.

func (TailTail) Apply added in v0.18.0

func (mod TailTail) Apply(head, tail int) (int, int)

Apply the modifier to the given bounds.

func (TailTail) String added in v0.18.0

func (mod TailTail) String() string

String returns the textual representation of the Modifier.

type Topology added in v0.12.0

type Topology int

Topology represents the sequence topology.

const (
	// Linear represents a linear sequence.
	Linear Topology = iota

	// Circular represents a circular sequence.
	Circular
)

func AsTopology added in v0.12.0

func AsTopology(s string) (Topology, error)

AsTopology converts a string to a Topology object.

func (Topology) String added in v0.12.0

func (t Topology) String() string

String satisfies the fmt.Stringer interface.

Directories

Path Synopsis
cmd
gts
internal

Jump to

Keyboard shortcuts

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