示例#1
0
文件: packed.go 项目: frogs/biogo
func checkPackedAlpha(alpha alphabet.Nucleic) error {
	if alpha.Len() != 4 {
		return bio.NewError("Cannot create packed sequence with alphabet length != 4", 0, alpha)
	}
	for _, v := range alphabet.BytesToLetters([]byte(alpha.String())) {
		if c, ok := alpha.Complement(v); ok && alpha.IndexOf(v) != alpha.IndexOf(c)^0x3 {
			// TODO: Resolution to the following problem:
			// Normal nucleotide alphabets (ACGT/ACGU) are safe with this in either case sensitive or
			// insensitive. Other alphabets may not be, in this case specify case sensitive.
			return bio.NewError("alphabet order not consistent with bit operations for packed.", 0, alpha)
		}
	}

	return nil
}