55.9k views
1 vote
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).

User AvgJoe
by
5.7k points

1 Answer

4 votes

Answer:

Step-by-step explanation:

The following code is written in Python. It continues looping and asking the user for an oligonucleotide sequence and as long as it is valid it outputs the reverse complement of the sequence. Otherwise it exits the loop

letters = {'A', 'C', 'G', 'T'}

reloop = True

while reloop:

sequence = input("Enter oligonucleotide sequence: ")

for x in sequence:

if x not in letters:

reloop = False;

break

if reloop == False:

break

newSequence = ""

for x in sequence:

if x == 'A':

newSequence += 'T'

elif x == 'T':

newSequence += 'A'

elif x == 'C':

newSequence += 'G'

elif x == 'G':

newSequence += 'C'

print("Reverse Complement: " + newSequence)

Write a program that prompts the user to enter an oligonucleotide sequence, such as-example-1
User Dan Leveille
by
5.1k points