sequtils

package module
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Sets of utilities to parse Fastq/a files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFna

func ExtractFna(file, prefix, taxid string, heads map[string]bool) error

Could be merged / removed because it can be accomplished with combination of simpler function/methods combination Load, Index, NewFasta, AddSequence, Write

func GetAvgQuality

func GetAvgQuality(input *os.File, output *os.File, phred bool) error

GetAvgQuality takes an fastq file and attempts to calculate the average sequence quality and the sequence count. Utilises phred33 representation. usage : GetAvgQuality(<input>, <output>) Keyword arguments: input : File pointer (*os.File()), input data, either gunzipped or plain text. output : File pointer, output data containing the average quality and sequence count.

If output is nil, writes to Stdout

Return: None : Directly writes to file or Stdout

func GetFileType

func GetFileType(inf *os.File) string

func Opener

func Opener(inf, outf string) (*os.File, *os.File, error)

func ParseFastq

func ParseFastq(r *bufio.Scanner, phred64 bool) (float64, float64)

Types

type Association added in v0.9.0

type Association struct {
	Old string
	New string
}

Type used to keep track of old and new header names. For use with Replace, AddHeaderPrefix and AddHeaderSuffix

type Converter added in v0.9.0

type Converter []*Association

func NewConverter added in v0.9.0

func NewConverter(nb int) Converter

Convenience method to create a new converter and allocate enough space for `nb` Associations

func (*Converter) AddAssociation added in v0.9.0

func (c *Converter) AddAssociation(idx int, old, new string) error

Adds an `Association` to the converter, replacing any existing one at position `idx` Return an error if `idx >= len(c)`

func (*Converter) ToCsv added in v0.9.0

func (c *Converter) ToCsv(o string) error

type Fasta

type Fasta struct {
	Header   string
	Sequence string
}

func NewFasta added in v0.8.0

func NewFasta(h, s string) *Fasta

function to create a fasta struct from two strings Take two arguments, 1. h : The header to use (will automatically add the starting '>') 2. s : The sequence itself.

func (*Fasta) Rename added in v0.8.2

func (f *Fasta) Rename(h string)

Changes the header to `h`

func (*Fasta) Subsequence added in v0.6.0

func (f *Fasta) Subsequence(s, e int) (*Fasta, error)

type FastaIndex added in v0.7.0

type FastaIndex map[string]int

type Fastq

type Fastq struct {
	Fasta
	Sep     string
	Quality string
}

type Fna

type Fna []*Fasta

func LoadFasta

func LoadFasta(file string) (Fna, error)

func NewFna added in v0.8.1

func NewFna() Fna

Convinience function to create a Fna struct

func (*Fna) AddFasta added in v0.8.1

func (f *Fna) AddFasta(seq *Fasta)

Convinience method to add a fasta struct to the Fna

func (*Fna) AddHeaderPrefix added in v0.9.0

func (f *Fna) AddHeaderPrefix(h, d string) (Converter, error)

Adds prefix `h` to the sequences' header seperating both by delimiter `d` Return the associated Converter and an error.

func (*Fna) AddHeaderSuffix added in v0.9.0

func (f *Fna) AddHeaderSuffix(h, d string) (Converter, error)

Adds prefix `h` to the sequences' header seperating both by delimiter `d` Return the associated Converter and an error.

func (*Fna) FilterLength

func (f *Fna) FilterLength(min, max int)

Simple Utility to filter the lengths of fasta sequences. Iterates over a slice of Sequences (Fna) and filters out the sequences whose lengths are lower or greater than the specified mininimum and maximum. If maximum <= 0, max is set to the length of the sequence. Returns filtered Fna

func (*Fna) Index added in v0.7.0

func (f *Fna) Index() (FastaIndex, error)

Index the loaded fasta file using fasta headers Assumes that all headers are unique, raises an error if not

func (*Fna) ReplaceHeader added in v0.9.0

func (f *Fna) ReplaceHeader(h string) (Converter, error)

Replaces all existing headers by `h` follow by a sequential number Return the associated Converter and an error.

func (Fna) Write

func (f Fna) Write(o string) error

type Fsq

type Fsq []*Fastq

Jump to

Keyboard shortcuts

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