def test_import_panel_sources(self): gene = GeneFactory(gene_symbol="ABCC5-AS1") A1CF = GeneFactory(gene_symbol="A1CF") GeneFactory(gene_symbol="STR_1") gps = GenePanelSnapshotFactory() gps.panel.name = "Panel One" gps.level4title.name = gps.panel.name gps.level4title.save() gps.panel.save() evidence = EvidenceFactory.create(name="Expert Review Amber") GenePanelEntrySnapshotFactory.create(gene_core=gene, panel=gps, evaluation=(None, ), evidence=(evidence, )) self.assertEqual( gps.get_gene(gene.gene_symbol).evidence.first().name, "Expert Review Amber") file_path = os.path.join(os.path.dirname(__file__), 'import_panel_data.tsv') test_panel_file = os.path.abspath(file_path) with open(test_panel_file) as f: url = reverse_lazy('panels:upload_panels') self.client.post(url, {'panel_list': f}) ap = GenePanel.objects.get(name="Panel One").active_panel self.assertEqual( ap.get_gene(gene.gene_symbol).evidence.first().name, "Expert Review Green") self.assertEqual(ap.get_gene(gene.gene_symbol).evidence.count(), 1) self.assertEqual(sorted(ap.get_gene('A1CF').phenotypes), sorted(['57h', 'wef']))
def test_have_child_entities(self): gene1 = GeneFactory() gene2 = GeneFactory() parent = GenePanelSnapshotFactory() gene1_data = { "gene": gene1.pk, "sources": [ Evidence.OTHER_SOURCES[0], ], "phenotypes": fake.sentences(nb=3), "rating": Evaluation.RATINGS.AMBER, "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "mode_of_pathogenicity": [x for x in Evaluation.MODES_OF_PATHOGENICITY][randint(1, 2)][0], "penetrance": GenePanelEntrySnapshot.PENETRANCE.Incomplete, "current_diagnostic": False, } gene2_data = { "gene": gene2.pk, "sources": [ Evidence.OTHER_SOURCES[0], ], "phenotypes": fake.sentences(nb=3), "rating": Evaluation.RATINGS.AMBER, "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "mode_of_pathogenicity": [x for x in Evaluation.MODES_OF_PATHOGENICITY][randint(1, 2)][0], "penetrance": GenePanelEntrySnapshot.PENETRANCE.Incomplete, "current_diagnostic": False, } child1 = GenePanelSnapshotFactory() child1.add_gene(self.gel_user, gene1.gene_symbol, gene1_data) child1.panel.active_panel.add_gene(self.gel_user, gene2.gene_symbol, gene2_data) child1 = child1.panel.active_panel child2 = GenePanelSnapshotFactory() child2.add_gene(self.gel_user, gene1.gene_symbol, gene1_data) child2 = child2.panel.active_panel parent.child_panels.set([child1, child2]) parent.update_saved_stats() del parent.is_super_panel self.assertEqual(len(parent.get_all_entities_extra), 3) self.assertTrue(parent.is_super_panel) self.assertTrue(child1.is_child_panel) self.assertTrue(child2.is_child_panel) self.assertIn(child1.get_gene(gene1.gene_symbol), parent.get_all_entities_extra) self.assertIn(child1.get_gene(gene2.gene_symbol), parent.get_all_entities_extra) self.assertTrue(parent.genepanelentrysnapshot_set.count() == 0)
def test_increment_child_version(self): gene1 = GeneFactory() gene2 = GeneFactory() parent = GenePanelSnapshotFactory( panel__status=GenePanel.STATUS.public) gene1_data = { "gene": gene1.pk, "sources": [ Evidence.OTHER_SOURCES[0], ], "phenotypes": fake.sentences(nb=3), "rating": Evaluation.RATINGS.AMBER, "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "mode_of_pathogenicity": [x for x in Evaluation.MODES_OF_PATHOGENICITY][randint(1, 2)][0], "penetrance": GenePanelEntrySnapshot.PENETRANCE.Incomplete, "current_diagnostic": False, } gene2_data = { "gene": gene2.pk, "sources": [ Evidence.OTHER_SOURCES[0], ], "phenotypes": fake.sentences(nb=3), "rating": Evaluation.RATINGS.AMBER, "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint(1, 12)][0], "mode_of_pathogenicity": [x for x in Evaluation.MODES_OF_PATHOGENICITY][randint(1, 2)][0], "penetrance": GenePanelEntrySnapshot.PENETRANCE.Incomplete, "current_diagnostic": False, } child1 = GenePanelSnapshotFactory( panel__status=GenePanel.STATUS.public) initial_child1_pk = child1.pk child1.add_gene(self.gel_user, gene1.gene_symbol, gene1_data) child1 = child1.panel.active_panel child1.add_gene(self.gel_user, gene2.gene_symbol, gene2_data) child1 = child1.panel.active_panel self.assertNotEqual(initial_child1_pk, child1.pk) child2 = GenePanelSnapshotFactory( panel__status=GenePanel.STATUS.public) initial_child2_pk = child2.pk child2.add_gene(self.gel_user, gene1.gene_symbol, gene1_data) child2 = child2.panel.active_panel self.assertNotEqual(initial_child2_pk, child2.pk) parent.child_panels.set([child1, child2]) parent.update_saved_stats() old_parent = parent child1.increment_version() child1 = child1.panel.active_panel child1.update_gene( self.gel_user, gene2.gene_symbol, { "gene": gene2, "sources": [ Evidence.OTHER_SOURCES[1], ], "phenotypes": fake.sentences(nb=3), "rating": Evaluation.RATINGS.GREEN, "moi": [x for x in Evaluation.MODES_OF_INHERITANCE][randint( 1, 12)][0], "mode_of_pathogenicity": [x for x in Evaluation.MODES_OF_PATHOGENICITY][randint(1, 2)][0], "penetrance": GenePanelEntrySnapshot.PENETRANCE.Incomplete, "current_diagnostic": False, }) child1.get_gene(gene2.gene_symbol).update_rating(3, self.gel_user, '') child1 = child1.panel.active_panel parent = parent.panel.active_panel parent.update_saved_stats() self.assertNotEqual(parent, old_parent) self.assertNotEqual(old_parent.stats, parent.stats) self.assertIn(child1, parent.child_panels.all()) self.assertIn(child2, parent.child_panels.all()) self.assertEqual(child1.genepanelsnapshot_set.count(), 1) self.assertEqual( child2.genepanelsnapshot_set.count(), 2) # contains reference to two versions of parent panel