User Tools

Site Tools


assignment3key

Assignment 3 Answer Key

olgioAnalyzer.py
'''
Author: Tai Montgomery, Oct. 10, 2018
 
Prints to the terminal basic stats for typical primer
length oligos. Melting tempurate (Tm) may not be accurate
in some instances.
 
Usage: python3 oligoAnalyzer.py
 
To exit the program, hit return.
'''
 
def oligo_analyzer():
	'''
	Print basic stats for DNA primers.
	Input (at prompt): a DNA or RNA sequence 18-25 nt long.
	'''
 
	while True:
		seq = input('Enter a sequence: ')
		original = ''
		revcomp = ''
		gc_sum = 0
		non_nt = False
 
		if seq == '':
			break
 
		for nt in seq:
			if nt == 'A' or nt == 'a':
				original += 'A'
				revcomp = 'T' + revcomp
			elif nt == 'T' or nt == 't':
				original += 'T'
				revcomp = 'A' + revcomp
			elif nt == 'C' or nt == 'c':
				original += 'C'
				revcomp = 'G' + revcomp
				gc_sum += 1						
			elif nt == 'G' or nt == 'g':
				original += 'G'
				revcomp = 'C' + revcomp
				gc_sum += 1
			elif nt == 'U' or nt == 'g':
				original += 'T'
				revcomp = 'A' + revcomp
				gc_sum += 1		
			else:
				non_nt = True
 
		tm = 64.9 + 41 * (gc_sum - 16.4) / len(original)
 
		if non_nt:
			print("\n\nWarning: Non-nt characters removed!!!")	
 
		print("\nOriginal Sequence:    " + original)
		print("Reverse Complement:   " + revcomp)
		print("Length:               " + str(len(original)) + " nt")
		print("GC Content:           " + str(int(gc_sum/len(original)*100)) + " %") 
		print("Tm:                   " + str(int(tm)) + " ˚C\n")
 
if __name__ == '__main__':
	oligo_analyzer()										
assignment3key.txt · Last modified: 2018/10/10 17:23 by dokuroot