#!/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/#importreimportcollectionsimportitertoolsimportpypath.resources.urlsasurlsimportpypath.share.curlascurlimportpypath.utils.mappingasmappingimportpypath.inputs.commonasinputs_commonimportpypath.inputs.cellascell
[docs]defrolland_hi_ii_14():""" Loads the HI-II-14 unbiased interactome from the large scale screening of from Rolland 2014. Returns list of interactions. """xlsname=cell.cell_supplementary(supp_url=urls.urls['hiii14']['url'],article_url=urls.urls['hiii14']['article_url'],)tbl=inputs_common.read_xls(xlsname,sheet='2G')forrowintbl[1:]:yield[c.split('.')[0]forcinrow]
[docs]defvidal_hi_iii_old(fname):""" Loads the HI-III unbiased interactome from preliminary data of the next large scale screening of Vidal Lab. The data is accessible here: http://interactome.dfci.harvard.edu/H_sapiens/dload_trk.php You need to register and accept the license terms. Returns list of interactions. """f=curl.FileOpener(fname)return[l.strip().split('\t')forlinf.result][1:]
[docs]defhi_iii_old():""" Loads the unbiased human interactome version III (HI-III). This is an unpublished data and its use is limited. Please check the conditions and licensing terms carefully at http://interactome.baderlab.org. """HiiiiInteraction=collections.namedtuple('HiiiiInteraction',['id_a','id_b','isoform_a','isoform_b','screens','score',])rescore=re.compile(r'author score: ([\d\.]+)')rescreens=re.compile(r'Found in screens ([\d,]+)')url=urls.urls['hid']['hi-iii']post_data={'form[request_dataset]':'2','form[request_file_format]':'psi',}c=curl.Curl(url,silent=False,large=True,post=post_data,slow=True,)forrowinc.result:ifnotrow.strip():continueid_a,id_b,rest=row.split(' ',maxsplit=2)id_a,isoform_a=id_a.split('-')if'-'inid_aelse(id_a,1)id_b,isoform_b=id_b.split('-')if'-'inid_belse(id_b,1)sc=rescore.search(rest)score=float(sc.groups()[0])ifscelseNonescreens=tuple(int(i)foriinrescreens.search(rest).groups()[0].split(','))yieldHiiiiInteraction(id_a=id_a[10:],id_b=id_b[10:],isoform_a=int(isoform_a),isoform_b=int(isoform_b),screens=screens,score=score,)
[docs]deflit_bm_13_interactions():""" Downloads and processes Lit-BM-13 dataset, the 2013 version of the high confidence literature curated interactions from CCSB. Returns list of interactions. """LitBm13Interaction=collections.namedtuple('LitBm13Interaction',['entrez_a','entrez_b','genesymbol_a','genesymbol_b',])url=urls.urls['hid']['lit-bm-13']c=curl.Curl(url,silent=False,large=True,slow=True)_=next(c.result)forrowinc.result:row=row.strip().split('\t')yieldLitBm13Interaction(entrez_a=row[0],entrez_b=row[2],genesymbol_a=row[1],genesymbol_b=row[3],)
[docs]deflit_bm_17_interactions():""" Downloads and processes Lit-BM-13 dataset, the 2017 version of the high confidence literature curated interactions from CCSB. Returns list of interactions. """LitBm17Interaction=collections.namedtuple('LitBm17Interaction',['id_a','id_b','pubmed','score',])url=urls.urls['hid']['lit-bm-17']c=curl.Curl(url,silent=False)data=c.resultc=curl.Curl(url,silent=False,large=True,slow=True)_=next(c.result)forrowinc.result:row=row.strip().split('\t')id_a=row[0][10:]id_b=row[1][10:]pubmed=row[8][7:]score=float(row[14][13:])yieldLitBm17Interaction(id_a=id_a,id_b=id_b,pubmed=pubmed,score=score,)
[docs]defhi_ii_interactions():""" Interactions from Rolland 2014 https://pubmed.ncbi.nlm.nih.gov/25416956/. """return_huri_interactions(dataset='hi-ii-14-pmi')
[docs]defhi_i_interactions():""" Interactions from Rual 2005 https://pubmed.ncbi.nlm.nih.gov/16189514/. """return_huri_interactions(dataset='hi-i-05-pmi')
[docs]deflit_bm_interactions():""" Literature collected interactions from Luck 2020. """LitBmInteraction=collections.namedtuple('LitBmInteraction',['uniprot_a','uniprot_b'],)url=urls.urls['hid']['lit-bm']c=curl.Curl(url,large=True,silent=False,slow=True)forrowinc.result:row=row.strip().split('\t')uniprots_a=mapping.map_name(row[0],'ensembl','uniprot')uniprots_b=mapping.map_name(row[1],'ensembl','uniprot')foruniprot_a,uniprot_binitertools.product(uniprots_a,uniprots_b):yieldLitBmInteraction(uniprot_a=uniprot_a,uniprot_b=uniprot_b,)