In: Computer Science
In phyton, lab 5 info.
def is_dna(one):
sequence = input().upper()
valid_dna = "ACGT"
sequence = sequence.replace(" ", "")
for i in sequence:
if i in valid_dna:
count = 1
else:
count=0
if count==1:
print("This is a valid DNA sequence.")
else:
print("This is an invalid DNA sequence")
5
def is_valid(dna):
for one in dna:
if not is_dna(one):
return False
return true
print(is_valid("AGCTAGCAAGTCTT")) #prints true
print(is_dna("ACGTTGGC")) #prints false
1. Write a function called 'transcribe' that takes a DNA sequence as an argument. Return the transcribed RNA sequence. For example, if the DNA sequence is: tagtacta Then the transcribed RNA sequence should be: uaguacua Write a program to prompt the user to enter a DNA sequence and validate the sequence using the function you wrote in lab 5 and display the transcribed RNA sequence. 2. Write a function called 'revcom' that takes a DNA sequence as an argument. Return the reverse complement of the DNA sequence. For example, if the DNA sequence is: tagtacta The the reverse complemented DNA sequence is: tagtacta Write a program to prompt the user to enter a DNA sequence and validate the sequence using the function you wrote n lab 5 and display the reverse complemented sequence. 3. Create a list called 'verbs' and populate it with 6 or more of your favourite verbs (work safe!) Print the list of verbs one verb per line using a for loop and again with a while loop.
'''
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++,
Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly,
HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
'''
def is_dna(one):
sequence = one.upper()
valid_dna = "ACGT"
sequence = sequence.replace(" ", "")
count=0
for i in sequence:
if i in valid_dna:
count = 1
if count==1:
print("This is a valid DNA sequence.")
return True
else:
print("This is an invalid DNA sequence")
return False
def is_valid(dna):
for one in dna:
if not is_dna(one):
return False
return True
print(is_valid("AGCTAGCAAGTCTT")) #prints true
print(is_dna("ACGTTGGC")) #prints false
def transcribe(dna):
check=is_valid(dna)
rna=""
if(check):
rna=dna.replace("T","U").replace("t","u")
print(rna)
transcribe("AGCTAGCAAGTCTT")#DNA to RNA
alt_map = {'ins':'0'}
complement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
def reverse_complement(seq):
seq=seq.upper()
if(is_valid(seq)):
for k,v in alt_map.items():
seq = seq.replace(k,v)
bases = list(seq)
bases = reversed([complement.get(base,base) for base in
bases])
bases = ''.join(bases)
for k,v in alt_map.items():
bases = bases.replace(v,k)
return bases
else:
return("in valid DNA")
print(reverse_complement("tagtacta"))#complement of DNA
def verbList():
verbs=['am','is','are','has','will']
print("Using for-loop")
for items in verbs:
print(items)
print("Using while-loop")
# Getting length of list
length = len(verbs)
i = 0
# Iterating using while loop
while i < length:
print(verbs[i])
i += 1
verbList()