#!/usr/bin/env python# -*- coding: utf-8 -*-## This file is part of the `pypath` python module## Copyright 2014-2023# EMBL, EMBL-EBI, Uniklinik RWTH Aachen, Heidelberg University## Authors: see the file `README.rst`# Contact: Dénes Türei (turei.denes@gmail.com)## Distributed under the GPLv3 License.# See accompanying file LICENSE.txt or copy at# https://www.gnu.org/licenses/gpl-3.0.html## Website: https://pypath.omnipathdb.org/#importitertoolsimportcollectionsimportpypath.inputs.commonasinputs_commonimportpypath.resources.urlsasurlsimportpypath.utils.mappingasmappingimportpypath.utils.orthologyasorthologyimportpypath.share.commonascommonimportpypath.inputs.cellascell_input
[docs]defembrace_raw():""" Returns Supplementary Table S11 from 10.1016/j.isci.2019.10.026 (Sheikh et al. 2019) as a list of tuples. """path=cell_input.cell_supplementary(supp_url=urls.urls['embrace']['url'],article_url=urls.urls['embrace']['article'],)content=inputs_common.read_xls(path)EmbraceRawRecord=collections.namedtuple('EmbraceRawRecord',content[0])return[EmbraceRawRecord(*(line[:2]+[int(float(n))forninline[2:]]))forlineincontent[1:]]
[docs]defembrace_translated(organism=9606):""" Returns Supplementary Table S11 from 10.1016/j.isci.2019.10.026 (Sheikh et al. 2019) translated to UniProt IDs of the requested organism. """raw=embrace_raw()record=raw[0].__class__result=[]forrowinraw:ligands=_embrace_id_translation(row.ligand_symbol,organism=organism,)receptors=_embrace_id_translation(row.receptor_symbol,organism=organism,)forligand,receptorinitertools.product(ligands,receptors):result.append(record(*((ligand,receptor)+row[2:])))returnresult
[docs]defembrace_interactions(organism=9606):""" Returns ligand-receptor interactions from Supplementary Table S11 of 10.1016/j.isci.2019.10.026 (Sheikh et al. 2019) translated to UniProt IDs of the requested organism. """EmbraceInteraction=collections.namedtuple('EmbraceInteraction',['ligand','receptor',])return[EmbraceInteraction(*rec[:2])forrecinembrace_translated(organism=organism)ifrec[0]andrec[1]]
[docs]defembrace_annotations(organism=9606,ncbi_tax_id=None):""" Returns protein annotations from Supplementary Table S11 of 10.1016/j.isci.2019.10.026 (Sheikh et al. 2019) translated to UniProt IDs of the requested organism. Returns dict with UniProt IDs as keys and sets of annotation tuples as values. """def_get_value(rec,mainclass,celltype):returnbool(getattr(rec,'%s_%s'%(celltype,mainclass)))EmbraceAnnotation=collections.namedtuple('EmbraceAnnotation',['mainclass','neuron','mural_cell','microglia','endothelial_cell',])organism=ncbi_tax_idororganismresult=collections.defaultdict(set)forrecinembrace_translated(organism=organism):formainclassin('ligand','receptor'):identifier=getattr(rec,'%s_symbol'%mainclass)ifnotidentifier:continueresult[identifier].add(EmbraceAnnotation(mainclass=mainclass,neuron=_get_value(rec,mainclass,'N'),mural_cell=_get_value(rec,mainclass,'P'),microglia=_get_value(rec,mainclass,'M'),endothelial_cell=_get_value(rec,mainclass,'EC'),))returndict(result)