class Test_Parsing_Detail_Line(unittest.TestCase): def setUp(self): self.parser = DetailParser() def test_correctly_parses_genesis_detail_line(self): result = self.parser.process_line(genesisDetailLine) expected_result = ('1', None, None, None, None, None, 'wzcagcccccccccccccccccccccccccccccccccccczvfcaxgab') self.assertTupleEqual(result, expected_result) def test_correctly_parses_detail_line_with_no_mutations(self): result = self.parser.process_line(detailLineWithNoMutations) expected_result = ('72','3', '18', None, None, 'Swp14-26', 'wzcagcccccccccccccccccccbccccccmccccccccczvfcaxgab') self.assertTupleEqual(result, expected_result) def test_correctly_parses_detail_line_with_one_mutation(self): result = self.parser.process_line(detailLineWithOneMutation) expected_result = ('1055','781', '781', 'Mc13y', None, 'Swp25-38', 'wzcagccccccccyccccccccwcccccccccccrcccccczvfcaxgab') self.assertTupleEqual(result, expected_result) def test_correctly_parses_detail_line_with_two_mutations(self): result = self.parser.process_line(detailLineWithTwoMutations) expected_result = ('79496','30490', '57433', 'Mc15y', 'Mc40z', 'Swp9-16', 'wzcagccccccccccycpcccehccccckccccckpcccczzvfcaxgab') self.assertTupleEqual(result, expected_result) def test_returns_nothing_for_incorrect_detail(self): detail_line = "123123 2312321 123123" result = self.parser.process_line(detail_line) self.assertIsNone(result)
def build_genealogy(self, detailDump): '''Build and return a Genealogy object by adding Genotypes parsed from a detail dump''' parser = DetailParser() genealogy = Genealogy() for line in detailDump: details = parser.process_line(line) if details: genealogy.add_genotype(Genotype(*details)) GenotypeRelationshipTool().\ create_relationships_between_genotypes_in_genealogy(genealogy) return genealogy
def setUp(self): self.parser = DetailParser()