Documentation
¶
Index ¶
- Variables
- func AddPrefix(s, prefix string) string
- func AmbiguousLocationParser(state *pars.State, result *pars.Result) error
- func Any(f Feature) bool
- func BetweenLocationParser(state *pars.State, result *pars.Result) error
- func ComplementLocationParser(state *pars.State, result *pars.Result) error
- func Composition(seq Sequence) map[byte]int
- func Equal(a, b Sequence) bool
- func FeatureListParser(prefix string) pars.Parser
- func FlatFileSplit(s string) []string
- func GenBankParser(state *pars.State, result *pars.Result) error
- func IsLiteralQualifier(name string) bool
- func IsQuotedQualifier(name string) bool
- func IsToggleQualifier(name string) bool
- func JoinLocationParser(state *pars.State, result *pars.Result) error
- func LocationLess(a, b Location) bool
- func OrderLocationParser(state *pars.State, result *pars.Result) error
- func PointLocationParser(state *pars.State, result *pars.Result) error
- func QualifierParser(prefix string) pars.Parser
- func RangeLocationParser(state *pars.State, result *pars.Result) error
- func RegisterLiteralQualifier(names ...string)
- func RegisterQuotedQualifier(names ...string)
- func RegisterToggleQualifier(names ...string)
- func Skew(seq Sequence, nSet, pSet string) float64
- type AmbiguousLocation
- type BasicSequence
- type BetweenLocation
- type ByLocation
- type ComplementLocation
- type Feature
- type FeatureFormatter
- type FeatureList
- type FeatureListFormatter
- type FeatureSelector
- type FeatureTable
- type Formatter
- type GenBank
- func (gb GenBank) Add(f Feature)
- func (gb GenBank) Bytes() []byte
- func (gb GenBank) Delete(pos, cnt int) error
- func (gb GenBank) Insert(pos int, seq Sequence) error
- func (gb GenBank) Metadata() interface{}
- func (gb GenBank) Replace(pos int, seq Sequence) error
- func (gb GenBank) Select(ss ...FeatureSelector) []Feature
- type GenBankFields
- type GenBankFormatter
- type JoinLocation
- type Location
- type Mutable
- type MutableSequence
- type OrderLocation
- type Organism
- type Pair
- type PairList
- type PointLocation
- type Qualifier
- type QualifierFormatter
- type QualifierType
- type Range
- type RangeLocation
- type Record
- type RecordScanner
- type Reference
- type Sequence
- type SequenceProxy
- type SequenceServer
- func (ss SequenceServer) Bytes() []byte
- func (ss *SequenceServer) Close()
- func (ss *SequenceServer) Delete(pos, cnt int) error
- func (ss *SequenceServer) Insert(pos int, seq Sequence) error
- func (ss SequenceServer) Proxy() SequenceProxy
- func (ss *SequenceServer) Replace(pos int, seq Sequence) error
- func (ss *SequenceServer) Spin()
- type Values
Constants ¶
This section is empty.
Variables ¶
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.
var FeatureTableParser = pars.Any( RecordParser.Map(func(result *pars.Result) error { rec := result.Value.(Record) ft := rec.Select() result.SetValue(ft) return nil }), featureDecoderParser(yamlDecoder), featureDecoderParser(jsonDecoder), )
FeatureTableParser attempts to parse a table of features.
var LocationParser pars.Parser
var RecordParser = pars.Any(GenBankParser)
RecordParser attempts to parse a single sequence record.
Functions ¶
func AmbiguousLocationParser ¶
AmbiguousLocationParser attempts to parse a AmbiguousLocation.
func BetweenLocationParser ¶
BetweenLocationParser attempts to parse a BetweenLocation.
func ComplementLocationParser ¶
ComplementLocationParser attempts to parse a ComplementLocation.
func Composition ¶
Composition computes the occurence of each byte within the Sequence.
func FeatureListParser ¶
FeatureListParser attempts to match an INSDC feature table.
func FlatFileSplit ¶
FlatFileSplit splits the string with the flatfile convention.
func GenBankParser ¶
GenBankParser attempts to parse a single GenBank record.
func IsLiteralQualifier ¶
IsLiteralQualifier tests if the given qualifier name is a literal qualifier.
func IsQuotedQualifier ¶
IsQuotedQualifier tests if the given qualifier name is a quoted qualifier.
func IsToggleQualifier ¶
IsToggleQualifier tests if the given qualifier name is a toggle qualifier.
func JoinLocationParser ¶
JoinLocationParser attempts to parse a JoinLocation.
func LocationLess ¶
LocationLess tests if the one location is smaller than the other.
func OrderLocationParser ¶
OrderLocationParser attempts to parse a OrderLocation.
func PointLocationParser ¶
PointLocationParser attempts to parse a PointLocation.
func QualifierParser ¶
QualfierParser attempts to match a single qualifier name-value pair.
func RangeLocationParser ¶
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 ¶
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 ¶
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 BasicSequence ¶
type BasicSequence []byte
BasicSequence is the most basic sequence type available. It is merely an alternate definition of a byte slice.
func Seq ¶
func Seq(arg interface{}) BasicSequence
Seq is a convenience utility function which will take the given argument and attempt to convert the object into a BasicSequence.
func Slice ¶
func Slice(seq Sequence, start, end int) BasicSequence
Slice returns a slice of the Sequnece.
func (BasicSequence) Bytes ¶
func (s BasicSequence) Bytes() []byte
Bytes satisifies the gts.Sequence interface.
func (*BasicSequence) Delete ¶
func (s *BasicSequence) Delete(pos, cnt int) error
Delete given number of bases from the specified position.
type BetweenLocation ¶
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 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 ¶
NewFeature creates a new feature.
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) Translation ¶
Translation returns the translation of the feature if available. it will return nil otherwise.
type FeatureFormatter ¶
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.
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) 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.
func (FeatureList) Select ¶
func (ff FeatureList) Select(ss ...FeatureSelector) []Feature
Select the features in the list matching the selector criteria.
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.
type FeatureSelector ¶
FeatureSelector represents a filter for selecting features.
func And ¶
func And(ss ...FeatureSelector) FeatureSelector
And returns true if all selectors return true.
func Key ¶
func Key(key string) FeatureSelector
Key returns true if the key of a feature matches the given key.
func Not ¶
func Not(s FeatureSelector) FeatureSelector
Not returns true if the given selector returns false.
func Or ¶
func Or(ss ...FeatureSelector) FeatureSelector
Or returns true if any of the selectors return true.
type FeatureTable ¶
type FeatureTable interface {
Select(ss ...FeatureSelector) []Feature
Add(f Feature)
}
FeatureTable represents a feature table.
type Formatter ¶
Formatter can be formatted to a string or write to an io.Writer.
func DefaultFormatter ¶
DefaultFormatter returns the default formatter for the given record.
type GenBank ¶
type GenBank struct {
Fields GenBankFields
Features FeatureList
Origin SequenceServer
}
GenBank represents a GenBank sequence record.
func (GenBank) Metadata ¶
func (gb GenBank) Metadata() interface{}
Metadata returns the metadata of the GenBank record.
func (GenBank) Select ¶
func (gb GenBank) Select(ss ...FeatureSelector) []Feature
Select the features in the list matching the selector criteria.
type GenBankFields ¶
type GenBankFields struct {
LocusName string
Molecule string
Topology string
Division string
Date time.Time
Definition string
Accession string
Version string
DBLink PairList
Keywords []string
Source Organism
References []Reference
Comment string
}
GenBankFields represents the fields of a GenBank record other than the features and sequence.
type GenBankFormatter ¶
type GenBankFormatter struct {
Rec Record
}
GenBankFormatter attempts to format a record in GenBank flatfile format.
func (GenBankFormatter) String ¶
func (gf GenBankFormatter) String() string
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 ¶
AsLocation attempts to interpret the given string as a Location.
type Mutable ¶
type Mutable interface {
Sequence
Insert(pos int, seq Sequence)
Delete(pos, cnt int)
Replace(pos int, seq Sequence)
}
Mutable is a sequence which can be manipulated in-place.
type MutableSequence ¶
type MutableSequence interface {
Insert(pos int, seq Sequence) error
Delete(pos, cnt int) error
Replace(pos int, seq 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 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 ¶
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.
type QualifierFormatter ¶
QualifierFormatter formats a Qualifier object with the given prefix.
func (QualifierFormatter) String ¶
func (qf QualifierFormatter) String() string
String satisfies the fmt.Stringer 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 RangeLocation ¶
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 {
Metadata() interface{}
FeatureTable
MutableSequence
}
Record is the interface for sequence records with metadata and features.
type RecordScanner ¶
type RecordScanner struct {
// contains filtered or unexported fields
}
RecordScanner scans one sequence record at a time.
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
Ranges []Range
Authors string
Group string
Title string
Journal string
Xref map[string]string
Comment string
}
Reference represents a reference of a record.
type Sequence ¶
type Sequence interface {
Bytes() []byte
}
Sequence represents a sequence type. All Sequence types must be able to generate a byte slice representation of itself.
func Complement ¶
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, cnt int) error
Delete given number of bases from the specified position.
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, cnt int) error
Delete given number of bases from the specified position.
func (*SequenceServer) Insert ¶
func (ss *SequenceServer) Insert(pos int, seq 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, seq 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 ¶
Values represents a collection of name-value list pairs.