Documentation
¶
Overview ¶
Package chain declares the Chain struct that describes an alignment block and contains functions that operates on chain structs.
Index ¶
- func AllToAxt(ch []Chain, target map[string][]dna.Base, query map[string][]dna.Base) []axt.Axt
- func ChainToBed(ch Chain, useTarget bool) bed.Bed
- func Equal(a []Chain, b []Chain) bool
- func IsChainFile(filename string) bool
- func OverlapChainBed(alpha Chain, beta bed.Bed, checkTarget bool) bool
- func Read(filename string) ([]Chain, HeaderComments)
- func ReadToChan(file *fileio.EasyReader, data chan<- Chain, wg *sync.WaitGroup)
- func SortByCoordinates(align []Chain, useTarget bool)
- func TPosToQPos(c Chain, TPos int) (int, bool)
- func ToAxt(ch Chain, target []dna.Base, query []dna.Base) axt.Axt
- func ToString(ch Chain) string
- func Write(filename string, chaining []Chain, comments HeaderComments)
- func WriteChain(file *fileio.EasyWriter, ch Chain)
- func WriteHeaderComments(file *fileio.EasyWriter, comments HeaderComments)
- func WriteToFile(filename string, chaining <-chan Chain, comments HeaderComments, ...)
- func WriteToFileHandle(file io.Writer, rec Chain)
- type BaseStats
- type Chain
- type HeaderComments
- type SeqChain
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllToAxt ¶
AllToAxt converts a slice of chain structs into a slice of axt structs, taking in the target and query faMaps.
func ChainToBed ¶
ChainToBed converts a chain into a bed region equal to the target bases covered by the chain, or the query bases if useTarget is false.
func IsChainFile ¶
IsChainFile will check the filename suffix and determine if the file input is a chain.
func OverlapChainBed ¶
OverlapChainBed returns true if the provided chain and bed overlap in genomic coordinates. If check target is true, this calculation is done on the chain's target, and otherwise on the chain's query.
func Read ¶
func Read(filename string) ([]Chain, HeaderComments)
Read processes an input file and returns a header stuct and a slice of chain alignments.
func ReadToChan ¶
func ReadToChan(file *fileio.EasyReader, data chan<- Chain, wg *sync.WaitGroup)
ReadToChan processes a chain text file to a channel of chains.
func SortByCoordinates ¶
SortByCoordinates will sort a slice of chain by genomic location. If useTarget is true then this sort will be based on the target coordinates, and will otherwise be the query coordinates.
func TPosToQPos ¶
TPosToQPos converts a target position in a chain to the corresponding query position. The bool returns true if the returned TPos was found in a (Size) section of a Chain, and false otherwise, as in when the TPos fell in TBases.
func ToAxt ¶
ToAxt converts a chain struct to an axt struct, taking in the target and query chromosome sequences.
func Write ¶
func Write(filename string, chaining []Chain, comments HeaderComments)
Write will write a chain slice and any given comments to the top of the file.
func WriteChain ¶
func WriteChain(file *fileio.EasyWriter, ch Chain)
WriteChain processes a chain struct and writes the data to a file.
func WriteHeaderComments ¶
func WriteHeaderComments(file *fileio.EasyWriter, comments HeaderComments)
WriteHeaderComments will take the HeaderComment struct and write to file.
func WriteToFile ¶
func WriteToFile(filename string, chaining <-chan Chain, comments HeaderComments, wg *sync.WaitGroup)
WriteToFile will process a chain channel and writes the data to a file. Once WriteToFile finishes ranging over the channel, it will call Done() on the waitGroup. WaitGroup must be set up beforehand.
func WriteToFileHandle ¶
WriteToFileHandle writes a chain record to an io.Writer
Types ¶
type BaseStats ¶
BaseStats is a cigar-like info for alignment block: First number is the length/size of bases, then number of target gaps and finally query gaps.
type Chain ¶
type Chain struct { Score int TName string TSize int TStrand bool TStart int TEnd int QName string QSize int QStrand bool QStart int QEnd int Alignment []BaseStats Id int }
Chain represents an alignment block based on the UCSC file format for chain
func AxtToChain ¶
AxtToChain converts an Axt alignment into chain format. The lengths of the target and query are needed for the conversion and an id for the chain is also needed as input.
func NewChain ¶
func NewChain(text string, reader *fileio.EasyReader) Chain
NewChain will process text into chain data fields. It will read the first line of the file and assign to header fields and use a reader to read and process the additional lines of the alignment.
func NextChain ¶
func NextChain(reader *fileio.EasyReader) (Chain, bool)
NextChain will read lines from an EasyReader and return one chain record at a time and also a bool, which will be true once it has reached the end of the file and has nothing left to return.
func (Chain) GetChromEnd ¶
GetChromEnd returns the ending position on the target chromosome
func (Chain) GetChromStart ¶
GetChromStart returns the starting position on the target chromosome
func (Chain) WriteToFileHandle ¶
WriteToFileHandle writes the chain to the io.Writer This methods helps to implement the Interval and Lift interfaces.
type HeaderComments ¶
type HeaderComments struct {
HashTag []string
}
HeaderComments stores the comment lines at the beginning of chain alignments into a struct.
func GoReadToChan ¶
func GoReadToChan(filename string) (<-chan Chain, HeaderComments)
GoReadToChan takes a chain filename and launches a go routine to read that file and place the alignments into the channel it returns along with header comments.
func ReadHeaderComments ¶
func ReadHeaderComments(er *fileio.EasyReader) HeaderComments
ReadHeaderComments will process header comments that sometimes appear at the beginning of chain file and returns a struct.