"""
Package alphabet provides structs for defining biological sequence alphabets.

"""
# python wrapper for package github.com/bebop/poly/alphabet within overall package poly
# This is what you import to use the package.
# File is generated by gopy. Do not edit.
# gopy pkg -vm=python3 github.com/bebop/poly

# the following is required to enable dlopen to open the _go.so file
import os,sys,inspect,collections
try:
	import collections.abc as _collections_abc
except ImportError:
	_collections_abc = collections

cwd = os.getcwd()
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
os.chdir(currentdir)
from . import _poly
from . import go

os.chdir(cwd)

# to use this code in your end-user python file, import it as follows:
# from poly import alphabet
# and then refer to everything using alphabet. prefix
# packages imported by this package listed below:




# ---- Types ---


#---- Enums from Go (collections of consts with same type) ---


#---- Constants from Go: Python can only ask that you please don't change these! ---


# ---- Global Variables: can only use functions to access ---
def DNA():
	"""
	DNA Gets Go Variable: alphabet.DNA
	
	"""
	return Alphabet(handle=_poly.alphabet_DNA())

def Set_DNA(value):
	"""
	Set_DNA Sets Go Variable: alphabet.DNA
	
	"""
	if isinstance(value, go.GoClass):
		_poly.alphabet_Set_DNA(value.handle)
	else:
		_poly.alphabet_Set_DNA(value)

def Protein():
	"""
	Protein Gets Go Variable: alphabet.Protein
	
	"""
	return Alphabet(handle=_poly.alphabet_Protein())

def Set_Protein(value):
	"""
	Set_Protein Sets Go Variable: alphabet.Protein
	
	"""
	if isinstance(value, go.GoClass):
		_poly.alphabet_Set_Protein(value.handle)
	else:
		_poly.alphabet_Set_Protein(value)

def RNA():
	"""
	RNA Gets Go Variable: alphabet.RNA
	
	"""
	return Alphabet(handle=_poly.alphabet_RNA())

def Set_RNA(value):
	"""
	Set_RNA Sets Go Variable: alphabet.RNA
	
	"""
	if isinstance(value, go.GoClass):
		_poly.alphabet_Set_RNA(value.handle)
	else:
		_poly.alphabet_Set_RNA(value)



# ---- Interfaces ---


# ---- Structs ---

# Python type for struct alphabet.Error
class Error(go.GoClass):
	"""Error is an error type that is returned when a symbol is not in the alphabet.\n"""
	def __init__(self, *args, **kwargs):
		"""
		handle=A Go-side object is always initialized with an explicit handle=arg
		otherwise parameters can be unnamed in order of field names or named fields
		in which case a new Go object is constructed first
		"""
		if len(kwargs) == 1 and 'handle' in kwargs:
			self.handle = kwargs['handle']
			_poly.IncRef(self.handle)
		elif len(args) == 1 and isinstance(args[0], go.GoClass):
			self.handle = args[0].handle
			_poly.IncRef(self.handle)
		else:
			self.handle = _poly.alphabet_Error_CTor()
			_poly.IncRef(self.handle)
	def __del__(self):
		_poly.DecRef(self.handle)
	def __str__(self):
		pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
		sv = 'alphabet.Error{'
		first = True
		for v in pr:
			if callable(v[1]):
				continue
			if first:
				first = False
			else:
				sv += ', '
			sv += v[0] + '=' + str(v[1])
		return sv + '}'
	def __repr__(self):
		pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
		sv = 'alphabet.Error ( '
		for v in pr:
			if not callable(v[1]):
				sv += v[0] + '=' + str(v[1]) + ', '
		return sv + ')'
	def Error(self):
		"""Error() str
		
		Error returns the error message for AlphabetError.
		"""
		return _poly.alphabet_Error_Error(self.handle)

# Python type for struct alphabet.Alphabet
class Alphabet(go.GoClass):
	"""Alphabet is a struct that holds a list of symbols and a map of symbols to their index in the list.\n"""
	def __init__(self, *args, **kwargs):
		"""
		handle=A Go-side object is always initialized with an explicit handle=arg
		otherwise parameters can be unnamed in order of field names or named fields
		in which case a new Go object is constructed first
		"""
		if len(kwargs) == 1 and 'handle' in kwargs:
			self.handle = kwargs['handle']
			_poly.IncRef(self.handle)
		elif len(args) == 1 and isinstance(args[0], go.GoClass):
			self.handle = args[0].handle
			_poly.IncRef(self.handle)
		else:
			self.handle = _poly.alphabet_Alphabet_CTor()
			_poly.IncRef(self.handle)
	def __del__(self):
		_poly.DecRef(self.handle)
	def __str__(self):
		pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
		sv = 'alphabet.Alphabet{'
		first = True
		for v in pr:
			if callable(v[1]):
				continue
			if first:
				first = False
			else:
				sv += ', '
			sv += v[0] + '=' + str(v[1])
		return sv + '}'
	def __repr__(self):
		pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
		sv = 'alphabet.Alphabet ( '
		for v in pr:
			if not callable(v[1]):
				sv += v[0] + '=' + str(v[1]) + ', '
		return sv + ')'
	def Encode(self, symbol):
		"""Encode(str symbol) int, str
		
		Encode returns the index of a symbol in the alphabet.
		"""
		return _poly.alphabet_Alphabet_Encode(self.handle, symbol)
	def Decode(self, code):
		"""Decode(str code) str, str
		
		Decode returns the symbol at a given index in the alphabet.
		"""
		return _poly.alphabet_Alphabet_Decode(self.handle, code)
	def Extend(self, symbols):
		"""Extend([]str symbols) object
		
		Extend returns a new alphabet that is the original alphabet extended with a list of symbols.
		"""
		return Alphabet(handle=_poly.alphabet_Alphabet_Extend(self.handle, symbols.handle))
	def Symbols(self):
		"""Symbols() []str
		
		Symbols returns the list of symbols in the alphabet.
		"""
		return go.Slice_string(handle=_poly.alphabet_Alphabet_Symbols(self.handle))


# ---- Slices ---


# ---- Maps ---


# ---- Constructors ---
def NewAlphabet(symbols):
	"""NewAlphabet([]str symbols) object
	
	NewAlphabet creates a new alphabet from a list of symbols.
	"""
	return Alphabet(handle=_poly.alphabet_NewAlphabet(symbols.handle))


# ---- Functions ---


