wutil

package
v0.0.0-...-040724e Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2019 License: BSD-3-Clause, GPL-2.0, BSD-3-Clause, + 1 more Imports: 17 Imported by: 11

Documentation

Overview

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

Constants

View Source
const MIXDELIMITER = "+"

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

Variables

This section is empty.

Functions

func AlphaToNum

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.

Example
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

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

func EPSILON_64

func EPSILON_64() float64

constasafunc EPSILON_64 returns the machine epsilon.

func EndsWith

func EndsWith(s, sfx string) bool

func FMax

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

func FMin

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

func GetFloat64FromMap

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

func GetIntFromMap

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

func GetMapFromMap

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

func GetStringFromMap

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

func MakeRankedList

func MakeRankedList(arr []int) []int

func Max

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

func Min

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

func NUniqueStringsInArray

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

func NumToAlpha(n int) string

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

Returns "" when n < 1.

Example
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

func ParseFloat(str string) float64

func ParseInt

func ParseInt(str string) int

func ReadFastaSeqs

func ReadFastaSeqs(fn string) []seq.Sequence

func RoundDown

func RoundDown(v float64) (int, error)

func RoundIgnoreNan

func RoundIgnoreNan(input float64, p int) float64

func RoundInt

func RoundInt(v float64) int
Example
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

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

func SADistinct

func SADistinct(sa []string) []string

func SeqToBioseq

func SeqToBioseq(s seq.Sequence) string

func Series

func Series(start, end int) []int32

func SortMapKeysBy

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

func StrInStrArray

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

func StringArrayEqual

func StringArrayEqual(a1, a2 []string) bool

Types

type AnthaRandom

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

AnthaRandom is a thread-safe version of math/rand

func GetRandom

func GetRandom() *AnthaRandom

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

func GetRandomWithSeed

func GetRandomWithSeed(seed int64, reseed bool) *AnthaRandom

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

func NewAnthaRandom

func NewAnthaRandom(seed int64) *AnthaRandom

NewAnthaRandom returns a thread-safe RNG

func (*AnthaRandom) ExpFloat64

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

func (ar *AnthaRandom) Float32() float32

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

func (*AnthaRandom) Float64

func (ar *AnthaRandom) Float64() float64

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

func (*AnthaRandom) Int

func (ar *AnthaRandom) Int() int

Int returns a non-negative pseudo-random int.

func (*AnthaRandom) Int31

func (ar *AnthaRandom) Int31() int32

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

func (*AnthaRandom) Int31n

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

func (ar *AnthaRandom) Int63() int64

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

func (*AnthaRandom) Int63n

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

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

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

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

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

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

func (ar *AnthaRandom) Uint32() uint32

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

func (*AnthaRandom) Uint64

func (ar *AnthaRandom) Uint64() uint64

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

type Cubic

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

function for cubics

func (Cubic) F

func (c Cubic) F(v float64) float64

func (Cubic) I

func (c Cubic) I(v float64) float64

should decide when this is safe

func (Cubic) Name

func (c Cubic) Name() string

func (*Cubic) P

func (c *Cubic) P() float64

func (*Cubic) Q

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

func (*Cubic) R

func (c *Cubic) R() float64

type Func1Prm

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

func UnmarshalFunc

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

type IntSet

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

func NewIntSet

func NewIntSet(s int) IntSet

func (*IntSet) Add

func (is *IntSet) Add(i int)

func (*IntSet) AsSlice

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

func (*IntSet) Remove

func (is *IntSet) Remove(s int)

type InvertibleFunc1Prm

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

type Quadratic

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

function for quadratics

func (Quadratic) F

func (c Quadratic) F(v float64) float64

func (Quadratic) Name

func (c Quadratic) Name() string

type Quartic

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

function for quadratics

func (Quartic) F

func (c Quartic) F(v float64) float64

func (Quartic) Name

func (q Quartic) Name() string

Directories

Path Synopsis
Package text formats strings for printing in a terminal using ansi codes
Package text formats strings for printing in a terminal using ansi codes

Jump to

Keyboard shortcuts

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