Пример #1
0
    def gene_mapping(cls, idx, idx_type, test_mode=False):
        ''' Load the mapping for the gene index. '''
        props = MappingProperties(idx_type)
        props.add_property("symbol", "string", analyzer="full_name") \
             .add_property("synonyms", "string", analyzer="full_name") \
             .add_property("chromosome", "string") \
             .add_property("source", "string") \
             .add_property("start", "long") \
             .add_property("stop", "long") \
             .add_property("strand", "string") \
             .add_property("description", "string") \
             .add_property("biotype", "string") \
             .add_property("pmids", "string") \
             .add_property("suggest", "completion", analyzer="full_name")

        dbxref_props = cls._get_nested_prop("dbxrefs", "ensembl")
        ortholog_props = MappingProperties("orthologs")
        ortholog_props.add_properties(cls._get_nested_prop("mmusculus", "ensembl"))
        ortholog_props.add_properties(cls._get_nested_prop("rnorvegicus", "ensembl"))
        dbxref_props.add_properties(ortholog_props)
        props.add_properties(dbxref_props)

        tags = MappingProperties("tags")
        tags.add_property("weight", "integer", index="not_analyzed")
        props.add_properties(tags)

        ''' create index and add mapping '''
        load = Loader()
        options = {"indexName": idx, "shards": 5}
        if not test_mode:
            load.mapping(props, idx_type, analyzer=Loader.KEYWORD_ANALYZER, **options)
        return props
Пример #2
0
    def mapping(cls, idx, idx_type):
        ''' Create the mapping for disease indexing '''
        props = MappingProperties("disease")
        props.add_property("name", "string") \
             .add_property("code", "string") \
             .add_property("description", "string", index="not_analyzed") \
             .add_property("colour", "string", index="not_analyzed") \
             .add_property("tier", "integer", index="not_analyzed") \
             .add_property("suggest", "completion", analyzer="full_name")

        tags = MappingProperties("tags")
        tags.add_property("weight", "integer", index="not_analyzed")
        props.add_properties(tags)
        load = Loader()
        options = {"indexName": idx, "shards": 1}
        load.mapping(props, 'disease', analyzer=Loader.KEYWORD_ANALYZER, **options)
Пример #3
0
    def _create_mapping(self, **options):
        ''' Create the mapping for gene names indexing '''
        props = MappingProperties("gene")
        props.add_property("gene_symbol", "string", analyzer="full_name") \
             .add_property("biotype", "string") \
             .add_property("synonyms", "string", analyzer="full_name") \
             .add_property("hgnc", "string") \
             .add_property("dbxrefs", "object") \
             .add_property("organism", "string")

        featureloc_props = MappingProperties("featureloc")
        featureloc_props.add_property("start", "integer") \
                        .add_property("end", "integer") \
                        .add_property("seqid", "string") \
                        .add_property("build", "string")
        props.add_properties(featureloc_props)
        ''' create index and add mapping '''
        self.mapping(props, 'gene', analyzer=self.KEYWORD_ANALYZER, **options)
Пример #4
0
    def create_criteria_mapping(cls, idx, idx_type, test_mode=False):
        ''' function to create mapping for criteria indexes
        @type  idx: string
        @param idx: name of the index
        @type  idx_type: string
        @param idx_type: name of the idx type, each criteria is an index type
        @type  test_mode:  string
        @param test_mode: flag to create or not create the mapping
        '''
        logger.warning('Idx ' + idx)
        logger.warning('Idx_type ' + idx_type)
        ''' Create the mapping for alias indexing '''
        props = MappingProperties(idx_type)
        props.add_property("score", "integer")
        props.add_property("disease_tags", "string", index="not_analyzed")
        props.add_property("qid", "string", index="not_analyzed")
        (main_codes, other_codes) = CriteriaManager().get_available_diseases()

        for disease in main_codes + other_codes:
            criteria_tags = MappingProperties(disease)
            criteria_tags.add_property("fid", "string", index="not_analyzed")
            criteria_tags.add_property("fname", "string", index="not_analyzed")

            fnotes = MappingProperties('fnotes')
            fnotes.add_property('linkid', "string", index="not_analyzed")
            fnotes.add_property('linkname', "string", index="not_analyzed")
            fnotes.add_property('linkdata', "string", index="not_analyzed")
            fnotes.add_property('linkvalue', "string", index="not_analyzed")
            criteria_tags.add_properties(fnotes)
            props.add_properties(criteria_tags)

        ''' create index and add mapping '''
        load = Loader()
        options = {"indexName": idx, "shards": 5}

        '''add meta info'''
        config = CriteriaManager.get_criteria_config()
        idx_type_cfg = config[idx_type]
        desc = idx_type_cfg['desc']
        meta = {"desc": desc}
        if not test_mode:
            load.mapping(props, idx_type, meta=meta, analyzer=Loader.KEYWORD_ANALYZER, **options)
        return props
Пример #5
0
 def _create_snp_mapping(self, idx_type, **options):
     ''' Create the mapping for snp index '''
     props = MappingProperties(idx_type)
     props.add_property("seqid", "string", index="not_analyzed") \
          .add_property("start", "integer", index="not_analyzed") \
          .add_property("id", "string", analyzer="full_name") \
          .add_property("ref", "string", index="no") \
          .add_property("alt", "string", index="no") \
          .add_property("qual", "string", index="no") \
          .add_property("filter", "string", index="no") \
          .add_property("info", "string", index="no") \
          .add_property("suggest", "completion", analyzer="full_name")
     tags = MappingProperties("tags")
     tags.add_property("weight", "integer", index="not_analyzed")
     props.add_properties(tags)
     self.mapping(props,
                  idx_type,
                  analyzer=Loader.KEYWORD_ANALYZER,
                  **options)
     return props