mutable

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package mutable is an implementation of biological sequences that mutate internally.

Index

Examples

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

func NewDna(s string) (*Dna, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, err := mutable.NewDna("ATGC")

	fmt.Printf("%s, %v", s, err)
}
Output:

ATGC, <nil>

func (*Dna) Alphabet

func (x *Dna) 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 mutable.NewDna()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.NewDna("ATGC")

	fmt.Println(s.Alphabet())
}
Output:

ACGT

func (*Dna) Complement

func (x *Dna) Complement() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, _ := mutable.NewDna("ATGC")
	rev, err := s.Complement()

	fmt.Printf("%s, %v", rev, err)
}
Output:

TACG, <nil>

func (*Dna) LetterCount

func (x *Dna) 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 mutable.NewDna()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.NewDna("ATGC" + "AAAA")

	fmt.Println(s.LetterCount())
}
Output:

map[A:5 C:1 G:1 T:1]

func (*Dna) RevComp

func (x *Dna) RevComp() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, _ := mutable.NewDna("ATGC")
	rev, err := s.RevComp()

	fmt.Printf("%s, %v", rev, err)
}
Output:

GCAT, <nil>

func (*Dna) Reverse

func (x *Dna) Reverse() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, _ := mutable.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/mutable"
)

func main() {
	s, _ := mutable.NewDna("ATGC")
	rev, err := s.Reverse()

	fmt.Printf("%s, %v", rev, err)
}
Output:

CGTA, <nil>

func (*Dna) Transcribe

func (x *Dna) Transcribe() (sequence.Interface, error)

Transcribe returns the DNA->RNA transcription product

func (*Dna) Translate

func (x *Dna) Translate(table codon.Interface, stop byte) (sequence.Interface, error)

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

func NewDnaIupac(s string) (*DnaIupac, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, err := mutable.NewDnaIupac("RYSWKM" + "BDHV" + "N" + "ATGC" + "-")

	fmt.Printf("%s, %v", s, err)
}
Output:

RYSWKMBDHVNATGC-, <nil>

func (*DnaIupac) Alphabet

func (x *DnaIupac) 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 mutable.NewDnaIupac()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.NewDnaIupac("RYSWKM" + "BDHV" + "N" + "ATGC" + "-")

	fmt.Println(s.Alphabet())
}
Output:

-ABCDGHKMNRSTVWY

func (*DnaIupac) Complement

func (x *DnaIupac) Complement() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, _ := mutable.NewDnaIupac("RYSWKM" + "BDHV" + "N" + "ATGC" + "-")
	rev, err := s.Complement()

	fmt.Printf("%s, %v", rev, err)
}
Output:

YRSWMKVHDBNTACG-, <nil>

func (*DnaIupac) LetterCount

func (x *DnaIupac) 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 mutable.NewDnaIupac()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.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

func (x *DnaIupac) RevComp() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, _ := mutable.NewDnaIupac("RYSWKM" + "BDHV" + "N" + "ATGC" + "-")
	rev, err := s.RevComp()

	fmt.Printf("%s, %v", rev, err)
}
Output:

-GCATNBDHVKMWSRY, <nil>

func (*DnaIupac) Reverse

func (x *DnaIupac) Reverse() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, _ := mutable.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/mutable"
)

func main() {
	s, _ := mutable.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

func NewProtein(s string) (*Protein, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, err := mutable.NewProtein("ACDEFGHIKLMNPQRSTVWY")

	fmt.Printf("%s, %v", s, err)
}
Output:

ACDEFGHIKLMNPQRSTVWY, <nil>

func (*Protein) Alphabet

func (x *Protein) 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 mutable.NewProtein()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.NewProtein("ACDEFGHIKLMNPQRSTVWY")

	fmt.Println(s.Alphabet())
}
Output:

ACDEFGHIKLMNPQRSTVWY

func (*Protein) LetterCount

func (x *Protein) 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 mutable.NewProtein()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.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

func (x *Protein) Reverse() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, _ := mutable.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/mutable"
)

func main() {
	s, _ := mutable.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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, err := mutable.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 mutable.NewProteinGapped()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.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 mutable.NewProteinGapped()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.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/mutable"
)

func main() {
	s, _ := mutable.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/mutable"
)

func main() {
	s, _ := mutable.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

func NewRna(s string) (*Rna, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, err := mutable.NewRna("AUGC")

	fmt.Printf("%s, %v", s, err)
}
Output:

AUGC, <nil>

func (*Rna) Alphabet

func (x *Rna) 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 mutable.NewRna()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.NewRna("AUGC")

	fmt.Println(s.Alphabet())
}
Output:

ACGU

func (*Rna) Complement

func (x *Rna) Complement() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, _ := mutable.NewRna("AUGC")
	rev, err := s.Complement()

	fmt.Printf("%s, %v", rev, err)
}
Output:

UACG, <nil>

func (*Rna) LetterCount

func (x *Rna) 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 mutable.NewRna()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.NewRna("AUGC" + "AAAA")

	fmt.Println(s.LetterCount())
}
Output:

map[A:5 C:1 G:1 U:1]

func (*Rna) RevComp

func (x *Rna) RevComp() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, _ := mutable.NewRna("AUGC")
	rev, err := s.RevComp()

	fmt.Printf("%s, %v", rev, err)
}
Output:

GCAU, <nil>

func (*Rna) Reverse

func (x *Rna) Reverse() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, _ := mutable.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/mutable"
)

func main() {
	s, _ := mutable.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

func NewRnaIupac(s string) (*RnaIupac, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, err := mutable.NewRnaIupac("RYSWKM" + "BDHV" + "N" + "AUGC" + "-")

	fmt.Printf("%s, %v", s, err)
}
Output:

RYSWKMBDHVNAUGC-, <nil>

func (*RnaIupac) Alphabet

func (x *RnaIupac) 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 mutable.NewRnaIupac()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.NewRnaIupac("RYSWKM" + "BDHV" + "N" + "AUGC" + "-")

	fmt.Println(s.Alphabet())
}
Output:

-ABCDGHKMNRSUVWY

func (*RnaIupac) Complement

func (x *RnaIupac) Complement() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, _ := mutable.NewRnaIupac("RYSWKM" + "BDHV" + "N" + "AUGC" + "-")
	rev, err := s.Complement()

	fmt.Printf("%s, %v", rev, err)
}
Output:

YRSWMKVHDBNUACG-, <nil>

func (*RnaIupac) LetterCount

func (x *RnaIupac) 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 mutable.NewRnaIupac()

package main

import (
	"fmt"

	"github.com/bio-ext/bio-go/bio/sequence/mutable"
)

func main() {
	s, _ := mutable.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

func (x *RnaIupac) RevComp() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, err := mutable.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/mutable"
)

func main() {
	s, _ := mutable.NewRnaIupac("RYSWKM" + "BDHV" + "N" + "AUGC" + "-")
	rev, err := s.RevComp()

	fmt.Printf("%s, %v", rev, err)
}
Output:

-GCAUNBDHVKMWSRY, <nil>

func (*RnaIupac) Reverse

func (x *RnaIupac) Reverse() (sequence.Interface, error)

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/mutable"
)

func main() {
	s, _ := mutable.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/mutable"
)

func main() {
	s, _ := mutable.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

func New

func New(s string, vs ...sequence.ValFunc) *Struct

New generates a new generalized sequence with optional validators

func (*Struct) Length

func (x *Struct) Length() uint

Length is the number of positions in the sequence

func (*Struct) Position

func (x *Struct) Position(n uint) (string, error)

Position is the letter found at position n

func (*Struct) Range

func (x *Struct) Range(st, sp uint) (string, error)

Range is the letters found in the half-open range

func (*Struct) String

func (x *Struct) String() string

String reveals the underlying string

func (*Struct) Validate

func (x *Struct) Validate() error

Validate runs a series of Validator funcs, returning the first error

func (*Struct) With

func (x *Struct) With(fs ...WithFunc) *Struct

With runs a series of transformative actions, returning the final result Attention: With does not call Validate.

type WithFunc

type WithFunc func(*Struct) *Struct

WithFunc is a transformative function that can be chained

func PositionAs

func PositionAs(n uint, pos string) WithFunc

PositionAs mutates a sequence position

func RangeAs

func RangeAs(st, sp uint, pos string) WithFunc

RangeAs mutates a sequence range

type Wither

type Wither interface {
	With(...WithFunc) *Struct
}

Wither provides a variadic method to transform the sequence

Jump to

Keyboard shortcuts

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