graph

package
v0.0.0-...-1be76fa Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package graph is used to process graphs. It converts, writes, aligns reads and processes GROOT graphs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadGFA

func LoadGFA(fileName string) (*gfa.GFA, error)

LoadGFA reads a GFA file into a GFA struct

Types

type GrootGraph

type GrootGraph struct {
	GrootVersion string
	GraphID      uint32
	SortedNodes  []*GrootGraphNode // essentially, this is the graph - a topologically sorted array of nodes
	Paths        map[uint32][]byte // lookup to relate PathIDs in each node to a path name
	Lengths      map[uint32]int    // lengths of sequences held in graph (lookup key corresponds to key in Paths)
	NodeLookup   map[uint64]int    // this map returns a the position of a node in the SortedNodes array, using the node segmentID as the locator
	Masked       bool              // a flag to prevent the graph being used by GROOT
	KmerTotal    uint64            // the total number of k-mers projected onto the graph
	EMiterations int               // the number of EM iterations ran
	// contains filtered or unexported fields
}

GrootGraph is the variation graph implementation used by GROOT

func CreateGrootGraph

func CreateGrootGraph(gfaInstance *gfa.GFA, id int) (*GrootGraph, error)

CreateGrootGraph is a GrootGraph constructor that takes a GFA instance and stores the info as a graph and then runs a topological sort

func (*GrootGraph) AlignRead

func (GrootGraph *GrootGraph) AlignRead(read *seqio.FASTQread, mapping *lshe.Key, references []*sam.Reference) ([]*sam.Record, error)

AlignRead is a method to run a read to graph hierarchical alignment

func (*GrootGraph) GetEMpaths

func (GrootGraph *GrootGraph) GetEMpaths() ([]string, []float64)

GetEMpaths is a method to print the paths and abundance values

func (*GrootGraph) GetNode

func (GrootGraph *GrootGraph) GetNode(nodeID uint64) (*GrootGraphNode, error)

GetNode takes a nodeID and returns a pointer to the corresponding node struct in the graph Note: this is method does not allow concurrent map access

func (*GrootGraph) GetPaths

func (GrootGraph *GrootGraph) GetPaths() error

GetPaths is a method to get the paths from a graph

func (*GrootGraph) GetRefIDs

func (GrootGraph *GrootGraph) GetRefIDs() ([]string, error)

GetRefIDs is a method to return all the reference IDs that are encoded as sequences in the graph

func (*GrootGraph) GetSketchStats

func (GrootGraph *GrootGraph) GetSketchStats() (int, int, int, error)

GetSketchStats returns the number of windows processed from the graph, the number of distinct sketches, the max span for merged sketches and any error

func (*GrootGraph) Graph2Seqs

func (GrootGraph *GrootGraph) Graph2Seqs() (map[uint32][]byte, error)

Graph2Seqs is a method to convert a variation graph to linear reference sequences

func (*GrootGraph) IncrementKmerCount

func (GrootGraph *GrootGraph) IncrementKmerCount(increment uint64)

IncrementKmerCount is a method to increment the counter for the number of kmers projected onto the graph

func (*GrootGraph) IncrementSubPath

func (GrootGraph *GrootGraph) IncrementSubPath(ContainedNodes map[uint64]float64, numKmers float64) error

IncrementSubPath is a method to adjust the weight of segments that are contained within a given sketch

  • given a ContainedNodes through a graph, the offset in the first segment, and the number of k-mers in this ContainedNodes
  • increment the weight of each segment contained in that ContainedNodes by their share of the k-mer coverage for the sketch

func (*GrootGraph) ProcessEMpaths

func (GrootGraph *GrootGraph) ProcessEMpaths(cutoff float64, totalKmers int) error

ProcessEMpaths is a method to process the paths after EM has been run

func (*GrootGraph) Prune

func (GrootGraph *GrootGraph) Prune(minKmerCoverage float64) bool

Prune is a method to remove paths and segments from the graph if they have insufficient coverage returns false if pruning results in no paths through the graph remaining

func (*GrootGraph) RemoveDeadPaths

func (GrootGraph *GrootGraph) RemoveDeadPaths() error

RemoveDeadPaths is a method to remove pathIDs from nodes if the path is no longer present in the graph

func (*GrootGraph) RunEM

func (GrootGraph *GrootGraph) RunEM(minIterations, numIterations int) error

RunEM is a method to run EM on an approximately weighted variation graph

func (*GrootGraph) SaveGraphAsGFA

func (GrootGraph *GrootGraph) SaveGraphAsGFA(fileName string, totalKmers int) (int, error)

SaveGraphAsGFA is a method to convert and save a GrootGraph in GFA format

func (*GrootGraph) WindowGraph

func (GrootGraph *GrootGraph) WindowGraph(windowSize, kmerSize, sketchSize int) (map[string]lshe.Keys, error)

WindowGraph is a method to slide a window over each path through the graph, sketching the paths and getting window information

type GrootGraphNode

type GrootGraphNode struct {
	SegmentID     uint64
	SegmentLength float64
	Sequence      []byte
	OutEdges      Nodes
	PathIDs       []uint32    // PathIDs are the lookup IDs to the linear reference sequences that use this segment (value corresponds to key in GrootGraph.Paths)
	Position      map[int]int // the start position of this segment in each reference sequence, using 1-based indexing (lookup key corresponds to PathID)
	KmerFreq      float64
	Marked        bool // TODO: tmp idea to mark nodes during pruning, rather than deleting
}

GrootGraphNode is a GFA segment (plus the extra info from path, links etc.) Note: GrootGraphNodes are not set up for concurrent access

func (*GrootGraphNode) IncrementKmerFreq

func (GrootGraphNode *GrootGraphNode) IncrementKmerFreq(increment float64) error

IncrementKmerFreq is a method to increment a node's k-mer count

type Nodes

type Nodes []uint64

Nodes is a slice of GrootGraphNodes

func (Nodes) Len

func (Nodes Nodes) Len() int

methods for Nodes to satisfy the sort interface

func (Nodes) Less

func (Nodes Nodes) Less(i, j int) bool

func (Nodes) Swap

func (Nodes Nodes) Swap(i, j int)

type Store

type Store map[uint32]*GrootGraph

Store stores the GROOT graphs, using the graphID as the lookup key

func (Store) GetSAMrefs

func (graphStore Store) GetSAMrefs() (map[int][]*sam.Reference, error)

GetSAMrefs is a method to convert all paths held in graphStore to sam.References

Jump to

Keyboard shortcuts

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