gts

package module
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2020 License: MIT Imports: 18 Imported by: 0

README

GTS: The Genomic Tool Suite

A software suite for genome flatfile manipulation.

Quick Start

Assuming you have a working Go distribution installed, installing GTS is as simple as simply running the following command:

go get gopkg.in/gts.v0/...

It is discouraged to go get from the GitHub repository.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	QuotedQualifierNames = []string{
		"allele", "altitude", "artificial_location", "bio_material",
		"bound_moiety", "cell_line", "cell_type", "chromosome",
		"clone", "clone_lib", "collected_by", "collection_date",
		"country", "cultivar", "culture_collection", "db_xref",
		"dev_stage", "EC_number", "ecotype", "exception",
		"experiment", "frequency", "function", "gap_type", "gene",
		"gene_synonym", "haplogroup", "haplotype", "host",
		"identified_by", "inference", "isolate", "isolation_source",
		"lab_host", "lat_lon", "linkage_evidence", "locus_tag", "map",
		"mating_type", "metagenome_source", "mobile_element_type",
		"mol_type", "ncRNA_class", "note", "old_locus_tag", "operon",
		"organelle", "organism", "PCR_conditions", "PCR_primers",
		"phenotype", "plasmid", "pop_variant", "product",
		"protein_id", "pseudogene", "recombination_class",
		"regulatory_class", "replace", "rpt_family", "rpt_unit_seq",
		"satellite", "segment", "serotype", "serovar", "sex",
		"specimen_voucher", "standard_name", "strain", "sub_clone",
		"submitter_seqid", "sub_species", "sub_strain", "tissue_lib",
		"tissue_type", "translation", "type_material", "variety",
	}

	LiteralQualifierNames = []string{
		"anticodon", "citation", "codon_start", "compare",
		"direction", "estimated_length", "mod_base", "number",
		"rpt_type", "rpt_unit_range", "tag_peptide", "transl_except",
		"transl_table",
	}

	ToggleQualifierNames = []string{
		"environmental_sample", "focus", "germline", "macronuclear",
		"partial", "proviral", "pseudo", "rearranged",
		"ribosomal_slippage", "transgenic", "trans_splicing",
	}
)

Names of qualifiers.

View Source
var FeatureTableParser = pars.Any(
	RecordParser.Map(func(result *pars.Result) error {
		rec := result.Value.(Record)
		ft := rec.Filter()
		result.SetValue(ft)
		return nil
	}),
	featureDecoderParser(NewGobDecoder),
	featureDecoderParser(NewMsgpackDecoder),
	featureDecoderParser(NewYAMLDecoder),
	featureDecoderParser(NewJSONDecoder),
)

FeatureTableParser attempts to parse a table of features.

View Source
var LocationParser pars.Parser

LocationParser attempts to parse some location.

View Source
var RecordParser = pars.Any(GenBankParser)

RecordParser attempts to parse a single sequence record.

Functions

func AddPrefix

func AddPrefix(s, prefix string) string

AddPrefix adds the given prefix after each newline.

func AmbiguousLocationParser

func AmbiguousLocationParser(state *pars.State, result *pars.Result) error

AmbiguousLocationParser attempts to parse a AmbiguousLocation.

func Any

func Any(f Feature) bool

Any returns true for any feature matched.

func BetweenLocationParser

func BetweenLocationParser(state *pars.State, result *pars.Result) error

BetweenLocationParser attempts to parse a BetweenLocation.

func ComplementLocationParser

func ComplementLocationParser(state *pars.State, result *pars.Result) error

ComplementLocationParser attempts to parse a ComplementLocation.

func Composition

func Composition(seq Sequence) map[byte]int

Composition computes the occurence of each byte within the Sequence.

func DecodeGob added in v0.3.0

func DecodeGob(data []byte, v Decodable) error

DecodeGob decodes the Decodable object from Gob.

func DecodeJSON added in v0.3.0

func DecodeJSON(data []byte, v Decodable) error

DecodeJSON decodes the Decodable object from JSON.

func DecoderParser added in v0.4.0

func DecoderParser(decCtor DecoderConstructor, objCtor Constructor) pars.Parser

DecoderParser creates a Parser using the Decoder and object constructed using the Constructor.

func DefaultWriter added in v0.6.0

func DefaultWriter(seq Sequence) io.WriterTo

DefaultWriter returns the default formatter for the given record.

func EncodeGob added in v0.3.0

func EncodeGob(v Encodable) ([]byte, error)

EncodeGob encodes the Encodable object as Gob.

func EncodeJSON added in v0.3.0

func EncodeJSON(v Encodable) ([]byte, error)

EncodeJSON encodes the Encodable object as JSON.

func Equal

func Equal(a, b Sequence) bool

Equal tests if the given Sequences have equal byte slice representations.

func FeatureListParser

func FeatureListParser(prefix string) pars.Parser

FeatureListParser attempts to match an INSDC feature table.

func FlatFileSplit

func FlatFileSplit(s string) []string

FlatFileSplit splits the string with the flatfile convention.

func GenBankParser

func GenBankParser(state *pars.State, result *pars.Result) error

GenBankParser attempts to parse a single GenBank record.

func Identical added in v0.6.0

func Identical(a, b Sequence) bool

Identical tests if the given Sequences have identical metadata values and byte slice representations.

func IsLiteralQualifier

func IsLiteralQualifier(name string) bool

IsLiteralQualifier tests if the given qualifier name is a literal qualifier.

func IsQuotedQualifier

func IsQuotedQualifier(name string) bool

IsQuotedQualifier tests if the given qualifier name is a quoted qualifier.

func IsToggleQualifier

func IsToggleQualifier(name string) bool

IsToggleQualifier tests if the given qualifier name is a toggle qualifier.

func JoinLocationParser

func JoinLocationParser(state *pars.State, result *pars.Result) error

JoinLocationParser attempts to parse a JoinLocation.

func Len added in v0.2.0

func Len(seq Sequence) int

Len returns the length of a Sequence.

func LocationLess

func LocationLess(a, b Location) bool

LocationLess tests if the one location is smaller than the other.

func NewRecordWriter added in v0.6.0

func NewRecordWriter(rec Record, filetype FileType) io.WriterTo

NewRecordWriter returns a record writer for the given filetype.

func NewSequenceWriter added in v0.6.0

func NewSequenceWriter(seq Sequence, filetype FileType) io.WriterTo

NewSequenceWriter returns a sequence writer for the given filetype.

func OrderLocationParser

func OrderLocationParser(state *pars.State, result *pars.Result) error

OrderLocationParser attempts to parse a OrderLocation.

func PointLocationParser

func PointLocationParser(state *pars.State, result *pars.Result) error

PointLocationParser attempts to parse a PointLocation.

func QualifierParser

func QualifierParser(prefix string) pars.Parser

QualifierParser attempts to match a single qualifier name-value pair.

func RangeLocationParser

func RangeLocationParser(state *pars.State, result *pars.Result) error

RangeLocationParser attempts to parse a RangeLocation.

func RegisterLiteralQualifier

func RegisterLiteralQualifier(names ...string)

RegisterLiteralQualifier registers the given qualifier names as being a literal qualifier (i.e. /name=value).

func RegisterQuotedQualifier

func RegisterQuotedQualifier(names ...string)

RegisterQuotedQualifier registers the given qualifier names as being a quoted qualifer (i.e. /name="value").

func RegisterToggleQualifier

func RegisterToggleQualifier(names ...string)

RegisterToggleQualifier registers the given qualifier names as being a toggle qualifier (i.e. /name).

func Skew

func Skew(seq Sequence, nSet, pSet string) float64

Skew calculates the skewness of the Sequence. Where `n` is the number of bytes in the given Sequence also appearing in the `nSet` string and `p` is the number of bytes in the given Sequence also appearing in the `pSet` string, the skewness of the Sequence is calculated as: (p - n) / (p + n).

Types

type AmbiguousLocation

type AmbiguousLocation struct {
	Start int
	End   int
}

AmbiguousLocation represents an ambiguous location.

func NewAmbiguousLocation

func NewAmbiguousLocation(start, end int) *AmbiguousLocation

NewAmbiguousLocation creates a new ambiguous location.

func (AmbiguousLocation) Len

func (loc AmbiguousLocation) Len() int

Len returns the length spanned by the location.

func (AmbiguousLocation) Locate

func (loc AmbiguousLocation) Locate(seq Sequence) Sequence

Locate the sequence at the pointing location.

func (AmbiguousLocation) Map

func (loc AmbiguousLocation) Map(index int) int

Map the given local index to a global index.

func (*AmbiguousLocation) Shift

func (loc *AmbiguousLocation) Shift(offset, amount int) (ok bool)

Shift the location position[s] if needed. Returns false if the shift invalidates the location.

func (AmbiguousLocation) String

func (loc AmbiguousLocation) String() string

String satisfies the fmt.Stringer interface.

type BetweenLocation

type BetweenLocation struct {
	Start int
	End   int
}

BetweenLocation represents a location between two points.

func NewBetweenLocation

func NewBetweenLocation(start, end int) *BetweenLocation

NewBetweenLocation creates a new BetweenLocation.

func (BetweenLocation) Len

func (loc BetweenLocation) Len() int

Len returns the length spanned by the location.

func (BetweenLocation) Locate

func (loc BetweenLocation) Locate(seq Sequence) Sequence

Locate the sequence at the pointing location.

func (BetweenLocation) Map

func (loc BetweenLocation) Map(index int) int

Map the given local index to a global index.

func (*BetweenLocation) Shift

func (loc *BetweenLocation) Shift(offset, amount int) (ok bool)

Shift the location position[s] if needed. Returns false if the shift invalidates the location.

func (BetweenLocation) String

func (loc BetweenLocation) String() string

String satisfies the fmt.Stringer interface.

type ByLocation

type ByLocation []Feature

ByLocation implements sort.Interface for []Feature by location.

func (ByLocation) Len

func (ff ByLocation) Len() int

Len is the number of elements in the feature table.

func (ByLocation) Less

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

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

func (ByLocation) Swap

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

Swap the elements with indices i and j.

type ComplementLocation

type ComplementLocation struct {
	Location Location
}

ComplementLocation represents the complement region of a location.

func NewComplementLocation

func NewComplementLocation(loc Location) *ComplementLocation

NewComplementLocation creates a new ComplementLocation.

func (ComplementLocation) Len

func (loc ComplementLocation) Len() int

Len returns the length spanned by the location.

func (ComplementLocation) Locate

func (loc ComplementLocation) Locate(seq Sequence) Sequence

Locate the sequence at the pointing location.

func (ComplementLocation) Map

func (loc ComplementLocation) Map(index int) int

Map the given local index to a global index.

func (*ComplementLocation) Shift

func (loc *ComplementLocation) Shift(offset, amount int) bool

Shift the location position[s] if needed. Returns false if the shift invalidates the location.

func (ComplementLocation) String

func (loc ComplementLocation) String() string

String satisfies the fmt.Stringer interface.

type Constructor added in v0.4.0

type Constructor func() interface{}

Constructor should construct an object.

type Date added in v0.4.0

type Date struct {
	Year  int        `json:"year" yaml:"year" msgpack:"year"`
	Month time.Month `json:"month" yaml:"month" msgpack:"month"`
	Day   int        `json:"day" yaml:"day" msgpack:"day"`
}

Date represents a date stamp for record entries.

func FromTime added in v0.4.0

func FromTime(t time.Time) Date

FromTime creates a Date from a time.Time object.

func (Date) ToTime added in v0.4.0

func (d Date) ToTime() time.Time

ToTime returns the time.Time object for the Date.

type Decodable added in v0.3.0

type Decodable interface {
	DecodeWith(dec Decoder) error
}

Decodable implements the DecodeWith method whch should decode the object using the given Decoder object.

type Decoder added in v0.3.0

type Decoder interface {
	Decode(v interface{}) error
}

Decoder implement the Decode method for reading and decoding from an input stream to the object pointed by the given value.

func NewGobDecoder added in v0.3.0

func NewGobDecoder(r io.Reader) Decoder

NewGobDecoder creates a Gob Decoder.

func NewJSONDecoder added in v0.3.0

func NewJSONDecoder(r io.Reader) Decoder

NewJSONDecoder creates a JSON Decoder.

func NewMsgpackDecoder added in v0.3.0

func NewMsgpackDecoder(r io.Reader) Decoder

NewMsgpackDecoder creates a Msgpack Decoder.

func NewYAMLDecoder added in v0.3.0

func NewYAMLDecoder(r io.Reader) Decoder

NewYAMLDecoder creates a YAML Decoder.

type DecoderConstructor added in v0.3.0

type DecoderConstructor func(io.Reader) Decoder

DecoderConstructor represents a constuctor function for a Decoder.

type Encodable added in v0.3.0

type Encodable interface {
	EncodeWith(enc Encoder) error
}

Encodable implements the EncodeTo method which should encode the object using the given Encoder object.

type Encoder added in v0.3.0

type Encoder interface {
	Encode(v interface{}) error
}

Encoder implements the Encode method for encoding and writing the given object in some serialized form.

func NewGobEncoder added in v0.4.0

func NewGobEncoder(w io.Writer) Encoder

NewGobEncoder creates a Gob Encoder.

func NewJSONEncoder added in v0.4.0

func NewJSONEncoder(w io.Writer) Encoder

NewJSONEncoder creates a JSON Encoder.

func NewMsgpackEncoder added in v0.4.0

func NewMsgpackEncoder(w io.Writer) Encoder

NewMsgpackEncoder creates a Msgpack Encoder.

func NewYAMLEncoder added in v0.4.0

func NewYAMLEncoder(w io.Writer) Encoder

NewYAMLEncoder creates a YAML Encoder.

type EncoderConstructor added in v0.3.0

type EncoderConstructor func(io.Writer) Encoder

EncoderConstructor represents a constuctor function for an Encoder.

type EncoderWriter added in v0.6.0

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

EncoderWriter provides an interface for encoding objects with the given Encoder.

func NewEncoderWriter added in v0.6.0

func NewEncoderWriter(v interface{}, ctor EncoderConstructor) EncoderWriter

NewEncoderWriter creates a new EncoderWriter.

func (EncoderWriter) WriteTo added in v0.6.0

func (f EncoderWriter) WriteTo(w io.Writer) (int64, error)

WriteTo satisfies the WriterTo interface.

type Fasta added in v0.6.0

type Fasta struct {
	Desc string
	Body []byte
}

Fasta represents a FASTA sequence object.

func (Fasta) Bytes added in v0.7.0

func (f Fasta) Bytes() []byte

Bytes returns the byte representation of the sequence.

func (*Fasta) Delete added in v0.6.0

func (f *Fasta) Delete(pos, arg int) error

Delete given number of bases from the specified position.

func (Fasta) Info added in v0.6.0

func (f Fasta) Info() interface{}

Info returns the metadata of the sequence.

func (*Fasta) Insert added in v0.6.0

func (f *Fasta) Insert(pos int, arg Sequence) error

Insert a sequence at the specified position.

func (*Fasta) Replace added in v0.6.0

func (f *Fasta) Replace(pos int, arg Sequence) error

Replace the bases from the specified position with the given sequence.

func (Fasta) String added in v0.6.0

func (f Fasta) String() string

String satisfies the fmt.Stringer interface.

func (Fasta) WriteTo added in v0.6.0

func (f Fasta) WriteTo(w io.Writer) (int64, error)

WriteTo satisfies the io.WriterTo interface.

type FastaWriter added in v0.6.0

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

FastaWriter attempts to format a sequence in FASTA format.

func (FastaWriter) WriteTo added in v0.6.0

func (ff FastaWriter) WriteTo(w io.Writer) (int64, error)

WriteTo satisfies the io.WriterTo interface.

type Feature

type Feature struct {
	Key        string
	Location   Location
	Qualifiers Values
	// contains filtered or unexported fields
}

Feature represents a single feature within a feature table.

func NewFeature

func NewFeature(key string, loc Location, qfs Values) Feature

NewFeature creates a new feature.

func (Feature) Bytes

func (f Feature) Bytes() []byte

Bytes returns the byte representation of the sequence.

func (*Feature) DecodeMsgpack added in v0.3.0

func (f *Feature) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack satisifes the msgpack.CustomDecoder interface.

func (*Feature) DecodeWith added in v0.3.0

func (f *Feature) DecodeWith(dec Decoder) (err error)

DecodeWith satisifes the Decodable interface.

func (Feature) Delete

func (f Feature) Delete(pos, cnt int) error

Delete given number of bases from the specified position.

func (Feature) EncodeMsgpack added in v0.3.0

func (f Feature) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack satisifes the msgpack.CustomEncoder interface.

func (Feature) EncodeWith added in v0.3.0

func (f Feature) EncodeWith(enc Encoder) error

EncodeWith satisfies the Encodable interface.

func (Feature) Format

func (f Feature) Format(prefix string, depth int) FeatureFormatter

Format creates a FeatureFormatter object for the qualifier with the given prefix and depth. If the Feature object was created by parsing some input, the qualifier values will be in the same order as in the input source. The exception to this rule is the `translation` qualifier which will always be written last. Qualifiers given during runtime will be sorted in ascending alphabetical order and written after the qualifiers present in the source.

func (Feature) Info added in v0.6.0

func (f Feature) Info() interface{}

Info returns the metadata of the sequence.

func (Feature) Insert

func (f Feature) Insert(pos int, seq Sequence) error

Insert a sequence at the specified position.

func (Feature) MarshalJSON added in v0.3.0

func (f Feature) MarshalJSON() ([]byte, error)

MarshalJSON satisifes the json.Marshaler interface.

func (Feature) MarshalYAML added in v0.3.0

func (f Feature) MarshalYAML() (interface{}, error)

MarshalYAML satisfies the yaml.Marshaler interface.

func (Feature) Replace

func (f Feature) Replace(pos int, seq Sequence) error

Replace the bases from the specified position with the given sequence.

func (Feature) Translation

func (f Feature) Translation() Sequence

Translation returns the translation of the feature if available. it will return nil otherwise.

func (*Feature) UnmarshalJSON added in v0.3.0

func (f *Feature) UnmarshalJSON(data []byte) error

UnmarshalJSON satisifes the json.Unmarshaler interface.

func (*Feature) UnmarshalYAML added in v0.3.0

func (f *Feature) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML satisifes the yaml.Unmarshaler interface.

type FeatureFilter added in v0.1.0

type FeatureFilter func(f Feature) bool

FeatureFilter represents a filter for selecting features.

func And

func And(ss ...FeatureFilter) FeatureFilter

And returns true if all selectors return true.

func Key

func Key(key string) FeatureFilter

Key returns true if the key of a feature matches the given key.

func Not

Not returns true if the given selector returns false.

func Or

func Or(ss ...FeatureFilter) FeatureFilter

Or returns true if any of the selectors return true.

type FeatureFormatter

type FeatureFormatter struct {
	Feature Feature
	Prefix  string
	Depth   int
}

FeatureFormatter formats a Feature object with the given prefix and depth.

func (FeatureFormatter) String

func (ff FeatureFormatter) String() string

String satisfies the fmt.Stringer interface.

func (FeatureFormatter) WriteTo

func (ff FeatureFormatter) WriteTo(w io.Writer) (int, error)

WriteTo satisfies the io.WriteTo interface.

type FeatureIO added in v0.3.0

type FeatureIO struct {
	Key        string      `json:"key" yaml:"key" msgpack:"key"`
	Location   string      `json:"location" yaml:"location" msgpack:"location"`
	Qualifiers []Qualifier `json:"qualifiers,omitempty" yaml:"qualifiers,omitempty" msgpack:"qualifiers,omitempty"`
}

FeatureIO represents a temporary object for reading and writing a Feature struct using various serialization libraries.

func NewFeatureIO added in v0.3.0

func NewFeatureIO(f Feature) FeatureIO

NewFeatureIO creates a new FeatureIO object.

func (FeatureIO) SetFeature added in v0.4.0

func (fio FeatureIO) SetFeature(f *Feature) error

SetFeature sets the fields of the given Feature pointer.

type FeatureList

type FeatureList []Feature

FeatureList represents an INSDC feature table. The features are sorted by Location in ascending order.

func ReadFeatureTable

func ReadFeatureTable(r io.Reader) (FeatureList, error)

ReadFeatureTable attempts to read and parse a table of features.

func (*FeatureList) Add

func (ff *FeatureList) Add(f Feature)

Add the feature to the feature table. The feature will be inserted in the sorted position with the exception of sources.

func (FeatureList) Filter added in v0.1.0

func (ff FeatureList) Filter(ss ...FeatureFilter) []Feature

Filter the features in the list matching the selector criteria.

func (FeatureList) Format

func (ff FeatureList) Format(prefix string, depth int) FeatureListFormatter

Format creates a FeatureFormatter object for the qualifier with the given prefix and depth.

func (*FeatureList) Insert

func (ff *FeatureList) Insert(i int, f Feature)

Insert the feature to the feature table at the given position. Note that inserting a feature that disrupts the sortedness of the features will inevitably lead to predictable yet unconventional behavior when the Add method is called later. Use Add instead if this is not desired.

type FeatureListFormatter

type FeatureListFormatter struct {
	FeatureList FeatureList
	Prefix      string
	Depth       int
}

FeatureListFormatter formats a FeatureList object with the given prefix and depth.

func (FeatureListFormatter) String

func (ff FeatureListFormatter) String() string

String satisfies the fmt.Stringer interface.

func (FeatureListFormatter) WriteTo

func (ff FeatureListFormatter) WriteTo(w io.Writer) (int64, error)

WriteTo satisfies the io.WriterTo interface.

type FeatureTable

type FeatureTable interface {
	Filter(ss ...FeatureFilter) []Feature
	Add(f Feature)
}

FeatureTable represents a feature table.

type FileType added in v0.4.0

type FileType int

FileType represents a file type.

const (
	DefaultFile FileType = iota
	UnknownFile
	JSONFile
	YAMLFile
	MsgpackFile
	FastaFile
	FastqFile
	GenBankFile
	EMBLFile
)

Available file types in GTS.

func Detect added in v0.4.0

func Detect(filename string) FileType

Detect returns the FileType associated to extension of the given filename.

func ToFileType added in v0.4.0

func ToFileType(name string) FileType

ToFileType converts the file type name string to a FileType

type GTS added in v0.6.0

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

GTS represents the most basic GTS sequence object.

func New added in v0.6.0

func New(info interface{}, data []byte) *GTS

New creates a new GTS object.

func Seq

func Seq(v interface{}) *GTS

Seq converts an arbitrary value to a GTS object.

func (GTS) Bytes added in v0.7.0

func (seq GTS) Bytes() []byte

Bytes returns the byte representation of the sequence.

func (*GTS) Delete added in v0.6.0

func (seq *GTS) Delete(pos, arg int) error

Delete given number of bases from the specified position.

func (GTS) Info added in v0.6.0

func (seq GTS) Info() interface{}

Info returns the metadata of the sequence.

func (*GTS) Insert added in v0.6.0

func (seq *GTS) Insert(pos int, arg Sequence) error

Insert a sequence at the specified position.

func (*GTS) Replace added in v0.6.0

func (seq *GTS) Replace(pos int, arg Sequence) error

Replace the bases from the specified position with the given sequence.

type GenBank

type GenBank struct {
	Fields   GenBankFields
	Features FeatureList
	Origin   SequenceServer
}

GenBank represents a GenBank sequence record.

func (GenBank) Add

func (gb GenBank) Add(f Feature)

Add a feature to the GenBank record.

func (GenBank) Bytes

func (gb GenBank) Bytes() []byte

Bytes returns the byte representation of the sequence.

func (*GenBank) DecodeMsgpack added in v0.3.0

func (gb *GenBank) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack satisifes the msgpack.CustomDecoder interface.

func (*GenBank) DecodeWith added in v0.3.0

func (gb *GenBank) DecodeWith(dec Decoder) error

DecodeWith satisifes the Decodable interface.

func (GenBank) Delete

func (gb GenBank) Delete(pos, cnt int) error

Delete given number of bases from the specified position.

func (GenBank) EncodeMsgpack added in v0.3.0

func (gb GenBank) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack satisifes the msgpack.CustomEncoder interface.

func (GenBank) EncodeWith added in v0.3.0

func (gb GenBank) EncodeWith(enc Encoder) error

EncodeWith satisfies the Encodable interface.

func (GenBank) Filter added in v0.1.0

func (gb GenBank) Filter(ss ...FeatureFilter) []Feature

Filter the features in the list matching the selector criteria.

func (*GenBank) GobDecode added in v0.3.0

func (gb *GenBank) GobDecode(data []byte) error

GobDecode satisifes the gob.GobDecoder interface.

func (GenBank) GobEncode added in v0.3.0

func (gb GenBank) GobEncode() ([]byte, error)

GobEncode satisifes the gob.GobEncoder interface.

func (GenBank) Info added in v0.6.0

func (gb GenBank) Info() interface{}

Info returns the metadata of the sequence.

func (GenBank) Insert

func (gb GenBank) Insert(pos int, seq Sequence) error

Insert a sequence at the specified position.

func (GenBank) MarshalJSON added in v0.3.0

func (gb GenBank) MarshalJSON() ([]byte, error)

MarshalJSON satisifes the json.Marshaler interface.

func (GenBank) MarshalYAML added in v0.3.0

func (gb GenBank) MarshalYAML() (interface{}, error)

MarshalYAML satisifes the yaml.Marshaler interface.

func (GenBank) Replace

func (gb GenBank) Replace(pos int, seq Sequence) error

Replace the bases from the specified position with the given sequence.

func (GenBank) String added in v0.6.0

func (gb GenBank) String() string

String satisifes the fmt.Stringer interface.

func (*GenBank) UnmarshalJSON added in v0.3.0

func (gb *GenBank) UnmarshalJSON(data []byte) error

UnmarshalJSON satisifes the json.Unmarshaler interface.

func (*GenBank) UnmarshalYAML added in v0.3.0

func (gb *GenBank) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML satisifes the yaml.Unmarshaler interface.

func (GenBank) WriteTo added in v0.6.0

func (gb GenBank) WriteTo(w io.Writer) (int64, error)

WriteTo satisfies the io.WriterTo interface.

type GenBankFields

type GenBankFields struct {
	LocusName string `json:"locus_name" yaml:"locus_name" msgpack:"locus_name"`
	Molecule  string `json:"molecule" yaml:"molecule" msgpack:"molecule"`
	Topology  string `json:"topology" yaml:"topology" msgpack:"topology"`
	Division  string `json:"division" yaml:"division" msgpack:"division"`
	Date      Date   `json:"date" yaml:"date" msgpack:"date"`

	Definition string      `json:"definition" yaml:"definition" msgpack:"definition"`
	Accession  string      `json:"accession" yaml:"accession" msgpack:"accession"`
	Version    string      `json:"version" yaml:"version" msgpack:"version"`
	DBLink     PairList    `json:"dblink" yaml:"dblink" msgpack:"dblink"`
	Keywords   []string    `json:"keywords,omitempty" yaml:"keywords,omitempty" msgpack:"keywords,omitempty"`
	Source     Organism    `json:"source" yaml:"source" msgpack:"source"`
	References []Reference `json:"references,omitempty" yaml:"references,omitempty" msgpack:"references,omitempty"`
	Comment    string      `json:"comment" yaml:"comment" msgpack:"comment"`
}

GenBankFields represents the fields of a GenBank record other than the features and sequence.

type GenBankIO added in v0.3.0

type GenBankIO struct {
	Fields   GenBankFields `json:"fields" yaml:"fields" msgpack:"fields"`
	Features []FeatureIO   `json:"features" yaml:"features" msgpack:"features"`
	Origin   []byte        `json:"origin" yaml:"origin" msgpack:"origin"`
}

GenBankIO represents a temporary object for reading and writing a GenBank struct using various serialization libraries.

func NewGenBankIO added in v0.3.0

func NewGenBankIO(gb GenBank) GenBankIO

NewGenBankIO creates a new GenBankIO object.

func (GenBankIO) SetGenBank added in v0.4.0

func (gbio GenBankIO) SetGenBank(gb *GenBank) error

SetGenBank sets the fields of the given GenBank pointer.

type GenBankWriter added in v0.6.0

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

GenBankWriter attempts to format a record in GenBank flatfile format.

func (GenBankWriter) WriteTo added in v0.6.0

func (gf GenBankWriter) WriteTo(w io.Writer) (int64, error)

WriteTo satisfies the io.WriterTo interface.

type JoinLocation

type JoinLocation struct {
	Locations []Location
}

JoinLocation represents multiple joined locations.

func NewJoinLocation

func NewJoinLocation(locs []Location) *JoinLocation

NewJoinLocation creates a new JoinLocation.

func (JoinLocation) Len

func (loc JoinLocation) Len() int

Len returns the length spanned by the location.

func (JoinLocation) Locate

func (loc JoinLocation) Locate(seq Sequence) Sequence

Locate the sequence at the pointing location.

func (JoinLocation) Map

func (loc JoinLocation) Map(index int) int

Map the given local index to a global index.

func (*JoinLocation) Shift

func (loc *JoinLocation) Shift(pos, n int) bool

Shift the location position[s] if needed. Returns false if the shift invalidates the location.

func (JoinLocation) String

func (loc JoinLocation) String() string

String satisfies the fmt.Stringer interface.

type Location

type Location interface {
	// Locate the sequence at the pointing location.
	Locate(seq Sequence) Sequence

	// Len returns the length spanned by the location.
	Len() int

	// String satisfies the fmt.Stringer interface.
	String() string

	// Shift the location by the given amount if needed.
	// Returns false if the shift invalidates the location.
	Shift(offset, amount int) bool

	// Map the given local index to a global index.
	Map(index int) int
}

Location represents a feature location as defined by the INSDC.

func AsLocation

func AsLocation(s string) (Location, error)

AsLocation attempts to interpret the given string as a Location.

type MultiParserScanner added in v0.4.0

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

MultiParserScanner tests for a matching parser on the first Scan and will attempt to use the same parser for the subsequent calls to Scan.

func NewMultiParserScanner added in v0.4.0

func NewMultiParserScanner(r io.Reader, ii ...interface{}) *MultiParserScanner

NewMultiParserScanner creates a new MultiParserScanner.

func (MultiParserScanner) Err added in v0.4.0

func (s MultiParserScanner) Err() error

Err returns the first non-EOF error that was encountered by the Scanner.

func (*MultiParserScanner) Scan added in v0.4.0

func (s *MultiParserScanner) Scan() bool

Scan advances the scanner using the given parsers. The first Scan can match any of the given parsers. All subsequent calls to Scan will require the same parser to match continually.

func (MultiParserScanner) Value added in v0.4.0

func (s MultiParserScanner) Value() interface{}

Value returns the most recent result value generated by one of the parsers.

type MutableSequence

type MutableSequence interface {
	Insert(pos int, arg Sequence) error
	Delete(pos, arg int) error
	Replace(pos int, arg Sequence) error
	Sequence
}

MutableSequence is a sequence which can be manipulated in-place.

type OrderLocation

type OrderLocation struct {
	Locations []Location
}

OrderLocation represents a group of locations.

func NewOrderLocation

func NewOrderLocation(locs []Location) *OrderLocation

NewOrderLocation creates a new OrderLocation.

func (OrderLocation) Len

func (loc OrderLocation) Len() int

Len returns the length spanned by the location.

func (OrderLocation) Locate

func (loc OrderLocation) Locate(seq Sequence) Sequence

Locate the sequence at the pointing location.

func (OrderLocation) Map

func (loc OrderLocation) Map(index int) int

Map the given local index to a global index.

func (*OrderLocation) Shift

func (loc *OrderLocation) Shift(pos, n int) bool

Shift the location position[s] if needed. Returns false if the shift invalidates the location.

func (OrderLocation) String

func (loc OrderLocation) String() string

String satisfies the fmt.Stringer interface.

type Organism

type Organism struct {
	Species string   `json:"species" yaml:"species" msgpack:"species"`
	Name    string   `json:"name" yaml:"name" msgpack:"name"`
	Taxon   []string `json:"taxon,omitempty" yaml:"taxon,omitempty" msgpack:"taxon,omitempty"`
}

Organism represents an organism of a record.

type Pair

type Pair struct {
	Key   string `json:"key" yaml:"key" msgpack:"key"`
	Value string `json:"value" yaml:"value" msgpack:"value"`
}

Pair represents a pair of strings.

type PairList

type PairList []Pair

PairList represents a list of pairs.

func (*PairList) Set

func (pl *PairList) Set(key, value string)

Set the value for the given key.

type ParserScanner added in v0.4.0

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

ParserScanner provides a convenient interface for continually matching a parser.

func NewParserScanner added in v0.4.0

func NewParserScanner(r io.Reader, i interface{}) *ParserScanner

NewParserScanner creates a new ParserScanner.

func (ParserScanner) Err added in v0.4.0

func (s ParserScanner) Err() error

Err returns the first non-EOF error that was encountered by the Scanner.

func (*ParserScanner) Scan added in v0.4.0

func (s *ParserScanner) Scan() bool

Scan advances the scanner using the given parser.

func (ParserScanner) Value added in v0.4.0

func (s ParserScanner) Value() interface{}

Value returns the most recent result value generated by the parser.

type PointLocation

type PointLocation struct{ Position int }

PointLocation represents a single point.

func NewPointLocation

func NewPointLocation(pos int) *PointLocation

NewPointLocation creates a new PointLocation.

func (PointLocation) Len

func (loc PointLocation) Len() int

Len returns the length spanned by the location.

func (PointLocation) Locate

func (loc PointLocation) Locate(seq Sequence) Sequence

Locate the sequence at the pointing location.

func (PointLocation) Map

func (loc PointLocation) Map(index int) int

Map the given local index to a global index.

func (*PointLocation) Shift

func (loc *PointLocation) Shift(offset, amount int) bool

Shift the location position[s] if needed. Returns false if the shift invalidates the location.

func (PointLocation) String

func (loc PointLocation) String() string

String satisfies the fmt.Stringer interface.

type Qualifier

type Qualifier [2]string

Qualifier represents a single qualifier name-value pair.

func (Qualifier) Format

func (q Qualifier) Format(prefix string) QualifierFormatter

Format creates a QualifierFormatter object for the qualifier with the given prefix.

func (Qualifier) String

func (q Qualifier) String() string

String satisfies the fmt.Stringer interface.

func (Qualifier) Unpack added in v0.4.0

func (q Qualifier) Unpack() (string, string)

Unpack returns the name and value strings of the Qualifier.

type QualifierFormatter

type QualifierFormatter struct {
	Qualifier Qualifier
	Prefix    string
}

QualifierFormatter formats a Qualifier object with the given prefix.

func (QualifierFormatter) String

func (qf QualifierFormatter) String() string

String satisfies the fmt.Stringer interface.

func (QualifierFormatter) WriteTo

func (qf QualifierFormatter) WriteTo(w io.Writer) (int, error)

WriteTo satisfies the io.WriterTo interface.

type QualifierType

type QualifierType int

QualifierType represents the type of qualifier.

const (
	QuotedQualifier QualifierType = iota
	LiteralQualifier
	ToggleQualifier
	UnknownQualifier
)

Available qualifier types.

func GetQualifierType

func GetQualifierType(name string) QualifierType

GetQualifierType returns the qualifier type of the given qualifier name.

type Range

type Range struct {
	Start int
	End   int
}

Range represents a start and end index pair.

type RangeLocation

type RangeLocation struct {
	Start    int
	End      int
	Partial5 bool
	Partial3 bool
}

RangeLocation represents a range of locations.

func NewPartialRangeLocation

func NewPartialRangeLocation(start, end int, p5, p3 bool) *RangeLocation

NewPartialRangeLocation creates a new partial RangeLocation.

func NewRangeLocation

func NewRangeLocation(start, end int) *RangeLocation

NewRangeLocation creates a new RangeLocation.

func (RangeLocation) Len

func (loc RangeLocation) Len() int

Len returns the length spanned by the location.

func (RangeLocation) Locate

func (loc RangeLocation) Locate(seq Sequence) Sequence

Locate the sequence at the pointing location.

func (RangeLocation) Map

func (loc RangeLocation) Map(index int) int

Map the given local index to a global index.

func (*RangeLocation) Shift

func (loc *RangeLocation) Shift(offset, amount int) (ok bool)

Shift the location position[s] if needed. Returns false if the shift invalidates the location.

func (RangeLocation) String

func (loc RangeLocation) String() string

String satisfies the fmt.Stringer interface.

type Record

type Record interface {
	FeatureTable
	MutableSequence
}

Record is the interface for sequence records with metadata and features.

func NewRecord

func NewRecord(seq Sequence, ff []Feature) Record

NewRecord creates a new record.

type RecordScanner

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

RecordScanner scans one sequence record at a time.

func NewRecordFileScanner added in v0.4.0

func NewRecordFileScanner(f *os.File) *RecordScanner

NewRecordFileScanner creates a new specialized RecordScanner based on the given filename.

func NewRecordScanner

func NewRecordScanner(r io.Reader) *RecordScanner

NewRecordScanner creates a new RecordScanner.

func (RecordScanner) Err

func (s RecordScanner) Err() error

Err returns the first non-EOF error that was encountered by the Scanner.

func (*RecordScanner) Record

func (s *RecordScanner) Record() Record

Record returns the most recent Record generated by a call to Scan.

func (*RecordScanner) Scan

func (s *RecordScanner) Scan() bool

Scan advances the Scanner to the next Record.

type Reference

type Reference struct {
	Number  int               `json:"number" yaml:"number" msgpack:"number"`
	Ranges  []Range           `json:"ranges,omitempty" yaml:"ranges,omitempty" msgpack:"ranges,omitempty"`
	Authors string            `json:"authors" yaml:"authors" msgpack:"authors"`
	Group   string            `json:"group" yaml:"group" msgpack:"group"`
	Title   string            `json:"title" yaml:"title" msgpack:"title"`
	Journal string            `json:"journal" yaml:"journal" msgpack:"journal"`
	Xref    map[string]string `json:"xref,omitempty" yaml:"xref,omitempty" msgpack:"xref,omitempty"`
	Comment string            `json:"comment" yaml:"comment" msgpack:"comment"`
}

Reference represents a reference of a record.

type Scanner added in v0.4.0

type Scanner interface {
	Scan() bool
	Value() interface{}
	Err() error
}

Scanner provides a convenient interface for reading data.

type Sequence

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

Sequence represents a sequence type. All Sequence types must be able to generate a byte slice representation of itself.

func Complement

func Complement(seq Sequence) Sequence

Complement returns the complement of the given sequence.

func Fragment

func Fragment(seq Sequence, window, slide int) []Sequence

Fragment returns a slice of Sequences containing all subsequences of the given Sequence from position 0 separated by `slide` bytes and with length of `window`.

func Slice

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

Slice returns a slice of the Sequnece.

type SequenceProxy

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

SequenceProxy represents a mutable sequence that will send modification requests to a SequenceServer.

func (SequenceProxy) Bytes

func (sp SequenceProxy) Bytes() []byte

Bytes satisfies the gts.Sequence interface.

func (SequenceProxy) Delete

func (sp SequenceProxy) Delete(pos, arg int) error

Delete given number of bases from the specified position.

func (SequenceProxy) Info added in v0.6.0

func (sp SequenceProxy) Info() interface{}

Info satisfies the gts.Sequence interface.

func (SequenceProxy) Insert

func (sp SequenceProxy) Insert(pos int, arg Sequence) error

Insert a sequence at the specified position.

func (SequenceProxy) Replace

func (sp SequenceProxy) Replace(pos int, arg Sequence) error

Replace the bases from the specified position with the given sequence.

type SequenceServer

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

SequenceServer is a mutable sequence that can be modified by proxies.

func NewSequenceServer

func NewSequenceServer(seq Sequence) SequenceServer

NewSequenceServer creates a new SequenceServer.

func (SequenceServer) Bytes

func (ss SequenceServer) Bytes() []byte

Bytes satisfies the gts.Sequence interface.

func (*SequenceServer) Close

func (ss *SequenceServer) Close()

Close deactivates the SequenceServer.

func (*SequenceServer) Delete

func (ss *SequenceServer) Delete(pos, arg int) error

Delete given number of bases from the specified position.

func (SequenceServer) Info added in v0.6.0

func (ss SequenceServer) Info() interface{}

Info satisfies the gts.Sequence interface.

func (*SequenceServer) Insert

func (ss *SequenceServer) Insert(pos int, arg Sequence) error

Insert a sequence at the specified position.

func (SequenceServer) Proxy

func (ss SequenceServer) Proxy() SequenceProxy

Proxy creates a proxy to the SequenceServer.

func (*SequenceServer) Replace

func (ss *SequenceServer) Replace(pos int, arg Sequence) error

Replace the bases from the specified position with the given sequence.

func (*SequenceServer) Spin

func (ss *SequenceServer) Spin()

Spin prepares internal channels for recieving messages from the proxies associated to this SequenceServer.

type Values

type Values map[string][]string

Values represents a collection of name-value list pairs.

func (Values) Add

func (v Values) Add(name, value string)

Add appends a value to the values associated to the given name.

func (Values) Del

func (v Values) Del(name string)

Del deletes the values associated to the given name.

func (Values) Get

func (v Values) Get(key string) []string

Get returns the values associated to the given name.

func (Values) Set

func (v Values) Set(name string, values ...string)

Set overwrites the values associated to the given name.

Directories

Path Synopsis
cmd
gts command
togo command

Jump to

Keyboard shortcuts

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