def buildseq(inmap,inseq,xdef=None):
	"""given a sequence and the mapping returns the encoding"""
	if xdef is not None:
		xdef = inmap[xdef]
		if len(inmap) < 254:
			r = "".join([chr(inmap.get(x,xdef)) for x in inseq])
		else:
			r = u"".join([unichr(inmap.get(x,xdef)) for x in inseq])
	else:
		if len(inmap)+len(inseq) < 254:
			r = "".join([chr(inmap[x]) for x in inseq])
		else:
			r = u"".join([unichr(inmap[x]) for x in inseq])
	return r
given a sequence and the mapping returns the encoding
recipes/Python/576806_Regular_Expressigeneric_sequences/recipe-576806.py