예제 #1
0
 def test_clear_models(self):
     """can remove all models at once."""
             
     # ensure that db is non empty
     self.assertGreater(self.desctab.count_rows(), 0)                         
     self.assertGreater(self.phenstab.count_rows(), 0)                        
     self.assertGreater(self.scoretab.count_rows(), 0)                        
     
     # attempt to clear everything
     impc = Phenoscoring(IMPCTestConfig())
     impc.clearmodels()        
     self.assertEqual(self.desctab.count_rows(), 0)                         
     self.assertEqual(self.phenstab.count_rows(), 0)                        
     self.assertEqual(self.scoretab.count_rows(), 0)                        
예제 #2
0
class AddModelsTests(unittest.TestCase):
    """Test cases for adding models to an empty phenoscoring db"""
    @classmethod
    def setUpClass(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()

    @classmethod
    def tearDownClass(self):
        """At end, ensure test db is deleted."""
        remove_db(self.dbfile)

    def setUp(self):
        """At beginning of each test, make sure there are no models."""
        self.pipeline.clearmodels()

    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)

    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)

    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")
예제 #3
0
# ##################################################################
# Execute the program if module is used as an executable

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