def question2():
	human = read_protein(HUMAN_EYELESS_URL)
	fly = read_protein(FRUITFLY_EYELESS_URL)
	scoringmatrix = read_scoring_matrix(PAM50_URL)
	pax = read_protein(CONSENSUS_PAX_URL)
	alignmentmatrix = student.compute_alignment_matrix(human, fly, scoringmatrix, False)
	score, align_x, align_y = student.compute_local_alignment(human, fly, scoringmatrix, alignmentmatrix)
	align_x2 = ""
	for item in align_x:
		if not item == '-':
			align_x2 += item 
	align_y2 = ""
	for item in align_y:
		if not item == '-':
			align_y2 += item 
	alignmentmatrix = student.compute_alignment_matrix(align_x2, pax, scoringmatrix, True)
	score3, align_x3, align_y3 = student.compute_global_alignment(align_x2, pax, scoringmatrix, alignmentmatrix)
	print align_x3
	print align_y3	
	print sum([align_x3[item] == align_y3[item] for item in range(len(align_x3))])/float(len(align_x3))
	
	alignmentmatrix = student.compute_alignment_matrix(align_y2, pax, scoringmatrix, True)
	score3, align_x3, align_y3 = student.compute_global_alignment(align_y2, pax, scoringmatrix, alignmentmatrix)
	print align_x3
	print align_y3	
	print sum([align_x3[item] == align_y3[item] for item in range(len(align_x3))])/float(len(align_x3))
def question3():
	letters = "ACBEDGFIHKMLNQPSRTWVYXZ"
	human = [random.choice(letters) for item in range(133)]
	fly = [random.choice(letters) for item in range(133)]
	print human
	print fly
	scoringmatrix = read_scoring_matrix(PAM50_URL)
	pax = read_protein(CONSENSUS_PAX_URL)
	alignmentmatrix = student.compute_alignment_matrix(human, fly, scoringmatrix, False)
	score, align_x, align_y = student.compute_local_alignment(human, fly, scoringmatrix, alignmentmatrix)
	align_x2 = ""
	for item in align_x:
		if not item == '-':
			align_x2 += item 
	align_y2 = ""
	for item in align_y:
		if not item == '-':
			align_y2 += item 
	alignmentmatrix = student.compute_alignment_matrix(align_x2, pax, scoringmatrix, True)
	score3, align_x3, align_y3 = student.compute_global_alignment(align_x2, pax, scoringmatrix, alignmentmatrix)
	print align_x3
	print align_y3	
	print sum([align_x3[item] == align_y3[item] for item in range(len(align_x3))])/float(len(align_x3))
	
	alignmentmatrix = student.compute_alignment_matrix(align_y2, pax, scoringmatrix, True)
	score3, align_x3, align_y3 = student.compute_global_alignment(align_y2, pax, scoringmatrix, alignmentmatrix)
	print align_x3
	print align_y3	
	print sum([align_x3[item] == align_y3[item] for item in range(len(align_x3))])/float(len(align_x3))
def question1():
	human = read_protein(HUMAN_EYELESS_URL)
	fly = read_protein(FRUITFLY_EYELESS_URL)
	scoringmatrix = read_scoring_matrix(PAM50_URL)
	alignmentmatrix = student.compute_alignment_matrix(human, fly, scoringmatrix, False)
	score, align_x, align_y = student.compute_local_alignment(human, fly, scoringmatrix, alignmentmatrix)
	print score
	print align_x
	print align_y
	print len(align_x), len(align_y)
Esempio n. 4
0
def question1():
    human = read_protein(HUMAN_EYELESS_URL)
    fly = read_protein(FRUITFLY_EYELESS_URL)
    scoringmatrix = read_scoring_matrix(PAM50_URL)
    alignmentmatrix = student.compute_alignment_matrix(human, fly,
                                                       scoringmatrix, False)
    score, align_x, align_y = student.compute_local_alignment(
        human, fly, scoringmatrix, alignmentmatrix)
    print score
    print align_x
    print align_y
    print len(align_x), len(align_y)
def question5():
	keys = q4_dict.keys()
	values = q4_dict.values()
	nominator = sum([keys[i] * values[i] for i in range(len(keys))])
	mean = float(nominator) / sum(values)
	nominator = sum([(keys[i] - mean)**2 * values[i] for i in range(len(keys))])
	stddev = math.sqrt(float(nominator) / sum(values))
	human = read_protein(HUMAN_EYELESS_URL)
	fly = read_protein(FRUITFLY_EYELESS_URL)
	scoringmatrix = read_scoring_matrix(PAM50_URL)
	alignmentmatrix = student.compute_alignment_matrix(human, fly, scoringmatrix, False)
	score, align_x, align_y = student.compute_local_alignment(human, fly, scoringmatrix, alignmentmatrix)
	return score, mean, stddev
def generate_null_distribution(seq_x,seq_y, scoring_matrix, num_trials):
	scoring_distribution = dict()
	seq_x_copy = list(seq_x)
	for item in range(num_trials):
		print item
		rand_y = list(seq_y)
		random.shuffle(rand_y)
		alignmentmatrix = student.compute_alignment_matrix(seq_x_copy, rand_y, scoring_matrix, False)
		score, align_x, align_y = student.compute_local_alignment(seq_x_copy, rand_y, scoring_matrix, alignmentmatrix)
		if score in scoring_distribution:
			scoring_distribution[score]+=1
		else:
			scoring_distribution[score] = 1
	return scoring_distribution
Esempio n. 7
0
def question5():
    keys = q4_dict.keys()
    values = q4_dict.values()
    nominator = sum([keys[i] * values[i] for i in range(len(keys))])
    mean = float(nominator) / sum(values)
    nominator = sum([(keys[i] - mean)**2 * values[i]
                     for i in range(len(keys))])
    stddev = math.sqrt(float(nominator) / sum(values))
    human = read_protein(HUMAN_EYELESS_URL)
    fly = read_protein(FRUITFLY_EYELESS_URL)
    scoringmatrix = read_scoring_matrix(PAM50_URL)
    alignmentmatrix = student.compute_alignment_matrix(human, fly,
                                                       scoringmatrix, False)
    score, align_x, align_y = student.compute_local_alignment(
        human, fly, scoringmatrix, alignmentmatrix)
    return score, mean, stddev
Esempio n. 8
0
def generate_null_distribution(seq_x, seq_y, scoring_matrix, num_trials):
    scoring_distribution = dict()
    seq_x_copy = list(seq_x)
    for item in range(num_trials):
        print item
        rand_y = list(seq_y)
        random.shuffle(rand_y)
        alignmentmatrix = student.compute_alignment_matrix(
            seq_x_copy, rand_y, scoring_matrix, False)
        score, align_x, align_y = student.compute_local_alignment(
            seq_x_copy, rand_y, scoring_matrix, alignmentmatrix)
        if score in scoring_distribution:
            scoring_distribution[score] += 1
        else:
            scoring_distribution[score] = 1
    return scoring_distribution
Esempio n. 9
0
def question3():
    letters = "ACBEDGFIHKMLNQPSRTWVYXZ"
    human = [random.choice(letters) for item in range(133)]
    fly = [random.choice(letters) for item in range(133)]
    print human
    print fly
    scoringmatrix = read_scoring_matrix(PAM50_URL)
    pax = read_protein(CONSENSUS_PAX_URL)
    alignmentmatrix = student.compute_alignment_matrix(human, fly,
                                                       scoringmatrix, False)
    score, align_x, align_y = student.compute_local_alignment(
        human, fly, scoringmatrix, alignmentmatrix)
    align_x2 = ""
    for item in align_x:
        if not item == '-':
            align_x2 += item
    align_y2 = ""
    for item in align_y:
        if not item == '-':
            align_y2 += item
    alignmentmatrix = student.compute_alignment_matrix(align_x2, pax,
                                                       scoringmatrix, True)
    score3, align_x3, align_y3 = student.compute_global_alignment(
        align_x2, pax, scoringmatrix, alignmentmatrix)
    print align_x3
    print align_y3
    print sum(
        [align_x3[item] == align_y3[item]
         for item in range(len(align_x3))]) / float(len(align_x3))

    alignmentmatrix = student.compute_alignment_matrix(align_y2, pax,
                                                       scoringmatrix, True)
    score3, align_x3, align_y3 = student.compute_global_alignment(
        align_y2, pax, scoringmatrix, alignmentmatrix)
    print align_x3
    print align_y3
    print sum(
        [align_x3[item] == align_y3[item]
         for item in range(len(align_x3))]) / float(len(align_x3))
Esempio n. 10
0
def question2():
    human = read_protein(HUMAN_EYELESS_URL)
    fly = read_protein(FRUITFLY_EYELESS_URL)
    scoringmatrix = read_scoring_matrix(PAM50_URL)
    pax = read_protein(CONSENSUS_PAX_URL)
    alignmentmatrix = student.compute_alignment_matrix(human, fly,
                                                       scoringmatrix, False)
    score, align_x, align_y = student.compute_local_alignment(
        human, fly, scoringmatrix, alignmentmatrix)
    align_x2 = ""
    for item in align_x:
        if not item == '-':
            align_x2 += item
    align_y2 = ""
    for item in align_y:
        if not item == '-':
            align_y2 += item
    alignmentmatrix = student.compute_alignment_matrix(align_x2, pax,
                                                       scoringmatrix, True)
    score3, align_x3, align_y3 = student.compute_global_alignment(
        align_x2, pax, scoringmatrix, alignmentmatrix)
    print align_x3
    print align_y3
    print sum(
        [align_x3[item] == align_y3[item]
         for item in range(len(align_x3))]) / float(len(align_x3))

    alignmentmatrix = student.compute_alignment_matrix(align_y2, pax,
                                                       scoringmatrix, True)
    score3, align_x3, align_y3 = student.compute_global_alignment(
        align_y2, pax, scoringmatrix, alignmentmatrix)
    print align_x3
    print align_y3
    print sum(
        [align_x3[item] == align_y3[item]
         for item in range(len(align_x3))]) / float(len(align_x3))