本文整理汇总了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
示例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