Question

In: Computer Science

In phyton, lab 5 info. def is_dna(one): sequence = input().upper() valid_dna = "ACGT" sequence = sequence.replace("...

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.

Solutions

Expert Solution

'''

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()


Related Solutions

def change_type(info: List[list]) -> None: """ Modify info to a float if and only if it...
def change_type(info: List[list]) -> None: """ Modify info to a float if and only if it represents a number that is not a whole number(a float), and convert info to an int if and only if it represents a whole number, keep everythingelse as a string. >>> i = [['apple', '888', 'School', '111.1']] >>> change_type(i) >>> i   [['apple', 888, 'School', '111.1']] Please help! Write as little code as possible! Please only use if statements, nested loop and lists to solve...
design a sequence detector that detects the sequence: 110. The device has one input x and...
design a sequence detector that detects the sequence: 110. The device has one input x and one output Y. When the input sequence is set to 1 followed by a 1 followed by a 0, then Y is set to 1 otherwise Y is set to 0. Use J-K flip-flops and minimum number of states is designing this detector and show the followings: a) Show the state diagram b)Show the state table for this detector
Write a function flipSwitches that accepts one argument, a sequence of upper or lower case letters...
Write a function flipSwitches that accepts one argument, a sequence of upper or lower case letters (the sequence can either be a str or a list, if you write your code correctly, it shouldn’t matter). This is a sequence of switches, uppercase means to turn a switch on, and lowercase to turn a switch off.   For example, ‘A’ means to turn the switch ‘A’ on, and ‘a’ means to turn the switch ‘A’ off.   (Turning an on switch on again,...
In this lab, you will write a function that takes five (5) doubles as input and...
In this lab, you will write a function that takes five (5) doubles as input and passes back the mean (average) and the standard deviation. Your function should be named mean_std and it should return the mean (a double) and pass the standard deviation (also a double) back by reference. The mean and standard deviation are a common calculation in statistics to express the range of "typical" values in a data set. This brief article explains how to calculate the...
Data Tables and Post-Lab Assessment Lab Questions 1.     Transcribe the following DNA sequence: Hb A: 5’...
Data Tables and Post-Lab Assessment Lab Questions 1.     Transcribe the following DNA sequence: Hb A: 5’ AGT AAC GGC AGA CTT CTC CTC AGG AGT CAG GTG CAC CAT 3’ 3'UCA UUG CCG UCU GAA GAG GAG UCC UCA GUC CAC GUG GUA 5' 2.     Translate your new RNA sequence using the genetic code. Remember that when determining your amino acid sequence, the RNA sequence is read from 5’ to 3’. val- val -his- val- ser -ser- glu- glu- ser-ser-...
Draw a TM that takes as input a sequence of 1s and doubles the input
Draw a TM that takes as input a sequence of 1s and doubles the input
1. Using Moore machine approach design a sequence detector with one input and one output. When...
1. Using Moore machine approach design a sequence detector with one input and one output. When input sequence 010 occurs the output becomes 1 and remains 1 until the sequence 010 occurs again in which case the output returns to 0. The output remains 0 until, 010 occurs the third time, and so on. Your design should be able to handle overlapping sequences, i.e., input sequence 11001010100 should produce the output 00000110011. Implement your detector using D flip-flops and the...
python: ask the user to input a sequence of positive numbers. the end of the sequence...
python: ask the user to input a sequence of positive numbers. the end of the sequence is determined when the user enters a negative number. print out the maximum number from the sequence. output: keep entering positive numbers. to quit, input a negative number. enter a number: 67 enter a number: 5 enter a number: 8 enter a number: -3 largest number entered: 67 (note: i do not want to ask the user how many numbers they will input)
Try to debug it! ######################################## ##def rev_list_buggy(L): ## """ ## input: L, a list ## Modifies...
Try to debug it! ######################################## ##def rev_list_buggy(L): ## """ ## input: L, a list ## Modifies L such that its elements are in reverse order ## returns: nothing ## """ ## for i in range(len(L)): ## j = len(L) - i ## L[i] = temp ## L[i] = L[j] ## L[j] = L[i] # ## FIXES: -------------------------- ## temp unknown ## list index out of range -> sub 1 to j ## get same list back -> iterate only over...
One strand of a double-helical DNA has the sequence 5'-GCGCAATATTTCTCAAAATATTGCGC-3'. Write the base sequence of the...
One strand of a double-helical DNA has the sequence 5'-GCGCAATATTTCTCAAAATATTGCGC-3'. Write the base sequence of the complementary strand. What special type of sequence is contained in this DNA segment? Does this double-stranded DNA have the potential to form any alternative structures?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT