antha: github.com/antha-lang/antha/antha/anthalib/wutil Index | Examples | Files | Directories

package wutil

import "github.com/antha-lang/antha/antha/anthalib/wutil"

Utility package

anthalib/wutil/ints.go: Part of the Antha language Copyright (C) 2016 The Antha authors. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

For more information relating to the software or licensing issues please contact license@antha-lang.org or write to the Antha team c/o Synthace Ltd. The London Bioscience Innovation Centre 2 Royal College St, London NW1 0NH UK

Index

Examples

Package Files

alphabet.go anthaRandom.go biogo_helpers.go constants.go cubic.go displaymap.go distinct.go endsWith.go error.go floatarray.go func.go ints.go intset.go makerankedlist.go parseint.go quadratic.go quartic.go round.go safegetmapparameter.go series.go sortmapkeysby.go strinstrarray.go warn.go

Constants

const MIXDELIMITER = "+"

MIXDELIMITER is the standard delimiter to be used when concatenating mixed components into a new component name

func AlphaToNum Uses

func AlphaToNum(s string) int

Convert string to n: "A" to 1, 53 to "BA", ... Returns 0 when s contains [^A-Z]

Inverse of NumToAlpha.

Code:

for _, v := range []string{"J", "A", "B", "CV", "AA"} {
    fmt.Printf("%s: %d\n", v, AlphaToNum(v))
}

Output:

J: 10
A: 1
B: 2
CV: 100
AA: 27

func DisplayMap Uses

func DisplayMap(s string, m map[string]interface{})

func EPSILON_64 Uses

func EPSILON_64() float64

constasafunc EPSILON_64 returns the machine epsilon.

func EndsWith Uses

func EndsWith(s, sfx string) bool

func Error Uses

func Error(msg error)

func FMax Uses

func FMax(floats []float64) (float64, bool)

func FMin Uses

func FMin(floats []float64) (float64, bool)

func GetFloat64FromMap Uses

func GetFloat64FromMap(m map[string]interface{}, k string) float64

func GetIntFromMap Uses

func GetIntFromMap(m map[string]interface{}, k string) int

func GetMapFromMap Uses

func GetMapFromMap(m map[string]interface{}, k string) map[string]interface{}

func GetStringFromMap Uses

func GetStringFromMap(m map[string]interface{}, k string) string

func MakeRankedList Uses

func MakeRankedList(arr []int) []int

func Max Uses

func Max(ints []int) (int, bool)

func Min Uses

func Min(ints []int) (int, bool)

func NUniqueStringsInArray Uses

func NUniqueStringsInArray(a []string, excludeBlanks bool) int

NUniqueStringsInArray counts the unique strings in an array i.e. if 1, all strings in the array are the same.

func NumToAlpha Uses

func NumToAlpha(n int) string

Convert n to a string: 1 to "A", 27 to "AA", 53 to "BA", ...

Returns "" when n < 1.

Code:

for _, v := range []int{10, 1, 2, 27, 100} {
    fmt.Printf("%d: %s\n", v, NumToAlpha(v))
}

Output:

10: J
1: A
2: B
27: AA
100: CV

func ParseFloat Uses

func ParseFloat(str string) float64

func ParseInt Uses

func ParseInt(str string) int

func ReadFastaSeqs Uses

func ReadFastaSeqs(fn string) []seq.Sequence

func RoundDown Uses

func RoundDown(v float64) (int, error)

func RoundIgnoreNan Uses

func RoundIgnoreNan(input float64, p int) float64

func RoundInt Uses

func RoundInt(v float64) int

Code:

fmt.Println(RoundInt(-3.3))
fmt.Println(RoundInt(3.3))
fmt.Println(RoundInt(-3.9))
fmt.Println(RoundInt(3.9))
fmt.Println(RoundInt(-3.5))
fmt.Println(RoundInt(3.5))

Output:

-3
3
-4
4
-4
4

func Roundto Uses

func Roundto(input float64, places int) (rounded float64, err error)

func SADistinct Uses

func SADistinct(sa []string) []string

func SeqToBioseq Uses

func SeqToBioseq(s seq.Sequence) string

func Series Uses

func Series(start, end int) []int32

func SortMapKeysBy Uses

func SortMapKeysBy(hashes []map[string]interface{}, key string)

func StrInStrArray Uses

func StrInStrArray(s string, a []string) bool

func StringArrayEqual Uses

func StringArrayEqual(a1, a2 []string) bool

func Warn Uses

func Warn(s string)

type AnthaRandom Uses

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

AnthaRandom is a thread-safe version of math/rand

func GetRandom Uses

func GetRandom() *AnthaRandom

GetRandom returns a random number generator, seeding it if it is not initialised

func GetRandomWithSeed Uses

func GetRandomWithSeed(seed int64, reseed bool) *AnthaRandom

GetRandomWithSeed returns a random number generator, seeded with the seed provided if requested

func NewAnthaRandom Uses

func NewAnthaRandom(seed int64) *AnthaRandom

NewAnthaRandom returns a thread-safe RNG

func (*AnthaRandom) ExpFloat64 Uses

func (ar *AnthaRandom) ExpFloat64() float64

ExpFloat64 returns an exponentially distributed float64 in the range (0, +math.MaxFloat64] with an exponential distribution whose rate parameter (lambda) is 1 and whose mean is 1/lambda (1).

func (*AnthaRandom) Float32 Uses

func (ar *AnthaRandom) Float32() float32

Float32 returns, as a float32, a pseudo-random number in [0.0,1.0).

func (*AnthaRandom) Float64 Uses

func (ar *AnthaRandom) Float64() float64

Float64 returns, as a float64, a pseudo-random number in [0.0,1.0).

func (*AnthaRandom) Int Uses

func (ar *AnthaRandom) Int() int

Int returns a non-negative pseudo-random int.

func (*AnthaRandom) Int31 Uses

func (ar *AnthaRandom) Int31() int32

Int31 returns a non-negative pseudo-random 31-bit integer as an int32.

func (*AnthaRandom) Int31n Uses

func (ar *AnthaRandom) Int31n(n int32) int32

Int31n returns, as an int32, a non-negative pseudo-random number in [0,n). It panics if n <= 0.

func (*AnthaRandom) Int63 Uses

func (ar *AnthaRandom) Int63() int64

Int63 returns a non-negative pseudo-random 63-bit integer as an int64.

func (*AnthaRandom) Int63n Uses

func (ar *AnthaRandom) Int63n(n int64) int64

Int63n returns, as an int64, a non-negative pseudo-random number in [0,n). It panics if n <= 0.

func (*AnthaRandom) Intn Uses

func (ar *AnthaRandom) Intn(n int) int

Intn returns, as an int, a non-negative pseudo-random number in [0,n). It panics if n <= 0.

func (*AnthaRandom) NormFloat64 Uses

func (ar *AnthaRandom) NormFloat64() float64

NormFloat64 returns a normally distributed float64 in the range [-math.MaxFloat64, +math.MaxFloat64] with standard normal distribution (mean = 0, stddev = 1).

func (*AnthaRandom) Perm Uses

func (ar *AnthaRandom) Perm(n int) []int

Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n).

func (*AnthaRandom) Read Uses

func (ar *AnthaRandom) Read(p []byte) (n int, err error)

Read generates len(p) random bytes and writes them into p. It always returns len(p) and a nil error. Read should not be called concurrently with any other Rand method.

func (*AnthaRandom) Seed Uses

func (ar *AnthaRandom) Seed(seed int64)

Seed uses the provided seed value to initialize the generator to a deterministic state. Seed should not be called concurrently with any other Rand method.

func (*AnthaRandom) Uint32 Uses

func (ar *AnthaRandom) Uint32() uint32

Uint32 returns a pseudo-random 32-bit value as a uint32.

func (*AnthaRandom) Uint64 Uses

func (ar *AnthaRandom) Uint64() uint64

Uint64 returns a pseudo-random 64-bit value as a uint64.

type Cubic Uses

type Cubic struct {
    Cubic string
    A     float64
    B     float64
    C     float64
    D     float64
    // contains filtered or unexported fields
}

function for cubics

func (Cubic) F Uses

func (c Cubic) F(v float64) float64

func (Cubic) I Uses

func (c Cubic) I(v float64) float64

should decide when this is safe

func (Cubic) Name Uses

func (c Cubic) Name() string

func (*Cubic) P Uses

func (c *Cubic) P() float64

func (*Cubic) Q Uses

func (c *Cubic) Q(v float64) float64

func (*Cubic) R Uses

func (c *Cubic) R() float64

type Func1Prm Uses

type Func1Prm interface {
    F(x float64) float64
    Name() string
}

func UnmarshalFunc Uses

func UnmarshalFunc(b []byte) (Func1Prm, error)

type IntSet Uses

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

func NewIntSet Uses

func NewIntSet(s int) IntSet

func (*IntSet) Add Uses

func (is *IntSet) Add(i int)

func (*IntSet) AsSlice Uses

func (is *IntSet) AsSlice() []int

func (*IntSet) Remove Uses

func (is *IntSet) Remove(s int)

type InvertibleFunc1Prm Uses

type InvertibleFunc1Prm interface {
    Func1Prm
    I(x float64) float64
}

type Quadratic Uses

type Quadratic struct {
    Quadratic string // just a label
    A         float64
    B         float64
    C         float64
}

function for quadratics

func (Quadratic) F Uses

func (c Quadratic) F(v float64) float64

func (Quadratic) Name Uses

func (c Quadratic) Name() string

type Quartic Uses

type Quartic struct {
    Quartic string
    A       float64
    B       float64
    C       float64
    D       float64
    E       float64
}

function for quadratics

func (Quartic) F Uses

func (c Quartic) F(v float64) float64

func (Quartic) Name Uses

func (q Quartic) Name() string

Directories

PathSynopsis
textPackage text formats strings for printing in a terminal using ansi codes

Package wutil imports 18 packages (graph) and is imported by 11 packages. Updated 2018-05-04. Refresh now. Tools for package owners.