Ejemplo n.º 1
0
def test_save_and_get_regression_values(output_dir):
    db = DbManager(os.path.join(output_dir, "temp_testing.db"))
    assert db is not None
    db.build()

    regression_template = {
        "measure_id": "test.measure",
        "figure_regression": "regfigpath",
        "figure_regression_small": "regfigsmallpath",
    }
    r = regression_template

    r["regression_id"] = "test_regression_1"
    r["pvalue_regression_male"] = "0.1"
    r["pvalue_regression_female"] = "0.2"
    db.save_regression_values(r)

    r["regression_id"] = "test_regression_2"
    r["pvalue_regression_male"] = "0.3"
    r["pvalue_regression_female"] = "0.4"
    db.save_regression_values(r)

    reg = db.get_regression_values("test.measure")
    assert reg == [
        (
            "test_regression_1",
            "test.measure",
            "regfigpath",
            "regfigsmallpath",
            0.1,
            0.2,
        ),
        (
            "test_regression_2",
            "test.measure",
            "regfigpath",
            "regfigsmallpath",
            0.3,
            0.4,
        ),
    ]
Ejemplo n.º 2
0
    def run(self):
        db = DbManager(dbfile=self.browser_db)
        db.build()

        if self.pheno_regressions:
            for reg_id, reg_data in self.pheno_regressions.regression.items():
                db.save_regression({
                    "regression_id": reg_id,
                    "instrument_name": reg_data.instrument_name,
                    "measure_name": reg_data.measure_name,
                    "display_name": reg_data.display_name,
                })

        for instrument in list(self.phenotype_data.instruments.values()):
            progress_nl()
            for measure in list(instrument.measures.values()):
                progress(text=str(measure) + "\n")
                var = self.handle_measure(measure)
                db.save(var)
                if self.pheno_regressions:
                    for regression in self.handle_regressions(measure):
                        db.save_regression_values(regression)