1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
// Copyright ©2011-2013 The bíogo Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package feat
import (
"strings"
)
const (
Undefined Moltype = iota - 1
DNA
RNA
Protein
)
var (
moltypeToString = [...]string{
"DNA", "RNA", "Protein",
}
stringToMoltype map[string]Moltype = map[string]Moltype{}
)
func init() {
for m, s := range moltypeToString {
stringToMoltype[strings.ToLower(s)] = Moltype(m)
stringToMoltype[s] = Moltype(m)
}
}
// Moltype represents the molecule type of a source of sequence data.
type Moltype int8
// Return a string representation of a Moltype.
func (m Moltype) String() string {
if m == Undefined {
return "Undefined"
}
return moltypeToString[m]
}
// ParseMoltype allows conversion from a string to a Moltype.
func ParseMoltype(s string) Moltype {
if m, ok := stringToMoltype[s]; ok {
return m
}
return Undefined
}
|