search

package
Version: 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, GPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package search is a utility package providing functions useful for: Searching for a target entry in a slice; Removing duplicate values from a slice; Comparing the Name of two entries of any type with a Name() method returning a string. FindAll instances of a target string within a template string.

Package search is a utility package providing functions useful for: Searching for a target entry in a slice; Removing duplicate values from a slice; Comparing the Name of two entries of any type with a Name() method returning a string. FindAll instances of a target string within a template string.

Package search is a utility package providing functions useful for: Searching for a target entry in a slice; Removing duplicate values from a slice; Comparing the Name of two entries of any type with a Name() method returning a string. FindAll instances of a target string within a template string.

Package search is a utility package providing functions useful for: Searching for a target entry in a slice; Removing duplicate values from a slice; Comparing the Name of two entries of any type with a Name() method returning a string. FindAll instances of a target string within a template string.

Package search is a utility package providing functions useful for: Searching for a target entry in a slice; Removing duplicate values from a slice; Comparing the Name of two entries of any type with a Name() method returning a string. FindAll instances of a target string within a template string.

Package search is a utility package providing functions useful for: Searching for a target entry in a slice; Removing duplicate values from a slice; Comparing the Name of two entries of any type with a Name() method returning a string. FindAll instances of a target string within a template string.

Package search is a utility package providing functions useful for: Searching for a target entry in a slice; Removing duplicate values from a slice; Comparing the Name of two entries of any type with a Name() method returning a string. FindAll instances of a target string within a template string.

Package search is a utility package providing functions useful for: Searching for a target entry in a slice; Removing duplicate values from a slice; Comparing the Name of two entries of any type with a Name() method returning a string. FindAll instances of a target string within a template string.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinarySearchInts

func BinarySearchInts(list []int, target int) bool

BinarySearchInts searchs for an int in a slice of ints using a binary search algorithm.

func CheckArrayType

func CheckArrayType(elements []interface{}) (typeName string, err error)

CheckArrayType reflects the type name as a string of all elements in a slice of interface values. If all values in the slice are not of the same type an error is returned.

func ContainsAllStrings

func ContainsAllStrings(template string, targets []string, options ...Option) (trueornot bool)

ContainsAllStrings searches for all instances of a slice of target strings in a template string. Not perfect yet! issue with byte conversion of certain characters! If all items are present, true is returned. If the IgnoreCase option is specified the strings will be compared ignoring case.

func ContainsEqualFold

func ContainsEqualFold(str, substr string) bool

ContainsEqualFold performs case insensitive evaluation of whether the substr value is present in str. The strings will both be trimmed of leading and trailing space prior to evaluation.

func EqualFold

func EqualFold(a, b string) bool

EqualFold performs case insensitive evaluation of the equality of two strings. The strings will both be trimmed of leading and trailing space prior to evaluation.

func EqualName

func EqualName(entry, target Named, options ...Option) bool

EqualName evaluates whether two arguments with a Name() method have equal names. If the IgnoreCase option is specified the strings will be compared ignoring case.

func FindAll

func FindAll(template string, target string, options ...Option) (positions []int)

FindAll searches for all instances of a target string in a template string. Not perfect yet! issue with byte conversion of certain characters! This returns positions in "HumanFriendly" format (i.e. the first position of the sequence will be 1 not 0) If the IgnoreCase option is specified the strings will be compared ignoring case.

func InInts

func InInts(list []int, target int) bool

InInts searchs for an int in a slice of ints

func InSequences

func InSequences(seqs []wtype.DNASequence, seq wtype.DNASequence, options ...Option) (bool, []int)

InSequences searches the positions of any matching instances of a sequence in a slice of sequences. By default, the name and the sequence will be checked for equality; If IgnoreName is included as an option, matching by name is excluded. If IgnoreSequences is included as an option, matching by sequence is excluded. If IgnoreCase is added as an option the case will be ignored. Ignores any sequence annotations and overhang information. Circularisation is taken into account. i.e. i.e a plasmid will not match with a linear sequence. To require matches to be strict and identical (annotations, overhand info and all) use the ExactMatch option. If ExactMatch is specified, all other Options are ignored.

Important Note: this function will not detect sequence equality if the sequence is: (A) a reverse complement (B) is a plasmid sequence which has been rotated. To handle these cases please use sequences.EqualFold and sequences.InSet: github.com/antha-lang/antha/antha/AnthaStandardLibrary/Packages/sequences/findSeq.go

func InStrings

func InStrings(list []string, target string, options ...Option) bool

InStrings searchs for a target string in a slice of strings and returns a boolean. If the IgnoreCase option is specified the strings will be compared ignoring case.

func IsFreeWell

func IsFreeWell(plate *wtype.Plate, well string) error

IsFreeWell checks for whether a well on a plate is free. An error is returned if the well is not found on the plate or is occupied.

func NextFreeWell

func NextFreeWell(plate *wtype.Plate, avoidWells []string, preferredWells []string, byRow bool, options ...Option) (well string, err error)

NextFreeWell checks for the next well which is empty in a plate. The user can also specify wells to avoid, preffered wells and whether to search through the well positions by row. The default is by column. If the SkipAlternateWells option is used we'll skip every other well. This is designed to support multichannelling when a plate has 16 rows (i.e. 384 well plate) when using a fixed 8 channel pipette head.

func PartialInStrings

func PartialInStrings(list []string, target string, options ...Option) bool

PartialInStrings seaches for a target string in a slice of strings and returns a boolean. True is returned if the target is a subset of a value in the slice of strings (i.e. value "foobar", target "bar" will return True). If the IgnoreCase option is specified the strings will be compared ignoring case.

func PositionsInInts

func PositionsInInts(list []int, target int) []int

PositionsInInts searchs for a target int in a slice of ints and returns all positions found.

func PositionsInStrings

func PositionsInStrings(list []string, target string, options ...Option) []int

PositionsInStrings searchs for a target string in a slice of strings and returns all positions found. If the IgnoreCase option is specified the strings will be compared ignoring case.

func RemoveDuplicateFloats

func RemoveDuplicateFloats(elements []float64) []float64

RemoveDuplicateFloats removes all duplicate values encountered in a slice of floats. No precision is specified to floats must be exact matches in order to be considered duplicates.

func RemoveDuplicateInts

func RemoveDuplicateInts(elements []int) []int

RemoveDuplicateInts removes all duplicate values in a slice of ints.

func RemoveDuplicateSequences

func RemoveDuplicateSequences(elements []wtype.DNASequence, options ...Option) []wtype.DNASequence

RemoveDuplicateSequences checks for sequence and name matches only and will remove any duplicates based on only these criteria. To remove duplicates based on absolute equality use the RemoveDuplicateValues function.

If ignoreName option is added, only duplicate sequences with duplicate plasmid status will be removed. If ignoreSequences option is added, sequences with duplicate names will be removed. If IgnoreCase is included as an option, case insensitive name comparison will be used. Sequence comparison will always be case insensitive Any leading or trailing space is always removed before comparing elements. Ignores any sequence annotations, overhang information and distinction between linear and plasmid DNA. To require matches to be strict and identical (annotations, overhand info and all) use the ExactMatch option. If ExactMatch is specified, all other Options are ignored.

func RemoveDuplicateStrings

func RemoveDuplicateStrings(elements []string, options ...Option) []string

RemoveDuplicateStrings removes all duplicate values in a slice of strings. If IgnoreCase is included as an option, case insensitive comparison will be used. Any leading or traling space is always removed before comparing elements.

func RemoveDuplicateValues

func RemoveDuplicateValues(elements []interface{}) ([]interface{}, error)

RemoveDuplicateValues removes duplicate values of an input slice of interface values and returns all unique entries in slice, preserving the order of the original slice an error will be returned if length of elements is 0

Types

type InvalidWell

type InvalidWell string

InvalidWell is an error type for when an well is requested from a plate which is invalid.

func (InvalidWell) Error

func (err InvalidWell) Error() string

Error returns an error message.

type Named

type Named interface {
	Name() string
}

Named is an interface for any typed value which has a method to return the Name as a string.

type Option

type Option string

Option is an option which can be used as an argument to search functions. Particularly InStrings, InSequences, RemoveDuplicateStrings, RemoveDuplicateSequences.

const (

	// IgnoreCase is an option which can be added to the InStrings and InSequences
	// functions to search ignoring case.
	//
	IgnoreCase Option = "IgnoreCase"

	// IgnoreName is an option which can be added to the InSequences
	// function to specify that matching will not include matching on the name.
	// By default sequence searches check both sequence and name equality.
	//
	IgnoreName Option = "IgnoreName"

	// IgnoreSequence is an option which can be added to the InSequences
	// function to specify that matching not include matching on DNA Sequence.
	// By default sequence searches check both sequence and name equality.
	//
	IgnoreSequence Option = "IgnoreSequence"

	// ExactMatch is an option which can be added to the InSequences function
	// to specify that all properties of the DNASequence must match to be
	// classified as a match. If ExactMatch is specified, currently, all other Options
	// are ignored and ExactMatch takes priority.
	//
	ExactMatch Option = "ExactMatch"

	// MatchName is now deprecated and IgnoreSequence should be used instead
	//
	MatchName Option = "IgnoreSequence"
)

Options available for use in Seqrch functions.

const SkipAlternateWells Option = "SkipAlternateWells"

SkipAlternateWells is an option which can be used in the NextFreeWell function to skip each other well and once the end of the plate is reached go back to the beginning and fill the skipped wells. This is designed to facilitate multichannel when using a 384 well plate and a fixed 8 channel pipette head.

type Result

type Result struct {
	Thing     string
	Positions []int
	Reverse   bool
}

Result is the positions found of a Thing in a query string. Reverse is given as an option to specify if the Result corresponds to a reverse of the original query, or reverse compliment in the case of a DNA sequence. For searching in BioSequences the sequences.SearchResult type is preferred. The sequences.FindAll and sequences.Replace functions are the recommended mechanisms to use with the sequences.SearchResult type. Positions are recorded in Human friendly form, i.e. the position of A in ABC is 1 and not 0.

func FindAllStrings

func FindAllStrings(template string, targets []string, options ...Option) (thingsfound []Result)

FindAllStrings searches for all instances of a slice of target strings in a template string. Not perfect yet! issue with byte conversion of certain characters! This returns positions in "HumanFriendly" format (i.e. the first position of the sequence will be 1 not 0) If the IgnoreCase option is specified the strings will be compared ignoring case.

func (Result) CodeFriendlyPositions

func (r Result) CodeFriendlyPositions() []int

CodeFriendlyPositions returns all positions in code friendly format where the first position is 0. i.e. the position of A in ABC is 0 and not 1.

func (Result) HumanFriendlyPositions

func (r Result) HumanFriendlyPositions() []int

HumanFriendlyPositions returns all positions in human friendly format where the first position is 1. i.e. the position of A in ABC is 1 and not 0.

func (Result) ToString

func (r Result) ToString() (descriptions string)

ToString returns a string description of the Result.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL