当前位置: 首页>>代码示例>>Python>>正文


Python criteria.Criteria类代码示例

本文整理汇总了Python中criteria.helper.criteria.Criteria的典型用法代码示例。如果您正苦于以下问题:Python Criteria类的具体用法?Python Criteria怎么用?Python Criteria使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Criteria类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_populate_container

    def test_populate_container(self):
            features = ['ENSG00000110800']
            diseases = ['T1D']
            fid = 'GDXHsS00004'
            fname = 'Barrett'
            fnotes = {'linkdata': 'somedata', 'linkvalue': 'somevalue'}
            result_container = Criteria.populate_container(fid, fname, fnotes, features, diseases, result_container={})
            expected_result = {'ENSG00000110800': {'T1D': [{'fid': 'GDXHsS00004', 'fname': 'Barrett',
                                                            'fnotes': {'linkvalue': 'somevalue',
                                                                       'linkdata': 'somedata'}}]}}
            self.assertEqual(expected_result, result_container, 'Expected result from populate container')

            features = ['ENSG00000110800']
            diseases = ['RA']
            fid = 'GDXHsS00003'
            fname = 'Barrett'
            fnotes = {'linkdata': 'somedata2', 'linkvalue': 'somevalue2'}
            result_container_populated_again = Criteria.populate_container(fid, fname, fnotes, features, diseases,
                                                                           result_container=result_container)

            expected_result_populated_again = {'ENSG00000110800': {'RA': [{'fname': 'Barrett', 'fid': 'GDXHsS00003',
                                                                           'fnotes': {'linkvalue': 'somevalue2',
                                                                                      'linkdata': 'somedata2'}}],
                                                                   'T1D': [{'fname': 'Barrett', 'fid': 'GDXHsS00004',
                                                                            'fnotes': {'linkvalue': 'somevalue',
                                                                                       'linkdata': 'somedata'}}]}}

            self.assertEqual(result_container_populated_again, expected_result_populated_again,
                             'Expected result after populating')
开发者ID:premanand17,项目名称:django-criteria,代码行数:29,代码来源:test_criteria.py

示例2: test_get_criteria_dict

    def test_get_criteria_dict(self):

        expected_dict = {'fid': 'GDXHsS00004', 'fname': 'Barrett'}
        criteria_dict = Criteria.get_criteria_dict('GDXHsS00004', 'Barrett')
        self.assertEqual(expected_dict, criteria_dict, 'dicts are equal')

        expected_dict = {'fid': 'GDXHsS00004', 'fnotes': {'rsq': '0.1'}, 'fname': 'Barrett'}
        criteria_dict = Criteria.get_criteria_dict('GDXHsS00004', 'Barrett', {'rsq': '0.1'})
        self.assertEqual(expected_dict, criteria_dict, 'dicts are equal')
开发者ID:premanand17,项目名称:django-criteria,代码行数:9,代码来源:test_criteria.py

示例3: test_get_elastic_query

    def test_get_elastic_query(self):
        config = IniParser().read_ini(MY_INI_FILE)
        section = "is_gene_in_mhc"
        range_query = Criteria.get_elastic_query(section, config)
        range_query_dict = range_query.__dict__
        self.assertTrue('range' in str(range_query_dict))

        section = "cand_gene_in_study"
        match_all_query = Criteria.get_elastic_query(section, config)
        match_all_query_dict = match_all_query.__dict__
        self.assertTrue('match_all' in str(match_all_query_dict))
开发者ID:premanand17,项目名称:django-criteria,代码行数:11,代码来源:test_criteria.py

示例4: test_available_criterias

    def test_available_criterias(self):
        feature = 'gene'
        available_criterias = Criteria.get_available_criterias(feature, INI_CONFIG)
        expected_dict = {'gene': ['cand_gene_in_study', 'gene_in_region', 'is_gene_in_mhc', 'cand_gene_in_region']}
        self.assertIsNotNone(available_criterias, 'Criterias as not none')
        self.assertIn('cand_gene_in_study', available_criterias['gene'])
        self.assertEqual(available_criterias.keys(), expected_dict.keys(), 'Dic keys equal')

        available_criterias = Criteria.get_available_criterias(feature=None, config=INI_CONFIG)
        self.assertIn('gene', available_criterias)
        self.assertIn('marker', available_criterias)
开发者ID:premanand17,项目名称:django-criteria,代码行数:11,代码来源:test_criteria.py

示例5: show_feature_criteria_details

def show_feature_criteria_details(feature_id, feature_type, feature_doc=None, section='criteria',
                                  section_title="criteria"):
    ''' Template inclusion tag to render criteria details bar. '''
    print('===================')
    print(feature_id)
    print(feature_type)
    print('====================')
    (idx, idx_types) = Criteria.get_feature_idx_n_idxtypes(feature_type)
    criteria_disease_tags = Criteria.get_all_criteria_disease_tags([feature_id], idx, idx_types)
    print(criteria_disease_tags)
    return {'criteria': criteria_disease_tags, 'feature_id': feature_id, 'appname': feature_type,
            'f': feature_doc, 'section': section, 'section_title': section_title}
开发者ID:D-I-L,项目名称:django-criteria,代码行数:12,代码来源:criteria_tags.py

示例6: test_get_feature_idx_n_idxtypes

    def test_get_feature_idx_n_idxtypes(self):

        (idx, idx_types) = Criteria.get_feature_idx_n_idxtypes('gene')
        self.assertEqual('pydgin_imb_criteria_gene', idx, 'Got the right idx back')
        self.assertIn('cand_gene_in_study', idx_types, 'Got the right idx type back')
        self.assertIn('cand_gene_in_region', idx_types, 'Got the right idx type back')

        (idx, idx_types) = Criteria.get_feature_idx_n_idxtypes('marker')
        self.assertEqual('pydgin_imb_criteria_marker', idx, 'Got the right idx back')

        self.assertIn('is_an_index_snp', idx_types, 'Got the right idx type back')
        self.assertIn('marker_is_gwas_significant_in_study', idx_types, 'Got the right idx type back')
        self.assertIn('is_marker_in_mhc', idx_types, 'Got the right idx type back')
开发者ID:premanand17,项目名称:django-criteria,代码行数:13,代码来源:test_criteria.py

示例7: get_criteria_details

    def get_criteria_details(cls, feature_id, idx=None, idx_type=None, config=None):
        'Function to get the criteria details for a given feature_id'
        if idx is None:
            idx = ElasticSettings.idx(cls.FEATURE_TYPE.upper()+'_CRITERIA')

        # get all the criterias from ini
        criteria_list = []
        if idx_type is None:
            available_criterias = cls.get_available_criterias(feature=cls.FEATURE_TYPE, config=config)
            criteria_list = available_criterias[cls.FEATURE_TYPE]
            idx_type = ','.join(criteria_list)

        result_dict = Criteria.get_criteria_details(feature_id, idx, idx_type)
        result_dict_expanded = Criteria.add_meta_info(idx, criteria_list, result_dict)
        return result_dict_expanded
开发者ID:D-I-L,项目名称:django-criteria,代码行数:15,代码来源:region_criteria.py

示例8: get_diseases

 def get_diseases(self):
     ''' Overridden get diseases for feature. '''
     if super(RegionDocument, self).get_diseases():
         idx = ElasticSettings.idx('REGION_CRITERIA')
         diseases = [getattr(d, "code") for d in Criteria.get_disease_tags(getattr(self, "region_id"), idx=idx)]
         return diseases
     return []
开发者ID:D-I-L,项目名称:pydgin,代码行数:7,代码来源:document.py

示例9: test_gene_criteria_types

    def test_gene_criteria_types(self):
        """Test if the indexes have records"""
        idx_key = "GENE_CRITERIA"
        feature_type = "gene"
        idx = ElasticSettings.idx(idx_key)

        idx_types = CriteriaDataIntegrityUtils.get_criteria_index_types(idx_key)
        gene_criterias = Criteria.get_available_criterias(feature_type)

        CriteriaDataIntegrityTestUtils().test_criteria_types(idx, idx_types, gene_criterias["gene"])
        CriteriaDataIntegrityTestUtils().test_criteria_mappings(idx, idx_types)

        # get random doc for each type ['gene_in_region', 'cand_gene_in_region', 'cand_gene_in_study', 'is_gene_in_mhc']
        idx_type = "gene_in_region"
        doc_by_idx_type = ElasticUtils.get_rdm_docs(idx, idx_type, size=1)
        self.assertTrue(len(doc_by_idx_type) == 1, "got back one document")
        gene_in_region_doc = doc_by_idx_type[0]

        #         {'score': 10, 'CRO': [{'fname': '4p11', 'fid': '4p11_005'}],
        #          '_meta': {'_type': 'gene_in_region', '_score': 0.9997835,
        #                    '_index': 'pydgin_imb_criteria_gene', '_id': 'ENSG00000250753'},
        #          'disease_tags': ['CRO'], 'qid': 'ENSG00000250753'}

        qid = getattr(gene_in_region_doc, "qid")
        print(qid)
        disease_tags = getattr(gene_in_region_doc, "disease_tags")
        #         ENSG00000248482
        #         ['IBD', 'UC']
        #         [{'fid': '5q31.1_013', 'fname': '5q31.1'}]
        #         [{'fid': '5q31.1_013', 'fname': '5q31.1'}]
        fnotes = getattr(gene_in_region_doc, disease_tags[0])
        region_id = fnotes[0]["fid"]
        print(region_id)
开发者ID:D-I-L,项目名称:django-criteria,代码行数:33,代码来源:test_gene_criteria_data.py

示例10: test_tag_feature_to_all_diseases

    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)
开发者ID:premanand17,项目名称:django-criteria,代码行数:17,代码来源:test_criteria.py

示例11: test_fetch_overlapping_features

    def test_fetch_overlapping_features(self):
        region_index = ElasticSettings.idx('REGION', idx_type='STUDY_HITS')
        (region_idx, region_idx_type) = region_index.split('/')

        seqid = '1'
        start = 206767602
        stop = 206772494
        result_docs = Criteria.fetch_overlapping_features('38', seqid, start, stop, region_idx, region_idx_type)
        self.assertTrue(len(result_docs) > 0, 'Got some overlapping features')
开发者ID:premanand17,项目名称:django-criteria,代码行数:9,代码来源:test_criteria.py

示例12: test_get_meta_desc

    def test_get_meta_desc(self):
        idx = 'pydgin_imb_criteria_gene'
        criteria_list = ['cand_gene_in_study', 'is_gene_in_mhc']
        meta_info = Criteria.get_meta_desc(idx, criteria_list)

        self.assertEqual(meta_info[idx]['is_gene_in_mhc'], 'Gene lies in MHC region',
                         'Got the right desc for is_gene_in_mhc')
        self.assertEqual(meta_info[idx]['cand_gene_in_study'], 'Candidate Gene for a Study',
                         'Got the right desc for cand_gene_in_study')
开发者ID:premanand17,项目名称:django-criteria,代码行数:9,代码来源:test_criteria.py

示例13: get_all_criteria_disease_tags

    def get_all_criteria_disease_tags(cls, qids, idx_type=None):

        (idx, idx_types) = cls.get_feature_idx_n_idxtypes(cls.FEATURE_TYPE)

        if idx_type is None:
            idx_type = idx_types

        criteria_disease_tags = Criteria.get_all_criteria_disease_tags(qids, idx, idx_type)
        return(criteria_disease_tags)
开发者ID:D-I-L,项目名称:django-criteria,代码行数:9,代码来源:region_criteria.py

示例14: test_do_identifier_search

    def test_do_identifier_search(self):

        identifiers = ['ptpn22', 'rs2476601', '1p13.2', 'ctla4', 'GDXHsS00025', 'foo', 'bar']
        result_dict = Criteria.do_identifier_search(identifiers)
        expected_dict = {'region': {'1p13.2': ['1p13.2_019']},
                         'marker': {'rs2476601': ['rs2476601']},
                         'gene': {'PTPN22': ['ENSG00000134242'], 'CTLA4': ['ENSG00000163599']},
                         'study': {'GDXHsS00025': ['GDXHsS00025']},
                         'missing': ['foo', 'bar']}
        self.assertEqual(result_dict, expected_dict, 'Got back correct results')
开发者ID:premanand17,项目名称:django-criteria,代码行数:10,代码来源:test_criteria.py

示例15: process_criterias

    def process_criterias(cls, feature, criteria=None, config=None, show=False, test=False):
        '''function to delegate the call to the right criteria class and build the criteria for that class
        '''
        from criteria.helper.criteria import Criteria
        from criteria.helper.gene_criteria import GeneCriteria
        from criteria.helper.marker_criteria import MarkerCriteria
        from criteria.helper.region_criteria import RegionCriteria
        from criteria.helper.study_criteria import StudyCriteria

        if config is None:
            if test:
                config = cls.get_criteria_config(ini_file='test_criteria.ini')
            else:
                config = cls.get_criteria_config(ini_file='criteria.ini')

        available_criterias = Criteria.get_available_criterias(feature, config=config, test=test)[feature]

        criterias_to_process = []
        if criteria is None:
            criterias_to_process = available_criterias
        else:
            criterias_list = criteria.split(',')
            criterias_to_process = [criteria.strip() for criteria in criterias_list
                                    if criteria.strip() in available_criterias]

        if show:
            print(criterias_to_process)
            return criterias_to_process

        logger.debug(datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S'))
        for section in criterias_to_process:
            if feature == 'gene':
                print('Call to build criteria gene index')
                Criteria.process_criteria(feature, section, config, GeneCriteria, test=test)
            elif feature == 'marker':
                print('Call to build criteria marker index')
                Criteria.process_criteria(feature, section, config, MarkerCriteria, test=test)
            elif feature == 'region':
                print('Call to build criteria region index')
                Criteria.process_criteria(feature, section, config, RegionCriteria, test=test)
            elif feature == 'study':
                print('Call to build criteria study index')
                Criteria.process_criteria(feature, section, config, StudyCriteria, test=test)
            else:
                logger.critical('Unsupported feature ... please check the inputs')

        logger.debug(datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S'))
        logger.debug('========DONE==========')
开发者ID:D-I-L,项目名称:django-criteria,代码行数:48,代码来源:criteria_manager.py


注:本文中的criteria.helper.criteria.Criteria类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。