cmd

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: MIT Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const VERSION = "0.12.0"

VERSION of seqkit

Variables

View Source
var IUPACBases map[rune]bool

IUPACBases is a map of valid IUPAC bases.

View Source
var RootCmd = &cobra.Command{
	Use:   "seqkit",
	Short: "a cross-platform and ultrafast toolkit for FASTA/Q file manipulation",
	Long: fmt.Sprintf(`SeqKit -- a cross-platform and ultrafast toolkit for FASTA/Q file manipulation

Version: %s

Author: Wei Shen <shenwei356@gmail.com>

Documents  : http://bioinf.shenwei.me/seqkit
Source code: https://github.com/shenwei356/seqkit
Please cite: https://doi.org/10.1371/journal.pone.0163962

`, VERSION),
}

RootCmd represents the base command when called without any subcommands

View Source
var Threads = runtime.NumCPU()

Threads for bread.NewBufferedReader()

Functions

func BashExec added in v0.11.0

func BashExec(command string)

BashExec executes a command via bash.

func CountReads added in v0.11.0

func CountReads(bamReader *bam.Reader, bamWriter *bam.Writer, countFile string, field string, rangeMin, rangeMax float64, printPass bool, printPrim bool, printLog bool, printBins int, binMode string, mapQual int, printFreq int, printDump bool, printDelay int, printPdf string, execBefore, execAfter string, printQuiet bool)

CountReads counts total, secondary and supplementary reads mapped to each reference.

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func FileExists added in v0.11.0

func FileExists(fn string) bool

FileExists checks if a file exists by calling os.Stat.

func FileSize added in v0.11.0

func FileSize(file string) int

FileSize gets size of a file by calling os.Stat.

func MaxInts added in v0.11.0

func MaxInts(s []int) (m int)

MaxInts calculates the maximum of a slice of integers.

func MinInts added in v0.11.0

func MinInts(s []int) (m int)

MinInts calculates the minimum of a slice of integers.

func NewAnonLinearSeq added in v0.11.0

func NewAnonLinearSeq(s string) *linear.Seq

NewAnonLinearSeq makes a new anonymous linear.Seq.

func NewBamReader added in v0.11.0

func NewBamReader(bamFile string, nrProc int) *bam.Reader

NewBamReader creates a new BAM reader from file.

func NewRawSeqStream added in v0.11.0

func NewRawSeqStream(inFastq string, chanSize int, qBase int) chan *simpleSeq

NewRawSeqStream initializes a new channel for reading fastq records in a robust way.

func NewSAMRecordFromAln added in v0.11.0

func NewSAMRecordFromAln(name string, ref *sam.Reference, refStart, refEnd, queryStart, queryEnd int, refAln, queryAln string, strand string, mapQ byte, seq string, qual []byte, aux []sam.Aux) (*sam.Record, error)

NewRecordFromAln builds a new SAM record based on the provided local alignment and its reference/query coordinates.

func RevCompDNA added in v0.11.0

func RevCompDNA(s string) string

RevCompDNA reverse complements a DNA sequence string.

func ReverseInt added in v0.11.0

func ReverseInt(d []int) []int

ReverseInt revsrees a slice of integers.

func SubLocationFlanking added in v0.11.0

func SubLocationFlanking(length, B, E, begin, end int, strictMode bool) (int, int, bool)

SubLocationFlanking returns location of a flanking range (begin:end, relative to amplicon). B/E: 0-based, location of amplicon. begin/end: 1-based, begin: relative location to 5' end of amplicon, end: relative location to 3' end of amplicon. Returned locations are 1-based.

            F
-----===============-----
 -3-1                        x/y
                    1 3 5    x/y
     F             R
-----=====-----=====-----
=====                        -5:-1
===                          -5:-3
                    =====     1:5
                      ===     3:5
    =================        -1:1
=========================    -5:5
                              x:-y (invalid)

func SubLocationInner added in v0.11.0

func SubLocationInner(length, B, E, begin, end int, strictMode bool) (int, int, bool)

SubLocationInner returns location of a range (begin:end, relative to amplicon). B/E: 0-based, location of amplicon. begin/end: 1-based, begin: relative location to 5' end of amplicon, end: relative location to 3' end of amplicon. Returned locations are 1-based.

            F
-----===============-----
     1 3 5                    x/y
              -5-3-1          x/y
     F             R
-----=====-----=====-----     x:y

     ===============          1:-1
     =======                  1:7
       =====                  3:7
          =====               6:10
          =====             -10:-6
             =====           -7:-3
                             -x:y (invalid)

func SumInts added in v0.11.0

func SumInts(s []int) (r int)

SumInts calculates the sum of a slice of integers.

func ValidateSeq added in v0.11.0

func ValidateSeq(seq *simpleSeq) error

ValidateSeq validates simpleSeq objects.

Types

type AlignedSeq added in v0.11.0

type AlignedSeq struct {
	Ref        *Reference
	Query      *Query
	QueryAln   string
	RefAln     string
	RefStart   int
	RefEnd     int
	QueryStart int
	QueryEnd   int
	Score      float64
	Best       bool
	Detector   *SeqDetector
}

AlignedSeq holds alignment results.

func AlignInfo added in v0.11.0

func AlignInfo(r *Reference, q *Query, f []feat.Pair) *AlignedSeq

AlignInfo constructs an *AlignedSeq structure based on raw alignment results.

func PairwiseAlignSW added in v0.11.0

func PairwiseAlignSW(r *Reference, q *Query, alnParams *AlnParams) *AlignedSeq

PairwiseAlignSW performs pairwise local alignment of two sequences using the biogo implementation of the Smith-Waterman algorithm.

func (*AlignedSeq) AlnString added in v0.11.0

func (a *AlignedSeq) AlnString() string

func (*AlignedSeq) Fields added in v0.11.0

func (a *AlignedSeq) Fields() []string

Fields returns the fields of AlignedSeq in a defined order.

func (*AlignedSeq) String added in v0.11.0

func (a *AlignedSeq) String() string

String generates string represenattion of a *AlignedSeq.

type AlnParams added in v0.11.0

type AlnParams struct {
	Match     int
	Mismatch  int
	GapOpen   int
	GapExtend int
}

AlnParams holds the alignment parameters.

type AmpliconFinder added in v0.11.0

type AmpliconFinder struct {
	Seq []byte
	F   []byte // Forward primer
	R   []byte // R should be reverse complementary sequence of reverse primer

	MaxMismatch int
	FMindex     *fmi.FMIndex
	// contains filtered or unexported fields
}

AmpliconFinder is a struct for locating amplicon via primer(s).

func NewAmpliconFinder added in v0.11.0

func NewAmpliconFinder(sequence, forwardPrimer, reversePrimerRC []byte, maxMismatch int) (*AmpliconFinder, error)

NewAmpliconFinder returns a AmpliconFinder struct.

func (*AmpliconFinder) Locate added in v0.11.0

func (finder *AmpliconFinder) Locate() ([]int, error)

Locate returns location of amplicon. Locations are 1-based, nil returns if not found.

func (*AmpliconFinder) LocateRange added in v0.11.0

func (finder *AmpliconFinder) LocateRange(begin, end int, flanking bool, strictMode bool) ([]int, error)

LocateRange returns location of the range (begin:end, 1-based).

type BedFeature

type BedFeature struct {
	Chr    string
	Start  int // 1based
	End    int // end included
	Name   *string
	Strand *string
}

BedFeature is the gff BedFeature struct

func ReadBedFeatures

func ReadBedFeatures(file string) ([]BedFeature, error)

ReadBedFeatures returns gtf BedFeatures of a file

func ReadBedFilteredFeatures

func ReadBedFilteredFeatures(file string, chrs []string) ([]BedFeature, error)

ReadBedFilteredFeatures returns gtf BedFeatures of selected chrs from file

type Config

type Config struct {
	Alphabet               *seq.Alphabet
	ChunkSize              int
	BufferSize             int
	Threads                int
	LineWidth              int
	IDRegexp               string
	IDNCBI                 bool
	OutFile                string
	Quiet                  bool
	AlphabetGuessSeqLength int
	ValidateSeqLength      int
}

Config is the global falgs

type Queries added in v0.11.0

type Queries []*Query

Queries is a slice of pointers to Query.

type Query added in v0.11.0

type Query struct {
	Name      string
	Seq       string
	Strand    string
	NullScore float64
}

Query holds information about a query sequence.

type Range added in v0.11.0

type Range struct {
	Start float64
	End   float64
}

Range defines a half-open slice over a sequence [Start, End).

func (Range) Len added in v0.11.0

func (r Range) Len() float64

Range returns the length of a range.

type Ranges added in v0.11.0

type Ranges []Range

Ranges is a slice of ranges.

type ReadCounts added in v0.11.0

type ReadCounts []*RefCounts

ReadCounts holds read counts for all references.

func NewReadCounts added in v0.11.0

func NewReadCounts(refs []*sam.Reference) ReadCounts

NewReadCounts initializes a new read count slice.

func (ReadCounts) Sorted added in v0.11.0

func (c ReadCounts) Sorted() ReadCounts

Sorted created a sorted copy of a read counts slice.

type RecordLoopBuffer added in v0.7.0

type RecordLoopBuffer struct {
	Size, Capacity int
	Current        *RecordNode
}

RecordLoopBuffer is a loop buffer for FASTA/Q records

func NewRecordLoopBuffer added in v0.7.0

func NewRecordLoopBuffer(capacity int) (*RecordLoopBuffer, error)

NewRecordLoopBuffer creats new RecordLoopBuffer object with certern capacity

func (*RecordLoopBuffer) Add added in v0.7.0

func (buf *RecordLoopBuffer) Add(value *fastx.Record)

Add add new RecordNode

func (*RecordLoopBuffer) Backward added in v0.7.0

func (buf *RecordLoopBuffer) Backward(n int)

Backward moves the current pointer backward N nodes

func (*RecordLoopBuffer) Next added in v0.7.0

func (buf *RecordLoopBuffer) Next() *RecordNode

Next returns next node

func (*RecordLoopBuffer) Prev added in v0.7.0

func (buf *RecordLoopBuffer) Prev() *RecordNode

Prev returns previous node

type RecordNode added in v0.7.0

type RecordNode struct {
	Value *fastx.Record
	// contains filtered or unexported fields
}

RecordNode is the node for double-linked loop list

func (RecordNode) String added in v0.7.0

func (node RecordNode) String() string

type RefCounts added in v0.11.0

type RefCounts struct {
	Ref      *sam.Reference
	Count    float64
	SecCount float64
	SupCount float64
}

RefCounts is a structure holding read count information for a given reference.

type Reference added in v0.11.0

type Reference struct {
	Name   string
	Seq    string
	Ranges Ranges
}

Reference holds information about a reference sequence along with the target ranges.

type Scorer added in v0.11.0

type Scorer interface {
	Score() int
}

Scorer is an interface for getting alignment score.

type SeqDetector added in v0.11.0

type SeqDetector struct {
	Queries   Queries
	SearchAll bool
	Stranded  bool
	NullMode  string
	Cutoff    float64
	AlnParams *AlnParams
}

SeqDetector holds paramters for sequence detection.

func NewSeqDetector added in v0.11.0

func NewSeqDetector(searchAll bool, stranded bool, nullMode string, cutoff float64, alnParams *AlnParams) *SeqDetector

NewSeqDetector initilizes a SeqDetector object.

func (*SeqDetector) AddAnonQueries added in v0.11.0

func (d *SeqDetector) AddAnonQueries(qrs []string)

AddAnonQueries adds anonymous queries from a list of comma separated strings.

func (*SeqDetector) Detect added in v0.11.0

func (d *SeqDetector) Detect(r *Reference, rec bool) []*AlignedSeq

Detect performs an optinally recursive alignments of the queries of a given reference sequence.

func (*SeqDetector) LoadQueries added in v0.11.0

func (d *SeqDetector) LoadQueries(fx string)

LoadQueries loads queries from a fasta file and calculates null scores for each.

type TopBuffer added in v0.11.0

type TopBuffer []topEntry

TopBuffer is a slice of topEntries.

Jump to

Keyboard shortcuts

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