本文整理汇总了Golang中github.com/biogo/biogo/alphabet.Alphabet.Letter方法的典型用法代码示例。如果您正苦于以下问题:Golang Alphabet.Letter方法的具体用法?Golang Alphabet.Letter怎么用?Golang Alphabet.Letter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/biogo/biogo/alphabet.Alphabet
的用法示例。
在下文中一共展示了Alphabet.Letter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Format
// Convert a Kmer into a string of bases
func Format(kmer Kmer, k int, alpha alphabet.Alphabet) (string, error) {
if alpha.Len() != 4 {
return "", ErrBadAlphabet
}
kmertext := make([]byte, k)
for i := k - 1; i >= 0; i, kmer = i-1, kmer>>2 {
kmertext[i] = byte(alpha.Letter(int(kmer & 3)))
}
return string(kmertext), nil
}
示例2: genCode
func genCode(w io.Writer, m string, a alphabet.Alphabet) error {
f, err := os.Open(m)
if err != nil {
return err
}
b, err := ioutil.ReadAll(f)
if err != nil {
return err
}
s := string(b)
var (
ind = a.LetterIndex()
ref []string
perm []int
mat [][]int
row int
lastBlank bool
)
for _, l := range strings.Split(s, "\n") {
nsl := noSpace(l)
switch {
case len(l) == 0:
if !lastBlank {
lastBlank = true
fmt.Fprintln(w, "\t//")
}
case l[0] == ' ':
ref = strings.Fields(nsl)
perm = make([]int, a.Len())
for i, l := range ref {
li := ind[l[0]]
if li < 0 {
continue
}
perm[li] = i
}
mat = make([][]int, a.Len())
for j := range mat {
mat[j] = make([]int, a.Len())
}
fallthrough
case l[0] == '#':
lastBlank = false
fmt.Fprintf(w, "\t// %s\n", l)
default:
lastBlank = false
fmt.Fprintf(w, "\t// %s\n", l)
for col, f := range strings.Fields(nsl)[1:] {
mat[ind[ref[row][0]]][ind[ref[col][0]]], err = strconv.Atoi(f)
if err != nil {
return err
}
}
row++
}
}
fmt.Fprintf(w, "\t%s = [][]int{\n\t\t/* ", strings.Replace(m, ".", "_", -1))
for j := range mat {
fmt.Printf("%c ", toUpper(a.Letter(j)))
}
fmt.Fprintln(w, "*/")
for i := range mat {
fmt.Printf("\t\t/* %c */ {", toUpper(a.Letter(i)))
for j, e := range mat[i] {
fmt.Fprint(w, e)
if j < len(mat[i])-1 {
fmt.Print(", ")
}
}
fmt.Fprintln(w, "},")
}
fmt.Fprintln(w, "\t}")
return nil
}