def random_alignment(scoring_matrix): ''' Take two random amino acids, compute the alignment and the consensus with pax Return the ratio of similarity To examine the solution of the homework ''' alphabet = "ACBEDGFIHKMLNQPSRTWVYXZ" length_human = 422 length_fruitfly = 857 random_human = '' for _ in range(length_human): random_human += random.choice(alphabet) random_fruitfly = '' for _ in range(length_fruitfly): random_fruitfly += random.choice(alphabet) alignment_matrix = compute_alignment_matrix(seq_x=random_human, seq_y=random_fruitfly, scoring_matrix=scoring_matrix, global_flag=False) score, align_human, align_fruitfly = compute_local_alignment(seq_x=random_human, seq_y=random_fruitfly, scoring_matrix=scoring_matrix, alignment_matrix=alignment_matrix) global_align_human, ratio_human_random = consensus_alignment(scoring_matrix, align_human) global_align_fruitfly, ratio_fruitfly_random = consensus_alignment(scoring_matrix, align_fruitfly) return ratio_human_random, ratio_fruitfly_random
def random_alignment(scoring_matrix): ''' Take two random amino acids, compute the alignment and the consensus with pax Return the ratio of similarity To examine the solution of the homework ''' alphabet = "ACBEDGFIHKMLNQPSRTWVYXZ" length_human = 422 length_fruitfly = 857 random_human = '' for _ in range(length_human): random_human += random.choice(alphabet) random_fruitfly = '' for _ in range(length_fruitfly): random_fruitfly += random.choice(alphabet) alignment_matrix = compute_alignment_matrix(seq_x=random_human, seq_y=random_fruitfly, scoring_matrix=scoring_matrix, global_flag=False) score, align_human, align_fruitfly = compute_local_alignment( seq_x=random_human, seq_y=random_fruitfly, scoring_matrix=scoring_matrix, alignment_matrix=alignment_matrix) global_align_human, ratio_human_random = consensus_alignment( scoring_matrix, align_human) global_align_fruitfly, ratio_fruitfly_random = consensus_alignment( scoring_matrix, align_fruitfly) return ratio_human_random, ratio_fruitfly_random
def protein_alignment(scoring_matrix): ''' compute the human eyeless protein and fruitfly eyeless portein alignment ''' human_protein = read_protein('HumanEyelessProtein.txt') fruitfly_protein = read_protein('FruitflyEyelessprotein.txt') alignment_matrix = compute_alignment_matrix(seq_x=human_protein, seq_y=fruitfly_protein, scoring_matrix=scoring_matrix, global_flag=False) score, align_human, align_fruitfly = compute_local_alignment(seq_x=human_protein, seq_y=fruitfly_protein, scoring_matrix=scoring_matrix, alignment_matrix=alignment_matrix) return score, align_human, align_fruitfly
def protein_alignment(scoring_matrix): ''' compute the human eyeless protein and fruitfly eyeless portein alignment ''' human_protein = read_protein('HumanEyelessProtein.txt') fruitfly_protein = read_protein('FruitflyEyelessprotein.txt') alignment_matrix = compute_alignment_matrix(seq_x=human_protein, seq_y=fruitfly_protein, scoring_matrix=scoring_matrix, global_flag=False) score, align_human, align_fruitfly = compute_local_alignment( seq_x=human_protein, seq_y=fruitfly_protein, scoring_matrix=scoring_matrix, alignment_matrix=alignment_matrix) return score, align_human, align_fruitfly