utils

package
v0.0.0-...-0d57c95 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package orderedmap implements an ordered map, i.e. a map that also keeps track of the order in which keys were inserted.

All operations are constant-time.

Github repo: https://github.com/wk8/go-ordered-map

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBamIndex

func CreateBamIndex(bamFile string) (err error)

CreateBamIndex is a temp implement for creating bai, by samtools command

func CtgName2Id

func CtgName2Id(ctg string) int

CtgName2Id convert chromosome name to bam (vcf) header idx (b37 for default) e.g. Mitochondrion named MT not M, and is followed by Y chromosome

Types

type OrderedMap

type OrderedMap struct {
	// contains filtered or unexported fields
}

func New

func New() *OrderedMap

New creates a new OrderedMap.

func (*OrderedMap) Delete

func (om *OrderedMap) Delete(key interface{}) (interface{}, bool)

Delete removes the key-value pair, and returns what `Get` would have returned on that key prior to the call to `Delete`.

func (*OrderedMap) Get

func (om *OrderedMap) Get(key interface{}) (interface{}, bool)

Get looks for the given key, and returns the value associated with it, or nil if not found. The boolean it returns says whether the key is present in the map.

func (*OrderedMap) GetPair

func (om *OrderedMap) GetPair(key interface{}) *Pair

GetPair looks for the given key, and returns the pair associated with it, or nil if not found. The Pair struct can then be used to iterate over the ordered map from that point, either forward or backward.

func (*OrderedMap) Len

func (om *OrderedMap) Len() int

Len returns the length of the ordered map.

func (*OrderedMap) Load

func (om *OrderedMap) Load(key interface{}) (interface{}, bool)

func (*OrderedMap) MoveAfter

func (om *OrderedMap) MoveAfter(key interface{}, mark_key interface{}) error

func (*OrderedMap) MoveBefore

func (om *OrderedMap) MoveBefore(key interface{}, mark_key interface{}) error

func (*OrderedMap) MoveToBack

func (om *OrderedMap) MoveToBack(key interface{}) error

func (*OrderedMap) MoveToFront

func (om *OrderedMap) MoveToFront(key interface{}) error

func (*OrderedMap) Newest

func (om *OrderedMap) Newest() *Pair

Newest returns a pointer to the newest pair. It's meant to be used to iterate on the ordered map's pairs from the newest to the oldest, e.g.: for pair := orderedMap.Oldest(); pair != nil; pair = pair.Next() { fmt.Printf("%v => %v\n", pair.Key, pair.Value) }

func (*OrderedMap) Oldest

func (om *OrderedMap) Oldest() *Pair

Oldest returns a pointer to the oldest pair. It's meant to be used to iterate on the ordered map's pairs from the oldest to the newest, e.g.: for pair := orderedMap.Oldest(); pair != nil; pair = pair.Next() { fmt.Printf("%v => %v\n", pair.Key, pair.Value) }

func (*OrderedMap) Set

func (om *OrderedMap) Set(key interface{}, value interface{}) (interface{}, bool)

Set sets the key-value pair, and returns what `Get` would have returned on that key prior to the call to `Set`.

func (*OrderedMap) Store

func (om *OrderedMap) Store(key interface{}, value interface{}) (interface{}, bool)

type Pair

type Pair struct {
	Key   interface{}
	Value interface{}
	// contains filtered or unexported fields
}

func (*Pair) Next

func (p *Pair) Next() *Pair

Next returns a pointer to the next pair.

func (*Pair) Prev

func (p *Pair) Prev() *Pair

Previous returns a pointer to the previous pair.

Jump to

Keyboard shortcuts

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