Documentation
¶
Index ¶
- Constants
- Variables
- func Init() (err error)
- type Alphabet
- type Complementable
- type Deoxyribonucleic
- type Generic
- func (self *Generic) AllValid(n []byte) (valid bool, pos int)
- func (self *Generic) IndexOf(n byte) int
- func (self *Generic) IsCaseSensitive() bool
- func (self *Generic) IsValid(n byte) bool
- func (self *Generic) Len() int
- func (self *Generic) LetterIndex() (i []int)
- func (self *Generic) String() (s string)
- func (self *Generic) ValidLetters() (v []bool)
- type Nucleic
- type Pairing
- type Peptide
- type Ribonucleic
Examples ¶
Constants ¶
const (
CaseSensitive = true
)
Variables ¶
var ( N = "acgt" Npairing = [2]string{"acgtnxACGTNX-", "tgcanxTGCANX-"} R = "acgu" Rpairing = [2]string{"acgunxACGUNX-", "ugcanxUGCANX-"} P = "abcdefghijklmnpqrstvxyz*" )
var ( DNA *Deoxyribonucleic RNA *Ribonucleic Protein *Peptide )
Functions ¶
Types ¶
type Alphabet ¶
type Alphabet interface { IsValid(byte) bool AllValid([]byte) (bool, int) Len() int ValidLetters() []bool LetterIndex() []int String() string }
Minimum requirements for an Alphabet.
type Complementable ¶
Nucleic alphabets are able to complement their values.
type Deoxyribonucleic ¶
type Deoxyribonucleic Nucleic
Deoxyribonucleic is an alias to Nucleic to provide type restrictions.
func NewDeoxyribonucleic ¶
func NewDeoxyribonucleic(letters string, pairs *Pairing, caseSensitive bool) (d *Deoxyribonucleic, err error)
Return a new Deoxyribonucleic alphabet.
type Generic ¶
type Generic struct {
// contains filtered or unexported fields
}
Single letter alphabet type.
func NewGeneric ¶
Return a new alphabet. Index values for letters reflect order of the letters parameter if Generic is case sensitive, otherwise index values will reflect ASCII sort order. Letters must be within the ASCII range.
func (*Generic) AllValid ¶
Check that a slice of bytes conforms to the alphabet, returning false and the position of the first invalid byte if invalid and true and a negative int if valid.
Example ¶
fmt.Println(DNA.AllValid([]byte("acgatcgatatagctatnagcatgc")))
Output: false 17
func (*Generic) IsCaseSensitive ¶
Return whether the alphabet is case sensitive.
func (*Generic) LetterIndex ¶
Return a copy of the internal []int specifying letter to index conversion.
func (*Generic) ValidLetters ¶
Return a copy of the internal []bool indicating valid letters.
type Nucleic ¶
The Nucleic type incorporates a Generic alphabet with the capacity to return a complement.
func NewNucleic ¶
Create a generalised Nucleic alphabet. The Complement table is checked for validity and an error is returned if an invalid complement pair is found. Pairings that result in no change but would otherwise be invalid are allowed. If invalid pairings are required, the Pairing should be provided after creating the Nucleic struct.
type Pairing ¶
type Pairing struct {
// contains filtered or unexported fields
}
Pairing provides a lookup table between a letter and its complement.
func NewPairing ¶
Create a new Pairing from a pair of strings.
func (*Pairing) ComplementOf ¶
Returns the complement of a letter and true if the complement is a valid letter otherwise unchanged and false.
Example ¶
var ( c byte ok bool ) c, ok = DNA.ComplementOf('a') fmt.Printf("%c %v\n", c, ok) c, ok = DNA.ComplementOf('n') fmt.Printf("%c %v\n", c, ok) c, ok = RNA.ComplementOf('a') fmt.Printf("%c %v\n", c, ok) _, ok = RNA.ComplementOf('t') fmt.Printf("%v\n", ok)
Output: t true n true u true false
func (*Pairing) ComplementTable ¶
Returns a complementation table based on the internal representation. Invalid pairs hold a value outside the ASCII range.
type Ribonucleic ¶
type Ribonucleic Nucleic
Ribonucleic is an alias to Nucleic to provide type restrictions.
func NewRibonucleic ¶
func NewRibonucleic(letters string, pairs *Pairing, caseSensitive bool) (r *Ribonucleic, err error)
Return a new Ribonucleic alphabet.