Merge beagle markers user Kantale

From PyPedia
Jump to: navigation, search

Contents

[edit] Documentation

Merge two beagle markers files.


[edit] Parameters

<inputs>
</inputs>


[edit] Return

[edit] See also

[edit] Code

def Merge_beagle_markers_user_Kantale(
	markers_1 = None,
	markers_2 = None,
	output = None,
):

	mar1_d = {}
	for line in open(markers_1).readlines():
		line_s = line.split()
		mar1_d[line_s[0]] = str.join(" ", line_s[1:])

	mar2_d = {}
	for line in open(markers_2).readlines():
		line_s = line.split()
		mar2_d[line_s[0]] = str.join(" ", line_s[1:])

	common_markers = set( list(mar1_d) + list(mar2_d) )

	output_f = open(output, "w")
	for marker in common_markers:
		if mar1_d.has_key(marker) and mar2_d.has_key(marker):
			if mar1_d[marker] != mar2_d[marker]:
				splitted_1 = mar1_d[marker].split()
				splitted_2 = mar2_d[marker].split()
				if splitted_1[0] == splitted_2[0]:
					#The position is the same
					if splitted_1[1] == splitted_2[2] and splitted_1[2] == splitted_2[1]:
						output_f.write(marker + " " + mar2_d[marker] + "\n")
					else:
						print "Problem in marker:", marker
						print "marker 1:", mar1_d[marker]
						print "marker 2:", mar2_d[marker]
						print "Writing the first.."
						output_f.write(marker + " " + mar1_d[marker] + "\n")
				else:
					print "Problem in marker:", marker
					print "marker 1:", mar1_d[marker]
					print "marker 2:", mar2_d[marker]
					print "Writing the second.."
					output_f.write(marker + " " + mar2_d[marker] + "\n")
			else:
				output_f.write(marker + " " + mar1_d[marker] + "\n")
		elif mar1_d.has_key(marker):
				output_f.write(marker + " " + mar1_d[marker] + "\n")
		elif mar2_d.has_key(marker):
				output_f.write(marker + " " + mar2_d[marker] + "\n")
		else:
			print "How we ended up here?"
	output_f.close()
	print "Warning: markers should be sorted.."
	print "# sort -n -k 2 HAPMAP_GONL_CHR20.markers"

[edit] Unit Tests

def uni1():
	return True

[edit] Development Code

def Merge_beagle_markers_user_Kantale():
	pass

[edit] Permissions

[edit] Documentation Permissions

Kantale

[edit] Code Permissions

Kantale

[edit] Unit Tests Permissions

Kantale

[edit] Permissions Permissions

Kantale

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox