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


Python GraphUtils.digest_id方法代码示例

本文整理汇总了Python中dipper.utils.GraphUtils.GraphUtils.digest_id方法的典型用法代码示例。如果您正苦于以下问题:Python GraphUtils.digest_id方法的具体用法?Python GraphUtils.digest_id怎么用?Python GraphUtils.digest_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dipper.utils.GraphUtils.GraphUtils的用法示例。


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

示例1: make_association_id

# 需要导入模块: from dipper.utils.GraphUtils import GraphUtils [as 别名]
# 或者: from dipper.utils.GraphUtils.GraphUtils import digest_id [as 别名]
    def make_association_id(definedby, sub, pred, obj, attributes=None):
        """
        A method to create unique identifiers for OBAN-style associations,
        based on all the parts of the association
        If any of the items is empty or None, it will convert it to blank.
        It effectively digests the  string of concatonated values.
        Subclasses of Assoc can submit an additional array of attributes
        that will be appeded to the ID.

        Note this is equivalent to a RDF blank node

        :param definedby: The (data) resource that provided the annotation
        :param subject:
        :param predicate:
        :param object:
        :param attributes:

        :return:

        """

        items_to_hash = [definedby, sub, pred, obj]
        if attributes is not None and len(attributes) > 0:
            items_to_hash += attributes

        items_to_hash = [x for x in items_to_hash if x is not None]

        assoc_id = ':'.join(('MONARCH', GraphUtils.digest_id('+'.join(items_to_hash))))
        assert assoc_id is not None
        return assoc_id
开发者ID:TomConlin,项目名称:dipper,代码行数:32,代码来源:Association.py

示例2: get_uniprot_entrez_id_map

# 需要导入模块: from dipper.utils.GraphUtils import GraphUtils [as 别名]
# 或者: from dipper.utils.GraphUtils.GraphUtils import digest_id [as 别名]
    def get_uniprot_entrez_id_map(self):
        taxon_digest = GraphUtils.digest_id(str(self.tax_ids))
        id_map = {}
        smallfile = '/'.join((self.rawdir, 'id_map_' + taxon_digest + '.yaml'))
        bigfile = '/'.join((self.rawdir, self.files['id-map']['file']))

        # if processed smallfile exists and is newer use it instesd
        if os.path.isfile(smallfile) and \
                os.path.getctime(smallfile) > os.path.getctime(bigfile):
            LOG.info("Using the cheap mapping file %s", smallfile)
            with open(smallfile, 'r') as fh:
                id_map = yaml.safe_load(fh)
        else:
            LOG.info(
                "Expensive Mapping from Uniprot ids to Entrez/ENSEMBL gene ids for %s",
                str(self.tax_ids))
            self.fetch_from_url(self.files['id-map']['url'], bigfile)
            with gzip.open(bigfile, 'rb') as csvfile:
                csv.field_size_limit(sys.maxsize)
                filereader = csv.reader(  # warning this file is over 10GB unzipped
                    io.TextIOWrapper(
                        csvfile, newline=""), delimiter='\t', quotechar='\"')
                for row in filereader:
                    (uniprotkb_ac, uniprotkb_id, geneid, refseq, gi, pdb, go,
                     uniref100, unifref90, uniref50, uniparc, pir, ncbitaxon, mim,
                     unigene, pubmed, embl, embl_cds, ensembl, ensembl_trs,
                     ensembl_pro, other_pubmed) = row
                    if int(ncbitaxon) not in self.tax_ids:
                        continue
                    genid = geneid.strip()
                    if geneid != '' and ';' not in genid:
                        id_map[uniprotkb_ac.strip()] = 'NCBIGene:' + genid
                    elif ensembl.strip() != '' and ';' not in ensembl:
                        id_map[uniprotkb_ac.strip()] = 'ENSEMBL:' + ensembl.strip()

            LOG.info("Writing id_map out as %s", smallfile)
            with open(smallfile, 'w') as fh:
                yaml.dump(id_map, fh)

        LOG.info(
            "Acquired %i 1:1 uniprot to [entrez|ensembl] mappings", len(id_map.keys()))

        return id_map
开发者ID:TomConlin,项目名称:dipper,代码行数:45,代码来源:GeneOntology.py


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