Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use python code, please: 1. Modify this code so that it computes the score for each alignment using the following scoring: match = +1 mismatch

Use python code, please:

1. Modify this code so that it computes the score for each alignment using the following scoring: match = +1 mismatch = 0 gap = -1

The program should find the optimal alignment(s) and print them with their score.

# Program to compute and print a dot plot of two nucleotide sequences

# Function to initialize a dot plot of a certain size def initDotPlot(rows, cols): # Initialize the dot_plot matrix empty_dot_plot = [] # For each row in the matrix for i in range(rows): # Initialize the row row = [] # For each col in the matrix for j in range(cols): # Insert a blank in the row row.append("-") empty_dot_plot.append(row) return empty_dot_plot

# Function to fill the dot plot def computeDotPlot(sideStr, topStr, dot_plot): # For each character in str2 (each row) for i in range(len(sideStr)): # For each character in str1 (each col) for j in range(len(topStr)): # If the character in str1 matches the character in str2 if topStr[j] == sideStr[i]: # Change the value in that position to a * dot_plot[i][j] = ' * ' return dot_plot # Function to print the dot plot of two sequences def printDotPlot(sideStr, topStr, dot_plot): row = "" for ch in topStr: row = row + " " + ch + " " print(" ", row) row = "" for i in range(len(dot_plot)): row = row + sideStr[i] + " " for j in range(len(dot_plot[i])): row = row + " " + dot_plot[i][j] + " " print(row) row = "" # Main function def main(): topStr = input("Enter top string: ") sideStr = input("Enter side string: ") empty_dot_plot = initDotPlot(len(sideStr), len(topStr)) dot_plot = computeDotPlot(sideStr, topStr, empty_dot_plot) printDotPlot(sideStr, topStr, dot_plot)

.... Then, add two counters and some print statements to your code to count how much work is done by this algorithm to find the optimal alignment. The main units of work in this program are adding a gap to a sequence, and comparisons to compute the score. You may use global variables to store the amount of work that is done. Test your result on the following sequences:

AAGGTAGCCTAACGTCCACTTTACCC

AGTAAGGTACCTACCTCAACTTCA

How much work does the algorithm do on these sequences?

NOTE: To use a global variable to represent the amount of work required to insert gaps into the sequences, include the following line of code in each function where you reference the variable:

global gap_work

Similarly for the variable to count the amount of work required to compare the characters in the sequences.

global compare_work

The following is an example of what your output might look like for several test cases:

image text in transcribed

image text in transcribed

image text in transcribed

main Enter string 1 GGAGTATAA Enter string 2: GCGTTA There are 84 alignments The following alignments are optimal GGAGTATAA -GCGT-T-A. Score 2 GGAGTATAA -GCGT-TA- Score 2 GGAGTATAA. G-CGT-T-A Score 2 GGAGTATAA G-CGT-TA- Score 2 GGAGTATAA. GC-GT-T-A Score 2 GGAGTATAA. GC-GT-TA- Score 2 Amount of work done Cgaps 279 Amount of work done (comparisons main Enter string 1 GGAGTATAA Enter string 2: GCGTTA There are 84 alignments The following alignments are optimal GGAGTATAA -GCGT-T-A. Score 2 GGAGTATAA -GCGT-TA- Score 2 GGAGTATAA. G-CGT-T-A Score 2 GGAGTATAA G-CGT-TA- Score 2 GGAGTATAA. GC-GT-T-A Score 2 GGAGTATAA. GC-GT-TA- Score 2 Amount of work done Cgaps 279 Amount of work done (comparisons

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Publishing With Filemaker Pro On The Web

Authors: Maria Langer

1st Edition

0201696657, 978-0201696653

More Books

Students also viewed these Databases questions

Question

5. Prepare a plan of action and execute itstarting now!

Answered: 1 week ago