def test_gene_list_too_big(self): with self.assertRaises(ClientException) as cm: save_custom_file(db=FakeDB(), user_info=None, type=GENE_LIST_TYPE, content=make_too_big()) self.assertEqual(ErrorType.UPLOADED_DATA_TOO_BIG, cm.exception.error_type) self.assertEqual(400, cm.exception.status_code)
def test_custom_range_list_range_sum_too_big(self): db = create_db_connection(TestWithPostgres.config.dbconfig) try: custom_list_key = save_custom_file(db, 'john', RANGE_TYPE, "1 1000 30001001") self.fail("Should have raised ValueError exception.") except ValueError as err: self.assertEqual(str(err), MAX_RANGE_ERROR_STR)
def create_custom_file(): user_info = "Addr:{} Browser:{} Platform:{} Agent:{}".format( request.remote_addr, request.user_agent.browser, request.user_agent.platform, request.user_agent.string) json_data = request.get_json() key = save_custom_file(get_db(), user_info, json_data.get('type'), json_data.get('content')) return make_json_response({'key': key})
def test_custom_range_list(self): db = create_db_connection(TestWithPostgres.config.dbconfig) custom_list_key = save_custom_file(db, 'john', RANGE_TYPE, "chr1 11873 11895") params = { SearchArgs.GENE_LIST: CUSTOM_RANGES_LIST, SearchArgs.CUSTOM_LIST_DATA: custom_list_key, SearchArgs.MODEL: "E2F1_0001(JS)", SearchArgs.UPSTREAM: "100", SearchArgs.DOWNSTREAM: "100", SearchArgs.PAGE: "1", SearchArgs.PER_PAGE: "10", } predictions, search_args, search_warning = get_predictions_with_guess(db, TestWithPostgres.config, "hg19", params) self.assertEqual(len(predictions), 1) self.assertEqual(0.4, float(predictions[0]['max']))
def test_custom_gene_list_with_lc_results(self): db = create_db_connection(TestWithPostgres.config.dbconfig) custom_list_key = save_custom_file(db, 'john', GENE_LIST_TYPE, "ddx11l1") params = { SearchArgs.GENE_LIST: CUSTOM_GENE_LIST, SearchArgs.CUSTOM_LIST_DATA: custom_list_key, SearchArgs.CUSTOM_GENE_SEARCH_TYPE: CUSTOM_GENE_NAME_TYPE, SearchArgs.MODEL: "E2F1_0001(JS)", SearchArgs.UPSTREAM: "100", SearchArgs.DOWNSTREAM: "100", SearchArgs.PAGE: "1", SearchArgs.PER_PAGE: "10", } predictions, search_args, search_warning = get_predictions_with_guess(db, TestWithPostgres.config, "hg19", params) self.assertEqual(len(predictions), 1)
def test_custom_range_list_bad_range(self): db = create_db_connection(TestWithPostgres.config.dbconfig) custom_list_key = save_custom_file(db, 'john', RANGE_TYPE, "chr1 91873 91883") params = { SearchArgs.GENE_LIST: CUSTOM_RANGES_LIST, SearchArgs.CUSTOM_LIST_DATA: custom_list_key, SearchArgs.MODEL: "E2F1_0001(JS)", SearchArgs.UPSTREAM: "100", SearchArgs.DOWNSTREAM: "100", SearchArgs.PAGE: "1", SearchArgs.PER_PAGE: "10", } predictions, search_args, search_warning = get_predictions_with_guess(db, TestWithPostgres.config, "hg19", params) self.assertEqual(len(predictions), 1) # we always return a record for range requests just with empty data for the matches self.assertEqual('None', predictions[0]['max'])
def test_custom_gene_list_id_results(self): """ These two splice variants belong to the same gene so they should list together in a single prediction. """ db = create_db_connection(TestWithPostgres.config.dbconfig) custom_list_key = save_custom_file(db, 'john', GENE_LIST_TYPE, "uc001aaa.3\nuc010nxr.1") params = { SearchArgs.GENE_LIST: CUSTOM_GENE_LIST, SearchArgs.CUSTOM_LIST_DATA: custom_list_key, SearchArgs.CUSTOM_GENE_SEARCH_TYPE: CUSTOM_ID_TYPE, SearchArgs.MODEL: "E2F1_0001(JS)", SearchArgs.UPSTREAM: "100", SearchArgs.DOWNSTREAM: "100", SearchArgs.PAGE: "1", SearchArgs.PER_PAGE: "10", } predictions, search_args, search_warning = get_predictions_with_guess(db, TestWithPostgres.config, "hg19", params) self.assertEqual(len(predictions), 1) first_pred_name = predictions[0]['name'] first_pred_name_parts = first_pred_name.split("; ") self.assertEqual(len(first_pred_name_parts), 2) self.assertIn("uc001aaa.3", first_pred_name_parts) self.assertIn("uc010nxr.1", first_pred_name_parts)
def test_custom_range_list_range_as_big_as_possible(self): db = create_db_connection(TestWithPostgres.config.dbconfig) custom_list_key = save_custom_file(db, 'john', RANGE_TYPE, "1 1000 30001000")
def test_gene_list_good_size(self): save_custom_file(db=FakeDB(), user_info=None, type=GENE_LIST_TYPE, content="WASH7P\nELK1\nNETS2")
def test_range_list_good_size(self): save_custom_file(db=FakeDB(), user_info=None, type=RANGE_TYPE, content="chr1 100 200\nchr2 200 300")