Пример #1
0
    def test_update_phenotypes(self):
        """update of phenotypes adds new phenotypes."""

        # rerun the update, should give twice the number of phenotypes
        impc2 = Phenoscoring(IMPCTestConfig())
        impc2.update()
        phentab = ModelPhenotypeTable(self.dbfile)
        self.assertEqual(phentab.count_rows(), 28, "phenotypes added twice")
Пример #2
0
    def test_build_mgi(self):
        """can build a phenoscoring database using only MGI data"""

        mgi = Phenoscoring(MGITestConfig())
        mgi.update()

        # in contrast to complete config, this db should have fewer rows
        desctab = ModelDescriptionTable(self.dbfile)
        self.assertEqual(desctab.count_rows(), 6)
        modeltab = ModelPhenotypeTable(self.dbfile)
        self.assertEqual(modeltab.count_rows(), 9)
Пример #3
0
    def test_build_impc(self):
        """can build a phenoscoring database using only IMPC data"""

        impc = Phenoscoring(IMPCTestConfig())
        impc.update()

        # in contrast to complete build, this db should have IMPC-only rows
        desctab = ModelDescriptionTable(self.dbfile)
        self.assertEqual(desctab.count_rows(), 8)
        modeltab = ModelPhenotypeTable(self.dbfile)
        self.assertEqual(modeltab.count_rows(), 14)
Пример #4
0
    def test_update_phenotypes_badids(self):
        """update of phenotypes aborts when file contains incorrect ids."""

        phentab = ModelPhenotypeTable(self.dbfile)
        self.assertEqual(phentab.count_rows(), 14, "initial phenotypes")

        config = IMPCTestConfig()
        config.model_descriptions = None
        config.model_phenotypes = "prep-IMPC-phenotypes-badids.tsv"
        impc2 = Phenoscoring(config)
        impc2.update()
        self.assertEqual(phentab.count_rows(), 14, "phenotypes unchanged")
Пример #5
0
 def setUp(self):
     """For setup, ensure db does not exist, then build a new one"""        
     config = CompleteTestConfig()        
     self.dbfile = config.db
     remove_db(self.dbfile)        
     self.pipeline = Phenoscoring(config)
     self.pipeline.build()
     impc = Phenoscoring(IMPCTestConfig())
     impc.update()
     
     # handles for models
     self.desctab = ModelDescriptionTable(self.dbfile)
     self.phenstab = ModelPhenotypeTable(self.dbfile)
     self.scoretab = ModelScoreTable(self.dbfile)
Пример #6
0
    def test_build_both(self):
        """can update database sequentially with MGI and IMPC"""

        mgi = Phenoscoring(MGITestConfig())
        mgi.update()
        impc = Phenoscoring(IMPCTestConfig())
        impc.update()

        desctab = ModelDescriptionTable(self.dbfile)
        self.assertEqual(desctab.count_rows(), 14, "8 IMPC, 6 MGI")

        modeltab = ModelPhenotypeTable(self.dbfile)
        self.assertEqual(modeltab.count_rows(), 23, "9 MGI, 14 IMPC")

        scoretab = ModelScoreTable(self.dbfile)
        self.assertGreater(scoretab.count_rows(), 0,
                           "score table is non-empty")
Пример #7
0
    def test_update_nowork(self):
        """can run build repeatedly without over-inserting"""

        # run update again, but without setting phenotypes
        impc = Phenoscoring(IMPCTestConfig())
        impc.model_phenotypes = None
        impc.update()

        desctab = ModelDescriptionTable(self.dbfile)
        self.assertEqual(desctab.count_rows(), 8,
                         "number of descriptions should be unchanged")

        # run again without setting anything
        impc.model_descriptions = None
        impc.update()
        self.assertEqual(desctab.count_rows(), 8,
                         "number of descriptions should be unchanged")
Пример #8
0
    def test_update_descriptions(self):
        """run update multiple times to change content of model descriptions."""

        desctab = ModelDescriptionTable(self.dbfile)
        self.assertEqual(desctab.count_rows(), 8,
                         "initial set of model descriptions")
        self.assertFalse(self.descriptions_contain("description", "UPDATED"))

        # run an update operation with only model descriptions
        config = IMPCTestConfig()
        config.model_descriptions = "prep-IMPC-descriptions-update.tsv"
        config.model_phenotypes = None
        impc2 = Phenoscoring(config)
        impc2.update()
        self.assertEqual(desctab.count_rows(), 8,
                         "number of models should be unchanged")
        self.assertTrue(self.descriptions_contain("description", "UPDATED"),
                        "descriptions in updated file contain string UPDATED")
Пример #9
0
    def test_update_skip_compute(self):
        """run update but skip score calculation"""

        # extract current number of models and scores
        desctab = ModelDescriptionTable(self.dbfile)
        scorestab = ModelScoreTable(self.dbfile)
        num_models = desctab.count_rows()
        num_scores = scorestab.count_rows()

        # run an update, but without computing scores
        config = MGITestConfig()
        config.skip_compute = True
        mgi = Phenoscoring(config)
        mgi.update()

        self.assertGreater(desctab.count_rows(), num_models,
                           "number of models should increase")
        self.assertEqual(scorestab.count_rows(), num_scores,
                         "number of scores should remain")
Пример #10
0
 def setUp(self):
     """At beginning of each test, make sure IMPC models are loaded."""
     self.pipeline.clearmodels()
     impc = Phenoscoring(IMPCTestConfig())
     impc.update()
Пример #11
0
if __name__ == "__main__":

    config = parser.parse_args()

    pipeline = Phenoscoring(config)
    if config.action == "build":
        # create a new sqlite database with references
        pipeline.build()

    if config.action == "clearmodels":
        # remove all models and model scores from the database
        pipeline.clearmodels()

    if config.action == "update":
        # add new or update existing model defintions/phenotypes
        pipeline.update()

    if config.action == "remove":
        # remove a subset of models from the database
        pipeline.remove()

    if config.action == "recompute":
        # remove all scores and re-generate them from scratch
        pipeline.recompute()

    if config.action == "export":
        # write a database table into a tsv file
        pipeline.export()

    if config.action == "representations":
        # compute complete representations for references and models