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 ¶
- Constants
- func AlphaToNum(s string) int
- func DisplayMap(s string, m map[string]interface{})
- func EPSILON_64() float64
- func EndsWith(s, sfx string) bool
- func FMax(floats []float64) (float64, bool)
- func FMin(floats []float64) (float64, bool)
- func GetFloat64FromMap(m map[string]interface{}, k string) float64
- func GetIntFromMap(m map[string]interface{}, k string) int
- func GetMapFromMap(m map[string]interface{}, k string) map[string]interface{}
- func GetStringFromMap(m map[string]interface{}, k string) string
- func MakeRankedList(arr []int) []int
- func Max(ints []int) (int, bool)
- func Min(ints []int) (int, bool)
- func NUniqueStringsInArray(a []string, excludeBlanks bool) int
- func NumToAlpha(n int) string
- func ParseFloat(str string) float64
- func ParseInt(str string) int
- func ReadFastaSeqs(fn string) []seq.Sequence
- func RoundDown(v float64) (int, error)
- func RoundIgnoreNan(input float64, p int) float64
- func RoundInt(v float64) int
- func Roundto(input float64, places int) (rounded float64, err error)
- func SADistinct(sa []string) []string
- func SeqToBioseq(s seq.Sequence) string
- func Series(start, end int) []int32
- func SortMapKeysBy(hashes []map[string]interface{}, key string)
- func StrInStrArray(s string, a []string) bool
- func StringArrayEqual(a1, a2 []string) bool
- type AnthaRandom
- func (ar *AnthaRandom) ExpFloat64() float64
- func (ar *AnthaRandom) Float32() float32
- func (ar *AnthaRandom) Float64() float64
- func (ar *AnthaRandom) Int() int
- func (ar *AnthaRandom) Int31() int32
- func (ar *AnthaRandom) Int31n(n int32) int32
- func (ar *AnthaRandom) Int63() int64
- func (ar *AnthaRandom) Int63n(n int64) int64
- func (ar *AnthaRandom) Intn(n int) int
- func (ar *AnthaRandom) NormFloat64() float64
- func (ar *AnthaRandom) Perm(n int) []int
- func (ar *AnthaRandom) Read(p []byte) (n int, err error)
- func (ar *AnthaRandom) Seed(seed int64)
- func (ar *AnthaRandom) Uint32() uint32
- func (ar *AnthaRandom) Uint64() uint64
- type Cubic
- type Func1Prm
- type IntSet
- type InvertibleFunc1Prm
- type Quadratic
- type Quartic
Examples ¶
Constants ¶
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 ¶
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 GetFloat64FromMap ¶
func GetIntFromMap ¶
func GetMapFromMap ¶
func GetStringFromMap ¶
func MakeRankedList ¶
func NUniqueStringsInArray ¶
NUniqueStringsInArray counts the unique strings in an array i.e. if 1, all strings in the array are the same.
func NumToAlpha ¶
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 ReadFastaSeqs ¶
func RoundIgnoreNan ¶
func RoundInt ¶
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 SADistinct ¶
func SeqToBioseq ¶
func SortMapKeysBy ¶
func StrInStrArray ¶
func StringArrayEqual ¶
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