Пример #1
0
    def test_get_criteria_details(self):
        config = IniParser().read_ini(MY_INI_FILE)
        idx = ElasticSettings.idx('REGION_CRITERIA')
        available_criterias = RegionCriteria.get_available_criterias(config=config)['region']
        idx_type = ','.join(available_criterias)

        doc_by_idx_type = ElasticUtils.get_rdm_docs(idx, idx_type, size=1)
        self.assertTrue(len(doc_by_idx_type) > 0)
        feature_id = getattr(doc_by_idx_type[0], 'qid')

        criteria_details = RegionCriteria.get_criteria_details(feature_id, config=config)

        hits = criteria_details['hits']
        first_hit = hits[0]
        _type = first_hit['_type']
        _index = first_hit['_index']
        _id = first_hit['_id']
        _source = first_hit['_source']

        disease_tag = _source['disease_tags'][0]
        self.assertTrue(feature_id, _id)
        self.assertIn(_type, idx_type)
        self.assertTrue(idx, _index)
        self.assertIn(disease_tag, list(_source.keys()))

        fdetails = _source[disease_tag][0]
        self.assertIn('fid', fdetails.keys())
        self.assertIn('fname', fdetails.keys())
Пример #2
0
    def test_is_region_for_disease(self):

        config = IniParser().read_ini(MY_INI_FILE)
        criteria_results = RegionCriteria.is_region_for_disease(self.region_region1, config=config, result_container={})

        expected_dict = {'1p36.32_002': {'IBD': [{'fid': 'IBD', 'fname': 'IBD'}],
                                         'PSC': [{'fid': 'PSC', 'fname': 'PSC'}],
                                         'CEL': [{'fid': 'CEL', 'fname': 'CEL'}],
                                         'RA': [{'fid': 'RA', 'fname': 'RA'}],
                                         'UC': [{'fid': 'UC', 'fname': 'UC'}],
                                         'ATD': [{'fid': 'ATD', 'fname': 'ATD'}],
                                         'MS': [{'fid': 'MS', 'fname': 'MS'}]}}

        self.assertEqual(criteria_results, expected_dict, 'Got result dict for is_region_for_disease as expected')
Пример #3
0
    def test_is_region_in_mhc(self):

        config = IniParser().read_ini(MY_INI_FILE)
        criteria_results = RegionCriteria.is_region_in_mhc(self.region_region1, config=config, result_container={})
        # should be tagged to all the diseases
        expected_dict = {'1p36.32_002': {'NAR': [{'fname': 'NAR', 'fid': 'NAR'}],
                                         'ATD': [{'fname': 'ATD', 'fid': 'ATD'}],
                                         'PSC': [{'fname': 'PSC', 'fid': 'PSC'}],
                                         'IBD': [{'fname': 'IBD', 'fid': 'IBD'}], 'AA': [{'fname': 'AA', 'fid': 'AA'}],
                                         'JIA': [{'fname': 'JIA', 'fid': 'JIA'}],
                                         'RA': [{'fname': 'RA', 'fid': 'RA'}], 'SLE': [{'fname': 'SLE', 'fid': 'SLE'}],
                                         'SSC': [{'fname': 'SSC', 'fid': 'SSC'}],
                                         'VIT': [{'fname': 'VIT', 'fid': 'VIT'}], 'AS': [{'fname': 'AS', 'fid': 'AS'}],
                                         'UC': [{'fname': 'UC', 'fid': 'UC'}],
                                         'CRO': [{'fname': 'CRO', 'fid': 'CRO'}],
                                         'SJO': [{'fname': 'SJO', 'fid': 'SJO'}],
                                         'MS': [{'fname': 'MS', 'fid': 'MS'}],
                                         'PSO': [{'fname': 'PSO', 'fid': 'PSO'}],
                                         'T1D': [{'fname': 'T1D', 'fid': 'T1D'}],
                                         'PBC': [{'fname': 'PBC', 'fid': 'PBC'}],
                                         'IGE': [{'fid': 'IGE', 'fname': 'IGE'}],
                                         'CEL': [{'fname': 'CEL', 'fid': 'CEL'}]}}

        self.assertEqual(criteria_results, expected_dict, 'Got result dict for is_region_in_mhc as expected')
Пример #4
0
def criteria_details(request):
    ''' Get criteria details for a given region ID. '''
    feature_id = request.POST.get('feature_id')
    criteria_details = RegionCriteria.get_criteria_details(feature_id)
    return JsonResponse(criteria_details)
Пример #5
0
 def criteria_disease_tags(cls, request, qids):
     ''' Get criteria disease tags for a given ensembl ID for all criterias. '''
     criteria_disease_tags = RegionCriteria.get_all_criteria_disease_tags(qids)
     return criteria_disease_tags