def test_tag_feature_to_all_diseases(self):
        config = IniParser().read_ini(MY_INI_FILE)
        section = "is_gene_in_mhc"
        feature_id = 'ENSG00000229281'
        result = Criteria.tag_feature_to_all_diseases(feature_id, section, config, {})
        result_diseases = sorted(list(result['ENSG00000229281'].keys()))
        (core_disease, other_disease) = CriteriaManager.get_available_diseases()
        available_diseases = sorted(core_disease + other_disease)
        self.assertEqual(result_diseases, available_diseases)

        section = "is_marker_in_mhc"
        feature_id = 'rs6679677'
        result = Criteria.tag_feature_to_all_diseases(feature_id, section, config, {})
        result_diseases = sorted(list(result['rs6679677'].keys()))
        (core_disease, other_disease) = CriteriaManager.get_available_diseases()
        available_diseases = sorted(core_disease + other_disease)
        self.assertEqual(result_diseases, available_diseases)
    def test_get_available_diseases(self):
        (main, other) = utils.Disease.get_site_diseases()
        self.assertEqual(12, len(main), "12 main diseases found when searching for all diseases")
        self.assertEqual(8, len(other), "8 other diseases found when searching for all diseases")

        (main_dis_code, other_dis_code) = CriteriaManager.get_available_diseases()

        self.assertIn("T1D", main_dis_code)
        self.assertIn("AA", other_dis_code)
Example #3
0
 def test_criteria_mappings(self, idx, idx_types):
     (main_codes, other_codes) = CriteriaManager.get_available_diseases()
     site_enabled_diseases = main_codes + other_codes
     elastic_url = ElasticSettings.url()
     for idx_type in idx_types:
         url = idx + '/' + idx_type + '/_mapping'
         response = Search.elastic_request(elastic_url, url, is_post=False)
         elastic_type_mapping = json.loads(response.content.decode("utf-8"))
         property_keys = list(elastic_type_mapping[idx]['mappings'][idx_type]['properties'].keys())
         '''check if score and disease_tags and qid are there in mapping'''
         self.assertIn('score', property_keys)
         self.assertIn('disease_tags', property_keys)
         self.assertIn('qid', property_keys)
         '''check if all the enabled diseases are there'''
         for disease in site_enabled_diseases:
             self.assertIn(disease, property_keys)