Ejemplo n.º 1
0
def boolean_gating(gate_params):
	points = gate_params['points']
	points2 = gate_params['1']
	boolean_op = gate_params['0']
	reverse_gate = '0'

	if 'reverse' in gate_params:
		if (gate_params['reverse']):
			reverse_gate = '1'

	## Generate unique datastore path, ensuring uniqueness.
	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'] == "boolean_gating"):
		if (len(points)%2 == 0) and (len(points2)%2 == 0):
			if (reverse_gate == '1'):
				if (boolean_op == 'or'):
					boolean_op = 'and'
				elif (boolean_op == 'and'):
					boolean_op = 'or'
				else:
					return generate_gating_feedback("fail", "The boolean operator must be either 'and' or 'or'")
			gate1_points = " ".join(str(p) for p in points)
			gate2_points = " ".join(str(p) for p in points2)
			queue.gate_boolean(gate_params['filename'], new_name, boolean_op, 'poly', gate1_points, reverse_gate, 'poly', gate2_points, reverse_gate, gate_params['axes']['x'], gate_params['axes']['y'], gate_params['axes']['x'], gate_params['axes']['y']);
			return generate_gating_feedback("success", "the boolean gating was performed correctly", new_name, gate_params['filename'], gate_params['axes']['x'], gate_params['axes']['y'])
		else:
			return generate_gating_feedback("fail", "notcorrect, wrong number of arguments")
Ejemplo n.º 2
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")
Ejemplo n.º 3
0
 def new_file(self, field_name, file_name, content_type, content_length, charset):
     ## Generate unique datastore path, ensuring uniqueness.
     while True:
         self.name = str(uuid1())
         path = ds.generate_path(buckets.DATA + "/", None, self.name)
         if not ds.check_exists(path, None):
             break
             ## Generate friendly name.
     friendly_name = splitext(file_name)[0]
     ## Setup file handle.
     self.file_handle = ds.add_file(path, friendly_name, "raw_data", "w")
     ## Setup uploaded file.
     self.upload = fcsUploadedFile(path, self.name, content_type, charset)
     return None
Ejemplo n.º 4
0
def change_axes(tool_params):
	## Generate unique datastore path, ensuring uniqueness.
	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 tool_params['newAxes']['x'] == tool_params['newAxes']['y']:
		return generate_gating_feedback("fail", "Please choose two different axes")

	# todo: check if the axes exist.

	queue.change_axis(tool_params['filename'], tool_params['newAxes']['x'], tool_params['newAxes']['y'], new_name)

	return generate_gating_feedback("success","the axis change was performed", new_name, tool_params['filename'], tool_params['newAxes']['x'], tool_params['newAxes']['y'])
Ejemplo n.º 5
0
def simple_gating(gate_params):
	points = gate_params['points']
	reverse_gate = '0'

	if 'reverse' in gate_params:
		if (gate_params['reverse']):
			reverse_gate = '1'

	## Generate unique datastore path, ensuring uniqueness.
	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'] == "rectangular_gating") :
		if len(points) == 4 :
			#Reoder the point to take the topLeft and bottomRight points of the square 
			if points[0] > points[2]:
				tempcoor = points[0]
				points[0] = points[2]
				points[2] = tempcoor
			if points[1] > points[3]:
				tempcoor = points[1]
				points[1] = points[3]
				points[3] = tempcoor

			gating_request = " ".join(str(p) for p in points)

			queue.gate_rectangle(gate_params['filename'], gating_request, new_name, reverse_gate, gate_params['axes']['x'], gate_params['axes']['y']);
			return generate_gating_feedback("success", "the rectangular gating was performed correctly", new_name, gate_params['filename'], gate_params['axes']['x'], gate_params['axes']['y'])
		else:
			return generate_gating_feedback("fail", "notcorrect " + params + " length:" + str(len(points)) + " is not equal to 4")

	elif (gate_params['tool'] == "polygon_gating") :
		if len(points)%2 == 0 :
			gating_request = " ".join(str(p) for p in points)

			queue.gate_polygon(gate_params['filename'], gating_request, new_name, reverse_gate, gate_params['axes']['x'], gate_params['axes']['y']);
			return generate_gating_feedback("success", "the polygonal gating was performed correctly", new_name, gate_params['filename'], gate_params['axes']['x'], gate_params['axes']['y'])
		else:
			return generate_gating_feedback("fail", "notcorrect " + params + " #pointCoordinates:" + str(len(points))-1 + " is not pair")

	elif (gate_params['tool'] == "oval_gating") :
		if len(points) == 6 :
			gating_request = " ".join(str(p) for p in points)

			queue.gate_circle(gate_params['filename'], gating_request, new_name, reverse_gate, gate_params['axes']['x'], gate_params['axes']['y']);
			return generate_gating_feedback("success", "the oval gating was performed correctly", new_name, gate_params['filename'], gate_params['axes']['x'], gate_params['axes']['y'])
		else:
			return generate_gating_feedback("fail", "notcorrect " + params + " #pointCoordinates:" + str(len(points)) + " is not even")

	elif (gate_params['tool'] == 'normal_gating') :
		if len(points) == 1 :
			gating_request = str(points[0])

			queue.gate_normal(gate_params['filename'], new_name, reverse_gate, gate_params['axes']['x'], gate_params['axes']['y'], gating_request);
			return generate_gating_feedback("success", "the normal gating was performed correctly", new_name, gate_params['filename'], gate_params['axes']['x'], gate_params['axes']['y'])
		else:
			return generate_gating_feedback("fail", "notcorrect, wrong number of arguments")

	else :
		return generate_gating_feedback("fail", "The gate " + gate_params['tool'] + " is not known")