Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that prompts the user to enter an oligonucleotide sequence, such

ID: 3713410 • Letter: W

Question

Write a program that prompts the user to enter an oligonucleotide sequence, such as TATGAGCCCGTA.

If the user entered a valid oligo sequence consisting only of the characters A, C, G, or T, the program should then display the reverse complement of that sequence, in this case TACGGGCTCATA, along with text indicating that it is the reverse complement .

After displaying the reverse complement, the program should then prompt the user to enter another sequence. The program should continue this pattern of prompting the user for a new oligo sequence and displaying its reverse complement until the user enters a sequence with at least one character that is invalid (i.e. a character other than A, C, G, or T).

At this point, the program should end its run with a message that mentions that an invalid character was found, with no further prompting to the user.

Python

Explanation / Answer

complement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}


def reverse_complement(seq):   
bases = list(seq)
bases = reversed([complement.get(base,base) for base in bases])
bases = ''.join(bases)
return bases


import re   
def check(seq):
return bool(re.search('^[ACTG]+$',seq))  
  
n=1
while n==1:
seq = input("Enter Seq")
if check(seq)==True :
print("Reverse Complement:")
print(reverse_complement(seq))
else :
print("invalid character found")
n=0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote