Пример #1
0
    def kid_genotype_question(self):
        """Ask for the genotypic ratio of children for this PunnetSet

        :return: string (user response from gui.QuestionLoop)
        """
        prompt = ('\n\nPlease enter the genotypic ratio of the offspring '
                  'below. Include a single genotype in each box, along with '
                  'the number number of offspring that will have that '
                  'genotype. Some boxes may remain blank.')
        kid_geno_solution = (
            'To answer this question you should construct a punnet square '
            'like the one shown below. Then you need to count the number of '
            'squares (representing children) with each unique genotype. '
            'The genotype ratio of this problem is: {}').format(': '.join(
                ['{} {}'.format(num, geno) for geno, num in self.kid_geno]))
        kid_geno_table = self.make_geno_square()
        correct_answers = [
            '{} {}'.format(num, geno) for geno, num in self.kid_geno
        ]

        if len(correct_answers) <= 4:
            entry_num = 4
        elif len(correct_answers) <= 6:
            entry_num = 6
        else:
            entry_num = 9
        questions = [""] * entry_num
        loop = gui.QuestionLoop(title=BOX_TITLE,
                                prompt=self.info + '\n' + prompt,
                                questions=questions,
                                correct_answers=correct_answers,
                                solution=kid_geno_solution,
                                checker=self.kid_genotype_checker,
                                solution_table=kid_geno_table)
        return loop.main_loop()
Пример #2
0
    def parent_phenotype_question(self):
        """Ask for the phenotypes of each parent in this PunnetSet

        :return: string (user response from gui.QuestionLoop)
        """
        prompt = ('\n\nPlease enter the phenotype of each parent below. '
                  'If the phenotype includes multiple traits, use "and" '
                  'between them. Ex: brown hair and blue eyes')
        questions = ["What is mom's phenotype?", "What is dad's phenotype?"]
        if self.loci_num == 1:
            correct_answers = [
                ''.join(self.mom.phenotype), ''.join(self.dad.phenotype)
            ]
        else:
            correct_answers = [
                ' and '.join(self.mom.phenotype),
                ' and '.join(self.dad.phenotype)
            ]

        parent_pheno_solution = self.parent_solution_for("pheno")

        loop = gui.QuestionLoop(title=BOX_TITLE,
                                prompt=self.info + '\n' + prompt,
                                questions=questions,
                                correct_answers=correct_answers,
                                solution=parent_pheno_solution,
                                checker=self.parent_phenotype_checker)
        return loop.main_loop()
Пример #3
0
    def ask(self):
        prompt = ('Assuming the population is at hardy-weinberg equilibrium, '
                  'report the requested values below as a '
                  'proportion, rounding to two decimal places.')
        question_dict = dict(
            zip(self.values.keys(),
                [terms[x][self.term_type] + ':' for x in self.values.keys()]))
        question_list = [
            question_dict[x] for x in ['p', 'q', 'p2', '_2pq', 'q2']
        ]

        loop = gui.QuestionLoop(title=BOX_TITLE,
                                prompt=self.question + '\n\n' + prompt,
                                questions=question_list,
                                correct_answers=self.answers,
                                solution=self.solution,
                                checker=self.answer_checker)
        return loop.main_loop()
Пример #4
0
    def gamete_question(self):
        """Ask what gametes can be made for this PunnetSet

        :return: string (user response from gui.QuestionLoop)
        """
        prompt = ('\n\nPlease enter the gametes each parent can make below, '
                  'separated by spaces.')
        questions = ['What eggs can mom make?', 'What sperm can dad make?']
        correct_answers = [
            ' '.join(self.mom.gametes), ' '.join(self.dad.gametes)
        ]

        gamete_solution = self.gamete_solution()
        loop = gui.QuestionLoop(title=BOX_TITLE,
                                prompt=self.info + '\n' + prompt,
                                questions=questions,
                                correct_answers=correct_answers,
                                solution=gamete_solution,
                                checker=self.check_gamete_answers)
        return loop.main_loop()
Пример #5
0
    def parent_genotype_question(self):
        """Ask for the genotypes of each parent in this PunnetSet

        :return: string (user response from gui.QuestionLoop)
        """

        prompt = ('\n\nPlease enter the genotype of each parent '
                  'in the boxes below.')
        questions = ["What is mom's genotype?", "What is dad's genotype?"]

        parent_geno_solution = self.parent_solution_for("geno")
        correct_answers = [
            self.correct_grammar(''.join(x))
            for x in [self.mom.genotype, self.dad.genotype]
        ]
        loop = gui.QuestionLoop(title=BOX_TITLE,
                                prompt=self.info + '\n' + prompt,
                                questions=questions,
                                correct_answers=correct_answers,
                                solution=parent_geno_solution,
                                checker=self.parent_genotype_checker)
        return loop.main_loop()