def counttc(refbit, tgtbit):
	"""Measure Tanimoto coefficient of reference bit (refbit) and target bit (tgtbit)"""
	a = refbit.count()
	b = tgtbit.count()
	c = 0
	while refbit.length():
		if refbit.pop() & tgtbit.pop():
			c += 1
		if refbit.length() < tgtbit.length():
			tgtbit.pop()

	tc = float(c)/(a+b-c)
	
	return tc