Exemplo n.º 1
0
def multiple_gating(gate_params):
	points = gate_params['points']
	while True:
		new_name = str(uuid1())
		new_path = ds.generate_path(DATA_BUCKET, None, new_name)
		if not ds.check_exists(new_path, None):
			break
	if (gate_params['tool'] == 'kmeans_gating') :
		if len(points) == 1 :
			clusters = new_name
			number_gates = points[0]
			new_names = [new_name]
			for i in range(0, number_gates-1):
				while True:
					next_new_name = str(uuid1())
					path = ds.generate_path(DATA_BUCKET, None, next_new_name)
					if not ds.check_exists(path, None):
						new_names.append(next_new_name)
						clusters = next_new_name + " " + clusters
						break
			
			queue.gate_kmeans(gate_params['filename'], clusters, str(number_gates), gate_params['axes']['x'], gate_params['axes']['y']);
			return generate_gating_feedback("success", "the kmeans gate was performed correctly", new_names, gate_params['filename'], gate_params['axes']['x'], gate_params['axes']['y'])
		else:
			return generate_gating_feedback("fail", "notcorrect, wrong number of arguments")

	elif (gate_params['tool'] == 'quadrant_gating') :
		if len(points) == 2 :
			other_new_names = []
			for i in range(0, 3):
				while True:
					next_new_name = str(uuid1())
					path = ds.generate_path(DATA_BUCKET, None, next_new_name)
					if not ds.check_exists(path, None):
						other_new_names.append(next_new_name)
						break
			x_coord = str(points[0])
			y_coord = str(points[1])

			queue.gate_quadrant(gate_params['filename'], x_coord, y_coord, new_name, other_new_names[0], other_new_names[1], other_new_names[2], gate_params['axes']['x'], gate_params['axes']['y']);

			new_paths = [new_name] + other_new_names
			new_paths.reverse() #Make sure the user polls for the last graph to be created
							
			return generate_gating_feedback("success", "the quadrant gate was performed correctly", new_paths, gate_params['filename'], gate_params['axes']['x'], gate_params['axes']['y'])
		else:
			return generate_gating_feedback("fail", "notcorrect, wrong number of arguments")