import sys;

prot2numf = sys.argv[1]
integrated_embf = sys.argv[2]
yeastoutf = sys.argv[3]
humanoutf = sys.argv[4]

def getmaps(mapf):
	prot2num = {}
	num2prot = {}
	with open(mapf, "r") as fi:
		for line in fi:
			larr = line.split()
			prot = larr[0]
			num = larr[1]
			prot2num[prot] = num
			num2prot[num] = prot
	return prot2num, num2prot

prot2num, num2prot = getmaps(prot2numf)

with open(yeastoutf, "w") as foyeast:
	with open(humanoutf, "w") as fohuman:
		with open(integrated_embf, "r") as fi:
			for line in fi:
				larr = line.split()
				num = larr[0]
				prot = num2prot[num]
				if prot[0] == "s":
					foyeast.write(f"{prot} {' '.join(larr[1:])}\n")
				else:
					fohuman.write(f"{prot} {' '.join(larr[1:])}\n")



