submat

package
v0.0.0-...-160f2ba Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Example (ScoreSeqs)
package main

import (
	"fmt"
	"github.com/andrew-torda/goutil/gotoh"
	"github.com/andrew-torda/goutil/submat"
)

func main() {
	seqs := []string{"acdefgacdefg", "cdefgacsfg", "cdefgactg", "cdefgacwg"}
	pnltys := gotoh.Pnlty{Open: 2, Wdn: 2}
	substMat, err := submat.Read("blosum62.txt")
	if err != nil {
		fmt.Print(err)
	}
	al_details := gotoh.Al_score{
		Pnlty:   pnltys,
		Al_type: gotoh.Local,
	}
	for i, s := range seqs {
		for j := i + 1; j < len(seqs); j++ {
			t := seqs[j]
			scr_mat := substMat.ScoreSeqs([]byte(s), []byte(t))
			pairlist, a_scr := gotoh.Align(scr_mat, &al_details)
			gotoh.PrintSeqDebug(true, pairlist, []byte(s), []byte(t), gotoh.Global)
			fmt.Println("score", a_scr)
		}
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmmtScanner

type CmmtScanner struct {
	bufio.Scanner
	// contains filtered or unexported fields
}

CmmtScanner is a wrapper around bufio.Scanner that will ignore anything after a comment character and remove leading and trailing white space.

func NewCmmtScanner

func NewCmmtScanner(r io.Reader, cmmt byte) *CmmtScanner

NewCmmtScanner is a wrapper around scanner, but

  • jumps over blank lines
  • removes leading spaces
  • removes anything after a comment character

func (*CmmtScanner) CBytes

func (s *CmmtScanner) CBytes() []byte

CBytes presents exactly the same interface as scanner.Bytes, but has to do a bit more work. Before returning, we remove anything after the comment symbol and strip leading and trailing white space. If this leaves us with an empty string, we call Scan again. Like the Bytes function, this works directly in the i/o buffer and does not allocate any memory. If you like the string it returns, you have to save it somewhere.

type Submat

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

Submat is the export type. it internals do not have to be exported.

func Read

func Read(fname string) (submat *Submat, err error)

Read will read a substitution matrix from a filename. Return a pointer to a Submat structure.

func (*Submat) Score

func (submat *Submat) Score(a, b byte) (f float32)

Score returns the similarity score of bytes a and b, given a specific scoring matrix.

func (*Submat) ScoreSeqs

func (submat *Submat) ScoreSeqs(s, t []byte) (scr_mat *matrix.FMatrix2d)

ScoreSeqs will take two sequences and calculate a similarity matrix based on the substitution matrix. We return an M x N matrix, where M and N are the lengths of first and second sequences respectively.

func (*Submat) String

func (submat *Submat) String() (s string)

String prints out a substitution matrix. Useful during debugging.

Jump to

Keyboard shortcuts

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