Use the JC69 model to calculate the substitution rate at all first, second and third codon positions in the two aligned sequences in SSA3. Assume the first position is 1 so the codon positions will be: 123123123123 etc in the sequences. #Here is the code for reading in Seub_SSA3 and Spar_SSA3 with open("SSA3.fasta") as f:     seqA = ""     seqB = ""     current_seq = ""     seq_header = ""          for line in f:         line = line.strip()         if line.startswith(">"):             if seq_header == ">Seub_SSA3":                 seqA = current_seq             elif seq_header == ">Spar_SSA3":                 seqB = current_seq              current_seq = ""             seq_header = line         else:             current_seq += line          if seq_header == ">Seub_SSA3":         seqA = current_seq     elif seq_header == ">Spar_SSA3":         seqB = current_seq with open("SeqA.fasta", "w") as f:     f.write(seqA) with open("SeqB.fasta", "w") as f:     f.write(seqB) print("Length of seqA:", len(seqA)) print("Lenght of seqB :", len(seqB)) # JC69 model  def jc69(seq1, seq2):     # Convert sequences to uppercase     seq1 = seq1.upper()     seq2 = seq2.upper()          # Check that sequences have the same length     if len(seq1) != len(seq2):         raise ValueError("Sequences have different lengths")          # Calculate number of differences     diff_count = sum([seq1[i] != seq2[i] for i in range(len(seq1))])          # Calculate proportion of differences     p = diff_count / len(seq1)          # Calculate substitution rate     K = -(3/4)*np.log(1 - p*(4/3))          return K

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Use the JC69 model to calculate the substitution rate at all first, second and third codon positions in the two aligned sequences in SSA3. Assume the first position is 1 so the codon positions will be: 123123123123 etc in the sequences.

#Here is the code for reading in Seub_SSA3 and Spar_SSA3

with open("SSA3.fasta") as f:
    seqA = ""
    seqB = ""
    current_seq = ""
    seq_header = ""
    
    for line in f:
        line = line.strip()
        if line.startswith(">"):
            if seq_header == ">Seub_SSA3":
                seqA = current_seq
            elif seq_header == ">Spar_SSA3":
                seqB = current_seq 
            current_seq = ""
            seq_header = line
        else:
            current_seq += line
    
    if seq_header == ">Seub_SSA3":
        seqA = current_seq
    elif seq_header == ">Spar_SSA3":
        seqB = current_seq

with open("SeqA.fasta", "w") as f:
    f.write(seqA)

with open("SeqB.fasta", "w") as f:
    f.write(seqB)
print("Length of seqA:", len(seqA))
print("Lenght of seqB :", len(seqB))


# JC69 model 
def jc69(seq1, seq2):
    # Convert sequences to uppercase
    seq1 = seq1.upper()
    seq2 = seq2.upper()
    
    # Check that sequences have the same length
    if len(seq1) != len(seq2):
        raise ValueError("Sequences have different lengths")
    
    # Calculate number of differences
    diff_count = sum([seq1[i] != seq2[i] for i in range(len(seq1))])
    
    # Calculate proportion of differences
    p = diff_count / len(seq1)
    
    # Calculate substitution rate
    K = -(3/4)*np.log(1 - p*(4/3))
    
    return K

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Binary numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education