예제 #1
0
def getPrimerChoices(top_sequence, primer_len):
	bottom_sequence = seqlib.complement(top_sequence)
	primer_set = []
	
	primer = top_sequence[:primer_len]
	primer_set.append(primer) #answer1
	answer1 = primer
	primer_set.append(seqlib.flip(primer))

	primer = bottom_sequence[:primer_len]
	primer_set.append(primer)
	primer_set.append(seqlib.flip(primer))
	
	primer = top_sequence[-primer_len:]
	primer_set.append(primer)
	primer_set.append(seqlib.flip(primer))
	
	primer = bottom_sequence[-primer_len:]
	primer_set.append(primer)  #answer2
	primer_set.append(seqlib.flip(primer))
	answer2 = seqlib.flip(primer)
	
	answer_set = [answer1, answer2]
	for ans in answer_set:
		for nt in list('ACGT'):
			if not nt in ans:
				return False, answer_set

	primer_set.sort()
	print(primer_set)
	print(answer_set)

	convert_set = []
	for primer in primer_set:
		subprimer = primer.replace('T', 'A')
		convert_set.append(subprimer)
		subprimer = primer.replace('C', 'G')
		convert_set.append(subprimer)
	if len(list(set(convert_set))) < 16:
		print("BAD PRIMERS")
		#sys.exit(1)
		return False, answer_set
	return primer_set, answer_set
예제 #2
0
def makeChoices(primer_set, answer_set):
	choices = set()
	choices.add(tuple(answer_set))

	wrong = (answer_set[0], seqlib.flip(answer_set[1]))
	choices.add(wrong)
	wrong = (answer_set[1], seqlib.flip(answer_set[0]))
	choices.add(wrong)
	wrong = (seqlib.flip(answer_set[0]), seqlib.flip(answer_set[1]))
	choices.add(wrong)
	
	while len(choices) < 6:
		c1 = random.choice(primer_set)
		c2 = random.choice(primer_set)
		if c1 != c2:
			choices.add((c1, c2))
	choices_list = list(choices)
	print(choices_list)
	random.shuffle(choices_list)
	return choices_list
def makeMultipleChoiceQuestion(enzyme_class, question_number=13):
	charlist = list("ABCDEFGHJKMPQRSTWXYZ")
	name = restrictlib.html_monospace(enzyme_class.__name__)
	cut_description = restrictlib.html_monospace(restrictlib.format_enzyme(enzyme_class))
	
	question = "{0}. ".format(question_number)
	question += "The restriction enzyme <b>{0}</b> cuts the sequence: {1}. ".format(name, cut_description)
	question += "Which one of the following sequences is the "
	question += "single-stranded nucleotide overhang region after cleavage? "

	#A. 5'-TGCA-3' B. 5'-CTGCA-3' C. 5'-TGCAG-3' D. 5'-ACGT-3'
	choices = []
	#print(enzyme_class.ovhgseq)
	#print(enzyme_class.site)
	#print(enzyme_class.elucidate())

	shift = (len(enzyme_class.site) - len(enzyme_class.ovhgseq))//2
	#print(shift)

	answer = ("5'-{0}-3'".format(enzyme_class.ovhgseq))
	choices.append(answer)

	inverse = ("5'-{0}-3'".format(seqlib.flip(enzyme_class.ovhgseq)))
	choices.append(inverse)

	expanded1 = ("5'-{0}-3'".format(enzyme_class.site[shift:]))
	choices.append(expanded1)

	expanded2 = ("5'-{0}-3'".format(enzyme_class.site[:-shift]))
	choices.append(expanded2)

	expandflip1 = ("5'-{0}-3'".format(seqlib.flip(enzyme_class.site[shift:])))
	choices.append(expandflip1)

	expandflip2 = ("5'-{0}-3'".format(seqlib.flip(enzyme_class.site[:-shift])))
	choices.append(expandflip2)

	#print(choices)
	choices = list(set(choices))
	#print(choices)
	if len(choices) > 5:
		a = choices.pop()
		if a == answer:
			choices.pop()
			choices.append(answer)
	try:
		choices.remove("5'--3'")
	except ValueError:
		pass

	#print(choices)
	random.shuffle(choices)
	#print(choices)

	if len(choices) <= 3:
		return None

	print(question)
	for i in range(len(choices)):
		ltr = charlist[i]
		choice = choices[i]
		prefix = ""
		if choice == answer:
			prefix = "*"
		print("{0}{1}. {2}".format(prefix, ltr, choice))
    seq = seqlib.makeSequence(seqlen)
    answer = seqlib.complement(seq)

    #============================
    print(
        "1. Which one of the following DNA sequences is complimentary to the direction-less DNA sequence {0} ?"
        .format(seqlib.html_monospace(seq)))

    #============================
    choices = []
    half = int(seqlen // 2)

    #choice 1
    choices.append(answer)
    #choice 2
    choices.append(seqlib.flip(seq))

    extra_choices = []
    extra_choices.append(answer[:half] + seq[half:])
    extra_choices.append(seq[:half] + answer[half:])
    extra_choices.append(seqlib.flip(seq[:half]) + seq[half:])
    extra_choices.append(seq[:half] + seqlib.flip(seq[half:]))
    extra_choices.append(seqlib.flip(answer[:half]) + answer[half:])
    extra_choices.append(answer[:half] + seqlib.flip(answer[half:]))
    extra_choices.append(answer[:half] + seqlib.flip(seq[half:]))
    random.shuffle(extra_choices)
    extra_choices = list(set(extra_choices))
    random.shuffle(extra_choices)

    for i in range(3):
        choices.append(extra_choices.pop())
예제 #5
0
#!/usr/bin/env python

import sys
import seqlib
import random

if __name__ == '__main__':
	if len(sys.argv) >= 2:
		seqlen = int(sys.argv[1])
	else:
		seqlen = 7

	#============================
	seq = seqlib.makeSequence(seqlen)
	answer = seqlib.flip(seqlib.complement(seq))

	#============================
	if random.random() < 0.5:
		print("1. Which one of the following sequences is complimentary to the sequence <span style='font-family: monospace;'>5'-%s-3'</span>? Hint: pay attention to the 5' and 3' directions!"%(seq))
	else:
		print("1. Which one of the following sequences is complimentary to the sequence <span style='font-family: monospace;'>3'-%s-5'</span>? Hint: pay attention to the 5' and 3' directions!"%(seqlib.flip(seq)))

	#============================
	choices = []
	half = int(seqlen//2)

	#choice 1
	choices.append(seq)
	#choice 2
	choices.append(seqlib.flip(seq))
	#choice 3
예제 #6
0
#!/usr/bin/env python

import sys
import seqlib

if __name__ == '__main__':
    if len(sys.argv) >= 2:
        seqlen = int(sys.argv[1])
    else:
        seqlen = 10

    #============================
    seq = seqlib.makeSequence(seqlen)
    answer = seqlib.transcribe(seqlib.complement(seq))

    #============================
    print(
        "blank 1. What is the RNA sequence to the DNA template strand sequence <span style='font-family: monospace;'>{0}</span>?"
        .format(seq))

    #============================
    print("A. {0}".format(answer))
    print("B. {0}".format(seqlib.flip(answer)))
#!/usr/bin/env python

import sys
import seqlib
import random

if __name__ == '__main__':
	if len(sys.argv) >= 2:
		seqlen = int(sys.argv[1])
	else:
		seqlen = 7

	#============================
	seq = seqlib.makeSequence(seqlen)
	answer = seqlib.flip(seqlib.complement(seq))

	#============================
	question = "1. Which one of the following sequences is RNA transcription to the "
	if random.random() < 0.5:
		dirseq = "5'-{0}-3'".format(seq)
		question += "DNA non-template/coding strand sequence {0} ?".format(seqlib.html_monospace(dirseq))
	else:
		dirseq = "3'-{0}-5'".format(seqlib.flip(seq))
		question += "DNA template strand sequence {0} ?".format(seqlib.html_monospace(dirseq))
	question += " Hint: pay attention to the 5' and 3' directions!"
	print(question)

	#============================
	choices = []
	half = int(seqlen//2)