Documentation ¶
Overview ¶
Package immutable is an implementation of biological sequences that have immutability. Each operation on an immutable object results in a new object with the original remaining unchanged. In order to improve memory utilization, any unmodified parts of the original object are reused. Intermediate version are safe to take copies of.
Index ¶
- type Dna
- func (x *Dna) Alphabet() alphabet.Interface
- func (x *Dna) Complement() (sequence.Interface, error)
- func (x *Dna) LetterCount() map[string]uint
- func (x *Dna) RevComp() (sequence.Interface, error)
- func (x *Dna) Reverse() (sequence.Interface, error)
- func (x *Dna) Transcribe() (sequence.Interface, error)
- func (x *Dna) Translate(table codon.Interface, stop byte) (sequence.Interface, error)
- type DnaIupac
- type Protein
- type ProteinGapped
- type Rna
- type RnaIupac
- type Struct
- type WithFunc
- type Wither
Examples ¶
- Dna.Alphabet
- Dna.Complement (Errored)
- Dna.Complement (Errorless)
- Dna.LetterCount
- Dna.RevComp (Errored)
- Dna.RevComp (Errorless)
- Dna.Reverse (Errored)
- Dna.Reverse (Errorless)
- DnaIupac.Alphabet
- DnaIupac.Complement (Errored)
- DnaIupac.Complement (Errorless)
- DnaIupac.LetterCount
- DnaIupac.RevComp (Errored)
- DnaIupac.RevComp (Errorless)
- DnaIupac.Reverse (Errored)
- DnaIupac.Reverse (Errorless)
- NewDna (Errored)
- NewDna (Errorless)
- NewDnaIupac (Errored)
- NewDnaIupac (Errorless)
- NewProtein (Errored)
- NewProtein (Errorless)
- NewProteinGapped (Errored)
- NewProteinGapped (Errorless)
- NewRna (Errored)
- NewRna (Errorless)
- NewRnaIupac (Errored)
- NewRnaIupac (Errorless)
- Protein.Alphabet
- Protein.LetterCount
- Protein.Reverse (Errored)
- Protein.Reverse (Errorless)
- ProteinGapped.Alphabet
- ProteinGapped.LetterCount
- ProteinGapped.Reverse (Errored)
- ProteinGapped.Reverse (Errorless)
- Rna.Alphabet
- Rna.Complement (Errored)
- Rna.Complement (Errorless)
- Rna.LetterCount
- Rna.RevComp (Errored)
- Rna.RevComp (Errorless)
- Rna.Reverse (Errored)
- Rna.Reverse (Errorless)
- RnaIupac.Alphabet
- RnaIupac.Complement (Errored)
- RnaIupac.Complement (Errorless)
- RnaIupac.LetterCount
- RnaIupac.RevComp (Errored)
- RnaIupac.RevComp (Errorless)
- RnaIupac.Reverse (Errored)
- RnaIupac.Reverse (Errorless)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dna ¶
type Dna struct {
*Struct
}
Dna is a sequence which validates against the Dna alphabet and knows how to reverse, complement, and revcomp itself
func NewDna ¶
NewDna generates a New sequence that validates against the Dna alphabet
Example (Errored) ¶
Building a new Dna from invalid letters results in an error Note that only the first error is returned, not all errors The invalid '%' is caught, but nothing is said of the invalid '&'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewDna("%" + "ATGC" + "&") fmt.Printf("%s, %v", s, err) }
Output: %ATGC&, "%" not in alphabet
Example (Errorless) ¶
Building a new Dna from valid letters results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewDna("ATGC") fmt.Printf("%s, %v", s, err) }
Output: ATGC, <nil>
func (*Dna) Alphabet ¶
Alphabet reveals the underlying alphabet in use
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewDna()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDna("ATGC") fmt.Println(s.Alphabet()) }
Output: ACGT
func (*Dna) Complement ¶
Complement is the same Dna with the sequence complemented
Example (Errored) ¶
Complementing an invalid Dna results in an error Note that both invalid letters '%' and '&' became 'X' (which is also an invalid letter)
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewDna("%" + "ATGC" + "&") rev, err := s.Complement() fmt.Printf("%s, %v", rev, err) }
Output: XTACGX, "X" not in alphabet
Example (Errorless) ¶
Complementing a valid Dna results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDna("ATGC") rev, err := s.Complement() fmt.Printf("%s, %v", rev, err) }
Output: TACG, <nil>
func (*Dna) LetterCount ¶
LetterCount reveals the number of occurrences for each letter in a sequence
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewDna()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDna("ATGC" + "AAAA") fmt.Println(s.LetterCount()) }
Output: map[A:5 C:1 G:1 T:1]
func (*Dna) RevComp ¶
RevComp is the same Dna with the sequence reversed and complemented
Example (Errored) ¶
Reverse complementing an invalid Dna results in an error Note that both invalid letters '%' and '&' became 'X' (which is also an invalid letter)
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewDna("%" + "ATGC" + "&") rev, err := s.RevComp() fmt.Printf("%s, %v", rev, err) }
Output: XGCATX, "X" not in alphabet
Example (Errorless) ¶
Reverse complementing a valid Dna results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDna("ATGC") rev, err := s.RevComp() fmt.Printf("%s, %v", rev, err) }
Output: GCAT, <nil>
func (*Dna) Reverse ¶
Reverse is the same Dna with the sequence reversed
Example (Errored) ¶
Reversing an invalid Dna results in an error Note that only the first error is returned, not all errors The invalid '&' is caught, but nothing is said of the invalid '%'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDna("%" + "ATGC" + "&") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: &CGTA%, "&" not in alphabet
Example (Errorless) ¶
Reversing a valid Dna results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDna("ATGC") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: CGTA, <nil>
func (*Dna) Transcribe ¶
Transcribe returns the DNA->RNA transcription product
func (*Dna) Translate ¶
Translate returns a translated genetic product made from using a codon table The stop argument determines which character to use for indicating a stop codon If any stop codon is found and the stop argument is not a valid character in the Protein alphabet, an error will result stating as such. Therefore, if a stop codon is expected, checking the error message for the quoted character should be done.
type DnaIupac ¶
type DnaIupac struct {
*Struct
}
DnaIupac is a sequence which validates against the DnaIupac alphabet and knows how to reverse, complement, and revcomp itself
func NewDnaIupac ¶
NewDnaIupac generates a New sequence that validates against the DnaIupac alphabet
Example (Errored) ¶
Building a new DnaIupac from invalid letters results in an error Note that only the first error is returned, not all errors The invalid '%' is caught, but nothing is said of the invalid '&'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewDnaIupac("%" + "RYSWKM" + "BDHV" + "N" + "ATGC" + "-" + "&") fmt.Printf("%s, %v", s, err) }
Output: %RYSWKMBDHVNATGC-&, "%" not in alphabet
Example (Errorless) ¶
Building a new DnaIupac from valid letters results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewDnaIupac("RYSWKM" + "BDHV" + "N" + "ATGC" + "-") fmt.Printf("%s, %v", s, err) }
Output: RYSWKMBDHVNATGC-, <nil>
func (*DnaIupac) Alphabet ¶
Alphabet reveals the underlying alphabet in use
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewDnaIupac()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDnaIupac("RYSWKM" + "BDHV" + "N" + "ATGC" + "-") fmt.Println(s.Alphabet()) }
Output: -ABCDGHKMNRSTVWY
func (*DnaIupac) Complement ¶
Complement is the same DnaIupac with the sequence complemented
Example (Errored) ¶
Complementing an invalid DnaIupac results in an error Note that both invalid letters '%' and '&' became 'X' (which is also an invalid letter)
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewDnaIupac("%" + "RYSWKM" + "BDHV" + "N" + "ATGC" + "-" + "&") rev, err := s.Complement() fmt.Printf("%s, %v", rev, err) }
Output: XYRSWMKVHDBNTACG-X, "X" not in alphabet
Example (Errorless) ¶
Complementing a valid DnaIupac results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDnaIupac("RYSWKM" + "BDHV" + "N" + "ATGC" + "-") rev, err := s.Complement() fmt.Printf("%s, %v", rev, err) }
Output: YRSWMKVHDBNTACG-, <nil>
func (*DnaIupac) LetterCount ¶
LetterCount reveals the number of occurrences for each letter in a sequence
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewDnaIupac()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDnaIupac("RYSWKM" + "BDHV" + "N" + "ATGC" + "-" + "NNNN") fmt.Println(s.LetterCount()) }
Output: map[-:1 A:1 B:1 C:1 D:1 G:1 H:1 K:1 M:1 N:5 R:1 S:1 T:1 V:1 W:1 Y:1]
func (*DnaIupac) RevComp ¶
RevComp is the same DnaIupac with the sequence reversed and complemented
Example (Errored) ¶
Reverse complementing an invalid DnaIupac results in an error Note that both invalid letters '%' and '&' became 'X' (which is also an invalid letter)
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewDnaIupac("%" + "RYSWKM" + "BDHV" + "N" + "ATGC" + "-" + "&") rev, err := s.RevComp() fmt.Printf("%s, %v", rev, err) }
Output: X-GCATNBDHVKMWSRYX, "X" not in alphabet
Example (Errorless) ¶
Reverse complementing a valid DnaIupac results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDnaIupac("RYSWKM" + "BDHV" + "N" + "ATGC" + "-") rev, err := s.RevComp() fmt.Printf("%s, %v", rev, err) }
Output: -GCATNBDHVKMWSRY, <nil>
func (*DnaIupac) Reverse ¶
Reverse is the same DnaIupac with the sequence reversed
Example (Errored) ¶
Reversing an invalid DnaIupac results in an error Note that only the first error is returned, not all errors The invalid '&' is caught, but nothing is said of the invalid '%'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDnaIupac("%" + "RYSWKM" + "BDHV" + "N" + "ATGC" + "-" + "&") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: &-CGTANVHDBMKWSYR%, "&" not in alphabet
Example (Errorless) ¶
Reversing a valid DnaIupac results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewDnaIupac("RYSWKM" + "BDHV" + "N" + "ATGC" + "-") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: -CGTANVHDBMKWSYR, <nil>
type Protein ¶
type Protein struct {
*Struct
}
Protein is a sequence which validates against the Protein alphabet and knows how to reverse itself
func NewProtein ¶
NewProtein generates a New sequence that validates against the Protein alphabet
Example (Errored) ¶
Building a new Protein from invalid letters results in an error Note that only the first error is returned, not all errors The invalid '%' is caught, but nothing is said of the invalid '&'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewProtein("%" + "ACDEFGHIKLMNPQRSTVWY" + "&") fmt.Printf("%s, %v", s, err) }
Output: %ACDEFGHIKLMNPQRSTVWY&, "%" not in alphabet
Example (Errorless) ¶
Building a new Protein from valid letters results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewProtein("ACDEFGHIKLMNPQRSTVWY") fmt.Printf("%s, %v", s, err) }
Output: ACDEFGHIKLMNPQRSTVWY, <nil>
func (*Protein) Alphabet ¶
Alphabet reveals the underlying alphabet in use
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewProtein()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewProtein("ACDEFGHIKLMNPQRSTVWY") fmt.Println(s.Alphabet()) }
Output: ACDEFGHIKLMNPQRSTVWY
func (*Protein) LetterCount ¶
LetterCount reveals the number of occurrences for each letter in a sequence
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewProtein()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewProtein("ACDEFGHIKLMNPQRSTVWY" + "NNNN") fmt.Println(s.LetterCount()) }
Output: map[A:1 C:1 D:1 E:1 F:1 G:1 H:1 I:1 K:1 L:1 M:1 N:5 P:1 Q:1 R:1 S:1 T:1 V:1 W:1 Y:1]
func (*Protein) Reverse ¶
Reverse is the same Protein with the sequence reversed
Example (Errored) ¶
Reversing an invalid Protein results in an error Note that only the first error is returned, not all errors The invalid '&' is caught, but nothing is said of the invalid '%'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewProtein("%" + "ACDEFGHIKLMNPQRSTVWY" + "&") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: &YWVTSRQPNMLKIHGFEDCA%, "&" not in alphabet
Example (Errorless) ¶
Reversing a valid Protein results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewProtein("ACDEFGHIKLMNPQRSTVWY") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: YWVTSRQPNMLKIHGFEDCA, <nil>
type ProteinGapped ¶
type ProteinGapped struct {
*Struct
}
ProteinGapped is a sequence which validates against the ProteinGapped alphabet and knows how to reverse itself
func NewProteinGapped ¶
func NewProteinGapped(s string) (*ProteinGapped, error)
NewProteinGapped generates a New sequence that validates against the ProteinGapped alphabet
Example (Errored) ¶
Building a new ProteinGapped from invalid letters results in an error Note that only the first error is returned, not all errors The invalid '%' is caught, but nothing is said of the invalid '&'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewProteinGapped("%" + "ACDEFGHIKLMNPQRSTVWY" + "-" + "&") fmt.Printf("%s, %v", s, err) }
Output: %ACDEFGHIKLMNPQRSTVWY-&, "%" not in alphabet
Example (Errorless) ¶
Building a new ProteinGapped from valid letters results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewProteinGapped("ACDEFGHIKLMNPQRSTVWY" + "-") fmt.Printf("%s, %v", s, err) }
Output: ACDEFGHIKLMNPQRSTVWY-, <nil>
func (*ProteinGapped) Alphabet ¶
func (x *ProteinGapped) Alphabet() alphabet.Interface
Alphabet reveals the underlying alphabet in use
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewProteinGapped()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewProteinGapped("ACDEFGHIKLMNPQRSTVWY" + "-") fmt.Println(s.Alphabet()) }
Output: -ACDEFGHIKLMNPQRSTVWY
func (*ProteinGapped) LetterCount ¶
func (x *ProteinGapped) LetterCount() map[string]uint
LetterCount reveals the number of occurrences for each letter in a sequence
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewProteinGapped()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewProteinGapped("ACDEFGHIKLMNPQRSTVWY" + "-" + "NNNN") fmt.Println(s.LetterCount()) }
Output: map[-:1 A:1 C:1 D:1 E:1 F:1 G:1 H:1 I:1 K:1 L:1 M:1 N:5 P:1 Q:1 R:1 S:1 T:1 V:1 W:1 Y:1]
func (*ProteinGapped) Reverse ¶
func (x *ProteinGapped) Reverse() (sequence.Interface, error)
Reverse is the same ProteinGapped with the sequence reversed
Example (Errored) ¶
Reversing an invalid ProteinGapped results in an error Note that only the first error is returned, not all errors The invalid '&' is caught, but nothing is said of the invalid '%'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewProteinGapped("%" + "ACDEFGHIKLMNPQRSTVWY" + "-" + "&") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: &-YWVTSRQPNMLKIHGFEDCA%, "&" not in alphabet
Example (Errorless) ¶
Reversing a valid ProteinGapped results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewProteinGapped("ACDEFGHIKLMNPQRSTVWY" + "-") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: -YWVTSRQPNMLKIHGFEDCA, <nil>
type Rna ¶
type Rna struct {
*Struct
}
Rna is a sequence which validates against the Rna alphabet and knows how to reverse, complement, and revcomp itself
func NewRna ¶
NewRna generates a New sequence that validates against the Rna alphabet
Example (Errored) ¶
Building a new Rna from invalid letters results in an error Note that only the first error is returned, not all errors The invalid '%' is caught, but nothing is said of the invalid '&'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewRna("%" + "AUGC" + "&") fmt.Printf("%s, %v", s, err) }
Output: %AUGC&, "%" not in alphabet
Example (Errorless) ¶
Building a new Rna from valid letters results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewRna("AUGC") fmt.Printf("%s, %v", s, err) }
Output: AUGC, <nil>
func (*Rna) Alphabet ¶
Alphabet reveals the underlying alphabet in use
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewRna()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRna("AUGC") fmt.Println(s.Alphabet()) }
Output: ACGU
func (*Rna) Complement ¶
Complement is the same Rna with the sequence complemented
Example (Errored) ¶
Complementing an invalid Rna results in an error Note that both invalid letters '%' and '&' became 'X' (which is also an invalid letter)
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewRna("%" + "AUGC" + "&") rev, err := s.Complement() fmt.Printf("%s, %v", rev, err) }
Output: XUACGX, "X" not in alphabet
Example (Errorless) ¶
Complementing a valid Rna results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRna("AUGC") rev, err := s.Complement() fmt.Printf("%s, %v", rev, err) }
Output: UACG, <nil>
func (*Rna) LetterCount ¶
LetterCount reveals the number of occurrences for each letter in a sequence
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewRna()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRna("AUGC" + "AAAA") fmt.Println(s.LetterCount()) }
Output: map[A:5 C:1 G:1 U:1]
func (*Rna) RevComp ¶
RevComp is the same Rna with the sequence reversed and complemented
Example (Errored) ¶
Reverse complementing an invalid Rna results in an error Note that both invalid letters '%' and '&' became 'X' (which is also an invalid letter)
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewRna("%" + "AUGC" + "&") rev, err := s.RevComp() fmt.Printf("%s, %v", rev, err) }
Output: XGCAUX, "X" not in alphabet
Example (Errorless) ¶
Reverse complementing a valid Rna results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRna("AUGC") rev, err := s.RevComp() fmt.Printf("%s, %v", rev, err) }
Output: GCAU, <nil>
func (*Rna) Reverse ¶
Reverse is the same Rna with the sequence reversed
Example (Errored) ¶
Reversing an invalid Rna results in an error Note that only the first error is returned, not all errors The invalid '&' is caught, but nothing is said of the invalid '%'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRna("%" + "AUGC" + "&") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: &CGUA%, "&" not in alphabet
Example (Errorless) ¶
Reversing a valid Rna results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRna("AUGC") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: CGUA, <nil>
type RnaIupac ¶
type RnaIupac struct {
*Struct
}
RnaIupac is a sequence which validates against the RnaIupac alphabet and knows how to reverse, complement, and revcomp itself
func NewRnaIupac ¶
NewRnaIupac generates a New sequence that validates against the RnaIupac alphabet
Example (Errored) ¶
Building a new RnaIupac from invalid letters results in an error Note that only the first error is returned, not all errors The invalid '%' is caught, but nothing is said of the invalid '&'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewRnaIupac("%" + "RYSWKM" + "BDHV" + "N" + "AUGC" + "-" + "&") fmt.Printf("%s, %v", s, err) }
Output: %RYSWKMBDHVNAUGC-&, "%" not in alphabet
Example (Errorless) ¶
Building a new RnaIupac from valid letters results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewRnaIupac("RYSWKM" + "BDHV" + "N" + "AUGC" + "-") fmt.Printf("%s, %v", s, err) }
Output: RYSWKMBDHVNAUGC-, <nil>
func (*RnaIupac) Alphabet ¶
Alphabet reveals the underlying alphabet in use
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewRnaIupac()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRnaIupac("RYSWKM" + "BDHV" + "N" + "AUGC" + "-") fmt.Println(s.Alphabet()) }
Output: -ABCDGHKMNRSUVWY
func (*RnaIupac) Complement ¶
Complement is the same RnaIupac with the sequence complemented
Example (Errored) ¶
Complementing an invalid RnaIupac results in an error Note that both invalid letters '%' and '&' became 'X' (which is also an invalid letter)
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewRnaIupac("%" + "RYSWKM" + "BDHV" + "N" + "AUGC" + "-" + "&") rev, err := s.Complement() fmt.Printf("%s, %v", rev, err) }
Output: XYRSWMKVHDBNUACG-X, "X" not in alphabet
Example (Errorless) ¶
Complementing a valid RnaIupac results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRnaIupac("RYSWKM" + "BDHV" + "N" + "AUGC" + "-") rev, err := s.Complement() fmt.Printf("%s, %v", rev, err) }
Output: YRSWMKVHDBNUACG-, <nil>
func (*RnaIupac) LetterCount ¶
LetterCount reveals the number of occurrences for each letter in a sequence
Example ¶
Note that the alphabet gets sorted and would be unaffected by an invalid input to immutable.NewRnaIupac()
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRnaIupac("RYSWKM" + "BDHV" + "N" + "AUGC" + "-" + "NNNN") fmt.Println(s.LetterCount()) }
Output: map[-:1 A:1 B:1 C:1 D:1 G:1 H:1 K:1 M:1 N:5 R:1 S:1 U:1 V:1 W:1 Y:1]
func (*RnaIupac) RevComp ¶
RevComp is the same RnaIupac with the sequence reversed and complemented
Example (Errored) ¶
Reverse complementing an invalid RnaIupac results in an error Note that both invalid letters '%' and '&' became 'X' (which is also an invalid letter)
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, err := immutable.NewRnaIupac("%" + "RYSWKM" + "BDHV" + "N" + "AUGC" + "-" + "&") rev, err := s.RevComp() fmt.Printf("%s, %v", rev, err) }
Output: X-GCAUNBDHVKMWSRYX, "X" not in alphabet
Example (Errorless) ¶
Reverse complementing a valid RnaIupac results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRnaIupac("RYSWKM" + "BDHV" + "N" + "AUGC" + "-") rev, err := s.RevComp() fmt.Printf("%s, %v", rev, err) }
Output: -GCAUNBDHVKMWSRY, <nil>
func (*RnaIupac) Reverse ¶
Reverse is the same RnaIupac with the sequence reversed
Example (Errored) ¶
Reversing an invalid RnaIupac results in an error Note that only the first error is returned, not all errors The invalid '&' is caught, but nothing is said of the invalid '%'
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRnaIupac("%" + "RYSWKM" + "BDHV" + "N" + "AUGC" + "-" + "&") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: &-CGUANVHDBMKWSYR%, "&" not in alphabet
Example (Errorless) ¶
Reversing a valid RnaIupac results in no error
package main import ( "fmt" "github.com/bio-ext/bio-go/bio/sequence/immutable" ) func main() { s, _ := immutable.NewRnaIupac("RYSWKM" + "BDHV" + "N" + "AUGC" + "-") rev, err := s.Reverse() fmt.Printf("%s, %v", rev, err) }
Output: -CGUANVHDBMKWSYR, <nil>
type Struct ¶
type Struct struct {
// contains filtered or unexported fields
}
Struct stores a linear sequence and has optional validators
type WithFunc ¶
WithFunc is a transformative function that can be chained
func PositionAs ¶
PositionAs mutates a sequence position