Question
Implement the global_alignment function useing the scoring method of +1 for match and -1 for mismatch and indel print the global alignment with one line
Implement the global_alignment function use\ing the scoring method of +1 for match and -1 for mismatch and indel print the global alignment with one line per string with '-' characters for indels.
import numpy as np import pandas as pd import scipy from plotnine import * def global_alignment(sequence1, sequence2): print("your code here")
''' support code for creating random sequence, no edits ''' def random_sequence(n): return("".join(np.random.choice(["A","C","G","T"], n)))
''' support code for mutating a sequence, no edits ''' def mutate(s, snp_rate, indel_rate): x = [c for c in s] i = 0 while i < len(x): if np.random.random() < snp_rate: x[i] = random_sequence(1) if np.random.random() < indel_rate: length = np.random.geometric(0.5) if np.random.random() < 0.5: # insertion x[i] = x[i] + random_sequence(length) else: for j in range(i,i+length): if j < len(x): x[j] = "" i += 1 i += 1 return("".join(x))
# creating related sequences s1 = random_sequence(100) s2 = mutate(s1, 0.1, 0.1)
# running your alignment code global_alignment(s1, s2)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started