def test_run_to_file(self): op = ".kk_test" if os.path.exists(op): shutil.rmtree(op) args = base_args() args.pvalue_column = "P" args.or_column = "OR" args.output_folder = op M03_betas.run(args) n = os.listdir(op)[0] n = os.path.join(op,n) r = pandas.read_table(n) assert_beta_pb(self, r) shutil.rmtree(op)
def test_run_skip(self): args = base_args("tests/_td/GWAS/scz2c") args.pvalue_column = "P" args.or_column = "OR" args.skip_until_header = "\t".join(["HG19CHRC", "SNPID", "A1", "A2", "BP", "INFO", "OR", "SE", "P", "NGT", "BETA", "ZSCORE", "BETA_SIGN"]) r = M03_betas.run(args) assert_beta_pb(self, r)
def test_run_split(self): args = base_args("tests/_td/GWAS/scz2b") args.gwas_file_pattern = ".*gz" args.pvalue_column = "P" args.or_column = "OR" r = M03_betas.run(args) assert_beta_pb(self, r)
def test_with_model(self): args = base_args() args.pvalue_column = "P" args.or_column = "OR" args.model_db_path = "tests/_td/dbs/test_3.db" r = M03_betas.run(args) assert_model_beta_pb(self, r)
def test_run_to_files(self): op = ".kk_test" if os.path.exists(op): shutil.rmtree(op) args = base_args("tests/_td/GWAS/scz2b") args.gwas_file_pattern = ".*gz" args.pvalue_column = "P" args.or_column = "OR" args.output_folder = op M03_betas.run(args) r = pandas.DataFrame() for n in sorted(os.listdir(op)): n = os.path.join(op,n) d = pandas.read_table(n) r = pandas.concat([r,d]) assert_beta_pb(self, r) shutil.rmtree(op)
def test_split_with_model(self): args = base_args("tests/_td/GWAS/scz2b") args.gwas_file_pattern = ".*gz" args.pvalue_column = "P" args.or_column = "OR" args.model_db_path = "tests/_td/dbs/test_3.db" r = M03_betas.run(args) assert_model_beta_pb(self, r)
def test_fix_pvalue(self): op = ".kk_test" if os.path.exists(op): shutil.rmtree(op) args = base_args("tests/_td/GWAS/scz2d") args.gwas_file_pattern = ".*gz" args.pvalue_column = "P" args.or_column = "OR" r = M03_betas.run(args) assert_beta_pb_fix(self, r)
def run(args): if not args.overwrite and args.output_file and os.path.exists(args.output_file): logging.info("%s already exists, move it or delete it if you want it done again", args.output_file) return if not args.model_db_path: logging.info("Need to provide a model database file path") return args.output_folder = None g = M03_betas.run(args) M04_zscores.run(args, g)
def run(args): if not args.overwrite and os.path.exists(args.output_file): logging.info("%s already exists, move it or delete it if you want it done again", args.output_file) return if not args.model_db_path: logging.info("Need to provide a model database file path") return args.output_folder = None g = M03_betas.run(args) M04_zscores.run(args, g)
def test_split_with_model(self): op = ".kk_test" if os.path.exists(op): shutil.rmtree(op) args = base_args("tests/_td/GWAS/scz2b") args.gwas_file_pattern = ".*gz" args.pvalue_column = "P" args.or_column = "OR" args.model_db_path = "tests/_td/dbs/test_3.db" r = M03_betas.run(args) assert_model_beta_pb(self, r)
def testWrongArguments(self, patch_validate_basic, patch_validate_strict): args = DummyArgs() with self.assertRaises(Exception) as c: M03_betas.run(args) args.gwas_folder = "tests/_td/GWAS/scz2" patch_validate_basic.side_effect = RuntimeError("k") with self.assertRaises(RuntimeError) as c: M03_betas.run(args) patch_validate_basic.side_effect = None patch_validate_strict.side_effect = RuntimeError() with self.assertRaises(RuntimeError) as c: M03_betas.run(args)
def run_folder_or_file(self, folder, file): args = base_args(folder, file) args.pvalue_column = "P" args.or_column = "OR" r = M03_betas.run(args) assert_beta_pb(self, r) args = base_args(folder, file) args.pvalue_column = "P" args.beta_column = "BETA" r = M03_betas.run(args) assert_beta_pb(self, r) args = base_args(folder, file) args.pvalue_column = "P" args.beta_sign_column = "BETA_SIGN" r = M03_betas.run(args) assert_beta_p(self, r) args = base_args(folder, file) args.beta_column = "BETA" args.se_column = "SE" r = M03_betas.run(args) assert_beta_bse(self, r) args = base_args(folder, file) args.beta_column = "BETA" args.se_column = "SE" r = M03_betas.run(args) assert_beta_bse(self, r) args = base_args(folder, file) args.or_column = "OR" args.se_column = "SE" r = M03_betas.run(args) assert_beta_bse(self, r) #Should fail args = base_args(folder, file) args.or_column = "BETA" args.se_column = "SE" with self.assertRaises(Exception): M03_betas.run(args)
def buildBetas(self): logging.info("Processing betas!") self.args.output_folder = args.beta_folder M03_betas.run(self.args)
def test_fail_incompatible_arguments(self): args = base_args("tests/_td/GWAS/scz2", "tests/_td/GWAS/scz2/scz2.gwas.results.txt.gz") with self.assertRaises(Exceptions.InvalidArguments) as c: M03_betas.run(args)