Documentation ¶
Overview ¶
Package genome is a package for representing the genome, relative to a tile library, with Go data structures. Provided are various functions to export/import the data within genomes, along with creating new Genome data structures in memory. Should be used in conjunction with the tilelibrary and structures packages.
Index ¶
- Variables
- func WriteGenomesPathToNumpy(genomes []*Genome, filepath string, path int) error
- type Genome
- func (g *Genome) Add(directory string) error
- func (g *Genome) AddFastJ(filepath string) error
- func (g *Genome) AssignLibrary(library *tilelibrary.Library) error
- func (g *Genome) Liftover(destination *tilelibrary.Library) error
- func (g *Genome) ReadGenomePathNumpy(filepath string) error
- func (g *Genome) WriteNumpy(directory string, genomePath int) error
- func (g *Genome) WriteToFile(filename string) error
- type Path
- type Step
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidGenome = errors.New("not a valid genome file")
ErrInvalidGenome is an error for when a file that is expected to be a .genome file is not one.
var ErrNoLibraryAttached = errors.New("genome has no library attached")
ErrNoLibraryAttached is an error for when a genome does not have a library in its Library field but needs one.
Functions ¶
Types ¶
type Genome ¶
type Genome struct { Paths [][]Path // Paths represents a genome through its paths. Two phases are present here (path and counterpart path). // contains filtered or unexported fields }
Genome is a struct to represent a genome. It contains a pointer to its reference library, which allows for easy tiling. The genome is split into paths, phases, and steps, and at each step there is potentially a tile variant of bases. If Paths[a][b][c] = d, then in the genome at path a, phase b, and step c, the variant is variant number d in the Library at path a and step c. Using the reference library, we can refer to the tile variant at each step using its tile variant number in the library, or using -1 to represent that there's no tile there due to a spanning tile variant.
func New ¶
func New(library *tilelibrary.Library) *Genome
New is a function to initialize a Genome. nil is allowed for the library if the library shouldn't be set yet. It can be set manually later.
func ReadGenomeFromFile ¶
ReadGenomeFromFile reads a text file containing genome information. Current file suffix is .genome (make sure all genomes written to disk have this suffix!)
func (*Genome) AddFastJ ¶
AddFastJ puts the contents of a FastJ into a Genome. Works with both gzipped and non-gzipped FastJ files.
func (*Genome) AssignLibrary ¶
AssignLibrary assigns an existing genome to a library. This library must match the ID found in the libraryID field of g.
func (*Genome) Liftover ¶
Liftover runs a liftover operation on a genome by changing what library the genome is attached to.
func (*Genome) ReadGenomePathNumpy ¶
ReadGenomePathNumpy reads one path's worth of information from a numpy file. This path should be assigned to a path of a genome.
func (*Genome) WriteNumpy ¶
WriteNumpy writes the values of a path of a genome to a numpy array. It alternates between each phase for each step. For example, if path 24 had two steps (0 and 1) all with complete tiles, and on phase 0 the step values were 0 and 2, and on phase 1 the step values were 1 and 1, the numpy array would be [0 1 2 1], since it writes out the data for step 0 first, and then writes out the values for step 1.
func (*Genome) WriteToFile ¶
WriteToFile writes a genome to a list format of indices relative to its reference library. It alternates between each phase for each step. For example, if path 24 had two steps (0 and 1) all with complete tiles, and on phase 0 the step values were 0 and 2, and on phase 1 the step values were 1 and 1, the numpy array would be [0 1 2 1], since it writes out the data for step 0 first, and then writes out the values for step 1. Will not work if the genome does not have a reference library (nil reference).